1 #include <msp/gl/view.h>
20 void Stage::add_things(Demo::ThingMap &things, const string &prefix)
22 things[prefix+"camera"] = static_cast<GL::Placeable *>(&camera);
25 void Stage::set_camera(const GL::Camera &c)
27 camera.set_object_matrix(c.get_object_matrix());
28 camera.set_up_direction(c.get_up_direction());
29 camera.set_field_of_view(c.get_field_of_view());
30 camera.set_depth_clip(c.get_near_clip(), c.get_far_clip());
34 Stage::UseInView::UseInView():
39 Stage::UseInView::UseInView(GL::View &v, Stage &s):
44 void Stage::UseInView::validate() const
47 throw logic_error("null view");
49 throw logic_error("null stage");
52 void Stage::UseInView::start(float, float)
54 if(!stage->pipeline || view!=stage->last_view)
56 stage->create_pipeline(*view);
58 throw logic_error("null pipeline");
59 stage->last_view = view;
62 view->set_camera(&stage->camera);
63 view->set_content(stage->pipeline);
67 Stage::SetCamera::SetCamera():
72 Stage::SetCamera::SetCamera(Stage &s, const GL::Camera &c):
77 void Stage::SetCamera::validate() const
80 throw logic_error("null stage");
82 throw logic_error("null camera");
85 void Stage::SetCamera::start(float, float)
87 stage->set_camera(*camera);
91 Stage::UseInView::Loader::Loader(UseInView &u, Demo &d):
92 DataFile::DerivedObjectLoader<UseInView, Action::Loader>(u, d)
94 add("stage", &Loader::stage);
95 add("view", &Loader::view);
98 void Stage::UseInView::Loader::stage(const string &n)
100 obj.stage = &demo.get_thing<Stage>(n);
103 void Stage::UseInView::Loader::view(const string &n)
105 obj.view = &demo.get_thing<GL::View>(n);
109 Stage::SetCamera::Loader::Loader(SetCamera &s, Demo &d):
110 DataFile::DerivedObjectLoader<SetCamera, Action::Loader>(s, d)
112 add("camera", &Loader::camera);
113 add("stage", &Loader::stage);
116 void Stage::SetCamera::Loader::stage(const string &n)
118 obj.stage = &demo.get_thing<Stage>(n);
121 void Stage::SetCamera::Loader::camera(const string &n)
123 obj.camera = &demo.get_resources().get<GL::Camera>(n);
126 } // namespace DemoScene