PixelLightAPI  .
SNMPhysicsUpdateVelocity.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SNMPhysicsUpdateVelocity.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_SCENENODEMODIFIERS_UPDATEVELOCITY_H__
00024 #define __PLPHYSICS_SCENENODEMODIFIERS_UPDATEVELOCITY_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Base/Event/EventHandler.h>
00032 #include <PLMath/Vector3.h>
00033 #include <PLMath/Quaternion.h>
00034 #include "PLPhysics/SceneNodeModifiers/SNMPhysics.h"
00035 
00036 
00037 //[-------------------------------------------------------]
00038 //[ Namespace                                             ]
00039 //[-------------------------------------------------------]
00040 namespace PLPhysics {
00041 
00042 
00043 //[-------------------------------------------------------]
00044 //[ Classes                                               ]
00045 //[-------------------------------------------------------]
00046 /**
00047 *  @brief
00048 *    Updates the linear and angular velocity of physics bodies according to the scene node movement
00049 *
00050 *  @remarks
00051 *    If there's a static (immobile) physics body which should for example move along a well defined path, this
00052 *    static physics body will not interact properly with dynamic physics bodies because it's assumed to stay on one
00053 *    and the same place. But when you have a moving platform or an escalator, this physics body should still be
00054 *    static and therefore not influenced by other physics bodies, but other dynamic physics object should interact
00055 *    correctly with the static moving physics body. (for example move with the platform) The static physics body is
00056 *    in such a case called a kinematic physics body and can be realized within the scene graph by adding this scene
00057 *    node modifier to your scene node which should be a kinematic physics body.
00058 *
00059 *  @note
00060 *    - Keeps track of position changes and updates the linear velocity of the static physics bodies
00061 *    - Keeps track of rotation changes and updates the angular velocity of the static physics bodies
00062 *    - Scene container ownership changes are not tracked
00063 */
00064 class SNMPhysicsUpdateVelocity : public SNMPhysics {
00065 
00066 
00067     //[-------------------------------------------------------]
00068     //[ RTTI interface                                        ]
00069     //[-------------------------------------------------------]
00070     pl_class(PLPHYSICS_RTTI_EXPORT, SNMPhysicsUpdateVelocity, "PLPhysics", PLPhysics::SNMPhysics, "Updates the linear and angular velocity of physics bodies according to the scene node movement")
00071         // Constructors
00072         pl_constructor_1(ParameterConstructor,  PLScene::SceneNode&,    "Parameter constructor",    "")
00073     pl_class_end
00074 
00075 
00076     //[-------------------------------------------------------]
00077     //[ Public functions                                      ]
00078     //[-------------------------------------------------------]
00079     public:
00080         /**
00081         *  @brief
00082         *    Constructor
00083         *
00084         *  @param[in] cSceneNode
00085         *    Owner scene node
00086         */
00087         PLPHYSICS_API SNMPhysicsUpdateVelocity(PLScene::SceneNode &cSceneNode);
00088 
00089         /**
00090         *  @brief
00091         *    Destructor
00092         */
00093         PLPHYSICS_API virtual ~SNMPhysicsUpdateVelocity();
00094 
00095 
00096     //[-------------------------------------------------------]
00097     //[ Protected virtual PLScene::SceneNodeModifier functions ]
00098     //[-------------------------------------------------------]
00099     protected:
00100         PLPHYSICS_API virtual void OnActivate(bool bActivate) override;
00101 
00102 
00103     //[-------------------------------------------------------]
00104     //[ Private functions                                     ]
00105     //[-------------------------------------------------------]
00106     private:
00107         /**
00108         *  @brief
00109         *    Called when the scene node position changed
00110         */
00111         void OnPosition();
00112 
00113         /**
00114         *  @brief
00115         *    Called when the scene node rotation changed
00116         */
00117         void OnRotation();
00118 
00119 
00120     //[-------------------------------------------------------]
00121     //[ Private event handlers                                ]
00122     //[-------------------------------------------------------]
00123     private:
00124         PLCore::EventHandler<> EventHandlerPosition;
00125         PLCore::EventHandler<> EventHandlerRotation;
00126 
00127 
00128     //[-------------------------------------------------------]
00129     //[ Private data                                          ]
00130     //[-------------------------------------------------------]
00131     private:
00132         bool               m_bPreviousPosition; /**< Is there a previous scene node position? */
00133         PLMath::Vector3    m_vPreviousPosition; /**< Previous scene node position */
00134         bool               m_bPreviousRotation; /**< Is there a previous scene node rotation? */
00135         PLMath::Quaternion m_qPreviousRotation; /**< Previous scene node rotation */
00136 
00137 
00138 };
00139 
00140 
00141 //[-------------------------------------------------------]
00142 //[ Namespace                                             ]
00143 //[-------------------------------------------------------]
00144 } // PLPhysics
00145 
00146 
00147 #endif // __PLPHYSICS_SCENENODEMODIFIERS_UPDATEVELOCITY_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:00
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported