X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fstage.cpp;h=267afe3a7dbe31148c590fa8fbf907fa9cb75813;hb=5dad2cbf4556cd4b433722c172f0b468d0161de5;hp=ef5cac44ca5bbdcf8429350e4f98cb35afff7bdb;hpb=35332818fc6bad98fe77831de2c51a11326e31aa;p=libs%2Fdemoscene.git diff --git a/source/stage.cpp b/source/stage.cpp index ef5cac4..267afe3 100644 --- a/source/stage.cpp +++ b/source/stage.cpp @@ -1,6 +1,8 @@ #include +#include "demo.h" #include "stage.h" +using namespace std; using namespace Msp; Stage::Stage(): @@ -12,14 +14,100 @@ Stage::~Stage() delete pipeline; } +void Stage::add_postprocessor(GL::PostProcessor &pp) +{ + pipeline->add_postprocessor(pp); +} + +void Stage::set_camera(const GL::Camera &c) +{ + camera.set_object_matrix(c.get_object_matrix()); + camera.set_up_direction(c.get_up_direction()); + camera.set_field_of_view(c.get_field_of_view()); + camera.set_depth_clip(c.get_near_clip(), c.get_far_clip()); +} + + +Stage::UseInView::UseInView(): + view(0), + stage(0) +{ } Stage::UseInView::UseInView(GL::View &v, Stage &s): - view(v), - stage(s) + view(&v), + stage(&s) { } +void Stage::UseInView::validate() const +{ + if(!view) + throw logic_error("null view"); + if(!stage) + throw logic_error("null stage"); +} + void Stage::UseInView::start(float, float) { - view.set_camera(&stage.camera_control.get_camera()); - view.set_content(stage.pipeline); + view->set_camera(&stage->camera); + view->set_content(stage->pipeline); +} + + +Stage::SetCamera::SetCamera(): + stage(0), + camera(0) +{ } + +Stage::SetCamera::SetCamera(Stage &s, const GL::Camera &c): + stage(&s), + camera(&c) +{ } + +void Stage::SetCamera::validate() const +{ + if(!stage) + throw logic_error("null stage"); + if(!camera) + throw logic_error("null camera"); +} + +void Stage::SetCamera::start(float, float) +{ + stage->set_camera(*camera); +} + + +Stage::UseInView::Loader::Loader(UseInView &u, Demo &d): + DataFile::DerivedObjectLoader(u, d) +{ + add("stage", &Loader::stage); + add("view", &Loader::view); +} + +void Stage::UseInView::Loader::stage(const string &n) +{ + obj.stage = &demo.get_thing(n); +} + +void Stage::UseInView::Loader::view(const string &n) +{ + obj.view = &demo.get_thing(n); +} + + +Stage::SetCamera::Loader::Loader(SetCamera &s, Demo &d): + DataFile::DerivedObjectLoader(s, d) +{ + add("camera", &Loader::camera); + add("stage", &Loader::stage); +} + +void Stage::SetCamera::Loader::stage(const string &n) +{ + obj.stage = &demo.get_thing(n); +} + +void Stage::SetCamera::Loader::camera(const string &n) +{ + obj.camera = &demo.get_resources().get(n); }