Results 1 to 2 of 2

Thread: How to use glLookat for navigation?

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    CA
    Posts
    5

    How to use glLookat for navigation?

    How do I use glLookat to navigate around a maze?

    If I try and move forward (with the up key)from my origin, I can change the x,y of the camera position to increment in the forward direction and it is fine.

    However, if I am facing back to the origin and I hit the same key, I move backwards because the I am still incrementing in a forward direction.

    How do I fix this?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: How to use glLookat for navigation?

    On a 3D maze you need all three axis for movement.

    x = left/right
    y = up/down
    z = forward/backwards.

    You need to have a direction variable to indicate which way is forward for your object. Just remember the changing the view does not change how things are moved in the world.
    If you are telling the computer to move the object north, just rotating the object does not mean that it now will start to moving south when you tell it north.


    example code, to give an idea of how to movie forward:

    if(ARROW_KEY_UP == key_press)
    {
    move_x = cos(direction);
    move_z = sin(direction);
    }

    Originally posted by UnderWear:
    How do I use glLookat to navigate around a maze?

    If I try and move forward (with the up key)from my origin, I can change the x,y of the camera position to increment in the forward direction and it is fine.

    However, if I am facing back to the origin and I hit the same key, I move backwards because the I am still incrementing in a forward direction.

    How do I fix this?
    [This message has been edited by nexusone (edited 11-21-2002).]

    [This message has been edited by nexusone (edited 11-21-2002).]

Similar Threads

  1. fps navigation
    By silicon_chipper in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-25-2007, 01:15 AM
  2. Cone Navigation
    By Kumar K in forum OpenGL: General
    Replies: 1
    Last Post: 04-21-2004, 08:55 PM
  3. Cone Navigation
    By Kumar K in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 04-21-2004, 05:31 AM
  4. Navigation
    By in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 03-27-2003, 07:31 AM
  5. Mouse Navigation
    By Gavin in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-11-2001, 01:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean