Open GL rotation question!
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
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.
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.
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 ?
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 ?
Quote:Original post by u_r_b_a_ngluLookAt 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.
Should i use perhaps gluLookAt() function?
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).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement