Jump to content
  • Advertisement
Sign in to follow this  

Setting body orientation in ODE

This topic is 4731 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got a CameraRig class that is just an ODE sphere. When I press the arrow keys I apply forces to it that move it around. That works pretty good. Now what I'm trying to do is change the orientation of the sphere depending on mouse movement. How do I do it? This is what I'm trying to do for changing the pitch of the camera:
// the CameraRig is inherited from CDynamicObject
void CDynamicObject::AdjustPitch(float amount)
{
	const real * qnow = dBodyGetQuaternion(physicsBody);
	
	dQuaternion qlater;
	dQFromAxisAndAngle(qlater, 1, 0, 0, amount);
	
	dQuaternion finish;
	dQMultiply0(finish, qnow, qlater);
	
	dBodySetQuaternion(physicsBody, finish);
}
This isn't really working. If I move the mouse a huge amount over a single frame (really fast, in other words) the orientation will jump somewhere else, otherwise it just sits there.

Share this post


Link to post
Share on other sites
Advertisement
Hmm, I think I might be on to something. The ODE docs (and the comments in the headers even) say that a dMatrix3 is a 4x3 matrix, but actually I have to treat it like a 3x4 matrix (3 rows and 4 columns). When I do that things start working.

Is there something I'm not getting? 1st number in dimension is the number of rows and the 2nd is the number of columns, right? So this is a 4x3 matrix:

[ a b c ]
[ d e f ]
[ g h i ]
[ j k l ]

and this is a 3x4 matrix:

[ a b c d ]
[ e f g h ]
[ i j k l ]

right?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!