Skip to main content
GameDev.net gamedev.net
🔒 Locked

Open GL rotation question!

Started by u_r_b_a_n Nov 25, 2008 at 5:55 AM 2 replies 650+ views
Original Post
u_r_b_a_n
u_r_b_a_n
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
V-man
V-man
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.
u_r_b_a_n
u_r_b_a_n
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 ?
swiftcoder
swiftcoder
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).
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.