Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: camera

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2002
    Posts
    1

    camera

    does anybody know some good docs about cameras ? (or does anybody have some code i could rip ? )

    i'm searching for some camera model where you have a location (where the eye is), a point were the camera looks at and a roll angle.

    thnx

  2. #2
    Junior Member Regular Contributor
    Join Date
    Feb 2000
    Posts
    148

    Re: camera

    Have you tried gluLookAt?... Does all you want but the roll angle is specified as an up vector..

  3. #3
    Intern Contributor
    Join Date
    Jul 2000
    Posts
    90

    Re: camera

    Using a roll angle is much better gluLookat sucks!!! Use something like this:

    void cam_glview( camera_t* cam ) {
    float M[16];
    float a,b,c;

    memset( M, 0, 16*sizeof(float) );

    a = cam->vn[0];
    b = cam->vn[1];
    c = cam->vn[2];

    M[0] = -c;
    M[8] = a;
    M[1] = -a*b;
    M[5] = a*a+c*c;
    M[9] = -b*c;
    M[2] = -a;
    M[6] = -b;
    M[10] = -c;
    M[15] = 1.0f;

    glRotatef( cam->angle, 0.0f,0.0f,1.0f );
    glMultMatrixf(M);
    glTranslatef(-cam->pos[0],-cam->pos[1],-cam->pos[2] );
    }

  4. #4
    Junior Member Newbie
    Join Date
    Oct 2002
    Posts
    1

    Re: camera

    well, gluLookAt isn't that bad...but how can i rotate the camera ? you know, for example if you're writing a flight simulator, and you want to turn left, the camera should rotate about it's own Y axis (and not about the world's Y axis)

  5. #5
    Intern Contributor
    Join Date
    Jul 2000
    Posts
    90

    Re: camera

    Sorry I should have explained the code but as in a rush

    The vector cam->vn[] is the normal in the viewing direction so this specifies where the camera is pointing like in gluLookat.

    cam->angle is the angle the camera is rotated about its own z-axis: ie the axis coming straight out of the lens. (you said y-axis but I think you meant z). If you want to rotate the camera about its y-axis just change the glrotate*() call but this wouldn't make much sense.

  6. #6
    Intern Contributor
    Join Date
    May 2000
    Location
    Ottawa, Ontario, Canada
    Posts
    77

    Re: camera

    Hi Ann
    OpenGl Superbible has the camera routine that you want (I think!).
    Cheers

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    839

    Re: camera

    What's your problem with gluLookAt? it's a function to calculate the transform between two completely-arbitary points. <shakes head in confusion> how can you say it sucks?

    cheers,
    John

  8. #8
    Intern Contributor
    Join Date
    Jul 2000
    Posts
    90

    Re: camera

    Hehe . I just find a roll angle more intuitive. Plus, since the up vector should always form a right angle with the view vector so why specify redundant information and allow the chance of an error.

    [This message has been edited by foobar (edited 07-28-2000).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •