Camera

Started by
5 comments, last by Lord_Vader 17 years, 2 months ago
Hello all, Can anyone tell me how to create a space camera that rotates only relatively to its own axes(that they are const oriented relatively to the camera(or the model)? thanks [Edited by - Lord_Vader on January 27, 2007 5:20:10 AM]
Advertisement
Quote:Original post by Lord_Vader
Hello all, Can anyone tell me how to create a space camera that rotates only relatively to its own axes(that they are const oriented relatively to the camera(or the model)?
I'm going to be lazy and just direct you to this source code.
Not exactly sure what you are getting at, however...

When you are using the MODELVIEW matrix stack it defaults to the viewing stack and any rotations/translations etc... you do will transform your camera/world.

Now if you want to transform an individual object, before you give gl it's vertices's you must call glPushMatrix(), then any transformations you do will effect only those vertices's on their local coordinate system. Should usually make a call to glLoadIdentity() before you transform, to clear any left overs in that matrix.

Don't forget to call glPopMatrix() after that object is done being transformed/vertexed(gave the vertex coord's). Or else you will be in MODEL mode the whole time.

ex...

glPushMatrix();

glTranslatef(10,0,0);
glRotatef(angle, 1,0,0);
m_drawCubeVerts();

glPopMatrix();
Quote:Original post by Anonymous Poster
Not exactly sure what you are getting at, however...

When you are using the MODELVIEW matrix stack it defaults to the viewing stack and any rotations/translations etc... you do will transform your camera/world.

Now if you want to transform an individual object, before you give gl it's vertices's you must call glPushMatrix(), then any transformations you do will effect only those vertices's on their local coordinate system. Should usually make a call to glLoadIdentity() before you transform, to clear any left overs in that matrix.

Don't forget to call glPopMatrix() after that object is done being transformed/vertexed(gave the vertex coord's). Or else you will be in MODEL mode the whole time.
What the OP is getting at is the problem of 6DOF motion, which the above does not address. 6DOF motion cannot be implemented in a direct way via OpenGL calls alone (at least not without awkward and perhaps costly state queries).

The code I linked to above implements both 6DOF and 'standard' FPS-style motions (and requires only a basic 3D vector class as support).
I tried and I dont think its possible only with simple glTranslate and glRotate calls.

jyk's code is fine but a little more documentation is needed
to it.
Quote:Original post by Lord_Vader
jyk's code is fine but a little more documentation is needed to it.
If you have specific questions about the code, feel free to post them here (or PM me if you prefer), and I'll be happy to try and help.
Quote:Original post by jyk
If you have specific questions about the code, feel free to post them here (or PM me if you prefer), and I'll be happy to try and help.


I have found your code very useful. I am trying to make it work with my little engine...

thanks again

This topic is closed to new replies.

Advertisement