Manipulatables.h

Go to the documentation of this file.
00001 #ifndef MANIPULATABLES_H_
00002 #define MANIPULATABLES_H_
00003 
00004 #include "math/Vector3.h"
00005 #include "render.h"
00006 #include "math/matrix.h"
00007 #include "math/quaternion.h"
00008 #include "../xyview/grid.h"
00009 
00010 struct FlatShadedVertex
00011 {
00012         Vertex3f vertex;
00013         Colour4b colour;
00014         Normal3f normal;
00015 
00016         FlatShadedVertex ()
00017         {
00018         }
00019 };
00020 
00021 // ================== Abstract Base Classes =================================
00022 
00023 class Manipulatable
00024 {
00025     public:
00026         virtual void Construct (const Matrix4& device2manip, const float x, const float y) = 0;
00027         virtual void
00028         Transform (const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y) = 0;
00029 };
00030 
00031 class Rotatable
00032 {
00033     public:
00034         virtual void rotate (const Quaternion& rotation) = 0;
00035 };
00036 
00037 class Translatable
00038 {
00039     public:
00040         virtual void translate (const Vector3& translation) = 0;
00041 };
00042 
00043 class Scalable
00044 {
00045     public:
00046         virtual void scale (const Vector3& scaling) = 0;
00047 };
00048 
00049 // ==========================================================================
00050 
00051 class RotateFree: public Manipulatable
00052 {
00053         Vector3 m_start;
00054         Rotatable& m_rotatable;
00055     public:
00056         RotateFree (Rotatable& rotatable) :
00057             m_rotatable(rotatable)
00058         {
00059         }
00060         void Construct (const Matrix4& device2manip, const float x, const float y);
00061         void Transform (const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y);
00062 };
00063 
00064 class RotateAxis: public Manipulatable
00065 {
00066         Vector3 m_axis;
00067         Vector3 m_start;
00068         Rotatable& m_rotatable;
00069     public:
00070         RotateAxis (Rotatable& rotatable) :
00071             m_rotatable(rotatable)
00072         {
00073         }
00074         void Construct (const Matrix4& device2manip, const float x, const float y);
00075 
00077         void Transform (const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y);
00078 
00079         void SetAxis (const Vector3& axis)
00080         {
00081             m_axis = axis;
00082         }
00083 };
00084 
00085 class TranslateAxis: public Manipulatable
00086 {
00087         Vector3 m_start;
00088         Vector3 m_axis;
00089         Translatable& m_translatable;
00090     public:
00091         TranslateAxis (Translatable& translatable) :
00092             m_translatable(translatable)
00093         {
00094         }
00095         void Construct (const Matrix4& device2manip, const float x, const float y);
00096         void Transform (const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y);
00097 
00098         void SetAxis (const Vector3& axis)
00099         {
00100             m_axis = axis;
00101         }
00102 };
00103 
00104 class TranslateFree: public Manipulatable
00105 {
00106     private:
00107         Vector3 m_start;
00108         Translatable& m_translatable;
00109     public:
00110         TranslateFree (Translatable& translatable) :
00111             m_translatable(translatable)
00112         {
00113         }
00114         void Construct (const Matrix4& device2manip, const float x, const float y);
00115         void Transform (const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y);
00116 };
00117 
00118 class ScaleAxis: public Manipulatable
00119 {
00120     private:
00121         Vector3 m_start;
00122         Vector3 m_axis;
00123         Scalable& m_scalable;
00124     public:
00125         ScaleAxis (Scalable& scalable) :
00126             m_scalable(scalable)
00127         {
00128         }
00129         void Construct (const Matrix4& device2manip, const float x, const float y);
00130         void Transform (const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y);
00131 
00132         void SetAxis (const Vector3& axis)
00133         {
00134             m_axis = axis;
00135         }
00136 };
00137 
00138 class ScaleFree: public Manipulatable
00139 {
00140     private:
00141         Vector3 m_start;
00142         Scalable& m_scalable;
00143     public:
00144         ScaleFree (Scalable& scalable) :
00145             m_scalable(scalable)
00146         {
00147         }
00148         void Construct (const Matrix4& device2manip, const float x, const float y);
00149         void Transform (const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y);
00150 };
00151 
00152 void transform_local2object (Matrix4& object, const Matrix4& local, const Matrix4& local2object);
00153 void translation_local2object (Vector3& object, const Vector3& local, const Matrix4& local2object);
00154 
00155 #endif /*MANIPULATABLES_H_*/

Generated by  doxygen 1.6.2