PDA

View Full Version : Can I revolve the view point ?



silvia_steven_2000
10-21-2003, 03:32 PM
Hi Guys

I think rotating the whole world around a point in the space is the same as orbiting the eye around the same point, my question is: can I physically orbit the eye while keeping the world stationary? how can we do that ?

thanks

Silvia

10-21-2003, 06:41 PM
If the camera is orbiting only in one of the two examples are they not the same. One solution is to use polar coordinates. From chapter 4 in the red book:

Suppose your application involves orbiting the camera around an object that's centered at the origin. In this case, you'd like to specify the viewing transformation by using polar coordinates. Let the distance variable define the radius of the orbit, or how far the camera is from the origin. (Initially, the camera is moved distance units along the positive z-axis.) The azimuth describes the angle of rotation of the camera about the object in the x-y plane, measured from the positive y-axis. Similarly, elevation is the angle of rotation of the camera in the y-z plane, measured from the positive z-axis. Finally, twist represents the rotation of the viewing volume around its line of sight.

Show that the following routine could serve as the viewing transformation:

void polarView{GLdouble distance, GLdouble twist,
GLdouble elevation, GLdouble azimuth)
{
glTranslated(0.0, 0.0, -distance);
glRotated(-twist, 0.0, 0.0, 1.0);
glRotated(-elevation, 1.0, 0.0, 0.0);
glRotated(azimuth, 0.0, 0.0, 1.0);
}

silvia_steven_2000
10-21-2003, 07:05 PM
my problem is not how to represent the camera orientation (polar or quaternion or whatelse), I need the final effect to be:
stationary world and orbiting camera, I do not need to orbit the whole world around the pivot point.

10-21-2003, 09:54 PM
I dont know what is most confusing your sex or the talk about orbiting the camera instead of the world. http://www.opengl.org/discussion_boards/ubb/tongue.gif
I guess the above is rude but what do you think the code does? The text clearly says that the code is for orbiting the camera.

silvia_steven_2000
10-22-2003, 08:16 AM
what the hell r u talking about ?
I am talking about OpenGL stuff and you are talking about sex !!!!
what is the matter with you ? anyhow thanks allot for the replys

chowe6685
10-22-2003, 10:54 AM
there is no such thing as a camera, its an analogy. The only thing you can do is change the position of objects in your world. Rotating the world makes it seem as though the "eye" is moving but there is no eye, its just the motion of the world

10-22-2003, 11:45 PM
Dont pretend to be a woman if you find it embarrasing. http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/014273.html

silvia_steven_2000
10-23-2003, 12:52 PM
Dear RH

Can you send me your e-mail
I need to talk to u in person
I have something to tell you

thanks

10-23-2003, 10:22 PM
No, its very tempting but I dont want to get between you and Moe. Its better if we are just friends. God knows what he would do if he found out about you and me. http://www.opengl.org/discussion_boards/ubb/eek.gif

dorbie
10-23-2003, 10:44 PM
Well if the point == the eye location it would rotate about the eye wouldn't it.

Now if the eye is at 0,0 (depends when the matrix for the rotation is applied) then there would be no need for the translates to and from the point of rotation at all.

So, a competent implementation would probably move the location in the code at which the rotation was applied on the modelview matrix and remove the translates.

The final thing you may want to do is reverse the angle of rotation since eye manipulations should be the reverse of model manipulations if you are trying to apply the equivalent of the model operation to the eye.

What course are you studying on?

silvia_steven_2000
10-24-2003, 07:57 AM
I am now able to orbit my camera successfully horizontally and vertically
Horizontally : the camera orbits in the plane formed by camera.direction
and camera.up ,the axis of rotation is camera.right and do not forget that
this axis of rotation is placed at the pivot point we are orbiting around
Vertically: the camera orbits in the plane formed by camera.direction
and camera.right ,the axis of rotation is camera.up

Here is the code flow:

OrbitCameraHorz(pivot,angle)
{
active_povit = pivot + (the projection of [vector from pivot to camera.position] on the camera.up)
cam.Quat*=cam.Quat.AxisAngleToQuat(angle,cam.up)
cam.Quat.Roate(cam.direction)
cam.right = cam.directionXcam.up
cam.up = same
new cam.position = active_pivot - R * cam.direction
where R = length(vector from active_poivot to old cam.position)
I have my own looat routine
LookAt(cam.pos,active_pivot,cam.up)
}

I hope I did not miss any thing, it looks strange but if you sketch
the diagram u will see it is a simple vector addition
I am using quaternions, u can use any thing else but the idea is the same

silvia_steven_2000
10-24-2003, 08:04 AM
sorry guys, I mean
I am now able to orbit my camera successfully horizontally and vertically
Vertically: the camera orbits in the plane formed by camera.direction
and camera.up ,the axis of rotation is camera.right and do not forget that
this axis of rotation is placed at the pivot point we are orbiting around
Horizontally: the camera orbits in the plane formed by camera.direction
and camera.right ,the axis of rotation is camera.up