Jump to content
  • Advertisement
Sign in to follow this  
u_r_b_a_n

OpenGL Open GL rotation question!

This topic is 3498 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have an OpenGL window with drawn coordinate sistem and lines. Lines are rotating around center point (0,0,0) with: glRotatef(xRotAng, 0, 1, 0) glRotatef(yRotAng, 1, 0, 0) and coordinate sistem is translated for: glTranslatef(0.0f, 2.0f, -10.0f) and it's rotating with lines... How can i make coordinate sistem to rotate with the same rotation as lines, only it must rotate around it's axis?! tnx for help

Share this post


Link to post
Share on other sites
Advertisement
This is a question on order of operations. The last operation is "done" first.
So

glTranslatef(0.0f, 2.0f, -10.0f)
glRotatef(xRotAng, 0, 1, 0)
glRotatef(yRotAng, 1, 0, 0)

should work for you. It rotates around x axis, then y axis, then translate.

Share this post


Link to post
Share on other sites
I tried that and it doesn't work ... Coordinate system gets some weird rotation...

I also tried reseting the window with glLoadIdentity() and it still doesn't work...

Before and after drawing of any object i use glPushMatrix() and glPopMatrix()...

Should i use perhaps gluLookAt() function ?

Share this post


Link to post
Share on other sites
Quote:
Original post by u_r_b_a_n
Should i use perhaps gluLookAt() function?
gluLookAt won't help you much if you don't understand how transformations work - gluLookAt computes exactly the same translations and rotations internally. I would suggest that you pick up a book on geometrical transformation and matrices - Computer Graphics, Principles and Practice is a little dated, but the low-level stuff (including math) is very useful.

Along the same lines as V-man's point, it is often helpful to think about camera transformations as affecting the world, not the camera (you don't translate the camera by 5 units along the z-axis, instead you translate the world by -5 along the z-axis).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!