Thread: cameras in opengl

  1. #1
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743

    cameras in opengl

    okay, i got the basics of my 3d walkaround working....but there is one more problem.

    When I press the right and left arrow keys, I simply rotate everything along the y-axis.

    As you can assume this isnt the best way to turn right and left....at all....

    Anybody know more about turning and stuff in 1st person view? im guessing u use cameras....i dont know how to use them though...
    My Website

    "Circular logic is good because it is."

  2. #2
    Registered User Coder's Avatar
    Join Date
    Aug 2001
    Location
    Cairo, Egypt
    Posts
    128
    Just define a camera :
    Code:
    struct Camera_t
    {
    Vec3_t vPos;
    Vec3_t vAngle;
    };
    Whenever the player walks, change the camera (player) position accordingly, whenever he looks around, change the camera's angle accordingly.

    Then, when you're going to render, make a camera (view) matrix with rotation (-vAngle.x,-vAngle.y,-vAngle.z) and translation (-vPos.x,-vPos.y,-vPos.z).
    This makes sense :
    When the player moves forward : The world moves backward
    When the player looks right : The world rotates to his left
    That's why you negate things.

    Multiply this matrix by the world coordinates of any object to get aligned coordinates (coordinates in the camera space), then by the projection matrix to get the final screen coordinates.
    Muhammad Haggag

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM