PixelLightAPI  .
SNMPhysicsJoint.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SNMPhysicsJoint.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 __PLPHYSICS_SCENENODEMODIFIERS_JOINT_H__
00024 #define __PLPHYSICS_SCENENODEMODIFIERS_JOINT_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLPhysics/SceneNodeModifiers/SNMPhysics.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Forward declarations                                  ]
00036 //[-------------------------------------------------------]
00037 namespace PLMath {
00038     class Matrix3x4;
00039 }
00040 namespace PLPhysics {
00041     class Joint;
00042     class ElementHandler;
00043     class SCPhysicsWorld;
00044     class SNMPhysicsBody;
00045 }
00046 
00047 
00048 //[-------------------------------------------------------]
00049 //[ Namespace                                             ]
00050 //[-------------------------------------------------------]
00051 namespace PLPhysics {
00052 
00053 
00054 //[-------------------------------------------------------]
00055 //[ Classes                                               ]
00056 //[-------------------------------------------------------]
00057 /**
00058 *  @brief
00059 *    Abstract physics joint scene node modifier
00060 *
00061 *  @note
00062 *    - There MUST already be a 'PLPhysics::SNMPhysicsBody'-modifier within the owner scene node, else the joint
00063 *      has no effect. Further the owner body can NOT have an infinity (zero = static, the default value) mass.
00064 *    - The scene node 'Target' MUST already exist, else the joint can not be attached to it!
00065 *    - By default joint disables collision with the linked bodies
00066 */
00067 class SNMPhysicsJoint : public SNMPhysics {
00068 
00069 
00070     //[-------------------------------------------------------]
00071     //[ Public definition                                     ]
00072     //[-------------------------------------------------------]
00073     public:
00074         /**
00075         *  @brief
00076         *    Scene node modifier flags
00077         */
00078         enum EFlags {
00079             LocalPinDirection  = 1<<2   /**< If this flag is set, the pin direction(s) of the joint is/are defined in local scene node space instead of scene container space */
00080         };
00081         pl_enum(EFlags)
00082             pl_enum_base(SNMPhysics::EFlags)
00083             pl_enum_value(LocalPinDirection,    "If this flag is set, the pin direction(s) of the joint is/are defined in local scene node space instead of scene container space")
00084         pl_enum_end
00085 
00086 
00087     //[-------------------------------------------------------]
00088     //[ RTTI interface                                        ]
00089     //[-------------------------------------------------------]
00090     pl_class(PLPHYSICS_RTTI_EXPORT, SNMPhysicsJoint, "PLPhysics", PLPhysics::SNMPhysics, "Abstract physics joint scene node modifier")
00091         // Attributes
00092         pl_attribute(Target,    PLCore::String,         "", ReadWrite,  GetSet, "Name of the target scene node (which must have a 'PLPhysics::SNMPhysicsBody' modifier!), can left undefined",  "")
00093             // Overwritten PLScene::SceneNodeModifier attributes
00094         pl_attribute(Flags,     pl_flag_type(EFlags),   0,  ReadWrite,  GetSet, "Flags",                                                                                                        "")
00095     pl_class_end
00096 
00097 
00098     //[-------------------------------------------------------]
00099     //[ Public RTTI get/set functions                         ]
00100     //[-------------------------------------------------------]
00101     public:
00102         PLPHYSICS_API PLCore::String GetTarget() const;
00103         PLPHYSICS_API void SetTarget(const PLCore::String &sValue);
00104         PLPHYSICS_API virtual void SetFlags(PLCore::uint32 nValue) override;    // From PLScene::SceneNodeModifier
00105 
00106 
00107     //[-------------------------------------------------------]
00108     //[ Public functions                                      ]
00109     //[-------------------------------------------------------]
00110     public:
00111         /**
00112         *  @brief
00113         *    Returns the PL physics world scene node container the physics joint is in
00114         *
00115         *  @return
00116         *    The PL physics world scene node container the physics joint is in, a null pointer on error
00117         *    (if that's the case, something went totally wrong :)
00118         *
00119         *  @note
00120         *    - This PL physics world scene node container can be another as the scene node container this scene node is in
00121         */
00122         PLPHYSICS_API SCPhysicsWorld *GetWorldContainer() const;
00123 
00124         /**
00125         *  @brief
00126         *    Returns the PL physics joint
00127         *
00128         *  @return
00129         *    The PL physics joint, a null pointer on error (if that's the case, something went totally wrong :)
00130         */
00131         PLPHYSICS_API Joint *GetJoint() const;
00132 
00133         /**
00134         *  @brief
00135         *    Returns the owner PL physics body scene node modifier the joint is attached to
00136         *
00137         *  @return
00138         *    The owner PL physics body scene node modifier, a null pointer if there's no such body
00139         *
00140         *  @note
00141         *    - The implementation is searching for the first "PLPhysics::SNMPhysicsBody" within the owner
00142         *      scene node of this scene node modifier, this is the "owner" physics body
00143         */
00144         PLPHYSICS_API SNMPhysicsBody *GetOwnerBodyModifier() const;
00145 
00146         /**
00147         *  @brief
00148         *    Returns the target PL physics body scene node modifier the joint is attached to
00149         *
00150         *  @return
00151         *    The target PL physics body scene node modifier, a null pointer if there's no such body
00152         */
00153         PLPHYSICS_API SNMPhysicsBody *GetTargetBodyModifier() const;
00154 
00155 
00156     //[-------------------------------------------------------]
00157     //[ Protected functions                                   ]
00158     //[-------------------------------------------------------]
00159     protected:
00160         /**
00161         *  @brief
00162         *    Constructor
00163         *
00164         *  @param[in] cSceneNode
00165         *    Owner scene node
00166         */
00167         PLPHYSICS_API SNMPhysicsJoint(PLScene::SceneNode &cSceneNode);
00168 
00169         /**
00170         *  @brief
00171         *    Destructor
00172         */
00173         PLPHYSICS_API virtual ~SNMPhysicsJoint();
00174 
00175         /**
00176         *  @brief
00177         *    Recreates the PL physics joint
00178         */
00179         PLPHYSICS_API void RecreatePhysicsJoint();
00180 
00181         /**
00182         *  @brief
00183         *    Calculates the transform matrix that transform from the local owner scene node space into the physics world scene container
00184         *
00185         *  @param[out] mTransform
00186         *    Receives the result
00187         */
00188         PLPHYSICS_API void CalculateJointTransformMatrix(PLMath::Matrix3x4 &mTransform) const;
00189 
00190 
00191     //[-------------------------------------------------------]
00192     //[ Protected virtual SNMPhysicsJoint functions           ]
00193     //[-------------------------------------------------------]
00194     protected:
00195         /**
00196         *  @brief
00197         *    Creates the PL physics joint
00198         */
00199         virtual void CreatePhysicsJoint() = 0;
00200 
00201 
00202     //[-------------------------------------------------------]
00203     //[ Protected data                                        ]
00204     //[-------------------------------------------------------]
00205     protected:
00206         PLCore::String     m_sTarget;           /**< Name of the target scene node (which must have a 'PLPhysics::SNMPhysicsBody' modifier!), can left undefined */
00207         SCPhysicsWorld    *m_pWorldContainer;   /**< The PL physics world scene node container the physics joint is in, can be a null pointer */
00208         ElementHandler    *m_pJointHandler;     /**< Holds the PL physics joint (ALWAYS valid!) */
00209 
00210 
00211     //[-------------------------------------------------------]
00212     //[ Protected virtual PLScene::SceneNodeModifier functions ]
00213     //[-------------------------------------------------------]
00214     protected:
00215         PLPHYSICS_API virtual void InformedOnInit() override;
00216 
00217 
00218 };
00219 
00220 
00221 //[-------------------------------------------------------]
00222 //[ Namespace                                             ]
00223 //[-------------------------------------------------------]
00224 } // PLPhysics
00225 
00226 
00227 #endif // __PLPHYSICS_SCENENODEMODIFIERS_JOINT_H__


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