View Full Version : Spherical Lookat()

JoeyBlunt

10-27-2000, 04:33 AM

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).

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?

I've just read myself and i was really no clear http://www.opengl.org/discussion_boards/ubb/frown.gif

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...

Antonio

10-31-2000, 09:32 AM

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 (http://www.fatech.com/tech)

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.