PDA

View Full Version : rotations//translate



mikethebike
01-28-2012, 06:04 AM
Hi
I need to rotate on all axes a terrain. ok but now how to translate for looking from above and at distance?

glTranslatef(0, 70, -250);//distance and above?
glRotatef ...pitch heading etc.

Like that the terrain moves but it should not move in relation to the viewer. In other words how to put the viewer into the middle of the rotating terrain?
Many thanks

Captain Code
02-02-2012, 09:28 AM
I think what you are asking for is how to rotate a terrain model around its own local axis.

Should be as simple as:

set up initial camera view
glPushMatrix(GL_MODELVIEW)

... now rotate the terrain model
.... terrain model is by definition in local model space and
.... should have been placed in the center (0,0,0), if not
.... use glTransalate3f () to place it at the local-space center
glRotate4f (a,b,c, n) ... where abc is the axis and n is angle in deg

glPopMatrix()

and that is it