Results 1 to 3 of 3

Thread: Realistic motion (turning left and right) question...

  1. #1
    Member Contributor
    Join Date
    Mar 2000
    Posts
    94

    Realistic motion (turning left and right) question...

    Hi,
    How hard is it to turn left and right on a 3d plane? (Is it a simple call, or 2 dozen factors to modify and keep track of?) Let me try and clarify my problem...I have created a very simple 3d world(a floor and a building) I can use glrotate(), but it rotates my entire scene about the oigin(which is nice to look at but not what i need) I can use translate (but that just moves me side to side) how hard would it be to turn left and right(not shift left and right) and maintain that my up key on the keyboard continuously moves me in the direction im facing(right now it moves toward the origin)? If you know how to do this (and it involves pushmatrix, popmatrix modelview) please try and explain it simple(I'm still FAR from learning how to use these things effectivly..A code snippet would be very usefull)Thanx so much in advance......

    bh9158@wcu.edu

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    569

    Re: Realistic motion (turning left and right) question...

    Trigonometry!!!!!!! You have to remember, going forward isn't just going on one axis, it is actually a vector. so you have to take into account the angles of rotation.

    Do it on paper, you'll see it is very simple.

  3. #3
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,342

    Re: Realistic motion (turning left and right) question...

    Do something like this pseudo:
    Code :
    if (key == LEFT)  angle += 0.1;
    if (key == RIGHT) angle -= 0.1;
    if (key == UP){
       Xpos += SPEED * cos(angle);
       Zpos += SPEED * sin(angle);
    }
    if (key == DOWN){
       Xpos -= SPEED * cos(angle);
       Zpos -= SPEED * sin(angle);
    }

Similar Threads

  1. noob question shifting the scene left or right?
    By bsabiston in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-17-2013, 03:23 AM
  2. glViewport from top left, not bottom left
    By sol in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 06-20-2007, 01:07 AM
  3. Realistic fire
    By t3jem in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 06-12-2005, 06:36 PM
  4. Replies: 0
    Last Post: 01-21-2005, 06:06 AM
  5. how to get realistic sunshine?
    By mogu in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-02-2001, 03:48 AM

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