The Description
I want to focus my perspective camera on an object. The object can be of arbirary size and I'm not facing the object head on. The camera should focus on multiple parts of the object: the front, one side and the top.
The camera fov is always 90 degrees and the target position is the center of the object. The problem I'm currently facing is: How can I determine the position of the camera?
The interface I have to work with:
void setCameraPosition(Vector3 cameraPosition, Vector3 cameraTarget);
The part in my code that should calculate the position knows nothing about the camera except the fov which is always fixed at 90 degrees.
The following picture shows where I'm currently at (in a simpliefied 2d representation):
- gray arrow = the camera which looks at the object
- blue rectangle = some kind of bounding box around the object (just an idea)
- black rectangle = the object itself
- green markings = marks the sides of the object which the camera should look at. As we are in 2d, the camera looks only at 2 sides instead of 3 as it should in the real application
What I've looked at so far
- How to Fit Camera to Object However, the solution there assumes I'm facing the object head on, which I'm not.
- Camera Zoom To Fit Object This post does not help me as the camera position is already there and only a distance is calculated to place the object within the cameras frustrum.