Vehicle wheels orientation wrong after coordinate system change

Vehicle wheels orientation wrong after coordinate system change

So, I changed the coordinate system of my vehicle, like this:

	data.m_chassisOrientation.setCols( hkVector4(0, 1, 0), hkVector4(1, 0, 0), hkVector4(0, 0, 1));
And I also fixed the positions to match:

		const hkReal hardPointY = -0.05f;
		suspension.m_wheelParams[0].m_hardpointChassisSpace.set (	-1,		hardPointY,		1.5		);

		suspension.m_wheelParams[1].m_hardpointChassisSpace.set (	1,		hardPointY,		1.5		);

		suspension.m_wheelParams[2].m_hardpointChassisSpace.set (	-1,		hardPointY,		-1.25		);

		suspension.m_wheelParams[3].m_hardpointChassisSpace.set (	1,		hardPointY,		-1.25		);

But the weels' orientation is still as it was before. Here are some screenshots:

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hey mindcalamity-A couple points:Are the vehicle hardpoints located inside the chassis? By my reckoning, you have (0,1,0) as the up axis for the vehicle but you define:consthkRealhardPointY=-0.05f; //Is this beneath the car?Does this make sense? The vehicle hardpoints must be located inside the vehicle.It seems possible that the wheels could be oriented correctly in Havok but render incorrectly in Ogre.Does the vehicle behave as you expect? Does it travel in the direction it should travel?What does the VDB movie of this same scene look like? Can you take some screengrabs of the VDB of the car? Is the car pointed in the right direction?Can you send more of your setup code? Perhaps attach as file or paste as code (remember to set language type to C++ in the dialog when you paste it).-Josh

Josh Developer Support Engineer Havok

Hey mindcalamity-Two things:1. Are your hard points located inside the chassis? You define +y as the "up" vector in chassis space, but then you set:const hkReal hardPointY = -0.05f;which might put it below the chassis. Just check your logic and make sure that the hardpoints are correct.2. Is it possible that the wheels are set correctly in Havok but are just rendering incorrectly? Does the car behave as expected? Is the car oriented the correct way? Please take some screengrabs of the Havok Visual Debugger output for this scene and post them so we can compare what Havok is doing with what Ogre is doing. Also, please post all your vehicle setup code (trim everything not vehicle-related, of course). Make sure to set the code type to "C++" when posting it.-Josh

Josh Developer Support Engineer Havok

Irecorded a video, here it is:And you can find my modified vehicle utilities here: you need anything more, the whole repository is located here:'m pretty sure rendered correctly, because I think the math conversion is correct. Here's how I convert the units:

                static hkVector4 ogreVec3ToHk(Ogre::Vector3 v)


                        return hkVector4(v.x, v.y, v.z);

                static hkVector4 ogreVec4ToHk(Ogre::Vector4 v)


                        return hkVector4(v.x, v.y, v.z, v.w);

                static hkQuaternion ogreQuatToHk(Ogre::Quaternion q)


                        return hkQuaternion(q.x, q.y, q.z, q.w);

                static Ogre::Vector3 hkVec3toOgre(const hkVector4& v)


                        return Ogre::Vector3(v(0), v(1), v(2));

                static Ogre::Vector4 hkVec4ToOgre(const hkVector4& v)


                        return Ogre::Vector4(v(0), v(1), v(2), v(3));

                static Ogre::Quaternion hkQuatToOgre(const hkQuaternion& q)


                        return Ogre::Quaternion(q.m_vec(3), q.m_vec(0), q.m_vec(1), q.m_vec(2));


Best Reply

Hey MindCalamity-I've taken a look and I think you are getting the wheel setup wrong. Check it:In the code here: have:

data.m_chassisOrientation.setCols( hkVector4(0, 1, 0), hkVector4(1, 0, 0), hkVector4(0, 0, 1));
From the Havok manual, we know "the first column is the 'up' direction of the vehicle, the second column is the 'forward' direction and the third column is perpendicular to both. Positive rotations about the third column correspond to the wheel motion when going forward. This direction affects gear shifting, braking and accelerating."

So you have made chassis y the up axis, chassis x the forward axis, and chassis z perpendicular to both (I think the Z sticks out the right side of the car, in the world ground plane).Later on, you set

data.m_wheelParams[0].m_axle = 0;

data.m_wheelParams[1].m_axle = 0;

and also:
steering.m_doesWheelSteer[0] = true;

steering.m_doesWheelSteer[1] = true;

So I think you want [0] and[1] to be on axis 0 and to do the steering, but then you do this:
suspension.m_wheelParams[0].m_hardpointChassisSpace.set (-1,hardPointY,1.5);

suspension.m_wheelParams[1].m_hardpointChassisSpace.set (1,hardPointY,1.5);

Remember, you made chassis x the forward vector, so this says "put one steering wheel at the front of the car and one at the back of the car". So that's weird.I would leave your setCols intact, and leave 0 and 1 as your steer wheels, but then change your hardpointChassisSpace to be:
suspension.m_wheelParams[0].m_hardpointChassisSpace.set (1,hardPointY,-1.5); //left front wheel

suspension.m_wheelParams[1].m_hardpointChassisSpace.set (1,hardPointY,1.5); //right front wheel

suspension.m_wheelParams[2].m_hardpointChassisSpace.set (-1,hardPointY,-1.5); //left rear

suspension.m_wheelParams[3].m_hardpointChassisSpace.set (-1,hardPointY,1.5); //right rear

Or something like that. There might be something else I've missed but I would start there.Try it out and let me know how you get on with this.-Josh

Josh Developer Support Engineer Havok

Thanks a lot for the help! I really appreciate it.My original code was commented out, but was this:

data.m_chassisOrientation.setCols( hkVector4(0, 1, 0), hkVector4(0, 0, 1), hkVector4(1, 0, 0));
the problem with this was obviously the X being wrong, it should have been -1.
data.m_chassisOrientation.setCols( hkVector4(0, 1, 0), hkVector4(0, 0, 1), hkVector4(-1, 0, 0));

Now it's the above and it's working perfectly.

Login to leave a comment.