Archived

This topic is now archived and is closed to further replies.

Newbie-Rotate Camera????

This topic is 5973 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

How do I rotate the camera around several objects... please be simple and direct. I''m still a newbie. Thnkz in advance Squizz-Repaint the World

Share this post


Link to post
Share on other sites
For a start you could try using glrotatef before you translate the scenario.......

glLoadidentity();
glRotatef (xx,xx,xx,xx);
glTranslatef (xx,xx,xx);

DRAW STUFF

if (key->left)
rotatef_left

if (key->right)
rotate_rigth


Hope this can help you out a little....

Take Care!

- -- ---[XaOs]--- -- -

Share this post


Link to post
Share on other sites
Unfortunatly it does not, I know those commands I what happens is they all rotate on thier OWN axis... is there a way to rotate them ALL... ie rotate the camera...

PLEASE HELP

Squizz-Repaint the World

Share this post


Link to post
Share on other sites
I such a DOOS
sorry for not reading your replay propley everything works now =) expect complex bricks... but thats not OpenGL thats game code... which I can sort out... Thnkz loadz as always you helpful guys in the gamedev forums always pull through.

Oh well thnkz again
*Squizz sets out to finish*

Squizz-Repaint the World

Share this post


Link to post
Share on other sites
I think you can use glPushMatrix() and glPopMatrix() to rotate about one origin

glPushMatrix() pushes the current matrix onto the stack. All further drawing is then made around the origin at the top of the stack.

glPopMatrix() discards the matrix at the top of the stack and places the second matrix at the top of the stack. All other matrices in the stack are moved up by one.

// Reset modelview matrix to identity matrix
glLoadIdentity();

// Push the current matrix onto the stack
glPushMatrix();

// perform transformations i.e:

glTranslatef(xx,xx,xx);
glRotatef(xx,xx,xx);

// Draw object in centre of screen
glBegin(XX)
glVertex3f(xx,xx,xx);
glEnd();

// destroy top matrix on stack (One that had been effected by the translation and rotation) making the second matrix on the stack current. This effectively resets drawing back to the origin of the screen.
glPopMatrix();

// further drawing is made from the origin of the screen

Hope this helps using this you can draw many objects in relation to other objects origins. You need to do this to ensure that all objects have a local origin to rotate about rather than just rotating along there own axis.

If you want to do a lot of camera movement I suggest taking a look at the gluLookAt() function. This allows you to control a camera easily without having to worry about matrices and complex stuff. Maybe even build yourself a Camera class that uses lower level routines

If you need me to clarify anything or go into more depth about the gluLookAt() function don''t hesitate to reply.

Hope this helps!!

~Steve~

Share this post


Link to post
Share on other sites
It''s a cruel world.....
I reply first, correct, and get missunderstood!!!!!!!
But Hey.....as long as things get good...everything is fine!! Rigth?


Take Care!




- -- ---[XaOs]--- -- -

Share this post


Link to post
Share on other sites