PixelLightAPI  .
SNMPhysicsCharacterController.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SNMPhysicsCharacterController.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 __PLENGINE_CONTROLLER_SNMPHYSICSCHARACTERCONTROLLER_H__
00024 #define __PLENGINE_CONTROLLER_SNMPHYSICSCHARACTERCONTROLLER_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Base/Event/EventHandler.h>
00032 #include "PLEngine/Controller/SNMPhysicsCharacter.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Forward declarations                                  ]
00037 //[-------------------------------------------------------]
00038 namespace PLScene {
00039     class SNMMeshUpdate;
00040 }
00041 namespace PLEngine {
00042     class PhysicsCharacterController;
00043 }
00044 
00045 
00046 //[-------------------------------------------------------]
00047 //[ Namespace                                             ]
00048 //[-------------------------------------------------------]
00049 namespace PLEngine {
00050 
00051 
00052 //[-------------------------------------------------------]
00053 //[ Classes                                               ]
00054 //[-------------------------------------------------------]
00055 /**
00056 *  @brief
00057 *    Basic PL physics character controller scene node modifier class
00058 *
00059 *  @remarks
00060 *    When using the unchanged virtual standard controller:
00061 *    Use a/w/d/s or cursor keys to walk, q/e to rotate and 'space' to jump. 'PageUp/PageDown'
00062 *    to move upwards/downwards. Hold the 'shift'-key to speed up, hold the 'strg'-key to slow down.
00063 *
00064 *  @note
00065 *    - Primary intended for rapid prototyping
00066 *    - Adds automatically a "PLScene::SNMMeshUpdate" scene node modifier (if there's not yet one) in order to frequently update the mesh
00067 */
00068 class SNMPhysicsCharacterController : public SNMPhysicsCharacter {
00069 
00070 
00071     //[-------------------------------------------------------]
00072     //[ Public definition                                     ]
00073     //[-------------------------------------------------------]
00074     public:
00075         /**
00076         *  @brief
00077         *    Scene node modifier flags (PLScene::SceneNodeModifier flags extension)
00078         */
00079         enum EFlags {
00080             NoJump  = 1<<3, /**< Do not allow jumping */
00081             NoRun   = 1<<4, /**< Do not allow running */
00082             NoCreep = 1<<5  /**< Do not allow creeping */
00083         };
00084         pl_enum(EFlags)
00085             pl_enum_base(SNMPhysicsCharacter::EFlags)
00086             pl_enum_value(NoJump,   "Do not allow jumping")
00087             pl_enum_value(NoRun,    "Do not allow running")
00088             pl_enum_value(NoCreep,  "Do not allow creeping")
00089         pl_enum_end
00090 
00091 
00092     //[-------------------------------------------------------]
00093     //[ RTTI interface                                        ]
00094     //[-------------------------------------------------------]
00095     pl_class(PL_RTTI_EXPORT, SNMPhysicsCharacterController, "PLEngine", PLEngine::SNMPhysicsCharacter, "Basic PL physics character controller scene node modifier class")
00096         // Attributes
00097         pl_attribute(InputSemantic,         PLCore::String,         "",     ReadWrite,  DirectValue,    "Semantic of this input controller (e.g. \"Camera\")",                                              "")
00098         pl_attribute(YRotVelocity,          float,                  0.0f,   ReadWrite,  DirectValue,    "Y rotation velocity, if 0, there's no rotation control",                                           "")
00099         pl_attribute(IdleAnimation,         PLCore::String,         "",     ReadWrite,  DirectValue,    "Idle animation",                                                                                   "")
00100         pl_attribute(IdleAnimationSpeed,    float,                  24.0f,  ReadWrite,  DirectValue,    "Idle animation playback speed",                                                                    "Min='0.0001'")
00101         pl_attribute(WalkAnimation,         PLCore::String,         "",     ReadWrite,  DirectValue,    "Walk animation",                                                                                   "")
00102         pl_attribute(WalkAnimationSpeed,    float,                  24.0f,  ReadWrite,  DirectValue,    "Walk animation playback speed",                                                                    "Min='0.0001'")
00103         pl_attribute(RunAnimationSpeed,     float,                  35.0f,  ReadWrite,  DirectValue,    "Run animation playback speed (walk animation, just faster)",                                       "Min='0.0001'")
00104         pl_attribute(RotationNode,          PLCore::String,         "",     ReadWrite,  DirectValue,    "If empty, take the rotation of the owner node for movement, else the rotation of the given node",  "")
00105             // Overwritten PLScene::SceneNodeModifier attributes
00106         pl_attribute(Flags,                 pl_flag_type(EFlags),   0,      ReadWrite,  GetSet,         "Flags",                                                                                            "")
00107         // Constructors
00108         pl_constructor_1(ParameterConstructor,  PLScene::SceneNode&,    "Parameter constructor",    "")
00109     pl_class_end
00110 
00111 
00112     //[-------------------------------------------------------]
00113     //[ Public functions                                      ]
00114     //[-------------------------------------------------------]
00115     public:
00116         /**
00117         *  @brief
00118         *    Constructor
00119         *
00120         *  @param[in] cSceneNode
00121         *    Owner scene node
00122         */
00123         PL_API SNMPhysicsCharacterController(PLScene::SceneNode &cSceneNode);
00124 
00125         /**
00126         *  @brief
00127         *    Destructor
00128         */
00129         PL_API virtual ~SNMPhysicsCharacterController();
00130 
00131 
00132     //[-------------------------------------------------------]
00133     //[ Public virtual PLScene::SceneNodeModifier functions   ]
00134     //[-------------------------------------------------------]
00135     public:
00136         PL_API virtual PLInput::Controller *GetInputController() const override;
00137 
00138 
00139     //[-------------------------------------------------------]
00140     //[ Protected virtual PLScene::SceneNodeModifier functions ]
00141     //[-------------------------------------------------------]
00142     protected:
00143         PL_API virtual void InformedOnInit() override;
00144         PL_API virtual void OnActivate(bool bActivate) override;
00145 
00146 
00147     //[-------------------------------------------------------]
00148     //[ Private functions                                     ]
00149     //[-------------------------------------------------------]
00150     private:
00151         /**
00152         *  @brief
00153         *    Called when the scene node modifier needs to be updated
00154         */
00155         void OnUpdate();
00156 
00157         /**
00158         *  @brief
00159         *    Returns a "PLScene::SNMMeshUpdate" instance from the owner scene node
00160         *
00161         *  @return
00162         *    A "PLScene::SNMMeshUpdate" instance
00163         *
00164         *  @note
00165         *    - If not already there, this method creates an instance of the "PLScene::SNMMeshUpdate" scene node modifier which frequently updates the mesh
00166         */
00167         PLScene::SNMMeshUpdate *GetSNMMeshUpdate() const;
00168 
00169 
00170     //[-------------------------------------------------------]
00171     //[ Private event handlers                                ]
00172     //[-------------------------------------------------------]
00173     private:
00174         PLCore::EventHandler<> EventHandlerUpdate;
00175 
00176 
00177     //[-------------------------------------------------------]
00178     //[ Private data                                          ]
00179     //[-------------------------------------------------------]
00180     private:
00181         bool                        m_bJumping;     /**< Are we currently jumping? */
00182         PhysicsCharacterController *m_pController;  /**< Physics character input controller instance, always valid! */
00183 
00184 
00185 };
00186 
00187 
00188 //[-------------------------------------------------------]
00189 //[ Namespace                                             ]
00190 //[-------------------------------------------------------]
00191 } // PLEngine
00192 
00193 
00194 #endif // __PLENGINE_CONTROLLER_SNMPHYSICSCHARACTERCONTROLLER_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