Results 1 to 3 of 3

Thread: free viewing

  1. #1

    free viewing


    I'am really new at this, but i'am trying to figure out how things work.
    I have made a small world with some geometric objects in it. Now i wanna
    navigate freely in it with my keyboard. So if i first use glTranslate()
    wich moves the coordinate system origin to the point specified by x,y,z
    (the viewer are located in x,y,z, so he is always standing in the origin)
    and after that do a glRotate() everything should be fine, the problems is
    that it always rotate about the "old" origin and not about the origin i have
    "defined" in glTranslate. I could offcourse first do a glRotate() and then a
    glTranslate() but if i then turn 180 degres the forwardbutton become a
    backwardbutton (and so it should do to). My first guess is that there is
    some lack of understanding from my side. How should i do?

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

    Re: free viewing

    You are almost there. You have to have the rotations before the translations, otherwise the rotation will be from the last axis. this is because the transformations are put in a stack and stack works in FIFO(first in first out) So if your glTranslate is before (in your code) than the rotation, it will actually be done after the rotations.

    Now, what you can got to understand, is that moving forward isn't just moving on one axis. It's actually a vector and it depends on the angles.

    So if your Z- goes in the screen and the Y+ goes up and X+ goes left, and the starting position is looking at Z-

    let's call roty the rotation around the y axis.

    moving forward is actually :

    xmov = speed*sin(roty);
    zmov = -speed*cos(roty);

    [This message has been edited by Gorg (edited 03-23-2000).]

  3. #3
    Member Contributor
    Join Date
    Aug 2000
    Epinay sur Seine, France

    Re: free viewing

    Sorry to be late in this topic

    how the example given by Gorg can be extended to use Y axis rotation AND X axis rotation like in quake 3 arena spectator view mode ??
    One life for hate , one eternity for love [img]/forum/images/%%GRAEMLIN_URL%%/smile.gif[/img]

Similar Threads

  1. opengl viewing
    By Sanjeev in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-25-2010, 12:42 PM
  2. Viewing
    By Mukund in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-11-2010, 10:02 PM
  3. 3-D Viewing
    By ToddAtWSU in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-26-2007, 01:34 AM
  4. 3D viewing
    By mochi in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 08-22-2001, 06:58 AM
  5. viewing transformations help please!!!
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 07-05-2000, 04:33 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