Sign in to follow this  
CGameProgrammer

[SOLVED] Displaying models along relative axes

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this