Results 1 to 7 of 7

Thread: camera orbiting

  1. #1
    Junior Member Newbie
    Join Date
    May 2002
    Posts
    14

    camera orbiting

    I'm interested in orbiting the 'camera' aroud my objects. I know there is gluLookAt, but I am not sure how this is used (i mean i know there are 9 parameters and what each of them is more or less, i just don't know how or where to insert the function into my code!)

    basically what I'm trying to acheive is to have the camera be above my objects and to the side (looking down at them) and then have the camera move in a circle around my objects. So it would be like looking at the objects and walking in a circle around them.

    Any input or tips appreciated as always.

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

    Re: camera orbiting

    A option that a lot of people use is to not move the camera but move the whole world to simulate the camera.

    Here is an example of how move around my world.


    glRotatef(WrotateX, 1.0f, 0.0f, 0.0f); rotate world
    glRotatef(WrotateY, 0.0f, 1.0f, 0.0f);
    glRotatef(WrotateZ, 0.0f, 0.0f, 1.0f);
    glTranslatef( 0,0, Worldz); Translate world

    glTranslatef(My_Object[(int)j].Curent_point.xyz[0], My_Object[(int)j].Curent_point.xyz[1], My_Object[(int)j].Curent_point.xyz[2]); Translate object in world.

    glRotatef(My_Object[(int)j].Rotation_x, 1.0f, 0.0f, 0.0f); Rotate object
    glRotatef(My_Object[(int)j].Rotation_y, 0.0f, 1.0f, 0.0f);
    glRotatef(My_Object[(int)j].Rotation_z, 0.0f, 0.0f, 1.0f);
    Draw_Object();


    Originally posted by Penance:
    I'm interested in orbiting the 'camera' aroud my objects. I know there is gluLookAt, but I am not sure how this is used (i mean i know there are 9 parameters and what each of them is more or less, i just don't know how or where to insert the function into my code!)

    basically what I'm trying to acheive is to have the camera be above my objects and to the side (looking down at them) and then have the camera move in a circle around my objects. So it would be like looking at the objects and walking in a circle around them.

    Any input or tips appreciated as always.

  3. #3
    Member Contributor
    Join Date
    Dec 2001
    Location
    Porto Velho
    Posts
    97

    Re: camera orbiting

    You alwalys move the whole world. In all graphic engines(directx...) even in linear algebra. Its a very relative question. When you move all the world its supposed that you are moving. Relativity theory.

    Sorry about my english.

  4. #4
    Member Contributor
    Join Date
    Mar 2002
    Location
    France
    Posts
    52

    Re: camera orbiting

    Isdi,

    do you mean that all 3D engine prefers moving all the world instead of a camera in such a situation ?

    Is it very more powerful than using gluLookAt ? anyway gluLookAt (as i think) uses transformations as you do when transforming all the world (rotation, translation & scaling). So, what is the real problem if you call it in the first matrix of modelview ?

    thanx
    Je suis celui qui failli qui trépasse et se lasse, je suis celui qu'on abuse à vider de sa face

  5. #5
    Senior Member Regular Contributor
    Join Date
    Mar 2001
    Posts
    184

    Re: camera orbiting

    he's just saying that moving the camera X units is identical to moving the entire world -X units. there is no visible difference.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Princeton, NJ
    Posts
    380

    Re: camera orbiting

    this same argument is going on at the NEHE forum, someone there put it best when he said
    you cannot move the camera without moving your moniter. OpenGL doesn't internally have a camera, everything is transformed by the modelview matrix and drawn relative to 0,0,0. all gluLookAt does is setup the modelview matrix to move appropriately

  7. #7
    Senior Member Regular Contributor
    Join Date
    Dec 2001
    Location
    Belmont, CA, USA
    Posts
    216

    Re: camera orbiting

    To answer your question...

    Call gluLookAt second, right after the glLoadIdentity call.

Similar Threads

  1. problem with camera orbiting around object -- gluLookAt
    By viorik in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 02-01-2014, 05:06 PM
  2. orbiting
    By morello in forum OpenGL: General
    Replies: 4
    Last Post: 11-26-2010, 05:22 PM
  3. Gimbal lock while orbiting camera around interest point
    By remedios79 in forum OpenGL: General
    Replies: 7
    Last Post: 12-01-2004, 08:49 PM
  4. Orbiting Camera
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-12-2004, 05:34 AM
  5. Orbiting camera around a point using quaternions
    By mohammad_aburrub in forum OpenGL: Basic Coding
    Replies: 10
    Last Post: 10-24-2003, 09:47 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