PixelLightAPI  .
SNMPositionMoveToTarget.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SNMPositionMoveToTarget.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 __PLSCENE_SCENENODEMODIFIER_POSITIONMOVETOTARGET_H__
00024 #define __PLSCENE_SCENENODEMODIFIER_POSITIONMOVETOTARGET_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Base/Event/EventHandler.h>
00032 #include "PLScene/Scene/SceneNodeModifiers/SNMTransform.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Namespace                                             ]
00037 //[-------------------------------------------------------]
00038 namespace PLScene {
00039 
00040 
00041 //[-------------------------------------------------------]
00042 //[ Classes                                               ]
00043 //[-------------------------------------------------------]
00044 /**
00045 *  @brief
00046 *    Scene node modifier class moving the owner scene node towards a target scene node
00047 *
00048 *  @note
00049 *    - Please note that within this simple scene node modifier, there's no path finding involved, the scene node is just moved towards the target position
00050 */
00051 class SNMPositionMoveToTarget : public SNMTransform {
00052 
00053 
00054     //[-------------------------------------------------------]
00055     //[ RTTI interface                                        ]
00056     //[-------------------------------------------------------]
00057     pl_class(PLS_RTTI_EXPORT, SNMPositionMoveToTarget, "PLScene", PLScene::SNMTransform, "Scene node modifier class moving the owner scene node towards a target scene node")
00058         // Attributes
00059         pl_attribute(Target,    PLCore::String, "",     ReadWrite,  DirectValue,    "Target scene node to move to", "")
00060         pl_attribute(Speed,     float,          2.0f,   ReadWrite,  DirectValue,    "Movement speed",               "Min='0.0001'")
00061         // Constructors
00062         pl_constructor_1(ParameterConstructor,  SceneNode&, "Parameter constructor",    "")
00063     pl_class_end
00064 
00065 
00066     //[-------------------------------------------------------]
00067     //[ Public functions                                      ]
00068     //[-------------------------------------------------------]
00069     public:
00070         /**
00071         *  @brief
00072         *    Constructor
00073         *
00074         *  @param[in] cSceneNode
00075         *    Owner scene node
00076         */
00077         PLS_API SNMPositionMoveToTarget(SceneNode &cSceneNode);
00078 
00079         /**
00080         *  @brief
00081         *    Destructor
00082         */
00083         PLS_API virtual ~SNMPositionMoveToTarget();
00084 
00085 
00086     //[-------------------------------------------------------]
00087     //[ Protected virtual SceneNodeModifier functions         ]
00088     //[-------------------------------------------------------]
00089     protected:
00090         PLS_API virtual void OnActivate(bool bActivate) override;
00091 
00092 
00093     //[-------------------------------------------------------]
00094     //[ Private functions                                     ]
00095     //[-------------------------------------------------------]
00096     private:
00097         /**
00098         *  @brief
00099         *    Returns the target position within the container space of the owner node
00100         *
00101         *  @param[out] vPos
00102         *    Will receive the position of the target scene node
00103         *
00104         *  @return
00105         *    'true' if all went fine, else 'false' (invalid target?)
00106         */
00107         bool GetTargetPosition(PLMath::Vector3 &vPos) const;
00108 
00109         /**
00110         *  @brief
00111         *    Called when the scene node modifier needs to be updated
00112         */
00113         void OnUpdate();
00114 
00115 
00116     //[-------------------------------------------------------]
00117     //[ Private event handlers                                ]
00118     //[-------------------------------------------------------]
00119     private:
00120         PLCore::EventHandler<> EventHandlerUpdate;
00121 
00122 
00123 };
00124 
00125 
00126 //[-------------------------------------------------------]
00127 //[ Namespace                                             ]
00128 //[-------------------------------------------------------]
00129 } // PLScene
00130 
00131 
00132 #endif // __PLSCENE_SCENENODEMODIFIER_POSITIONMOVETOTARGET_H__


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