Jump to content
  • Advertisement
Sign in to follow this  

[SOLVED] Displaying models along relative axes

This topic is 4981 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

[Fixed. The error was that I flipped rows and columns around... for instance, I thought the first row was the right vector, but it's supposed to be the first column.] I have a model with its own forward/right/up axes that represent its orientation. For example, normally forward is (0,0,1) but if you yaw the model 90 degrees to the right, its new forward would be (1,0,0), and the new right vector would be (0,0,-1). Anyway the math is correct, but I'm having trouble displaying it. I tried multiplying the camera view matrix with the orientation matrix of the model (first row is right vector, second row up vector, third row forward vector) but it's not correct; it just shows the model rotated around the absolute X/Y/Z axes. For instance, if you roll 90 degrees and then pitch up (relative to the model) 90 degrees, the new forward is (1,0,0). This is working correctly, but what gets displayed is the model pitching up relative to the world, not itself... so it looks like the forward vector would be (0,1,0). To help explain, transforms are done like this:
model::ChangePitch ( float Amount )
    matrix Matrix;
//  Changing pitch means rotating around the local X axis,
//  which is the right vector:
    Matrix.RotateAroundAxis( Right, Amount );

//  Now rotate the forward and up axes to reflect the new pitch
//  (right is unaffected):
    Forward = Forward * Matrix;
    Up = Up * Matrix;
This math works correctly, it's just I don't know the correct matrix multiplication to display the model rotated correctly. [Edited by - CGameProgrammer on November 29, 2004 7:09:54 PM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!