Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Auto-zoom view  (Read 1624 times)

0 Members and 2 Guests are viewing this topic.

TechRogue

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Auto-zoom view
« on: August 04, 2011, 09:11:12 pm »
I'm trying to implement a camera that pans and zooms to always keep a set of points in view. Currently I center a sf::View on the average position of all objects in a std::vector< const sf::Vector2f* >, and that hasn't given me any trouble. Zooming is proving to be a pain though.

What I want to do is zoom out if any point is further from the center than a given distance, or zoom in if a point is less than a certain distance, with some kind of buffer. I've already tried using sf::Rect<>::Contains (unpredictable and choppy) and getting the length of a line between the center of the view and the points (unreliable as the view zooms out). Anybody have any tips?

 

anything