PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: RagdollBody.h * 00003 * 00004 * Copyright (C) 2002-2012 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 __PLPHYSICS_SCENENODES_RAGDOLLBODY_H__ 00024 #define __PLPHYSICS_SCENENODES_RAGDOLLBODY_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLMath/Vector3.h> 00032 #include <PLMath/Quaternion.h> 00033 #include "PLPhysics/PLPhysics.h" 00034 00035 00036 //[-------------------------------------------------------] 00037 //[ Forward declarations ] 00038 //[-------------------------------------------------------] 00039 namespace PLGraphics { 00040 class Color4; 00041 } 00042 namespace PLRenderer { 00043 class Renderer; 00044 } 00045 namespace PLScene { 00046 class VisNode; 00047 } 00048 namespace PLPhysics { 00049 class Body; 00050 class SNRagdoll; 00051 class ElementHandler; 00052 class SCPhysicsWorld; 00053 } 00054 00055 00056 //[-------------------------------------------------------] 00057 //[ Namespace ] 00058 //[-------------------------------------------------------] 00059 namespace PLPhysics { 00060 00061 00062 //[-------------------------------------------------------] 00063 //[ Classes ] 00064 //[-------------------------------------------------------] 00065 /** 00066 * @brief 00067 * Ragdoll body 00068 * 00069 * @note 00070 * - If you changed some of the initial settings you have to recreate 00071 * the physics object in order to see the changes. 00072 */ 00073 class RagdollBody { 00074 00075 00076 //[-------------------------------------------------------] 00077 //[ Public functions ] 00078 //[-------------------------------------------------------] 00079 public: 00080 /** 00081 * @brief 00082 * Constructor 00083 * 00084 * @param[in] pParent 00085 * Parent ragdoll 00086 */ 00087 PLPHYSICS_API RagdollBody(SNRagdoll *pParent); 00088 00089 /** 00090 * @brief 00091 * Destructor 00092 */ 00093 PLPHYSICS_API virtual ~RagdollBody(); 00094 00095 /** 00096 * @brief 00097 * Returns the PL physics body 00098 * 00099 * @return 00100 * The PL physics body, a null pointer on error (if that's the case, something went totally wrong :) 00101 */ 00102 PLPHYSICS_API Body *GetBody() const; 00103 00104 /** 00105 * @brief 00106 * Sets the name of the body 00107 * 00108 * @param[in] sName 00109 * New body name 00110 * 00111 * @return 00112 * 'true' if all went fine, else 'false' 00113 * (maybe this name is already used within the ragdoll?) 00114 */ 00115 PLPHYSICS_API bool SetName(const PLCore::String &sName); 00116 00117 /** 00118 * @brief 00119 * Draws the physics body 00120 * 00121 * @param[in] cRenderer 00122 * Renderer to use 00123 * @param[in] cColor 00124 * Color to use 00125 * @param[in] cVisNode 00126 * The current visibility node of this scene node 00127 */ 00128 PLPHYSICS_API void Draw(PLRenderer::Renderer &cRenderer, const PLGraphics::Color4 &cColor, const PLScene::VisNode &cVisNode) const; 00129 00130 /** 00131 * @brief 00132 * Creates the physics body 00133 * 00134 * @note 00135 * - After this function the physics body is in it's initial pose 00136 */ 00137 PLPHYSICS_API void CreatePhysicsBody(); 00138 00139 /** 00140 * @brief 00141 * Destroys the physics body 00142 */ 00143 PLPHYSICS_API void DestroyPhysicsBody(); 00144 00145 /** 00146 * @brief 00147 * Returns the current rotation of the physics body 00148 * 00149 * @param[out] qQ 00150 * Will receive the current rotation of the physics body 00151 */ 00152 PLPHYSICS_API void GetRotation(PLMath::Quaternion &qQ) const; 00153 00154 /** 00155 * @brief 00156 * Returns the current transform matrix of the physics body 00157 * 00158 * @param[out] mTrans 00159 * Will receive the current transform matrix of the physics body 00160 */ 00161 PLPHYSICS_API void GetTransformMatrix(PLMath::Matrix3x4 &mTrans) const; 00162 00163 /** 00164 * @brief 00165 * Adds a force to the body 00166 * 00167 * @param[in] vForce 00168 * Force to add 00169 */ 00170 PLPHYSICS_API void AddForce(const PLMath::Vector3 &vForce); 00171 00172 00173 //[-------------------------------------------------------] 00174 //[ Public data ] 00175 //[-------------------------------------------------------] 00176 public: 00177 PLCore::uint32 nIndex; 00178 PLCore::String sName; 00179 00180 PLCore::String sJoint; /**< Joint this body is attached to */ 00181 00182 // Specified whether the body (and any possible joints its connected to) are enabled 00183 bool bEnabled; 00184 00185 PLMath::Vector3 vSize; 00186 PLMath::Vector3 vPos; 00187 PLMath::Quaternion qRot; 00188 float fMass; 00189 00190 SNRagdoll *m_pParentRagdoll; 00191 ElementHandler *m_pBodyHandler; /**< Holds the PL physics body */ 00192 00193 00194 }; 00195 00196 00197 //[-------------------------------------------------------] 00198 //[ Namespace ] 00199 //[-------------------------------------------------------] 00200 } // PLPhysics 00201 00202 00203 #endif // __PLPHYSICS_SCENENODES_RAGDOLLBODY_H__
|