]> git.tdb.fi Git - libs/gl.git/blobdiff - source/transform.h
Add compatibility support for slope-based animation interpolation
[libs/gl.git] / source / transform.h
index 35dc56310ff8ec139b1d133a1efa3ef208a065e1..01c783bd7aa3ede6fe428f85f28c4cb4878ff079 100644 (file)
@@ -1,20 +1,57 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #ifndef MSP_GL_TRANSFORM_H_
 #define MSP_GL_TRANSFORM_H_
 
+#include <msp/datafile/objectloader.h>
+#include "matrix.h"
+
 namespace Msp {
 namespace GL {
 
-void translate(float, float, float);
-void rotate(float, float, float, float);
-void scale(float, float, float);
-void scale_uniform(float);
+/**
+Stores a coordinate space transform as individual components.  Primarily
+intended for loading data from external sources.  At runtime transforms
+should generally be stored as matrices.
+*/
+class Transform
+{
+public:
+       class Loader: public DataFile::ObjectLoader<Transform>
+       {
+       public:
+               Loader(Transform &);
+
+       private:
+               void position(float, float, float);
+               void euler(float, float, float);
+               void rotation(float, float, float, float);
+               void scale_uniform(float);
+               void scale(float, float, float);
+       };
+
+       typedef Geometry::Angle<float> Angle;
+       typedef LinAl::Vector<Angle, 3> AngleVector3;
+
+private:
+       Vector3 position;
+       AngleVector3 euler;
+       Vector3 scale;
+
+public:
+       Transform();
+
+       static Transform from_matrix(const Matrix &);
+
+       void set_position(const Vector3 &);
+       void set_euler(const AngleVector3 &);
+       void set_rotation(const Angle &, const Vector3 &);
+       void set_scale(float);
+       void set_scale(const Vector3 &);
+       const Vector3 &get_position() const { return position; }
+       const AngleVector3 &get_euler() const { return euler; }
+       const Vector3 &get_scale() const { return scale; }
+
+       Matrix to_matrix() const;
+};
 
 } // namespace GL
 } // namespace Msp