X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ftransform.h;h=01c783bd7aa3ede6fe428f85f28c4cb4878ff079;hp=24a274b81014ec6b1fe3cbd27da1b5607008b3d4;hb=22ed49c0b233566fc5d72b7c9769fd3ba543ab40;hpb=f14435e58bfa0fa697a06ba9a454bb30cd37d9d8 diff --git a/source/transform.h b/source/transform.h index 24a274b8..01c783bd 100644 --- a/source/transform.h +++ b/source/transform.h @@ -1 +1,59 @@ +#ifndef MSP_GL_TRANSFORM_H_ +#define MSP_GL_TRANSFORM_H_ + +#include #include "matrix.h" + +namespace Msp { +namespace GL { + +/** +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 + { + 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 Angle; + typedef LinAl::Vector 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 + +#endif