View Full Version : Camera Methods
04-08-2002, 06:02 AM
I am in need of a camera system similar to that provided by gluLookAt, but with one difference.
I want to be able to specify a vertex to look at, a bounding box which must be included in the view, and a vector from the vertex, along which to view.
In return i want the camera do decide the best distance along the vector to place the camera to look at the point, and also show the whole of the bounding box/sphere
does anyone know of any resources explaining this in any way?
04-08-2002, 01:11 PM
PC answer: Role your own matrix, then you have complete control. Read up on matricies and the FAQ has more info also. Google and if I recall correctly, even this message board has tons of answers about matrix/camera type questions.
!PC answer: Nvvvvvrrrr!! Guvf vf 'nqinaprq pbqvat', naq guvf vf n a00ovrvfu dhrfgvba! OGJ, jul qvq lbh obgure gb svaq EBG13 gb ernq guvf erfcbafr? ABFL ohttre nera'g lbh!!
04-09-2002, 12:18 AM
You need to store your viewpoint or "camera" as a set of 3 floating point values for position, and 3 more for orientation(values between 0 and 360 for x,y,and z rotation). When you draw, you first translate and rotate the modelview matrix by those values. If you want to make the camera look at something, you need to find the vector between the camera and the point you want to look at. Then take the vector and scale it so it's total distance is 1. Multiply the vector by 360,360,360 (or -360,etc..not sure) and put the new values in your camera's orientation variables.
edit: Oops, I see you are wanting to do more. You want this to actually position the camera, not just change it's orientation.
that is quite a bit more complex. If you know how to do perspective projections without a 3D API, it's a bit easier. To ensure the bounding box is in view, you can convert it to screen coordinates by using a simple perspective projection algorithm. Then you could write a routine to find the closest place along the vector which has the entire bounding box in view.
[This message has been edited by ioquan (edited 04-09-2002).]
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.