# Rotate 3DS models

I have read 3DS models into the OpenGL, and I can rotate them around the Z axis. But I don’t know how to make them rotate around the other two axises:X, Y?
Is there anyone can help me? Please tell me! Thanks a lot!

Huh ? That is very trivial OpenGL, nothing to do with algorithms.

From the spec :
void glRotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z);

produces a rotation of angle degrees around the vector (x y z).

So for z axis you have :
glRotated(alpha,0,0,1);

for y axis you have :
glRotated(alpha,0,1,0);

other weird angle :
glRotated(alpha,0,sqrt(2)/2,sqrt(2)/2);

EDIT: and you even don’t have to normalize the vector your rotate around.

But I found the 3DS models are different from the models built by OpenGL, so I can not only simply use the “glRotatef” to control models to rotate.
So is there any other method to solve the problem?

Whell, i had that problem the other day, when i was trying to rotate some models in my own editor.

At the end I used the technique called Compose Affine Transformations(a foolish name, it´s obvious).

You have to get a matrix. This matrix is

“Translate” * Rotate * Translate

“Translate” =
|1 0 0 -x|
|0 1 0 -y|
|0 0 1 -z|
|0 0 0 1|
Rotate is the matrix that containts the axis to rotate,
Translate =
|1 0 0 x|
|0 1 0 y|
|0 0 1 z|
|0 0 0 1|