Sign in to follow this  
altra4u

Positioning camera to see mentioned points

Recommended Posts

altra4u    122
Hi

Lets say I have 3 points I want to make sure are included in the camera's vision frustum.
How can I ensure that the camera is placed at the most optimal position closest to the points but far enough to be able to see all of them together?

Thanks

Share this post


Link to post
Share on other sites
szecs    2990
I think you should give some more information in order to get more specific answers. How is your camera "defined", do you want the frustum's geometry to be static (meaning the angle of view never changes), how accurate does it have to be?

Share this post


Link to post
Share on other sites
Emergent    982
Are there obstacles that can occlude the points? If not, this is basically a 2d problem. Your three points lie in a single plane. Now you're looking for the smallest bounding box containing those points. Google "minimum bounding box" and you'll find how to do this. Once you have that, some simple logic will tell you what a minimal bounding box with your camera's aspect ratio is; it'll be the minimal box with one dimension stretched a little. Once you have this, the size of the box, and its rotation, tell you how far away from the plane the camera needs to be, and how it needs to be rotated.

Granted, there are other choices, and I haven't even really thought through what optimization problem this answer is solving, but it seems quite reasonable.

Share this post


Link to post
Share on other sites
altra4u    122
@[url="user/155219-szecs/"]szecs[/url]
My camera is defined as an object that could be translated and rotated. The problem is I don't really have access to the camera's view frustum settings. All I can do is zoom in and out. That works for player controlled camera where he would like to zoom in and out but I'm having trouble automating the zoom to have the proper view frustum.
To begin with need not be that accurate. If the points had to move, I would simply put the logic in game loop. To start with I would just like to have the camera look straight at the points(lets say they were in the same vertical plane).

@Emergent. Yes this is like a 2d problem No obstacles or anything. I'll try messing with your suggested solution. Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this