- Point minp;
- Point maxp;
-
- const list<Track3D *> &tracks = layout_3d->get_tracks();
- for(list<Track3D *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
- {
- Point tmin;
- Point tmax;
- (*i)->get_bounds(0, tmin, tmax);
- minp.x = min(minp.x, tmin.x);
- minp.y = min(minp.y, tmin.y);
- maxp.x = max(maxp.x, tmax.x);
- maxp.y = max(maxp.y, tmax.y);
- }
-
- float t = tan(camera.get_field_of_view()/2)*2;
- float size = max((maxp.y-minp.y+0.1), (maxp.x-minp.x+0.1)/camera.get_aspect());
- float cam_dist = size/t+size*0.25;
- Point center((minp.x+maxp.x)/2, (minp.y+maxp.y)/2);
- camera.set_position(GL::Vector3(center.x, center.y-cam_dist*0.5, cam_dist*0.866));
- camera.set_look_direction(GL::Vector3(0, 0.5, -0.866));