Jump to content
  • Advertisement
Sign in to follow this  
RealmRPGer

Yaw + Pitch Object Rotations

This topic is 4409 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'm having trouble getting the correct rotations out of my object. I have a yaw and a pitch for the object. When the user presses up, down, left, and right, the object is supposed to rotate about its current local axis. The pitch is always correct, but the object rotates about its initial yaw axis... which I don't want to do. How do I solve this? I'm using two calculations: One, on input, the yaw and pitch are set in vectors: yaw +/- (.1,0,0) pitch +/- (0,0.1) Then I use a directX (I've also tried manually using axes, to no avail) yaw/pitch/roll matrix function (ignore the pitch to roll thing...): D3DXMatrixRawPitchRoll( yaw, 0, pitch); Again, any help would be much appreciated. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Save the current yaw/pitch in a Matrix, and constantly multiply a new YawPitch matrix by it.

Ex.


D3DXMatrix m_RotationMatrix

...

yaw +/- (.1,0,0)
pitch +/- (0,0.1)

D3DXMatrix rot = D3DXMatrixYawPitchRoll( yaw, pitch, 0 );
m_RotationMatrix = m_RotationMatrix * rot;

...

D3DSetWorldMatrix( &m_RotationMatrix );



The functions might not all be correct, but you get the idea.

I think that's what you're looking for. If not, i tried :).

Share this post


Link to post
Share on other sites
No, that's not quite what I'm looking for.

Let me see if I can explain this more clearly. What I want is a rotation about the y axis followed by a rotation about the NEW z axis. That is:

If rotation by theta about the y axis results in the new coordinate system i,j,k, then I want to rotate the object by theta degrees about y, followed by iota degrees about k.

What I'm currently getting is a rotation about y followed by a rotation about z.

Here's an image of my problem:



[Edited by - RealmRPGer on November 19, 2006 12:04:22 AM]

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!