#ifndef _TRANSFORMMATRIX_H_ #define _TRANSFORMMATRIX_H_ #include #pragma warning(disable: 4003) #include "gmtl/gmtl.h" namespace projection { /** * Transform matrix class. */ class TransformMatrix { public: /** * Constructor. * * Default transform matrix value is identity matrix. */ TransformMatrix(); /** * Destructor. */ virtual ~TransformMatrix(); /** * Set position of the transform matrix. * * @param pos Position of the transform matrix. */ void setPosition(const gmtl::Vec3f& pos) { m_pos = pos; } /** * Retrieve the position of the transform matrix. * * @return Position of the transform matrix. */ gmtl::Vec3f getPosition() const { return m_pos; } /** * Set rotation of the transform matrix. * * @param rot Rotation of the transform matrix. */ void setRotation(const gmtl::Vec3f& rot) { m_rot = rot; } /** * Retrieve the rotation of the transform matrix. * * @return Rotation of the transform matrix. */ gmtl::Vec3f getRotation() const { return m_rot; } /** * Set scaling of the transform matrix. * * @param scale Scaling of the transform matrix. */ void setScaling(const gmtl::Vec3f& scale) { m_scale = scale; } /** * Retrieve the scaling of the transform matrix. * * @return Scaling of the transform matrix. */ gmtl::Vec3f getScaling() const { return m_scale; } /** * Set whether using scale or not in the transform matrix. * * @param bUseScale True to use scaling in the transform matrix. */ void setUseScaling(bool bUseScale) { m_bUseScale = bUseScale; } /** * Check whether using scale or not in the transform matrix. * * @return True if using scale in the transform matrix. */ bool getUseScaling() const { return m_bUseScale; } /** * Retrieve the trasform matrix. * * @return Trasform matrix. */ gmtl::Matrix44f getMatrix() const; /** * Retrieve the trasform matrix without scaling. * * @return Trasform matrix without scaling. */ gmtl::Matrix44f getMatrixWOScaling() const; /** * Retrieve transform parameters like 'Rotate 45 1 0 0;'. * * @param numSpaces Number of space characters for indent. * @return Transform params. */ QString getParams(int numSpaces=0) const; /** * Assignment operator. * * @param m Assignment source transform matrix. */ TransformMatrix& operator=(const TransformMatrix& m) { m_pos = m.m_pos; m_rot = m.m_rot; m_scale = m.m_scale; return *this; } /** * Equal operator. * * @param a Operand transform matrix. * @param b Operand transform matrix. */ friend bool operator==(const TransformMatrix &a, const TransformMatrix &b) { return (a.m_pos == b.m_pos && a.m_rot == b.m_rot && a.m_scale == b.m_scale); } /** * Not equal operator. * * @param a Operand transform matrix. * @param b Operand transform matrix. */ friend bool operator!=(const TransformMatrix &a, const TransformMatrix &b) { return !(a==b); } /** * Restore the transform matrix from XML data. * * @param element Parent XML element of the transform matrix data. */ virtual void initFromDOMElement(const QDomElement& element); /** * Store the current transform matrix as XML data. * * @param name XML node name of the data. * @param doc XML document to store the data. * @return Current transform matrix data as XML data. */ virtual QDomElement domElement(const QString& name, QDomDocument& doc) const; /** * Reset the matrix. */ void reset(); private: bool m_bUseScale; gmtl::Vec3f m_pos; //!< Position of the tranform matrix. gmtl::Vec3f m_rot; //!< Rotation of the tranform matrix. gmtl::Vec3f m_scale; //!< Scaling of the tranform matrix. double m_mat[16]; //!< Matrix values. Calculated when getMatrix() called. }; }; // projection #endif // _TRANSFORMMATRIX_H_