# successive rotation

hello,
i am kind of new to openGL,and i faced this biiig probleme

so let’s say i rotate my cube arround X , when i rotate again on Y it ends up rotating arround Z :dejection:
i did some research andi found out that glrotatef rotate evrything including the axis

so basically what i want is a way to rotate arround a specific axis all the time (world axis in my case since i need to make a model for rubik’s cube 3X3X3 )

is my question more than beginner level or what???

You need to do some basic reading on how coordinate frame transforms work. They are applied to the local (then-current) coordinate frame, not any given global coordinate frame.

The OpenGL Programming Guide has a good description of how to think about successive modeling transforms, among others.

thank you for responding,but it would be helpfull if you give me more direct information or reading matrial
(btw I can have axess to almost any book so don’t feel restrained when giving recomondation)

thank you for responding,but it would be helpfull if you give me more direct information or reading matrial

Sure thing.

[ul]
[li]OpenGL Programming Guide: “Viewing” chapter (Chapter 3 in my old 4th ed) – focus particularly on the “Thinking about Transformations” section (A quick google will turn this up on-line. For instance here) [/li][/ul]
If you have any other transformation-related questions, look for the answers in there.

For a good on-line quick ref guide to OpenGL transforms:

[ul]
[li]OpenGL Transformation (Song Ho Ahn) [/li][/ul]
Googling around, looks like:

[ul]
[li]3D Math Primer for Graphics and Game Development may have some good stuff in Section 8.1 [/li][/ul]
but don’t have it handy here to read so I can’t vouch for it.

[QUOTE=flashcs5;1240144]…i rotate my cube arround X , when i rotate again on Y it ends up rotating arround Z[/QUOTE] This is a very common problem encountered by people new to OpenGL or computer graphics in general.
The easiest way to code up rotations is to do something like …

glRotatef (xrot, 1,0,0);
glRotatef (yrot, 0,1,0);
glRotatef (zrot, 0,0,1);

Draw_Objects ();

This results in an Euler rotation sequence, where the successive rotations are not necessarily around body axes or world axes. Most of the time this is o.k., but in special cases (which yours seems to be), you may have to resort to something more involved. With the help of another contributor, I posted some OpenGL code that shows a way to do both world or object space rotations. If you take the time to look at it, you’ll see that it is quite a bit more involved than the code above. Good luck …