Jump to content

  • Log In with Google      Sign In   
  • Create Account

Vehicle Wheels Position


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 19 June 2013 - 10:26 PM

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):

vehicle1.png



Sponsor:

#2 ankhd   Members   -  Reputation: 1357

Like
0Likes
Like

Posted 20 June 2013 - 02:28 AM

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.



#3 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 20 June 2013 - 06:20 AM

@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, 20 June 2013 - 06:27 AM.


#4 shazen   Members   -  Reputation: 285

Like
0Likes
Like

Posted 20 June 2013 - 06:40 AM

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, 20 June 2013 - 07:20 AM.


#5 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 20 June 2013 - 07:19 AM

@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);


#6 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 20 June 2013 - 08:15 AM

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.

Attached Thumbnails

  • vehicle 3ds max.png


#7 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 22 June 2013 - 08:41 AM

Any suggestions?






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS