Sign in to follow this  
Medo Mex

Vehicle Wheels Position

Recommended Posts

Medo Mex    891

I have create a simple vehicle in 3Ds Max and trying to adjust the wheels position in bullet physics.

 

I'm able to grab each wheel position by getting each wheel transformation matrix.

 

Though I'm not getting the wheels position same as the position in 3Ds Max, How can I adjust the wheels position to be exactly as in 3Ds Max model?.

 

The model consist of (chassis mesh, wheel1 mesh, wheel2 mesh, wheel3 mesh, wheel4 mesh), all in a single .x file.

D3DXMATRIX matWorld;
btVector3 connectionPointCS0;
bool isFrontWheel = true;

// WHEEL 1
matWorld = wheel[0]->TransformationMatrix;
connectionPointCS0 = btVector3(matWorld._41, matWorld._42, matWorld._43);
m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);

// WHEEL 2
matWorld = wheel[1]->TransformationMatrix;
connectionPointCS0 = btVector3(matWorld._41, matWorld._42, matWorld._43);
m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);

isFrontWheel = false;

// WHEEL 3
matWorld = wheel[2]->TransformationMatrix;
connectionPointCS0 = btVector3(matWorld._41, matWorld._42, matWorld._43);
m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);

// WHEEL 4
matWorld = wheel[3]->TransformationMatrix;
connectionPointCS0 = btVector3(matWorld._41, matWorld._42, matWorld._43);
m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);

Screenshot (BTW, In this screenshot, the vehicle didn't hit the ground yet):

[attachment=16392:vehicle1.png]

Share this post


Link to post
Share on other sites
ankhd    2304

Hi there.

It all depends on how you load the mesh.

1. if you load the mesh wheels and body as one model. then you should have a frame hierarchy.

    then you have your matrix all you need to do then is update the frame hierarchy and then use the matrix for each wheel.

Share this post


Link to post
Share on other sites
Medo Mex    891

@ankhd: I'm loading the mesh hierarchy in memory, then rendering each frame, the problem is that when I add each wheel, I set its position according to the model space position, I get the results you see in the screenshot (the wheels are not adjusted correctly).

matWorld = wheel[0]->TransformationMatrix; // Wheel transformation matrix
connectionPointCS0 = btVector3(matWorld._41, matWorld._42, matWorld._43);

// etc...
Edited by Medo3337

Share this post


Link to post
Share on other sites
shazen    291

you need to know if the wheel transforms are relative to the chassis transform or if they are relative to the world origin in 3ds. You then will need to treat them the same in your code.
 
You have it implemented as if they are relative to the world origin. You can switch it to relative to the chassis to see if it works like this:
 

connectionPointCS0 =(btVector3(matWorld._41, matWorld._42, matWorld._43)) + 
(btVector3(chassisWorld._41, chassisWorld._42, chassisWorld._43));

if that makes the wheels display in the correct place, then essentially you've imported the model with a bone hierarchy that will need to be updated every frame or at least every time the car changes position or rotation.

Edited by shazen

Share this post


Link to post
Share on other sites
Medo Mex    891

@shazen: Tried that, I still see the wheels far from the chassis and not adjusted in the same position as in 3Ds Max.

 

I'm still trying to find a way to make the wheels adjust exactly as in 3Ds Max, the wheels in 3Ds Max are separated meshes in the same scene.

D3DXMATRIX matChassis = chassis->TransformationMatrix; // Chassis (model space) transformation matrix
btVector3 connectionPointCS0;
btVector3 chassisPosition(matChassis._41, matChassis._42, matChassis._43);

D3DXMATRIX matWorld;
matWorld = wheel[3]->TransformationMatrix;
connectionPointCS0 = btVector3(matWorld._41, matWorld._42, matWorld._43) + chassisPosition;
m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);

Share this post


Link to post
Share on other sites
Medo Mex    891

Notice that when I move the wheels position (Up) in 3Ds Max, I get better results in the game, though I still don't know why the wheels are not adjusted to be the same as in 3Ds Max.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this