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

camera call

Started by JARVIS_UK Oct 13, 2005 at 3:45 PM 2 replies 750+ views
Original Post
JARVIS_UK
JARVIS_UK
when trying to position my camera as a first person, i find that it moves out of sync with the rest of the 3d objects which represent the body. i believe the reason is because the camera position is created then the objects are moved then drawn. is there a way of calling the camera after the objects have been moved and drawn. when i move the camera call it just displays every thing drawn after the call i.e nothing
Cocalus
Cocalus
The camera must be called first since the way the camera works is be moving everything else in the world. A basic example would be if you wanted to move your camera to 0,0,100, you do this by moving everything you draw by 0,0,-100 before drawing it. So you can implement a camera with a some glTranslate and glRotate calls if you wanted.

Your problem is probably that you have a bug putting the body and camera in different places.

But if you want to position an object relative to the camera (ie to put a gun in front of your player you just move the gun a little bit in the z-axis). You draw the object before calling glulookat (or whatever your using to setup your camera)
chowe6685
chowe6685
Keep in mind that the camera is a metaphor - opengl doesn't think in terms of a camera. So when you move the "camera" you're really just transforming all the objects in your scene. Thus if you apply the "camera transform" after everything has been drawn there is no effect.
JARVIS_UK
JARVIS_UK
cheers for the posts :)

i knew all of the basics where the scene moves and not the camera but the wording of the posts made it clear that instead of drawing the objects relative to the scene then positioning the camera, I had to draw the object relative to the camera then move the camera to position.

Cheers again everyone:)

Topic Locked

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

Sign in to reply to this topic.