Posted: Sat Oct 15, 2005 12:54 am
I've modified your script and prepared a model to test the scripts. Look at this:
I think to have understood the basic of the hinge joint. Thanks Nout.
Here, there is the download of two mini-demo that use this script.
http://realityfactory.altervista.org/do ... r_test.zip
1) Down the Hill. Look the car go down accordingly with the gravity force (no torque on wheels) to see how the hinge joint works. THE WHEELS ROTATE!
2) Car_Test. "LeftClick" to apply a torque on the front wheels. Any idea on how to turn the wheels in the examples, Nout, and make it work like a real car? This is the main question of my previous posts.
The car chassis has a buggy rotation problems. Are these the Y-Axis rotation problems that you solved in the next release? Does the physic development proceed in the desired way? Are you plannig an upgrade (exe + headers)?
Download: http://realityfactory.altervista.org/do ... r_test.zip
Code: Select all
{
PosX [0]
PosY [0]
PosZ [0]
Dx [0]
Dy [0]
Dz [0]
Mass [1]
Scale [1]
ALPHA [255]
MyBodyId [-1]
SenId1 [-1]
RocketId [-1]
KeyReleased [true]
Depth [0.0]
TORQUE_REAR [0]
Body
{
Body0 [0]
Body1 [0]
Body2 [0]
Body3 [0]
Body4 [0]
Body5 [0]
Body6 [0]
Body7 [0]
Body8 [0]
Body9 [0]
Body10 [0]
Body11 [0]
Body12 [0]
Body13 [0]
Body14 [0]
Body15 [0]
Body16 [0]
Body17 [0]
Body18 [0]
Body19 [0]
Body20 [0]
}
Init[ () //Is excecuted only once.
{
Console(true);
PosX = 0;
PosY = -340;
PosZ = 0;
DefineMaterial(1, 10, 0.5);
Body[0] = CreateRigidBody("Body0", "chassis.act",8,8,8, 255, PosX, PosY, PosZ, 0,0,0, 0,0,0 , true, ALPHA, "Box 133 40 74", 1, 0,0,0,0, Mass/4);
Dx = GetBodyBBox(Body[0], 0);
Dy = GetBodyBBox(Body[0], 1);
Dz = GetBodyBBox(Body[0], 2);
Body[1] = CreateRigidBody("Body1", "tyre.act", 8,8,8, 255, PosX+Dx*0.3, PosY-Dy*0.45, PosZ+Dz*0.35,0,0,0, 0,0,0, true, ALPHA, "Sphere 0", 0, 0,0,0,0, Mass/4);
Body[2] = CreateRigidBody("Body1", "tyre.act", 8,8,8, 255, PosX+Dx*0.3, PosY-Dy*0.45, PosZ-Dz*0.35,0,0,0, 0,0,0, true, ALPHA, "Sphere 0", 0, 0,0,0,0, Mass/4);
Body[3] = CreateRigidBody("Body1", "tyre.act", 8,8,8, 255, PosX-Dx*0.3, PosY-Dy*0.45, PosZ+Dz*0.35,0,0,0, 0,0,0, true, ALPHA, "Sphere 0", 0, 0,0,0,0, Mass/4);
Body[4] = CreateRigidBody("Body1", "tyre.act", 8,8,8, 255, PosX-Dx*0.3, PosY-Dy*0.45, PosZ-Dz*0.35,0,0,0, 0,0,0, true, ALPHA, "Sphere 0", 0, 0,0,0,0, Mass/4);
CreateHingeJoint(Body[0], Body[1], PosX+Dx*0.3, PosY-Dy*0.45, PosZ+Dz*0.35, -180, 180, -180, 180, Dz*0.25, -1, 0, 0);
CreateHingeJoint(Body[0], Body[2], PosX+Dx*0.3, PosY-Dy*0.45, PosZ-Dz*0.35, -180, 180, -180, 180, Dz*0.25, -1, 0, 0);
CreateHingeJoint(Body[0], Body[3], PosX-Dx*0.3, PosY-Dy*0.45, PosZ+Dz*0.35, -180, 180, -180, 180, Dz*0.25, -1, 0, 0);
CreateHingeJoint(Body[0], Body[4], PosX-Dx*0.3, PosY-Dy*0.45, PosZ-Dz*0.35, -180, 180, -180, 180, Dz*0.25, -1, 0, 0);
} ]
Start[ ()
{
Console(true);
ShowPhysicsBBox(false);
debug(self.leftmousekey_pressed);
debug(TORQUE_REAR);
Dx = GetBodyBBox(Body[0], 0);
Dy = GetBodyBBox(Body[0], 1);
Dz = GetBodyBBox(Body[0], 2);
debug(Dx);
debug(Dy);
debug(Dz);
//SetTorque(Body[1], 0, 0, TORQUE_REAR, true);
//SetTorque(Body[2], 0, 0, TORQUE_REAR, true);
SetTorque(Body[3], 0, 0, TORQUE_REAR, true);
SetTorque(Body[4], 0, 0, TORQUE_REAR, true);
if(self.leftmousekey_pressed=true)
{
TORQUE_REAR=TORQUE_REAR+10;
}
else
{
TORQUE_REAR=TORQUE_REAR-40;
}
if(self.rightmousekey_pressed)
{
SetTorque(Body[3], 0, 0, 0, true);
SetTorque(Body[4], 0, 0, 0, true);
}
else
{
if(TORQUE_REAR<=0)
{
TORQUE_REAR=0;
}
if(TORQUE_REAR>500)
{
TORQUE_REAR=500;
}
}
} ]
}
Here, there is the download of two mini-demo that use this script.
http://realityfactory.altervista.org/do ... r_test.zip
1) Down the Hill. Look the car go down accordingly with the gravity force (no torque on wheels) to see how the hinge joint works. THE WHEELS ROTATE!
2) Car_Test. "LeftClick" to apply a torque on the front wheels. Any idea on how to turn the wheels in the examples, Nout, and make it work like a real car? This is the main question of my previous posts.
The car chassis has a buggy rotation problems. Are these the Y-Axis rotation problems that you solved in the next release? Does the physic development proceed in the desired way? Are you plannig an upgrade (exe + headers)?
Download: http://realityfactory.altervista.org/do ... r_test.zip