PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: SceneNodeModifier.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_H__ 00024 #define __PLSCENE_SCENENODEMODIFIER_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLScene/Scene/SceneNode.h" 00032 00033 00034 //[-------------------------------------------------------] 00035 //[ Namespace ] 00036 //[-------------------------------------------------------] 00037 namespace PLScene { 00038 00039 00040 //[-------------------------------------------------------] 00041 //[ Classes ] 00042 //[-------------------------------------------------------] 00043 /** 00044 * @brief 00045 * Abstract scene node modifier (other name: controller) class 00046 * 00047 * @remarks 00048 * A scene node modifier modifies the behavior of a scene node. For instance it adds 00049 * a physical behavior, make a light source flickering etc. The 'SceneNodeClass' property 00050 * is the information on which class this modifier operates on. For instance, it's not 00051 * possible to assign a light flickering modifier to a a scene node which is a noise. 00052 * 00053 * @note 00054 * - Derived classes should use a 'SNM'-prefix (example: SNMTransform) 00055 */ 00056 class SceneNodeModifier : public PLCore::Object { 00057 00058 00059 //[-------------------------------------------------------] 00060 //[ Friends ] 00061 //[-------------------------------------------------------] 00062 friend class SceneNode; 00063 00064 00065 //[-------------------------------------------------------] 00066 //[ Public definition ] 00067 //[-------------------------------------------------------] 00068 public: 00069 /** 00070 * @brief 00071 * Scene node modifier flags 00072 */ 00073 enum EFlags { 00074 Inactive = 1<<0, /**< This scene node modifier is currently NOT active */ 00075 Automatic = 1<<1 /**< This scene node modifier was created automatically during runtime and should 00076 not be saved with the scene. Such scene nodes modifiers may also be hidden for 00077 instance within a scene editor. */ 00078 }; 00079 pl_enum(EFlags) 00080 pl_enum_value(Inactive, "This scene renderer pass is currently NOT active") 00081 pl_enum_value(Automatic, "This scene node modifier was created automatically during runtime and should not be saved with the scene. Such scene nodes modifiers may also be hidden for instance within a scene editor.") 00082 pl_enum_end 00083 00084 00085 //[-------------------------------------------------------] 00086 //[ RTTI interface ] 00087 //[-------------------------------------------------------] 00088 pl_class(PLS_RTTI_EXPORT, SceneNodeModifier, "PLScene", PLCore::Object, "Abstract scene node modifier (other name: controller) class") 00089 // Properties 00090 pl_properties 00091 pl_property("SceneNodeClass", "PLScene::SceneNode") 00092 pl_properties_end 00093 // Attributes 00094 pl_attribute(Flags, pl_flag_type(EFlags), 0, ReadWrite, GetSet, "Flags", "") 00095 #ifdef PLSCENE_EXPORTS // The following is only required when compiling PLScene 00096 // Methods 00097 pl_method_0(GetSceneNode, pl_ret_type(SceneNode&), "Returns the owner scene node.", "") 00098 pl_method_0(GetSceneNodeIndex, pl_ret_type(int), "Returns the index of this scene node modifier within the scene node modifier list of the owner scene node, <0 on failure.", "") 00099 pl_method_0(Clone, pl_ret_type(SceneNodeModifier*), "Creates a clone of this scene node modifier within the owner scene node. Returns the created clone of this scene node modifier within the owner scene node, null pointer on error.", "") 00100 pl_method_1(CloneAtIndex, pl_ret_type(SceneNodeModifier*), int, "Creates a clone of this scene node modifier within the owner scene node at a certain index inside the scene node modifier list. Index position specifying the location within the scene node modifier list where the scene node modifier should be added as first parameter (<0 for at the end). Returns the created clone of this scene node modifier within the owner scene node, null pointer on error.", "") 00101 pl_method_0(GetAbsoluteName, pl_ret_type(PLCore::String), "Constructs an unique absolute name for the scene node modifier by using \"<absolute owner scene node name>:<scene node modifier class name>.<zero based index>\" (for instance 'Root.MyScene.MyNode:SNMRotationLinearAnimation.0'). Do not use this method on a regular basis.", "") 00102 pl_method_0(IsActive, pl_ret_type(bool), "Returns whether the scene node modifier is active or not. Returns 'true' if the scene node modifier is active, else 'false'.", "") 00103 pl_method_1(SetActive, pl_ret_type(void), bool, "Sets whether the scene node modifier is active or not. 'true' as first parameter if the scene node modifier should be active, else 'false' (sets/unsets the 'Inactive'-flag).", "") 00104 pl_method_0(GetInputController, pl_ret_type(PLInput::Controller*), "Get the input controller. Returns the input controller (can be a null pointer).", "") 00105 #endif 00106 pl_class_end 00107 00108 00109 //[-------------------------------------------------------] 00110 //[ Public RTTI get/set functions ] 00111 //[-------------------------------------------------------] 00112 public: 00113 PLS_API virtual PLCore::uint32 GetFlags() const; 00114 PLS_API virtual void SetFlags(PLCore::uint32 nValue); 00115 00116 00117 //[-------------------------------------------------------] 00118 //[ Public functions ] 00119 //[-------------------------------------------------------] 00120 public: 00121 /** 00122 * @brief 00123 * Returns the owner scene node 00124 * 00125 * @return 00126 * The owner scene node 00127 */ 00128 inline SceneNode &GetSceneNode() const; 00129 00130 /** 00131 * @brief 00132 * Returns the index of this scene node modifier within the scene node modifier list of the owner scene node 00133 * 00134 * @return 00135 * The index of this scene node modifier within the scene node modifier list of the owner scene node, <0 on failure 00136 */ 00137 inline int GetSceneNodeIndex(); 00138 00139 /** 00140 * @brief 00141 * Creates a clone of this scene node modifier within the owner scene node 00142 * 00143 * @return 00144 * The created clone of this scene node modifier within the owner scene node, null pointer on error 00145 */ 00146 PLS_API SceneNodeModifier *Clone(); 00147 00148 /** 00149 * @brief 00150 * Creates a clone of this scene node modifier within the owner scene node at a certain index inside the scene node modifier list 00151 * 00152 * @param[in] nPosition 00153 * Index position specifying the location within the scene node modifier list where the scene node modifier should be added, <0 for at the end 00154 * 00155 * @return 00156 * The created clone of this scene node modifier within the owner scene node, null pointer on error 00157 */ 00158 PLS_API SceneNodeModifier *CloneAtIndex(int nPosition); 00159 00160 /** 00161 * @brief 00162 * Returns the scene context the owner scene node is in 00163 * 00164 * @return 00165 * The scene context the owner scene node is in, can but shouldn't be a null pointer 00166 */ 00167 inline SceneContext *GetSceneContext() const; 00168 00169 /** 00170 * @brief 00171 * Returns the scene node class this modifier operates on 00172 * 00173 * @return 00174 * The scene node class this modifier operates on 00175 */ 00176 PLS_API PLCore::String GetSceneNodeClass() const; 00177 00178 /** 00179 * @brief 00180 * Returns an unique absolute name for the scene node modifier 00181 * 00182 * @return 00183 * An unique absolute name for the scene node modifier 00184 * 00185 * @remarks 00186 * Constructs an unique absolute name for the scene node modifier by using 00187 * "<absolute owner scene node name>:<scene node modifier class name>.<zero based index>" 00188 * (for instance 'Root.MyScene.MyNode:SNMRotationLinearAnimation.0'). Do not use this 00189 * method on a regular basis. 00190 */ 00191 PLS_API PLCore::String GetAbsoluteName() const; 00192 00193 /** 00194 * @brief 00195 * Is the scene node modifier active? 00196 * 00197 * @return 00198 * 'true' if the scene node modifier is active, else 'false' 00199 * 00200 * @note 00201 * - Please note that this active state doesn't necessarily mean that the owner scene node is active as well! 00202 */ 00203 inline bool IsActive() const; 00204 00205 /** 00206 * @brief 00207 * Sets whether the scene node modifier is active or not 00208 * 00209 * @param[in] bActive 00210 * Should the scene node modifier be active? 00211 * 00212 * @note 00213 * - Sets/unsets the 'Inactive'-flag 00214 * 00215 * @see 00216 * - IsActive() 00217 */ 00218 PLS_API void SetActive(bool bActive = true); 00219 00220 00221 //[-------------------------------------------------------] 00222 //[ Public virtual SceneNodeModifier functions ] 00223 //[-------------------------------------------------------] 00224 public: 00225 /** 00226 * @brief 00227 * Get input controller 00228 * 00229 * @return 00230 * Input controller (can be a null pointer) 00231 * 00232 * @note 00233 * - The default implementation is empty 00234 * - Derived scene node modifiers may add a string attribute called "InputSemantic" to tell the world about 00235 * the purpose of the input controller (for example controlling a free camera) 00236 */ 00237 PLS_API virtual PLInput::Controller *GetInputController() const; 00238 00239 00240 //[-------------------------------------------------------] 00241 //[ Protected virtual SceneNodeModifier functions ] 00242 //[-------------------------------------------------------] 00243 protected: 00244 /** 00245 * @brief 00246 * Informed on scene node modifier initialization 00247 * 00248 * @note 00249 * - The default implementation is empty 00250 */ 00251 PLS_API virtual void InformedOnInit(); 00252 00253 /** 00254 * @brief 00255 * Called when the scene node modifier has been activated or deactivated 00256 * 00257 * @param[in] bActivate 00258 * 'true' if the scene node modifier is now active, else 'false' 00259 * 00260 * @note 00261 * - The scene node "Inactive"-flag as well as the "Frozen"-flag are taken into account 00262 * - 'bActivate' will be 'true' if the scene node modifier AND the owner scene node AND it's parent scene container (recursive!) are active 00263 * - 'bActivate' will be 'false' if the scene node modifier OR the owner scene node OR it's parent scene container (recursive!) is inactive 00264 * - The default implementation is empty 00265 */ 00266 PLS_API virtual void OnActivate(bool bActivate); 00267 00268 00269 //[-------------------------------------------------------] 00270 //[ Protected functions ] 00271 //[-------------------------------------------------------] 00272 protected: 00273 /** 00274 * @brief 00275 * Constructor 00276 * 00277 * @param[in] cSceneNode 00278 * Owner scene node 00279 */ 00280 PLS_API SceneNodeModifier(SceneNode &cSceneNode); 00281 00282 /** 00283 * @brief 00284 * Destructor 00285 */ 00286 PLS_API virtual ~SceneNodeModifier(); 00287 00288 00289 //[-------------------------------------------------------] 00290 //[ Private data ] 00291 //[-------------------------------------------------------] 00292 private: 00293 PLCore::uint32 m_nFlags; /**< Flags */ 00294 SceneNode *m_pSceneNode; /**< Owner scene node (ALWAYS valid!) */ 00295 00296 00297 }; 00298 00299 00300 //[-------------------------------------------------------] 00301 //[ Namespace ] 00302 //[-------------------------------------------------------] 00303 } // PLScene 00304 00305 00306 //[-------------------------------------------------------] 00307 //[ Implementation ] 00308 //[-------------------------------------------------------] 00309 #include "PLScene/Scene/SceneNodeModifier.inl" 00310 00311 00312 #endif // __PLSCENE_SCENENODEMODIFIER_H__
|