Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Spherical Lookat()

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2000
    Location
    Glen Head
    Posts
    1

    Spherical Lookat()

    I need some help implementing an app that will allow the use of the arrow keys to move the "camara" aroung a object (located at the origin) in a spherical manner. That is, the camara is always positioned on the sphere shell defined by equation X^2 + Y^2 + Z^2 = R, (where R is the radius of the sphere).

  2. #2
    Intern Contributor
    Join Date
    Aug 2000
    Location
    france
    Posts
    89

    Re: Spherical Lookat()

    What u have to do is (in pseudo code):

    translate u'r camera to the center of the sphere
    Rotate around two axes with two angles
    Translate inverse from the center of the sphere

    Was it clear?

  3. #3
    Intern Contributor
    Join Date
    Aug 2000
    Location
    france
    Posts
    89

    Re: Spherical Lookat()

    I've just read myself and i was really no clear

    So second chance:

    Translate the camera to the center of the sphere
    The camera is looking to its -Z axis.

    So rotate around its X axis and around its Y Axis.
    Now u have the good orientation but u are still centered in the sphere.

    So you just have to do the inverse translation.

    exemple:

    glTranslatef(0.f, 0.f, -Distance_Camera_CenterOfTheSphere);
    glRotatef(AroundYAngle, 0.f, 1.f, 0.f);
    glRotatef(AroundXAngle, 1.f, 0.f, 0.f);
    glTranslatef(0.f, 0.f, Distance_Camera_CenterOfTheSphere);

    Hope that helped...

  4. #4
    Intern Contributor
    Join Date
    Jul 2000
    Location
    Braga, Portugal
    Posts
    91

    Re: Spherical Lookat()

    Do you want to have the camera on ther surface of a sphere, looking at the origin?

    If this is the case then you could use polar coordinates, where R is fixed, and use the arrows to change the two angles to set the camera position. As for looking at the origin, and since you already have the position of the camera, using gluLookAt you can set the look at point to be the origin.

    Antonio www.fatech.com/tech
    Antonio Ramires Fernandes www.lighthouse3d.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •