help with zooming and turing camera

This is a discussion on help with zooming and turing camera within the Game Programming forums, part of the General Programming Boards category; hi, I am wondering how to turn the camera when my object turns in 1st person view using gluLookat and ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    31

    help with zooming and turing camera

    hi, I am wondering how to turn the camera when my object turns in 1st person view using gluLookat and how to zoom in on a particular object or scene. Thanks in advance.
    'The bigger they are, the harder they fall' ~Yang

  2. #2
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    I haven't used it, but I'd probably just move the camera closer to the target. Something similar with rotating too... in this case using trig to move the camera's aim.
    Last edited by Frobozz; 05-22-2004 at 10:26 PM.

  3. #3
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Most games deal with zoom by temporarily changing the FOV (field of view).
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  4. #4
    Banned
    Join Date
    Dec 2003
    Posts
    367
    To zoom in and out, change the camera position. Rotation can be as hard as you want it to be. For my camera system, I have a unit sphere around the camera, and it calculates a point on it, given yaw and pitch. You just set the reference point to where on the sphere it's at. My camera system doesn't implement roll yet, but the up vector determines roll.

    For more info, http://www.mevis.de/~uwe/opengl/gluLookAt.html

  5. #5
    Banned
    Join Date
    May 2004
    Posts
    129
    just so you know, you don't have to do a lot of crazy vector rotations on arbitrary planes to get the camera rotation effect in opengl! glulookat makes life *so* difficult! you can code something in your own matrix structure in c and generate your own 4x4 matrix utilizing the pitch and yaw (or roll too if you need), and replace the opengl modelview matrix with that specialized matrix before you do any rendering.

    just remember that you must plug in the *negative* angles and negative xyz displacement (because technically the camera must stay in same position, and hte world is rotated and moved backwards to get the same effect).

    Here is some code from a computer game engine that achieves this functionality with the built in opengl commands. you do this before rendering the world:

    Code:
    //dont clear color buffer bit this is not needed and slows
    //things down, will not produce the half life 'mirror' effect unless
    //you are a) outside of the world or b) dont have at least a skybox to render
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    	glLoadIdentity();
    		glRotatef(-rad2deg(mpCam->xRadians),1,0,0);
    		glRotatef(-rad2deg(mpCam->yRadians),0,1,0);
    		glTranslatef(-Pos.x,-Pos.y,-Pos.z);
    		CQUAKE3ShaderManager->DumpShaderstoColorBuffer();	//fancy terms for rendering the world :)
    and another thing, i think altering the near plane distance achieves the same effect...this is because opengl takes the viewing frustum, and alters it into a cube (such that all objects inside the frustum are transformed so that closer objects must be made bigger to stay in the relative size to the frustum, and far objects in the distance (where the frustum is fatter) must be made smaller, this is what scales objects in 3d) . i have not tried this, and altering the fov as was mentioned is more intuitive.
    Last edited by vNvNation; 05-25-2004 at 11:43 PM.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21