joint for car wheel

maroxe

06-09-2008 23:55:46

Hi,
i'm trying to make a basic racing game, but i do't know wich joint is more convinient for a car wheel since ther's not D6joint .
I tried that, but apprently, it doesn't work:

//create car body
car = new Body(CarMeshFileName, scene, new Cube(2, 2, 2) , NxOgre::Pose(Vector3(0, 0, 0)), CarParams);
//car rotates only around Y Axis
car->raiseBodyFlag(NX_BF_FROZEN_ROT_X);
car->raiseBodyFlag(NX_BF_FROZEN_ROT_Z);
//create wheel body
wheel = new Body(WheelMeshFileName, scene, new Wheel(0.4, WheelParams()), NxOgre::Pose(Vector3(2, 0, 2)), WheelParams);
//joint betwen the car and the first wheel
RevoluteJoint *joint = scene->createRevoluteJoint(this, wheel, Vector3::UNIT_X, wheel->getGlobalPositionAsOgreVector3());

betajaen

07-09-2008 08:46:22

Your doing it all wrong. You add the Wheel to the first body as a shape; (mActor->addShape), and joints have nothing to do with the Wheel system.

maroxe

07-09-2008 15:44:34

i was thinking that Wheel are a sort of shape.
so my new question is how to simulate a car? is there any Vehicle class?

betajaen

07-09-2008 17:50:01

Tons, like the amount of posts dedicated to vehicles - Use the search, seriously.

maroxe

07-09-2008 20:20:37

i took a look at this topic: http://www.ogre3d.org/phpBB2addons/view ... ht=vehicle and others
and this my new code:

Chasis = new CPlayer(String("Car;") + "maddog_body.mesh", mNxScene, new NxOgre::Cube(5, 1, 5), NxOgre::Pose(Vector3(0, 2, 0)), "mass: 50");
WheelParams WParams;
WParams.setToDefault();
WParams.mMass = 5.f;
WParams.mLocalPose.t.set(NxVec3(0, 0, 2));

mWheels = WheelSet::createFourWheelSet(1, float3(2, 0, 2), float3(-2, 0, -2), Chasis, WParams, "model: maddog_wheell.mesh");

i have too problem:
the chasis of the car fall down until it touches the ground
the car doesn't move( i proced like that in my framelistener:
mWheels->drive(20000);)

this a PXD file(you can open it with the remoote debugger) that shows the scene: http://www.mediafire.com/download.php?nzayovqfwau

maroxe

07-09-2008 21:13:15

i resolved my problem by adding mWheels->setAs( NxOgre::WheelSet::TL_Front );