Results 1 to 9 of 9

Thread: looking and moving around in GL_PROJECTION matrix mode

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2001
    Posts
    17

    looking and moving around in GL_PROJECTION matrix mode

    First off, I'm doing this in C++ and in gluPerspective, not Ortho.

    ok, this is what I have.
    My first problem is looking around, the axeses of rotaion aren't right, but I can't seem to figure it out. Here what I have:

    glPushMatrix();
    glRotatef(-yaw,0.0,1.0,0.0);
    glRotatef(-pitch,1.0,0.0,0.0);
    glRotatef(-roll,0.0,0.0,1.0);
    glTranslatef(-eyeX,-eyeY,-eyeZ);
    .
    .
    .

    Can anybody help?

    I'll get to the next problem when this one is solved.

  2. #2
    Member Contributor
    Join Date
    Jul 2001
    Location
    Camarillo, CA, USA
    Posts
    58

    Re: looking and moving around in GL_PROJECTION matrix mode

    HI. Take a look at this page
    http://www.lighthouse3d.com/opengl/glut/index.php3?6

    Trust me; If you pay attention, it helps...

    download the source and execute it to see it.. its kinda cool
    PROGRAMMERS SHALL RULE THE WORLD

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2001
    Posts
    17

    Re: looking and moving around in GL_PROJECTION matrix mode

    Thanks, but I'm trying to do this WITHOUT using the lookat command.

    Can anyone help with the method I am using above?


    [This message has been edited by drummerboy_2002 (edited 10-23-2001).]

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    763

    Re: looking and moving around in GL_PROJECTION matrix mode

    > Thanks, but I'm trying to do this WITHOUT using the lookat command

    why? do you want to do graphics without any gl commands, also?

    cheers,
    John

  5. #5
    Junior Member Newbie
    Join Date
    Oct 2001
    Posts
    17

    Re: looking and moving around in GL_PROJECTION matrix mode

    It was strongly suggested by my professor to NOT use LOOKAT. Instead, we use:


    glRotate(-yaw...
    glRotate(-pitch...
    glRotate(-roll...
    GlTrastlate(-eyeX, -eyeY, -eyeZ);

    He has done a lot of work with flight simulators, so I assume there is a very good reason for it.

  6. #6
    Member Contributor
    Join Date
    Jul 2001
    Location
    Camarillo, CA, USA
    Posts
    58

    Re: looking and moving around in GL_PROJECTION matrix mode

    Your going to want to brush up on your geometry my friend. Especially if you plan on using JUST rotatef and translatef.

    You want to translate according to the negative player.x, player.y, and player.z, and you want to rotate according to -player.rotation. You just need to do your rotations and translations in the right order. Rotate and then translate before drawing your scene.

    Also, if you want the player to move foward relative to his rotation, you need to use some simple trig. In case you didn't already know, that's the following:

    x += sin(angle) * speed;
    y += cos(angle) * speed;

    (you may need to switch the sine and cosine depending on how your coordinates are set up)

    Also, remember that glRotate takes angles in degree measure, while sine and cosine take angles in radian measure, so you'll need to convert between the two. Remember the following:

    1 degree = PI/180 radians

    A trick to compute PI quickly, easily, and painlessly, is the following:

    PI = atan(1) * 4
    PROGRAMMERS SHALL RULE THE WORLD

  7. #7
    Junior Member Newbie
    Join Date
    Oct 2001
    Posts
    17

    Re: looking and moving around in GL_PROJECTION matrix mode

    "Also, remember that glRotate takes angles in degree measure, while sine and cosine take angles in radian measure, so you'll need to convert between the two."

    Ah, maybe that's what's going wrong... hmmm. I'll have to try that tomorrow. It's getting too late to do it tonight.

    We'll see how things go.

    *EDIT* hehe, goemetry is not a problem. Cal III, now that was a problem.

    [This message has been edited by drummerboy_2002 (edited 10-23-2001).]

  8. #8
    Senior Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    SWEDEN
    Posts
    601

    Re: looking and moving around in GL_PROJECTION matrix mode

    Also, you don't change viewing direction in projection matrix mode, you do it in modelview. All this is covered very well in the FAQ.

  9. #9
    Junior Member Newbie
    Join Date
    Oct 2001
    Posts
    17

    Re: looking and moving around in GL_PROJECTION matrix mode

    "Also, you don't change viewing direction in projection matrix mode, you do it in modelview"

    Yeah, I know. I screwed up the topic title and couldn't change it.

    I CAN move and look around, but the axises of rotation aren't quite right for the yaw, pitch and roll. That is what I'm am asking help on.

    [This message has been edited by drummerboy_2002 (edited 10-25-2001).]

Similar Threads

  1. Replies: 4
    Last Post: 06-20-2016, 08:10 AM
  2. Moving the GLUT Teapot Model Using a Transformation Matrix
    By Maria-Rando in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-04-2015, 02:05 PM
  3. GL_PROJECTION matrix mode: using translations, etc
    By imported_sansan in forum OpenGL: General
    Replies: 9
    Last Post: 06-27-2008, 06:42 AM
  4. matrix mode GL_TEXTURE usage
    By MickeyMouse in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-10-2002, 04:12 AM
  5. What do the "matrix mode" and "PortView"variable change
    By HAMCircuitsWillBearMyName in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-29-2001, 07:05 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