Jump to content
  • Advertisement
Sign in to follow this  
altra4u

Positioning camera to see mentioned points

This topic is 2562 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

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
Advertisement
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
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
@szecs
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
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!