0 registered members (),
975
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
6D Joints / Hinge Joints and vehicles
#405378
07/29/12 20:55
07/29/12 20:55
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
OP
Expert
|
OP
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
Hey guys!
I am currently working on car physics (using PhysX in A8) and I have stumbled upon a problem: the wheels.
Generally the PhysX SDK would provide wheel functions, however, they are not included in the GS-Wrapper. Furthermore, I cannotuse the raycast-wheel GS delivers, because I need to have more settings on the wheel (like mass, friction etc, that actually has an effect on the wheel).
Now I tried hinge joints using an extra entity for the control-able wheels (usually the front ones), but that did not work, as the chassis did not move, though the "extra entity" did.
6D Joints added a lot of oscillating of the wheels and I was not able to add rotation, as the angles were rotated (means, when I rotated the wheel's pan, the tilt was rotated as well).
Anyone could point me in the right direction for Gamestudio?
Thanks in advance and best regards, Rei
|
|
|
Re: 6D Joints / Hinge Joints and vehicles
[Re: HeelX]
#405418
07/30/12 14:45
07/30/12 14:45
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
OP
Expert
|
OP
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
Here is a example that uses the gamestudio CUBE_MDL (that shows the movement of wheels quite good).
#include <acknex.h>
#include <default.c>
#include <ackphysx.h>
void main()
{
/* Init */
wait(1);
level_load(NULL);
physX_open();
camera.x = 218;
camera.y = 442;
camera.z = 81;
camera.pan = 247;
ENTITY* ground = ent_create(CUBE_MDL,vector(0,0,0),NULL);
vec_set(ground.scale_x,vector(100,100,1));
pXent_settype(ground,PH_STATIC,PH_BOX);
pXent_setfriction(ground,90);
/* Vehicle */
var motion[6] = { 0, 0, 0, NX_D6JOINT_MOTION_FREE, 0, 0};
var drive[6] = { 0, 0, 0, NX_D6JOINT_DRIVE_VELOCITY, 0, 0 };
VECTOR pos;
vec_set(pos, vector(0,0,100));
ENTITY *chassis = ent_create(CUBE_MDL, pos, NULL);
vec_set(chassis.scale_x, vector(10,5,4));
pXent_settype(chassis, PH_RIGID, PH_BOX);
pXent_setgroup(chassis, 2);
pXent_setmass(chassis, 50);
ENTITY *wheel1 = ent_create(CUBE_MDL, pos, NULL);
vec_fill(wheel1.scale_x, 2);
vec_add(wheel1.x, vector(60,60,-32));
pXent_settype(wheel1, PH_RIGID, PH_SPHERE);
pXent_setgroup(wheel1, 2);
pXent_setmass(wheel1, 30);
pXcon_add(PH_6DJOINT, wheel1, chassis, 0);
pXcon_setparams1(wheel1, wheel1.x, NULL, NULL);
pXcon_set6djoint(wheel1, motion, drive);
ENTITY *wheel2 = ent_create(CUBE_MDL, pos, NULL);
vec_fill(wheel2.scale_x, 2);
vec_add(wheel2.x, vector(60,-60,-32));
pXent_settype(wheel2, PH_RIGID, PH_SPHERE);
pXent_setgroup(wheel2, 2);
pXent_setmass(wheel2, 30);
pXcon_add(PH_6DJOINT, wheel2, chassis, 0);
pXcon_setparams1(wheel2, wheel2.x, NULL, NULL);
pXcon_set6djoint(wheel2, motion, drive);
ENTITY *wheel3 = ent_create(CUBE_MDL, pos, NULL);
vec_fill(wheel3.scale_x, 2);
vec_add(wheel3.x, vector(-60,60,-32));
pXent_settype(wheel3, PH_RIGID, PH_SPHERE);
pXent_setgroup(wheel3, 2);
pXent_setmass(wheel3, 30);
pXcon_add(PH_6DJOINT, wheel3, chassis, 0);
pXcon_setparams1(wheel3, wheel3.x, NULL, NULL);
pXcon_set6djoint(wheel3, motion, drive);
ENTITY *wheel4 = ent_create(CUBE_MDL, pos, NULL);
vec_fill(wheel4.scale_x, 2);
vec_add(wheel4.x, vector(-60,-60,-32));
pXent_settype(wheel4, PH_RIGID, PH_SPHERE);
pXent_setgroup(wheel4, 2);
pXent_setmass(wheel4, 30);
pXcon_add(PH_6DJOINT, wheel4, chassis, 0);
pXcon_setparams1(wheel4, wheel4.x, NULL, NULL);
pXcon_set6djoint(wheel4, motion, drive);
var accel;
while(1)
{
accel = (key_w-key_s)*500;
pXcon_setmotor(wheel1, vector(0,0,accel), 0);
pXcon_setmotor(wheel2, vector(0,0,accel), 0);
wait(1);
}
}
This is only for driving forward and backward, as the wheels start spinning whenever I use NX_D6JOINT_MOTION_FREE / NX_D6JOINT_MOTION_LIMITED (with limits set).
|
|
|
Re: 6D Joints / Hinge Joints and vehicles
[Re: HeelX]
#405425
07/30/12 16:58
07/30/12 16:58
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
OP
Expert
|
OP
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
I do not really get what you mean by this Because simply adding another joint (pXcon_add) between wheel and chassis disables any movement of the wheel. Or do you mean by another entity?
|
|
|
Re: 6D Joints / Hinge Joints and vehicles
[Re: HeelX]
#405459
07/31/12 14:00
07/31/12 14:00
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
OP
Expert
|
OP
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
Okay, tried it. The result is not too bad (better than anything I achieved with 6D joints thus far), however, the front wheels just move into the ground. The example is using CUBE_MDL. Would be awesome if you could take another look at it
#include <acknex.h>
#include <default.c>
#include <ackphysx.h>
void main()
{
/* Init */
wait(1);
level_load(NULL);
physX_open();
camera.x = 218;
camera.y = 442;
camera.z = 81;
camera.pan = 247;
ENTITY* ground = ent_create(CUBE_MDL,vector(0,0,0),NULL);
vec_set(ground.scale_x,vector(100,100,1));
pXent_settype(ground,PH_STATIC,PH_BOX);
pXent_setfriction(ground,90);
/* Vehicle */
var motion[6] = { 0, 0, 0, NX_D6JOINT_MOTION_FREE, 0, 0};
var drive[6] = { 0, 0, 0, 0, 0, 0 };
var motionRot[6] = { 0, 0, 0, 0, 0, NX_D6JOINT_MOTION_LIMITED};
var driveRot[6] = { 0, 0, 0, 0, 0, 0 };
VECTOR pos;
vec_set(pos, vector(0,0,100));
ENTITY *chassis = ent_create(CUBE_MDL, pos, NULL);
vec_set(chassis.scale_x, vector(10,5,4));
pXent_settype(chassis, PH_RIGID, PH_BOX);
pXent_setgroup(chassis, 2);
pXent_setmass(chassis, 50);
ENTITY *wheel1Rot = ent_create(CUBE_MDL, pos, NULL);
vec_add(wheel1Rot.x, vector(60,60,0));
pXent_settype(wheel1Rot, PH_RIGID, PH_BOX);
pXent_setgroup(wheel1Rot, 2);
pXent_setmass(wheel1Rot, 30);
pXcon_add(PH_6DJOINT, wheel1Rot, chassis, 0);
pXcon_setparams1(wheel1Rot, wheel1Rot.x, NULL, vector(999,999,999));
pXcon_setparams2(wheel1Rot, vector(30,30,30), vector(0,30,0), vector(999,999,999));
pXcon_set6djoint(wheel1Rot, motionRot, driveRot);
ENTITY *wheel2Rot = ent_create(CUBE_MDL, pos, NULL);
vec_add(wheel2Rot.x, vector(60,-60,0));
pXent_settype(wheel2Rot, PH_RIGID, PH_BOX);
pXent_setgroup(wheel2Rot, 2);
pXent_setmass(wheel2Rot, 30);
pXcon_add(PH_6DJOINT, wheel2Rot, chassis, 0);
pXcon_setparams1(wheel2Rot, wheel2Rot.x, NULL, vector(999,999,999));
pXcon_setparams2(wheel2Rot, vector(30,30,30), vector(0,30,0), vector(999,999,999));
pXcon_set6djoint(wheel2Rot, motionRot, driveRot);
ENTITY *wheel1 = ent_create(CUBE_MDL, pos, NULL);
vec_fill(wheel1.scale_x, 2);
vec_add(wheel1.x, vector(60,60,-32));
pXent_settype(wheel1, PH_RIGID, PH_SPHERE);
pXent_setgroup(wheel1, 2);
pXent_setmass(wheel1, 30);
pXcon_add(PH_6DJOINT, wheel1, wheel1Rot, 0);
pXcon_setparams1(wheel1, wheel1.x, NULL, NULL);
pXcon_setparams2(wheel1, vector(30,30,30), vector(0,30,0), vector(999,999,999));
pXcon_set6djoint(wheel1, motion, drive);
ENTITY *wheel2 = ent_create(CUBE_MDL, pos, NULL);
vec_fill(wheel2.scale_x, 2);
vec_add(wheel2.x, vector(60,-60,-32));
pXent_settype(wheel2, PH_RIGID, PH_SPHERE);
pXent_setgroup(wheel2, 2);
pXent_setmass(wheel2, 30);
pXcon_add(PH_6DJOINT, wheel2, wheel2Rot, 0);
pXcon_setparams1(wheel2, wheel2.x, NULL, NULL);
pXcon_set6djoint(wheel2, motion, drive);
ENTITY *wheel3 = ent_create(CUBE_MDL, pos, NULL);
vec_fill(wheel3.scale_x, 2);
vec_add(wheel3.x, vector(-60,60,-32));
pXent_settype(wheel3, PH_RIGID, PH_SPHERE);
pXent_setgroup(wheel3, 2);
pXent_setmass(wheel3, 30);
pXcon_add(PH_6DJOINT, wheel3, chassis, 0);
pXcon_setparams1(wheel3, wheel3.x, NULL, NULL);
pXcon_set6djoint(wheel3, motion, drive);
ENTITY *wheel4 = ent_create(CUBE_MDL, pos, NULL);
vec_fill(wheel4.scale_x, 2);
vec_add(wheel4.x, vector(-60,-60,-32));
pXent_settype(wheel4, PH_RIGID, PH_SPHERE);
pXent_setgroup(wheel4, 2);
pXent_setmass(wheel4, 30);
pXcon_add(PH_6DJOINT, wheel4, chassis, 0);
pXcon_setparams1(wheel4, wheel4.x, NULL, NULL);
pXcon_set6djoint(wheel4, motion, drive);
var accel;
var steer;
while(1)
{
accel = (key_w-key_s)*500;
steer = (key_a-key_d);
if(!steer)
{
pXcon_setparams2(wheel1Rot, vector(30,30,30), vector(-0.1,0.1,0), vector(999,999,999));
pXcon_setparams2(wheel2Rot, vector(30,30,30), vector(-0.1,0.1,0), vector(999,999,999));
}
else if(sign(steer) == -1)
{
pXcon_setparams2(wheel1Rot, vector(30,30,30), vector(-0.1,30,0), vector(999,999,999));
pXcon_setparams2(wheel2Rot, vector(30,30,30), vector(-0.1,30,0), vector(999,999,999));
}
else
{
pXcon_setparams2(wheel1Rot, vector(30,30,30), vector(-30,0.1,0), vector(999,999,999));
pXcon_setparams2(wheel2Rot, vector(30,30,30), vector(-30,0.1,0), vector(999,999,999));
}
pXent_addtorquelocal(wheel1Rot, vector(0,0,steer));
pXent_addtorquelocal(wheel2Rot, vector(0,0,steer));
pXent_addtorquelocal(wheel1, vector(0,accel,0));
pXent_addtorquelocal(wheel2, vector(0,accel,0));
wait(1);
}
}
|
|
|
|