From: Mikko Rasa Date: Tue, 4 Jun 2019 09:26:54 +0000 (+0300) Subject: Move transform loading to ObjectInstance X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=0cacf19c2e6aaa182ae0fcc7dfaae345aedd0e74;p=libs%2Fgl.git Move transform loading to ObjectInstance --- diff --git a/source/animatedobject.cpp b/source/animatedobject.cpp index 3a781100..390b90b8 100644 --- a/source/animatedobject.cpp +++ b/source/animatedobject.cpp @@ -6,7 +6,6 @@ #include "programdata.h" #include "renderer.h" #include "technique.h" -#include "transform.h" using namespace std; @@ -78,11 +77,9 @@ void AnimatedObject::setup_render(Renderer &renderer, const Tag &) const AnimatedObject::Loader::Loader(AnimatedObject &o): - DataFile::ObjectLoader(o) + DataFile::DerivedObjectLoader(o) { - add("transform", &Loader::transform); - - // Deprecated; Use the transform statement instead + // Deprecated; Use the transform statement defined in ObjectInstance instead add("position", &Loader::position); add("rotation", &Loader::rotation); add("scale", &Loader::scale); @@ -109,12 +106,5 @@ void AnimatedObject::Loader::scale_uniform(float s) obj.matrix.scale(s); } -void AnimatedObject::Loader::transform() -{ - Transform trn; - load_sub(trn); - obj.matrix = trn.to_matrix(); -} - } // namespace GL } // namespace Msp diff --git a/source/animatedobject.h b/source/animatedobject.h index 73c39e2c..2b640b76 100644 --- a/source/animatedobject.h +++ b/source/animatedobject.h @@ -16,7 +16,7 @@ An object instance that can be animated by an AnimationPlayer. class AnimatedObject: public ObjectInstance { public: - class Loader: public DataFile::ObjectLoader + class Loader: public DataFile::DerivedObjectLoader { public: Loader(AnimatedObject &); @@ -26,7 +26,6 @@ public: void rotation(float, float, float, float); void scale(float, float, float); void scale_uniform(float); - void transform(); }; private: diff --git a/source/objectinstance.cpp b/source/objectinstance.cpp index 912ec05f..450c8106 100644 --- a/source/objectinstance.cpp +++ b/source/objectinstance.cpp @@ -1,5 +1,6 @@ #include "objectinstance.h" #include "renderer.h" +#include "transform.h" using namespace std; @@ -26,5 +27,19 @@ void ObjectInstance::setup_render(Renderer &renderer, const Tag &) const renderer.transform(matrix); } + +ObjectInstance::Loader::Loader(ObjectInstance &o): + DataFile::ObjectLoader(o) +{ + add("transform", &Loader::transform); +} + +void ObjectInstance::Loader::transform() +{ + Transform trn; + load_sub(trn); + obj.matrix = trn.to_matrix(); +} + } // namespace GL } // namespaec Msp diff --git a/source/objectinstance.h b/source/objectinstance.h index 906ba2f3..7c2cc9a7 100644 --- a/source/objectinstance.h +++ b/source/objectinstance.h @@ -18,6 +18,16 @@ render all instances of the same object consecutively. */ class ObjectInstance: public PlacedRenderable { +public: + class Loader: public DataFile::ObjectLoader + { + public: + Loader(ObjectInstance &); + + private: + void transform(); + }; + protected: const Object &object;