PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: SNMOrbiting.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 __PLSCENE_SCENENODEMODIFIER_ORBITING_H__ 00024 #define __PLSCENE_SCENENODEMODIFIER_ORBITING_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLCore/Base/Event/EventHandler.h> 00032 #include "PLScene/Scene/SceneNodeModifier.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Forward declarations ] 00037 //[-------------------------------------------------------] 00038 namespace PLMath { 00039 class Vector3; 00040 } 00041 namespace PLRenderer { 00042 class Renderer; 00043 } 00044 namespace PLScene { 00045 class VisNode; 00046 } 00047 00048 00049 //[-------------------------------------------------------] 00050 //[ Namespace ] 00051 //[-------------------------------------------------------] 00052 namespace PLScene { 00053 00054 00055 //[-------------------------------------------------------] 00056 //[ Classes ] 00057 //[-------------------------------------------------------] 00058 /** 00059 * @brief 00060 * Scene node modifier class for orbiting around a target scene node 00061 * 00062 * @remarks 00063 * This scene node modifier is for comfortable orbiting without the need to combine 00064 * multiple scene node modifiers. (for example 'SNMRotationTarget', 'SNMMoveController' and 'SNMRotationFixRoll') 00065 */ 00066 class SNMOrbiting : public SceneNodeModifier { 00067 00068 00069 //[-------------------------------------------------------] 00070 //[ RTTI interface ] 00071 //[-------------------------------------------------------] 00072 pl_class(PLS_RTTI_EXPORT, SNMOrbiting, "PLScene", PLScene::SceneNodeModifier, "Scene node modifier class for orbiting around a target scene node") 00073 // Attributes 00074 pl_attribute(Target, PLCore::String, "", ReadWrite, DirectValue, "Target scene node to 'look at', if empty nothing happens", "") 00075 pl_attribute(MinDistance, float, 0.0f, ReadWrite, GetSet, "Minimum distance to the target, negative = no minimum, always <= 'MaxDistance'", "") 00076 pl_attribute(MaxDistance, float, -1.0f, ReadWrite, GetSet, "Maximum distance to the target, negative = no maximum, always >= 'MinDistance'", "") 00077 pl_attribute(Distance, float, -1.0f, ReadWrite, GetSet, "Distance to the target, negative = not initialized yet", "") 00078 pl_attribute(Offset, PLMath::Vector3, PLMath::Vector3::Zero, ReadWrite, DirectValue, "Target scene node position offset (same scene container space as target scene node)", "") 00079 pl_attribute(UpVector, PLMath::Vector3, PLMath::Vector3::Zero, ReadWrite, DirectValue, "Up vector (null vector for no limitation)", "") 00080 pl_attribute(Pan, PLMath::Vector3, PLMath::Vector3::Zero, ReadWrite, DirectValue, "Pan", "") 00081 // Constructors 00082 pl_constructor_1(ParameterConstructor, SceneNode&, "Parameter constructor", "") 00083 pl_class_end 00084 00085 00086 //[-------------------------------------------------------] 00087 //[ Public RTTI get/set functions ] 00088 //[-------------------------------------------------------] 00089 public: 00090 PLS_API float GetMinDistance() const; 00091 PLS_API void SetMinDistance(float fValue); 00092 PLS_API float GetMaxDistance() const; 00093 PLS_API void SetMaxDistance(float fValue); 00094 PLS_API float GetDistance(); 00095 PLS_API void SetDistance(float fValue); 00096 00097 00098 //[-------------------------------------------------------] 00099 //[ Public functions ] 00100 //[-------------------------------------------------------] 00101 public: 00102 /** 00103 * @brief 00104 * Constructor 00105 * 00106 * @param[in] cSceneNode 00107 * Owner scene node 00108 */ 00109 PLS_API SNMOrbiting(SceneNode &cSceneNode); 00110 00111 /** 00112 * @brief 00113 * Destructor 00114 */ 00115 PLS_API virtual ~SNMOrbiting(); 00116 00117 00118 //[-------------------------------------------------------] 00119 //[ Protected virtual SceneNodeModifier functions ] 00120 //[-------------------------------------------------------] 00121 protected: 00122 PLS_API virtual void OnActivate(bool bActivate) override; 00123 00124 00125 //[-------------------------------------------------------] 00126 //[ Private functions ] 00127 //[-------------------------------------------------------] 00128 private: 00129 /** 00130 * @brief 00131 * Validates the minimum, maximum and distance settings 00132 */ 00133 void ValidateSettings(); 00134 00135 /** 00136 * @brief 00137 * Returns the target position within the container space of the owner node 00138 * 00139 * @param[out] vPos 00140 * Will receive the position of the target scene node, not manipulated on error 00141 * 00142 * @return 00143 * 'true' if all went fine, else 'false' (invalid target?) 00144 */ 00145 bool GetTargetPosition(PLMath::Vector3 &vPos) const; 00146 00147 /** 00148 * @brief 00149 * Called on scene node position or rotation change or update request 00150 */ 00151 void OnPositionRotationUpdate(); 00152 00153 /** 00154 * @brief 00155 * Called on scene node debug draw 00156 * 00157 * @param[in] cRenderer 00158 * The used renderer 00159 * @param[in] pVisNode 00160 * The current visibility node of this scene node, can be a null pointer 00161 */ 00162 void OnDrawDebug(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode); 00163 00164 00165 //[-------------------------------------------------------] 00166 //[ Private event handlers ] 00167 //[-------------------------------------------------------] 00168 private: 00169 PLCore::EventHandler<PLRenderer::Renderer &, const VisNode *> EventHandlerDrawDebug; 00170 PLCore::EventHandler<> EventHandlerPositionRotationUpdate; 00171 00172 00173 //[-------------------------------------------------------] 00174 //[ Protected data ] 00175 //[-------------------------------------------------------] 00176 protected: 00177 float m_fMinDistance; /**< Minimum distance to the target, negative = no minimum, always <= 'MaxDistance' */ 00178 float m_fMaxDistance; /**< Maximum distance to the target, negative = no maximum, always >= 'MinDistance' */ 00179 float m_fDistance; /**< Distance to the target, negative = not initialized yet */ 00180 bool m_bPositionListening; /**< Listen for position events? */ 00181 00182 00183 }; 00184 00185 00186 //[-------------------------------------------------------] 00187 //[ Namespace ] 00188 //[-------------------------------------------------------] 00189 } // PLScene 00190 00191 00192 #endif // __PLSCENE_SCENENODEMODIFIER_ORBITING_H__
|