1 #include <msp/gl/tests.h>
11 View3D::View3D(Layout3D &l, unsigned w, unsigned h):
17 pipeline.set_camera(&camera);
18 pipeline.add_renderable_for_pass(layout.get_scene(), 0);
20 GL::Pipeline::Pass *pass = &pipeline.add_pass(0);
21 pass->set_lighting(&layout.get_lighting());
22 pass->set_depth_test(&GL::DepthTest::lequal());
24 camera.set_up_direction(GL::Vector3(0, 0, 1));
26 camera.set_look_direction(GL::Vector3(0, 0.5, -0.866));
27 camera.set_aspect(float(width)/height);
32 void View3D::view_all(bool tight)
34 const set<Track *> &tracks = layout.get_layout().get_all<Track>();
35 Geometry::BoundingBox<float, 3> bbox;
36 for(set<Track *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
37 bbox = bbox|(*i)->get_bounding_box();
39 const Vector &minp = bbox.get_minimum_point();
40 const Vector &maxp = bbox.get_maximum_point();
42 float t = tan(camera.get_field_of_view()/2.0f)*2.0f;
43 float size = max((maxp.y-minp.y+0.1), (maxp.x-minp.x+0.1)/camera.get_aspect());
46 dist += sin(camera.get_field_of_view()/2.0f)*size;
47 GL::Vector3 center = (minp+maxp)/2.0f;
48 const GL::Vector3 &look = camera.get_look_direction();
49 camera.set_position(center-look*dist);