## Disfigurement When Rotating Objects

Member
Posts: 153
Joined: 2004.12
Post: #16
glRotatef,glTranslatef, and glScalef use hardware acceleration that glMultMatrixf cant use. You might be better off just using those simple functions rather then having to deal with matrix math. Especially if you dont need to do anything besides those simple transformations.

EDIT: To answer your question, you can use 'Concatenation of Transformations', Simply multiplying the matrices together will result in a new matrix that you can use. However you have to be careful because order matters. For example if you wanted to combine those three rotation matrices i gave you, you would multiply Rz * Ry * Rx. Im pretty sure in order to combine Translations,Scaling, and rotations you do: Scaling * Translation * Rotation

There was a long silence...
'I claim them all,' said the Savage at last.
Sage
Posts: 1,066
Joined: 2004.07
Post: #17
Ok one thing I don't understand is this:
hangt5 Wrote:resultant = Rz* point
resultant = ry * resultant
resultant = rx * resultant
What is resultant? The new point? Thanks for helping me out with all the matrices too.
Member
Posts: 153
Joined: 2004.12
Post: #18
Nick Wrote:Ok one thing I don't understand is this:

What is resultant? The new point? Thanks for helping me out with all the matrices too.

Yup, basically you have to multiply your point by the Rz matrix. Then that new point by the Ry matrix, then that new point by the Rx matrix... which results in your final point

There was a long silence...
'I claim them all,' said the Savage at last.
Member
Posts: 156
Joined: 2002.11
Post: #19
Check those links I posted here. They have a wealth of information.

Multiplying matrices to concatenate rotations is much more expensive than multiplying quaternions. Just bear that in mind if performance becomes a concern at some point in your project.
tigakub
Unregistered

Post: #20
I was wondering why you were resistant to using glRotate. To obtain a matrix that you can use yourself you can do something like this.

Code:
```double matrix16[16]; glMatrixMode(GL_MODELVIEW) glPushMatrix() -- to save the current model matrix state glLoadIdentity() -- to load the identity matrix onto the stack top glTranslate -- do your transforms in whatever order you like glRotate glScale glGetParameterd(GL_MODELVIEW_MATRIX, matrix16) -- to retrieve the matrix glPopMatrix()```

This will give you a transformation matrix that you can use to transform your own vertex list if you want without having to deal with any of the component transformation matrices, and at the same time, you can leverage OpenGL's optimizations. I'm sure that it's making use of veclib or something while if you do the matrix operations in your own code ...

But if you're doing a FPS where the gun is stationary relative to the camera, have you considered just drawing the gun before you perform any model view transformations? That way, you don't have to worry about transforming its geometry at all.