PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: SceneNodeModifier.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_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(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'.", "") 00099 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).", "") 00100 pl_method_0(GetInputController, pl_ret_type(PLInput::Controller*), "Get the input controller. Returns the input controller (can be a null pointer).", "") 00101 #endif 00102 pl_class_end 00103 00104 00105 //[-------------------------------------------------------] 00106 //[ Public RTTI get/set functions ] 00107 //[-------------------------------------------------------] 00108 public: 00109 PLS_API virtual PLCore::uint32 GetFlags() const; 00110 PLS_API virtual void SetFlags(PLCore::uint32 nValue); 00111 00112 00113 //[-------------------------------------------------------] 00114 //[ Public functions ] 00115 //[-------------------------------------------------------] 00116 public: 00117 /** 00118 * @brief 00119 * Returns the owner scene node 00120 * 00121 * @return 00122 * The owner scene node 00123 */ 00124 PLS_API SceneNode &GetSceneNode() const; 00125 00126 /** 00127 * @brief 00128 * Returns the scene context the owner scene node is in 00129 * 00130 * @return 00131 * The scene context the owner scene node is in, can but shouldn't be a null pointer 00132 */ 00133 PLS_API SceneContext *GetSceneContext() const; 00134 00135 /** 00136 * @brief 00137 * Returns the scene node class this modifier operates on 00138 * 00139 * @return 00140 * The scene node class this modifier operates on 00141 */ 00142 PLS_API PLCore::String GetSceneNodeClass() const; 00143 00144 /** 00145 * @brief 00146 * Is the scene node modifier active? 00147 * 00148 * @return 00149 * 'true' if the scene node modifier is active, else 'false' 00150 * 00151 * @note 00152 * - Please note that this active state doesn't necessarily mean that the owner scene node is active as well! 00153 */ 00154 PLS_API bool IsActive() const; 00155 00156 /** 00157 * @brief 00158 * Sets whether the scene node modifier is active or not 00159 * 00160 * @param[in] bActive 00161 * Should the scene node modifier be active? 00162 * 00163 * @note 00164 * - Sets/unsets the 'Inactive'-flag 00165 * 00166 * @see 00167 * - IsActive() 00168 */ 00169 PLS_API void SetActive(bool bActive = true); 00170 00171 00172 //[-------------------------------------------------------] 00173 //[ Public virtual SceneNodeModifier functions ] 00174 //[-------------------------------------------------------] 00175 public: 00176 /** 00177 * @brief 00178 * Get input controller 00179 * 00180 * @return 00181 * Input controller (can be a null pointer) 00182 * 00183 * @note 00184 * - The default implementation is empty 00185 * - Derived scene node modifiers may add a string attribute called "InputSemantic" to tell the world about 00186 * the purpose of the input controller (for example controlling a free camera) 00187 */ 00188 PLS_API virtual PLInput::Controller *GetInputController() const; 00189 00190 00191 //[-------------------------------------------------------] 00192 //[ Protected virtual SceneNodeModifier functions ] 00193 //[-------------------------------------------------------] 00194 protected: 00195 /** 00196 * @brief 00197 * Informed on scene node modifier initialization 00198 * 00199 * @note 00200 * - The default implementation is empty 00201 */ 00202 PLS_API virtual void InformedOnInit(); 00203 00204 /** 00205 * @brief 00206 * Called when the scene node modifier has been activated or deactivated 00207 * 00208 * @param[in] bActivate 00209 * 'true' if the scene node modifier is now active, else 'false' 00210 * 00211 * @note 00212 * - The scene node "Inactive"-flag as well as the "Frozen"-flag are taken into account 00213 * - 'bActivate' will be 'true' if the scene node modifier AND the owner scene node AND it's parent scene container (recursive!) are active 00214 * - 'bActivate' will be 'false' if the scene node modifier OR the owner scene node OR it's parent scene container (recursive!) is inactive 00215 * - The default implementation is empty 00216 */ 00217 PLS_API virtual void OnActivate(bool bActivate); 00218 00219 00220 //[-------------------------------------------------------] 00221 //[ Protected functions ] 00222 //[-------------------------------------------------------] 00223 protected: 00224 /** 00225 * @brief 00226 * Constructor 00227 * 00228 * @param[in] cSceneNode 00229 * Owner scene node 00230 */ 00231 PLS_API SceneNodeModifier(SceneNode &cSceneNode); 00232 00233 /** 00234 * @brief 00235 * Destructor 00236 */ 00237 PLS_API virtual ~SceneNodeModifier(); 00238 00239 00240 //[-------------------------------------------------------] 00241 //[ Private data ] 00242 //[-------------------------------------------------------] 00243 private: 00244 PLCore::uint32 m_nFlags; /**< Flags */ 00245 SceneNode *m_pSceneNode; /**< Owner scene node (ALWAYS valid!) */ 00246 00247 00248 }; 00249 00250 00251 //[-------------------------------------------------------] 00252 //[ Namespace ] 00253 //[-------------------------------------------------------] 00254 } // PLScene 00255 00256 00257 #endif // __PLSCENE_SCENENODEMODIFIER_H__
|