# [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.

## 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]

1. 1
2. 2
Rutin
25
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 22
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631764
• Total Posts
3002210
×