Results 1 to 8 of 8

Thread: camera directions...

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Aurora, Illinois, USA
    Posts
    192

    camera directions...

    ok, I am relatively new to OpenGL (student didn't have the time between finals and APs).

    Anyway, I drew some stuff in OpengGL and now I want to navigate through the environment being able to look up, down, left and right, instead of walking forward or sideways... I am using glTranslatef() to move the camera... is there a more efficent way to navigate through the world? or how about turning the camera 60 or 90 degrees w/o moving?!?

    Any help will be appreciated.

    -Navreet
    Navreet Gill [img]/forum/images/%%GRAEMLIN_URL%%/smile.gif[/img]

  2. #2
    Senior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Aurora, Illinois, USA
    Posts
    192

    Re: camera directions...

    I JUST thought of this, but should I use glRotatef() to move the entire world around me, instead of the camera moving itself?!

    Is this the best way to do it? (Is it even a way?). Again any comments would be appreciated.

    -Navreet

    [This message has been edited by ngill (edited 06-05-2000).]
    Navreet Gill [img]/forum/images/%%GRAEMLIN_URL%%/smile.gif[/img]

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: camera directions...

    There are no camera in OpenGL. Just a viewpoint located at the world origin.

    When you move the "camera" forward, you are actually moving the world backwards. This is the only way to do it in OpenGL, aswell as in any API. Ok, some API's got functions that say you move the camera, but actually you are moving the world in the oposite direction.

    You should either use glTranslate/glRotate OR gluLookAt (i recomend you use this one) to setup the viewpoint.

  4. #4
    Junior Member Newbie
    Join Date
    May 2000
    Location
    Austria
    Posts
    21

    Re: camera directions...

    ca=cos(anglex*0.0174533);
    sa=sin(anglex*0.0174533);
    looky=-sin(angley*0.0174533);
    d=-cos(angley*0.0174533);
    lookx=sa*d;
    lookz=ca*d;
    lookupy=-sin((angley+90.0)*0.0174533);
    d=-cos((angley+90.0)*0.0174533);
    lookupx=sa*d;
    lookupz=ca*d;

    [glRotatef(anglez, 0.0, 0.0, 1.0);]
    gluLookAt (xpos, ypos, zpos, xpos+lookx, ypos+looky, zpos+lookz, lookupx, lookupy, lookupz);

    anglex: rotation round y-axis
    angley: rotation round x-axis
    [anglez: rotation round z-axis](if you need it)

    Try this and you will be happy

  5. #5
    Senior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Aurora, Illinois, USA
    Posts
    192

    Re: camera directions...

    Thanks, I'll look into that.
    Navreet Gill [img]/forum/images/%%GRAEMLIN_URL%%/smile.gif[/img]

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,502

    Re: camera directions...

    I used to use glRotate and glTranslate to do all my object and camera positioning. Then I ran into a problem when I wanted to render transparent polygons correctly. The only solution I could come up with was to largely abandon the use of glRotate and glTranslate, and do my own object->world->clip transforms so that I could have the depth info needed to sort the transparent polys. Just letting you know in case you run into the same problem.


    [This message has been edited by DFrey (edited 06-05-2000).]

  7. #7
    Member Contributor
    Join Date
    May 2000
    Location
    Ottawa, Ontario, Canada
    Posts
    75

    Re: camera directions...

    Check out OpenGl SuperBible version 1.0 which I believe is free online. Has the code you need I forget where also I forget the URL but am sure you can find it. Is what I use and works perfectly.

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

    Re: camera directions...

    A minor, but religious issue... opengl DOES have a camera. That thing set by glFrustum? or gluPerspective? that'll be opengl's camera model.

Similar Threads

  1. Moving directions
    By LearningOGL in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-23-2011, 11:40 AM
  2. Moving directions
    By LearningOGL in forum OpenGL: General
    Replies: 0
    Last Post: 12-20-2011, 07:28 PM
  3. help me directions to this problem! please.
    By luongbeta in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-28-2011, 03:38 PM
  4. normals directions
    By yakovm in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 03-22-2010, 05:40 PM
  5. "Drawing" 32 bit directions
    By dslprog in forum OpenGL: Advanced Coding
    Replies: 14
    Last Post: 04-08-2004, 01:29 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