Jump to content
  • Advertisement
Sign in to follow this  
Seikilos

Camera Rotation - basic question

This topic is 3734 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have some massive blackout. I want to create a camera that rotates around a specified point, using some way of "LookAt" implies some problems, since I require eye Position and a correct UP-Vector. While rotating the camera my, up-vector calculation and eye-position would be a mess but unfortunately I forgot how to do it in other ways. Actually its not a problem to create a translation to point like (0,-10,100), looking from above down, adding a rotation matrix, multiplying them et voila, I would have a perfect rotation, but not the rotation I require. These steps would rotate the camera around a -10 coordinate, I require an other point, like (0,0,0) for instance, but since the camera is pointing downward in a straight line this doesnt work :/

Share this post


Link to post
Share on other sites
Advertisement
What about this?
Suppose that d is the distance from the look at point and you eye

Set eye = -d
Rotate eye around the origin for the desidered angle
Transform eye with a translation such that (0,0,0) would become your lookat point, that is, translate by (x,y,z), where x, y, and z are the lookat point coordinates.

Now you have your eye and the direction (lookat - eye).
Now you find the up and right vectors by doing:
direction cross (0,1,0) => right vector
direction cross right => up vector

Could this work?

In addition, try giving a look to quatrnions. I never used them, but perhaps they are more suited for things like this....

EDIT: of course, you have to adjust values if you are using OpenGl coordinate system conventions (-z pointing inside the scene).

Share this post


Link to post
Share on other sites
(Sorry got a bug above, desired camera position is (0,100,10) with Z axis pointing towards myself)

This approach implies some problems, as I believe.

The problem here is, that the camera is looking down in a straight line, so camera look direction is (0,-1,0). Your approach would require besically two rotations ( the second one is simply the rotation around (0,-1,0) which is no problem), the one complex rotation have to rotate the camera around the X axis to create a facing towards a point that is not directly below the camera ( can you follow me?) but the trick here is, what kind of rotation? What angle should I rotate the camera to get a correct position at the end? This rotation must incorporate the position (0,100,10) because rotation angle depends on the position of the camera, wrong rotation would cause the object not to be centered at the screen but somewhere else or even not show the object at all

Btw I know about quaternions :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!