PixelLightAPI  .
JointState.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: JointState.h                                   *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLMESH_JOINTSTATE_H__
00024 #define __PLMESH_JOINTSTATE_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLMath/Matrix3x3.h>
00032 #include <PLMath/Matrix3x4.h>
00033 #include <PLMath/Quaternion.h>
00034 #include "PLMesh/PLMesh.h"
00035 
00036 
00037 //[-------------------------------------------------------]
00038 //[ Namespace                                             ]
00039 //[-------------------------------------------------------]
00040 namespace PLMesh {
00041 
00042 
00043 //[-------------------------------------------------------]
00044 //[ Classes                                               ]
00045 //[-------------------------------------------------------]
00046 /**
00047 *  @brief
00048 *    Joint state class
00049 */
00050 class JointState {
00051 
00052 
00053     //[-------------------------------------------------------]
00054     //[ Friends                                               ]
00055     //[-------------------------------------------------------]
00056     friend class Skeleton;
00057 
00058 
00059     //[-------------------------------------------------------]
00060     //[ Public functions                                      ]
00061     //[-------------------------------------------------------]
00062     public:
00063         /**
00064         *  @brief
00065         *    Constructor
00066         */
00067         PLMESH_API JointState();
00068 
00069         /**
00070         *  @brief
00071         *    Destructor
00072         */
00073         PLMESH_API virtual ~JointState();
00074 
00075         //[-------------------------------------------------------]
00076         //[ Data relative to the parent, if the joint has one     ]
00077         //[-------------------------------------------------------]
00078         /**
00079         *  @brief
00080         *    Gets the joint translation
00081         *
00082         *  @return
00083         *    Joint translation
00084         */
00085         PLMESH_API const PLMath::Vector3 &GetTranslation() const;
00086 
00087         /**
00088         *  @brief
00089         *    Sets the joint translation
00090         *
00091         *  @param[in] vTranslation
00092         *    Joint translation
00093         */
00094         PLMESH_API void SetTranslation(const PLMath::Vector3 &vTranslation);
00095 
00096         /**
00097         *  @brief
00098         *    Gets the joint rotation
00099         *
00100         *  @return
00101         *    Joint rotation
00102         */
00103         PLMESH_API const PLMath::Quaternion &GetRotation() const;
00104 
00105         /**
00106         *  @brief
00107         *    Sets the joint rotation
00108         *
00109         *  @param[in] qRotation
00110         *    Joint rotation
00111         */
00112         PLMESH_API void SetRotation(const PLMath::Quaternion &qRotation);
00113 
00114         //[-------------------------------------------------------]
00115         //[ Absolute data                                         ]
00116         //[-------------------------------------------------------]
00117         /**
00118         *  @brief
00119         *    Gets the absolute joint translation
00120         *
00121         *  @return
00122         *    Absolute joint translation
00123         */
00124         PLMESH_API const PLMath::Vector3 &GetTranslationAbsolute() const;
00125 
00126         /**
00127         *  @brief
00128         *    Sets the absolute joint translation
00129         *
00130         *  @param[in] vTranslation
00131         *    Absolute joint translation
00132         */
00133         PLMESH_API void SetTranslationAbsolute(const PLMath::Vector3 &vTranslation);
00134 
00135         /**
00136         *  @brief
00137         *    Gets the absolute joint rotation
00138         *
00139         *  @return
00140         *    Absolute joint rotation
00141         */
00142         PLMESH_API const PLMath::Quaternion &GetRotationAbsolute() const;
00143 
00144         /**
00145         *  @brief
00146         *    Sets the absolute joint rotation
00147         *
00148         *  @param[in] qRotation
00149         *    Absolute joint rotation
00150         */
00151         PLMESH_API void SetRotationAbsolute(const PLMath::Quaternion &qRotation);
00152 
00153         /**
00154         *  @brief
00155         *    Gets the absolute joint matrix
00156         *
00157         *  @return
00158         *    Absolute joint matrix
00159         *
00160         *  @note
00161         *    - This absolute transform matrix is created using the absolute joint
00162         *      translation and rotation.
00163         */
00164         PLMESH_API const PLMath::Matrix3x4 &GetMatrixAbsolute() const;
00165 
00166         /**
00167         *  @brief
00168         *    Gets the transform joint matrix
00169         *
00170         *  @return
00171         *    Transform joint matrix
00172         */
00173         PLMESH_API const PLMath::Matrix3x3 &GetMatrixTransform() const;
00174 
00175         //[-------------------------------------------------------]
00176         //[ Joint space data                                      ]
00177         //[-------------------------------------------------------]
00178         /**
00179         *  @brief
00180         *    Gets the joint space joint translation
00181         *
00182         *  @return
00183         *    Joint space joint translation
00184         */
00185         PLMESH_API const PLMath::Vector3 &GetTranslationJointSpace() const;
00186 
00187         /**
00188         *  @brief
00189         *    Sets the joint space joint translation
00190         *
00191         *  @param[in] vTranslation
00192         *    Joint space joint translation
00193         */
00194         PLMESH_API void SetTranslationJointSpace(const PLMath::Vector3 &vTranslation);
00195 
00196         /**
00197         *  @brief
00198         *    Gets the joint space joint rotation
00199         *
00200         *  @return
00201         *    Joint space joint rotation
00202         */
00203         PLMESH_API const PLMath::Quaternion &GetRotationJointSpace() const;
00204 
00205         /**
00206         *  @brief
00207         *    Sets the joint space joint rotation
00208         *
00209         *  @param[in] qRotation
00210         *    Joint space joint rotation
00211         */
00212         PLMESH_API void SetRotationJointSpace(const PLMath::Quaternion &qRotation);
00213 
00214         //[-------------------------------------------------------]
00215         //[ Misc                                                  ]
00216         //[-------------------------------------------------------]
00217         /**
00218         *  @brief
00219         *    Copy operator
00220         *
00221         *  @param[in] cSource
00222         *    Source to copy from
00223         *
00224         *  @return
00225         *    This joint state
00226         */
00227         PLMESH_API JointState &operator =(const JointState &cSource);
00228 
00229         /**
00230         *  @brief
00231         *    Compares two joint states
00232         *
00233         *  @param[in] cJointState
00234         *    Joint state to compare with
00235         *
00236         *  @return
00237         *    'true' if both joint states are equal, else 'false'
00238         */
00239         PLMESH_API bool operator ==(const JointState &cJointState) const;
00240 
00241 
00242     //[-------------------------------------------------------]
00243     //[ Protected data                                        ]
00244     //[-------------------------------------------------------]
00245     protected:
00246         // Data relative to the parent, if the joint has one
00247         PLMath::Vector3    m_vTranslation;              /**< Translation */
00248         PLMath::Quaternion m_qRotation;                 /**< Rotation */
00249         // Absolute data
00250         PLMath::Vector3    m_vTranslationAbsolute;      /**< Absolute translation */
00251         PLMath::Quaternion m_qRotationAbsolute;         /**< Absolute rotation */
00252         PLMath::Matrix3x4  m_mTransAbsolute;            /**< Absolute transformation matrix */
00253         PLMath::Matrix3x3  m_mTrans;                    /**< 3x3 orthonormal rotation matrix */
00254         // Joint space data
00255         PLMath::Vector3    m_vTranslationJointSpace;    /**< Joint space 3D translation vector */
00256         PLMath::Quaternion m_qRotationJointSpace;       /**< Joint space rotation */
00257 
00258 
00259     //[-------------------------------------------------------]
00260     //[ Private functions                                     ]
00261     //[-------------------------------------------------------]
00262     private:
00263         /**
00264         *  @brief
00265         *    Calculates the initial absolute translation and rotation states and the transform joint matrix
00266         *
00267         *  @param[in] pParentJointState
00268         *    Parent joint state, a null pointer if there's no one
00269         *
00270         *  @return
00271         *    'true' if all went fine, else 'false'
00272         */
00273         bool CalculateInitialStates(const JointState *pParentJointState = nullptr);
00274 
00275 
00276 };
00277 
00278 
00279 //[-------------------------------------------------------]
00280 //[ Namespace                                             ]
00281 //[-------------------------------------------------------]
00282 } // PLMesh
00283 
00284 
00285 #endif // __PLMESH_JOINTSTATE_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:50:57
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported