PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: SceneNode.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_SCENENODE_H__ 00024 #define __PLSCENE_SCENENODE_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLCore/Base/Object.h> 00032 #include <PLCore/Container/Element.h> 00033 #include <PLCore/Container/ElementHandler.h> 00034 #include <PLCore/Container/ElementManager.h> 00035 #include <PLMath/Sphere.h> 00036 #include <PLMath/Transform3.h> 00037 #include <PLMath/AABoundingBox.h> 00038 #include "PLScene/PLScene.h" 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Forward declarations ] 00043 //[-------------------------------------------------------] 00044 namespace PLInput { 00045 class Controller; 00046 } 00047 namespace PLRenderer { 00048 class Renderer; 00049 } 00050 namespace PLMesh { 00051 class MeshHandler; 00052 } 00053 namespace PLScene { 00054 class VisNode; 00055 class SceneContext; 00056 class SceneContainer; 00057 class SceneHierarchy; 00058 class SceneNodeModifier; 00059 class SceneHierarchyNodeItem; 00060 } 00061 00062 00063 //[-------------------------------------------------------] 00064 //[ Namespace ] 00065 //[-------------------------------------------------------] 00066 namespace PLScene { 00067 00068 00069 //[-------------------------------------------------------] 00070 //[ Classes ] 00071 //[-------------------------------------------------------] 00072 /** 00073 * @brief 00074 * Abstract scene node (leaf node) class 00075 * 00076 * @remarks 00077 * This is a leaf node of the scene graph. The node transformation is relative to the 00078 * container the node is in. 00079 * 00080 * @note 00081 * - '.' characters within 'concrete' scene node names are NOT allowed (SceneNode::SetName()) 00082 * - The name 'Root' is NOT allowed for scene nodes, this name is reserved for the 'scene root container' 00083 * - The name 'Parent' is NOT allowed for scene nodes, this name is reserved for the 'parent scene container' 00084 * - The name 'This' is NOT allowed for scene nodes, this name is reserved for the 'this scene node' 00085 * - The name of the 'root scene container' can NOT be changed 00086 * - Derived classes should use a 'SN'-prefix (example: SNLight) 00087 * - The "Rotation"-attribute of the scene node is a derived (human friendly) Euler angles (in degree) representation of the internal rotation quaternion, 00088 * so, whenever possible, work internally with "GetTransform()" instead of "GetRotation()"! 00089 */ 00090 class SceneNode : public PLCore::Object, public PLCore::Element<SceneNode> { 00091 00092 00093 //[-------------------------------------------------------] 00094 //[ Friends ] 00095 //[-------------------------------------------------------] 00096 friend class SNFog; 00097 friend class SQCull; 00098 friend class SCCell; 00099 friend class SNLight; 00100 friend class SNPortal; 00101 friend class SNCamera; 00102 friend class SQRender; 00103 friend class SceneContext; 00104 friend class SceneContainer; 00105 friend class SceneHierarchy; 00106 friend class SceneNodeModifier; 00107 friend class SceneHierarchyNode; 00108 friend class SceneHierarchyNodeItem; 00109 friend class PLCore::ElementManager<SceneNode>; 00110 00111 00112 //[-------------------------------------------------------] 00113 //[ Public definitions ] 00114 //[-------------------------------------------------------] 00115 public: 00116 /** 00117 * @brief 00118 * Scene node flags 00119 */ 00120 enum EFlags { 00121 Inactive = 1<<0, /**< This scene node is currently NOT active */ 00122 Invisible = 1<<1, /**< This scene node is currently NOT visible */ 00123 Frozen = 1<<2, /**< This scene node is currently frozen and therefore not updated */ 00124 Reserved = 1<<3, /**< Reserved for future use */ 00125 Automatic = 1<<4, /**< This scene node was created automatically during runtime and should 00126 not be saved with the scene. Such scene nodes are also hidden for instance 00127 within the scene editor. */ 00128 NoCulling = 1<<5, /**< No visibility culling for this node, please (the container the node is in may still be culled...) */ 00129 NoLighting = 1<<6, /**< No lighting for this node, please */ 00130 CanOcclude = 1<<7, /**< This scene node can occlude other scene nodes */ 00131 CastShadow = 1<<8, /**< Shadow caster */ 00132 ReceiveShadow = 1<<9 /**< Shadow receiver */ 00133 }; 00134 pl_enum(EFlags) 00135 pl_enum_value(Inactive, "This scene node is currently NOT active") 00136 pl_enum_value(Invisible, "This scene node is currently NOT visible") 00137 pl_enum_value(Frozen, "This scene node is currently frozen and therefore not updated") 00138 // pl_enum_value(Reserved, "Reserved for future use") // Don't expose this to the RTTI 00139 pl_enum_value(Automatic, "This scene node was created automatically during runtime and should not be saved with the scene. Such scene nodes are also hidden for instance within the scene editor.") 00140 pl_enum_value(NoCulling, "No visibility culling for this node, please (the container the node is in may still be culled...)") 00141 pl_enum_value(NoLighting, "No lighting for this node, please") 00142 pl_enum_value(CanOcclude, "This scene node can occlude other scene nodes") 00143 pl_enum_value(CastShadow, "Shadow caster") 00144 pl_enum_value(ReceiveShadow, "Shadow receiver") 00145 pl_enum_end 00146 00147 /** 00148 * @brief 00149 * Scene node debug flags 00150 */ 00151 enum EDebugFlags { 00152 DebugEnabled = 1<<0, /**< Debug mode is enabled (if this flag isn't set, no debug information is drawn at all) */ 00153 DebugNoDrawSignal = 1<<1, /**< Do not create a draw debug signal */ 00154 DebugContainerAABBox = 1<<2, /**< Draw (the white) container space axis aligned bounding box */ 00155 DebugContainerSphere = 1<<3, /**< Draw container space bounding sphere */ 00156 DebugNoLocalCoordinateAxis = 1<<4, /**< Do not draw the local coordinate axis */ 00157 DebugNoName = 1<<5, /**< Do not draw the name of the scene node */ 00158 DebugNoAABBox = 1<<6, /**< Do not draw (the yellow) axis aligned bounding box */ 00159 DebugText = 1<<7 /**< Draw some basic debug text information */ 00160 }; 00161 pl_enum(EDebugFlags) 00162 pl_enum_value(DebugEnabled, "Debug mode is enabled (if this flag isn't set, no debug information is drawn at all)") 00163 pl_enum_value(DebugNoDrawSignal, "Do not create a draw debug signal") 00164 pl_enum_value(DebugContainerAABBox, "Draw (the white) container space axis aligned bounding box") 00165 pl_enum_value(DebugContainerSphere, "Draw container space bounding sphere") 00166 pl_enum_value(DebugNoLocalCoordinateAxis, "Do not draw the local coordinate axis") 00167 pl_enum_value(DebugNoName, "Do not draw the name of the scene node") 00168 pl_enum_value(DebugNoAABBox, "Do not draw (the yellow) axis aligned bounding box") 00169 pl_enum_value(DebugText, "Draw some basic debug text information") 00170 pl_enum_end 00171 00172 /** 00173 * @brief 00174 * Draw function flags 00175 */ 00176 enum EDrawFunctionFlags { 00177 UseDrawPre = 1<<0, /**< Use DrawPre()-function */ 00178 UseDrawSolid = 1<<1, /**< Use DrawSolid()-function */ 00179 UseDrawTransparent = 1<<2, /**< Use DrawTransparent()-function */ 00180 UseDrawDebug = 1<<3, /**< Use DrawDebug()-function */ 00181 UseDrawPost = 1<<4 /**< Use DrawPost()-function */ 00182 }; 00183 00184 00185 //[-------------------------------------------------------] 00186 //[ RTTI interface ] 00187 //[-------------------------------------------------------] 00188 pl_class(PLS_RTTI_EXPORT, SceneNode, "PLScene", PLCore::Object, "Abstract scene node (leaf node) class") 00189 // Properties 00190 pl_properties 00191 pl_property("Icon", "Data/Textures/IconSceneNode.dds") 00192 pl_properties_end 00193 // Attributes 00194 pl_attribute(Flags, pl_flag_type(EFlags), 0, ReadWrite, GetSet, "Flags", "") 00195 pl_attribute(DebugFlags, pl_flag_type(EDebugFlags), 0, ReadWrite, GetSet, "Debug flags", "") 00196 pl_attribute(Position, PLMath::Vector3, PLMath::Vector3::Zero, ReadWrite, GetSet, "Position", "") 00197 pl_attribute(Rotation, PLMath::Vector3, PLMath::Vector3::Zero, ReadWrite, GetSet, "Rotation as Euler angles in degree, [0, 360]", "Inc=1") 00198 pl_attribute(Scale, PLMath::Vector3, PLMath::Vector3::One, ReadWrite, GetSet, "Scale", "") 00199 pl_attribute(MaxDrawDistance, float, 0.0f, ReadWrite, DirectValue, "Maximum draw distance of the scene node to the camera, if 0 do always draw, if negative, do always draw this node before other", "") 00200 pl_attribute(AABBMin, PLMath::Vector3, PLMath::Vector3::Zero, ReadWrite, GetSet, "Minimum position of the 'scene node space' axis aligned bounding box", "") 00201 pl_attribute(AABBMax, PLMath::Vector3, PLMath::Vector3::Zero, ReadWrite, GetSet, "Maximum position of the 'scene node space' axis aligned bounding box", "") 00202 pl_attribute(Name, PLCore::String, "", ReadWrite, GetSet, "Optional scene node name. If not defined, a name is chosen automatically", "") 00203 #ifdef PLSCENE_EXPORTS // The following is only required when compiling PLScene 00204 // Methods 00205 pl_method_0(GetContainer, pl_ret_type(SceneContainer*), "Returns the scene container the scene node is in or a null pointer if this is the root node.", "") 00206 pl_method_1(SetContainer, pl_ret_type(bool), SceneContainer&, "Sets the scene container the scene node is in. Scene container this node is in as first parameter. Returns 'true' if all went fine, else 'false' (Position, rotation, scale etc. are not manipulated, only the container is changed!).", "") 00207 pl_method_0(GetRootContainer, pl_ret_type(SceneContainer*), "Returns the scene root container (this scene container can be the root scene container), a null pointer on error.", "") 00208 pl_method_1(GetCommonContainer, pl_ret_type(SceneContainer*), SceneNode&, "Gets the common container of this and another scene node. The other scene node as first parameter. Returns the common container, or a null pointer.", "") 00209 pl_method_0(GetContainerIndex, pl_ret_type(int), "Returns the index of this scene node within the scene node list of the scene container this scene node is in, <0 on failure (e.g. the scene node is not within a scene container).", "") 00210 pl_method_0(Clone, pl_ret_type(SceneNode*), "Creates a clone of this scene node within the scene container this scene node is in. Returns the created clone of this scene node within the same scene container the original scene node is in, null pointer on error. Scene nodes and scene node modifiers with a set \"Automatic\"-flag will not be cloned. The debug flags of the created clone are set to 0.", "") 00211 pl_method_1(CloneAtIndex, pl_ret_type(SceneNode*), int, "Creates a clone of this scene node within the scene container this scene node is in at a certain index inside the scene node list. Index position specifying the location within the scene node list where the scene node should be added as first parameter (<0 for at the end). The created clone of this scene node within the same scene container the original scene node is in, null pointer on error. Scene nodes and scene node modifiers with a set \"Automatic\"-flag will not be cloned. The debug flags of the created clone are set to 0.", "") 00212 pl_method_0(GetHierarchy, pl_ret_type(SceneHierarchy*), "Returns the scene hierarchy this scene node is linked into. Returns the scene hierarchy this scene node is linked into, a null pointer on error.", "") 00213 pl_method_0(GetAbsoluteName, pl_ret_type(PLCore::String), "Returns the unique absolute name of the scene node (for instance 'Root.MyScene.MyNode').", "") 00214 pl_method_0(IsActive, pl_ret_type(bool), "Returns whether the scene node is active or not. Returns 'true' if the scene node is active, else 'false'.", "") 00215 pl_method_1(SetActive, pl_ret_type(void), bool, "Sets whether the scene node is active or not. 'true' as first parameter if the scene node should be active, else 'false' (sets/unsets the 'Inactive'-flag).", "") 00216 pl_method_0(IsVisible, pl_ret_type(bool), "Returns whether the scene node is visible or not. Returns 'true' if the scene node is visible, else 'false' (invisible/inactive). If the scene node is not active it's automatically invisible but the 'Invisible'-flag is not touched. 'Visible' doesn't mean 'currently' on screen, it just means 'can be seen in general'.", "") 00217 pl_method_1(SetVisible, pl_ret_type(void), bool, "Sets whether the scene node is visible or not. 'true' as first parameter if the scene node should be visible, else 'false' (sets/unsets the 'Invisible'-flag). See 'IsVisible()'-method for more information.", "") 00218 pl_method_0(IsFrozen, pl_ret_type(bool), "Returns whether the scene node is frozen or not. Returns 'true' if the scene node is frozen, else 'false'." , "") 00219 pl_method_1(SetFrozen, pl_ret_type(void), bool, "Sets whether the scene node is frozen or not. 'true' as first parameter if the scene node should be frozen, else 'false' (sets/unsets the 'Frozen'-flag).", "") 00220 pl_method_0(IsContainer, pl_ret_type(bool), "Returns whether this scene node is a scene container (SceneContainer) or not. Returns 'true' if this scene node is a scene container, else 'false'.", "") 00221 pl_method_0(IsCell, pl_ret_type(bool), "Returns whether this scene node is a cell (SCCell) or not. Returns 'true' if this scene node is a cell, else 'false'.", "") 00222 pl_method_0(IsPortal, pl_ret_type(bool), "Returns whether this scene node is a portal (SNPortal) or not. Returns 'true' if this scene node is a portal, else 'false'.", "") 00223 pl_method_0(IsCamera, pl_ret_type(bool), "Returns whether this scene node is a camera (SNCamera) or not. Returns 'true' if this scene node is a camera, else 'false'.", "") 00224 pl_method_0(IsLight, pl_ret_type(bool), "Returns whether this scene node is a light (SNLight) or not. Returns 'true' if this scene node is a light, else 'false'.", "") 00225 pl_method_0(IsFog, pl_ret_type(bool), "Returns whether this scene node is a fog (SNFog) or not. Returns 'true' if this scene node is a fog, else 'false'.", "") 00226 pl_method_1(GetNumOfModifiers, pl_ret_type(PLCore::uint32), const PLCore::String&, "Returns the number of modifiers. Optional modifier class name to return the number of instances from as first parameter (if empty return the total number of modifiers).", "") 00227 pl_method_2(AddModifier, pl_ret_type(SceneNodeModifier*), const PLCore::String&, const PLCore::String&, "Adds a modifier. Modifier class name of the modifier to add as first parameter and optional parameter string as second parameter. Returns a pointer to the modifier instance if all went fine, else a null pointer (maybe unknown/incompatible modifier).", "") 00228 pl_method_3(AddModifierAtIndex, pl_ret_type(SceneNodeModifier*), const PLCore::String&, const PLCore::String&, int, "Adds a modifier at a certain index inside the scene node modifier list. Modifier class name of the modifier to add as first parameter and optional parameter string as second parameter, optional index position specifying the location within the scene node modifier list where the scene node modifier should be added as third parameter (<0 for at the end). Returns a pointer to the modifier instance if all went fine, else a null pointer (maybe unknown/incompatible modifier).", "") 00229 pl_method_2(GetModifier, pl_ret_type(SceneNodeModifier*), const PLCore::String&, PLCore::uint32, "Returns a modifier. Modifier class name of the modifier to return as first parameter, optional modifier index as second parameter (used if class name is empty or if there are multiple instances of this modifier class). Returns the requested modifier, a null pointer on error.", "") 00230 pl_method_1(RemoveModifierByReference, pl_ret_type(bool), SceneNodeModifier&, "Removes a modifier by using a given reference to the modifier to remove. Modifier to remove as first parameter. Returns 'true' if all went fine, else 'false' (maybe invalid modifier). After this method succeeded, the given reference is no longer valid.", "") 00231 pl_method_2(RemoveModifier, pl_ret_type(bool), const PLCore::String&, PLCore::uint32, "Removes a modifier. Modifier class name of the modifier to remove as first parameter, modifier index as second parameter (used if class name is empty or if there are multiple instances of this modifier class). Returns 'true' if all went fine, else 'false' (maybe invalid modifier).", "") 00232 pl_method_0(ClearModifiers, pl_ret_type(void), "Clears all modifiers.", "") 00233 pl_method_1(Delete, pl_ret_type(bool), bool, "Deletes this scene node. If the first parameter is 'true' the scene node will also be deleted when it's protected. Returns 'true' when all went fine, else 'false'.", "") 00234 pl_method_0(GetInputController, pl_ret_type(PLInput::Controller*), "Get the input controller. Returns the input controller (can be a null pointer).", "") 00235 #endif 00236 // Signals 00237 pl_signal_0(SignalDestroy, "Scene node destruction signal. Unlike \"PLCore::Object::SignalDestroyed\", the scene node is still intact at the point the signal is emitted.","") 00238 pl_signal_0(SignalActive, "Scene node active state change signal", "") 00239 pl_signal_0(SignalVisible, "Scene node visible state change signal", "") 00240 pl_signal_0(SignalContainer, "Scene node parent container change signal", "") 00241 pl_signal_0(SignalAABoundingBox, "Scene node axis aligned bounding box change signal", "") 00242 pl_signal_0(SignalInit, "Scene node initialization signal", "") 00243 pl_signal_0(SignalDeInit, "Scene node de-initialization change signal", "") 00244 pl_signal_1(SignalAddedToVisibilityTree, VisNode&, "Scene node was added to a visibility tree signal. Visibility node representing this scene node within the visibility tree as parameter.", "") 00245 pl_signal_2(SignalDrawPre, PLRenderer::Renderer&, const VisNode*, "Scene node pre-draw signal. Used renderer and current visibility node of the scene node (can be a null pointer) as parameter.", "") 00246 pl_signal_2(SignalDrawSolid, PLRenderer::Renderer&, const VisNode*, "Scene node solid-draw signal. Used renderer and current visibility node of the scene node (can be a null pointer) as parameter.", "") 00247 pl_signal_2(SignalDrawTransparent, PLRenderer::Renderer&, const VisNode*, "Scene node transparent-draw signal. Used renderer and current visibility node of the scene node (can be a null pointer) as parameter.", "") 00248 pl_signal_2(SignalDrawDebug, PLRenderer::Renderer&, const VisNode*, "Scene node debug-draw signal. Used renderer and current visibility node of the scene node (can be a null pointer) as parameter.", "") 00249 pl_signal_2(SignalDrawPost, PLRenderer::Renderer&, const VisNode*, "Scene node post-draw signal. Used renderer and current visibility node of the scene node (can be a null pointer) as parameter.", "") 00250 pl_class_end 00251 00252 00253 //[-------------------------------------------------------] 00254 //[ Public RTTI get/set functions ] 00255 //[-------------------------------------------------------] 00256 public: 00257 PLS_API virtual PLCore::uint32 GetFlags() const; 00258 PLS_API virtual void SetFlags(PLCore::uint32 nValue); 00259 PLS_API virtual PLCore::uint32 GetDebugFlags() const; 00260 PLS_API virtual void SetDebugFlags(PLCore::uint32 nValue); 00261 PLS_API const PLMath::Vector3 &GetPosition() const; 00262 PLS_API void SetPosition(const PLMath::Vector3 &vValue); 00263 PLS_API PLMath::Vector3 GetRotation() const; 00264 PLS_API void SetRotation(const PLMath::Vector3 &vValue); 00265 PLS_API const PLMath::Vector3 &GetScale() const; 00266 PLS_API void SetScale(const PLMath::Vector3 &vValue); 00267 PLS_API const PLMath::Vector3 &GetAABBMin() const; 00268 PLS_API void SetAABBMin(const PLMath::Vector3 &vValue); 00269 PLS_API const PLMath::Vector3 &GetAABBMax() const; 00270 PLS_API void SetAABBMax(const PLMath::Vector3 &vValue); 00271 00272 00273 //[-------------------------------------------------------] 00274 //[ Public functions ] 00275 //[-------------------------------------------------------] 00276 public: 00277 /** 00278 * @brief 00279 * Returns the scene context the scene node is in 00280 * 00281 * @return 00282 * The scene context the scene node is in, can but shouldn't be a null pointer 00283 * 00284 * @note 00285 * - Do NOT use this function inside a SceneNode-constructor 00286 */ 00287 PLS_API SceneContext *GetSceneContext() const; 00288 00289 /** 00290 * @brief 00291 * Returns the scene container the scene node is in 00292 * 00293 * @return 00294 * Scene container this node is in, or a null pointer if this is the root node 00295 * 00296 * @note 00297 * - You can also use GetManager() from PLCore::Element directly 00298 */ 00299 PLS_API SceneContainer *GetContainer() const; 00300 00301 /** 00302 * @brief 00303 * Sets the scene container the scene node is in 00304 * 00305 * @param[in] cSceneContainer 00306 * Scene container this node is in 00307 * 00308 * @return 00309 * 'true' if all went fine, else 'false' 00310 * 00311 * @note 00312 * - Position, rotation, scale etc. are NOT manipulated, ONLY the container is changed! 00313 */ 00314 PLS_API bool SetContainer(SceneContainer &cSceneContainer); 00315 00316 /** 00317 * @brief 00318 * Returns the scene root container 00319 * 00320 * @return 00321 * Scene root container, (this scene container can be the root scene container) a null pointer on error 00322 * 00323 * @remarks 00324 * This function searches for the scene root container (scene container without a parent) and returns it. 00325 */ 00326 PLS_API SceneContainer *GetRootContainer() const; 00327 00328 /** 00329 * @brief 00330 * Gets the common container of this and another scene node 00331 * 00332 * @param[in] cSceneNode 00333 * The other scene node 00334 * 00335 * @return 00336 * Common container, or a null pointer 00337 */ 00338 PLS_API SceneContainer *GetCommonContainer(SceneNode &cSceneNode) const; 00339 00340 /** 00341 * @brief 00342 * Returns the index of this scene node within the scene node list of the scene container this scene node is in 00343 * 00344 * @return 00345 * The index of this scene node within the scene node list of the scene container this scene node is in, <0 on failure 00346 * (e.g. the scene node is not within a scene container) 00347 */ 00348 PLS_API int GetContainerIndex(); 00349 00350 /** 00351 * @brief 00352 * Creates a clone of this scene node within the scene container this scene node is in 00353 * 00354 * @return 00355 * The created clone of this scene node within the same scene container the original scene node is in, null pointer on error 00356 * 00357 * @note 00358 * - Scene nodes and scene node modifiers with a set "Automatic"-flag will not be cloned 00359 * - The debug flags of the created clone are set to 0 00360 */ 00361 PLS_API SceneNode *Clone(); 00362 00363 /** 00364 * @brief 00365 * Creates a clone of this scene node within the scene container this scene node is in at a certain index inside the scene node list 00366 * 00367 * @param[in] nPosition 00368 * Index position specifying the location within the scene node list where the scene node should be added, <0 for at the end 00369 * 00370 * @return 00371 * The created clone of this scene node within the same scene container the original scene node is in, null pointer on error 00372 * 00373 * @see 00374 * - "Clone()" 00375 */ 00376 PLS_API SceneNode *CloneAtIndex(int nPosition); 00377 00378 /** 00379 * @brief 00380 * Returns the scene hierarchy this scene node is linked into 00381 * 00382 * @return 00383 * Scene hierarchy this scene node is linked into, a null pointer on error 00384 */ 00385 PLS_API SceneHierarchy *GetHierarchy() const; 00386 00387 /** 00388 * @brief 00389 * Returns the unique absolute name of the scene node 00390 * 00391 * @return 00392 * Unique absolute name of the scene node (for instance 'Root.MyScene.MyNode') 00393 * 00394 * @note 00395 * - This function 'constructs' the absolute scene node name. For performance 00396 * reasons DON'T call this function a few million times per frame! 00397 */ 00398 PLS_API PLCore::String GetAbsoluteName() const; 00399 00400 /** 00401 * @brief 00402 * Is the scene node initialized? 00403 * 00404 * @return 00405 * 'true' if the scene node is initialized, else 'false' 00406 */ 00407 PLS_API bool IsInitialized() const; 00408 00409 /** 00410 * @brief 00411 * Returns whether the scene node is active or not 00412 * 00413 * @return 00414 * 'true' if the scene node is active, else 'false' 00415 */ 00416 PLS_API bool IsActive() const; 00417 00418 /** 00419 * @brief 00420 * Sets whether the scene node is active or not 00421 * 00422 * @param[in] bActive 00423 * Should the scene node be active? 00424 * 00425 * @note 00426 * - Sets/unsets the 'Inactive'-flag 00427 */ 00428 PLS_API void SetActive(bool bActive = true); 00429 00430 /** 00431 * @brief 00432 * Evaluates whether or not the scene node is active in respect of the complete scene graph 00433 * 00434 * @return 00435 * 'true' if the scene node is active in respect of the complete scene graph, else 'false' 00436 * 00437 * @note 00438 * - For evaluation, the scene node "Inactive"-flag as well as the "Frozen"-flag are taken into account 00439 * - Will be 'true' if the scene node AND the parent scene container (recursive!) are active 00440 * - Will be 'false' if the scene node OR the parent scene container (recursive!) is inactive 00441 * - Try to avoid using this method when possible, due to it's recursive nature it may affect performance when called to often 00442 */ 00443 PLS_API bool EvaluateGlobalActiveState() const; 00444 00445 /** 00446 * @brief 00447 * Returns whether the scene node is visible or not 00448 * 00449 * @return 00450 * 'true' if the scene node is visible, else 'false' (invisible/inactive) 00451 * 00452 * @remarks 00453 * If the scene node is not active it's automatically invisible but 00454 * the 'Invisible'-flag is not touched. 'Visible' doesn't mean 'currently' 00455 * on screen, it just means 'can be seen in general'. 00456 */ 00457 PLS_API bool IsVisible() const; 00458 00459 /** 00460 * @brief 00461 * Sets whether the scene node is visible or not 00462 * 00463 * @param[in] bVisible 00464 * Should the scene node be visible? 00465 * 00466 * @note 00467 * - Sets/unsets the 'Invisible'-flag 00468 * 00469 * @see 00470 * - IsVisible() 00471 */ 00472 PLS_API void SetVisible(bool bVisible = true); 00473 00474 /** 00475 * @brief 00476 * Returns whether the scene node is frozen or not 00477 * 00478 * @return 00479 * 'true' if the scene node is frozen, else 'false' 00480 */ 00481 PLS_API bool IsFrozen() const; 00482 00483 /** 00484 * @brief 00485 * Sets whether the scene node is frozen or not 00486 * 00487 * @param[in] bFrozen 00488 * Should the scene node be frozen? 00489 * 00490 * @note 00491 * - Sets/unsets the 'Frozen'-flag 00492 */ 00493 PLS_API void SetFrozen(bool bFrozen = true); 00494 00495 /** 00496 * @brief 00497 * Gets the scene node draw function flags 00498 * 00499 * @return 00500 * Scene node draw function flags (see EDrawFunctionFlags) 00501 */ 00502 PLS_API PLCore::uint8 GetDrawFunctionFlags() const; 00503 00504 /** 00505 * @brief 00506 * Sets the scene node draw function flags 00507 * 00508 * @param[in] nFlags 00509 * New scene node draw function flags which should be set (see EDrawFunctionFlags) 00510 */ 00511 PLS_API void SetDrawFunctionFlags(PLCore::uint8 nFlags); 00512 00513 //[-------------------------------------------------------] 00514 //[ Transformation ] 00515 //[-------------------------------------------------------] 00516 /** 00517 * @brief 00518 * Gets the node transform 00519 * 00520 * @return 00521 * Node transform 00522 * 00523 * @remarks 00524 * This function will get/set ONLY the scene node transform. No cell-portal check 00525 * etc. is performed! When just 'moving' the node, use MoveTo() instead. 00526 */ 00527 inline const PLMath::Transform3 &GetTransform() const; 00528 inline PLMath::Transform3 &GetTransform(); 00529 00530 /** 00531 * @brief 00532 * Moves the node to a new position 00533 * 00534 * @param[in] vPosition 00535 * New node position 00536 * 00537 * @remarks 00538 * Unlike 'SetPosition()' this function checks whether or not the node 00539 * passes a cell-portal while 'moving' from the current position to the new one. 00540 */ 00541 PLS_API void MoveTo(const PLMath::Vector3 &vPosition); 00542 00543 //[-------------------------------------------------------] 00544 //[ Bounding volume ] 00545 //[-------------------------------------------------------] 00546 /** 00547 * @brief 00548 * Returns the axis align bounding box in 'scene node space' 00549 * 00550 * @return 00551 * The axis align bounding box in 'scene node space' 00552 * 00553 * @note 00554 * - The 'scene node space' can be seen as 'object space' :) 00555 * - Use GetContainerAABoundingBox() to get this bounding box in 00556 * 'scene container space' (see it as 'world space' :) 00557 * - This axis align bounding box is recalculated internally if required 00558 * - Within the default implementation, the axis align bounding box 00559 * is not recalculated 00560 */ 00561 PLS_API const PLMath::AABoundingBox &GetAABoundingBox(); 00562 00563 /** 00564 * @brief 00565 * Sets the axis align bounding box in 'scene node space' 00566 * 00567 * @param[in] cAABoundingBox 00568 * The axis align bounding box in 'scene node space' 00569 * 00570 * @see 00571 * - GetAABoundingBox() 00572 */ 00573 PLS_API void SetAABoundingBox(const PLMath::AABoundingBox &cAABoundingBox); 00574 00575 /** 00576 * @brief 00577 * Returns the current axis align bounding box in 'scene container space' 00578 * 00579 * @return 00580 * The current axis align bounding box in 'scene container space' 00581 * 00582 * @note 00583 * - If position, rotation, scale or the bounding box itself was changed, the 00584 * current axis align bounding box in 'scene container space' is recalculated 00585 * internally before it is returned 00586 * 00587 * @see 00588 * - GetAABoundingBox() 00589 */ 00590 PLS_API const PLMath::AABoundingBox &GetContainerAABoundingBox(); 00591 00592 /** 00593 * @brief 00594 * Returns the bounding sphere in 'scene node space' 00595 * 00596 * @return 00597 * The bounding sphere in 'scene node space' 00598 * 00599 * @note 00600 * - This sphere recalculated internally if the bounding box was changed 00601 * - Within the default implementation, the bounding sphere is calculated 00602 * by using the the bounding box 00603 * - Note that it's not guaranteed that this sphere totally includes the axis align bounding box 00604 * in any space. A derived class may decide that another radius fit's the needs 00605 * better - for instance a light is using it's radius. 00606 * 00607 * @see 00608 * - GetAABoundingBox() 00609 */ 00610 PLS_API const PLMath::Sphere &GetBoundingSphere(); 00611 00612 /** 00613 * @brief 00614 * Returns the current bounding sphere in 'scene container space' 00615 * 00616 * @return 00617 * The current bounding in 'scene container space' 00618 * 00619 * @note 00620 * - If position, rotation, scale or the bounding box itself was changed, the current bounding 00621 * sphere in 'scene container space' is recalculated internally before it is returned 00622 * - Note that it's not guaranteed that this sphere totally includes the axis align bounding box 00623 * in 'scene container space' (that's no bug or so :) 00624 * 00625 * @see 00626 * - GetBoundingSphere() 00627 */ 00628 PLS_API const PLMath::Sphere &GetContainerBoundingSphere(); 00629 00630 //[-------------------------------------------------------] 00631 //[ Instance of ] 00632 //[-------------------------------------------------------] 00633 /** 00634 * @brief 00635 * Returns whether this scene node is a scene container (SceneContainer) or not 00636 * 00637 * @return 00638 * 'true' if this scene node is a scene container, else 'false' 00639 * 00640 * @note 00641 * - More performant than IsInstanceOf("PLScene::SceneContainer") 00642 */ 00643 inline bool IsContainer() const; 00644 00645 /** 00646 * @brief 00647 * Returns whether this scene node is a cell (SCCell) or not 00648 * 00649 * @return 00650 * 'true' if this scene node is a cell, else 'false' 00651 * 00652 * @note 00653 * - More performant than IsInstanceOf("PLScene::SCCell") 00654 */ 00655 inline bool IsCell() const; 00656 00657 /** 00658 * @brief 00659 * Returns whether this scene node is a portal (SNPortal) or not 00660 * 00661 * @return 00662 * 'true' if this scene node is a portal, else 'false' 00663 * 00664 * @note 00665 * - More performant than IsInstanceOf("PLScene::SNPortal") 00666 */ 00667 inline bool IsPortal() const; 00668 00669 /** 00670 * @brief 00671 * Returns whether this scene node is a camera (SNCamera) or not 00672 * 00673 * @return 00674 * 'true' if this scene node is a camera, else 'false' 00675 * 00676 * @note 00677 * - More performant than IsInstanceOf("PLScene::SNCamera") 00678 */ 00679 inline bool IsCamera() const; 00680 00681 /** 00682 * @brief 00683 * Returns whether this scene node is a light (SNLight) or not 00684 * 00685 * @return 00686 * 'true' if this scene node is a light, else 'false' 00687 * 00688 * @note 00689 * - More performant than IsInstanceOf("PLScene::SNLight") 00690 */ 00691 inline bool IsLight() const; 00692 00693 /** 00694 * @brief 00695 * Returns whether this scene node is a fog (SNFog) or not 00696 * 00697 * @return 00698 * 'true' if this scene node is a fog, else 'false' 00699 * 00700 * @note 00701 * - More performant than IsInstanceOf("PLScene::SNFog") 00702 */ 00703 inline bool IsFog() const; 00704 00705 //[-------------------------------------------------------] 00706 //[ Modifier ] 00707 //[-------------------------------------------------------] 00708 /** 00709 * @brief 00710 * Returns the number of modifiers 00711 * 00712 * @param[in] sClass 00713 * Modifier class name to return the number of instances from, if empty 00714 * return the total number of modifiers 00715 * 00716 * @return 00717 * Number of modifiers 00718 */ 00719 PLS_API PLCore::uint32 GetNumOfModifiers(const PLCore::String &sClass = "") const; 00720 00721 /** 00722 * @brief 00723 * Adds a modifier 00724 * 00725 * @param[in] sClass 00726 * Modifier class name of the modifier to add 00727 * @param[in] sParameters 00728 * Optional parameter string 00729 * 00730 * @return 00731 * Pointer to the modifier instance if all went fine, else a null pointer 00732 * (maybe unknown/incompatible modifier) 00733 */ 00734 inline SceneNodeModifier *AddModifier(const PLCore::String &sClass, const PLCore::String &sParameters = ""); 00735 00736 /** 00737 * @brief 00738 * Adds a modifier at a certain index inside the scene node modifier list 00739 * 00740 * @param[in] sClass 00741 * Modifier class name of the modifier to add 00742 * @param[in] sParameters 00743 * Optional parameter string 00744 * @param[in] nPosition 00745 * Optional index position specifying the location within the scene node modifier list where the scene node modifier should be added, <0 for at the end 00746 * 00747 * @return 00748 * Pointer to the modifier instance if all went fine, else a null pointer 00749 * (maybe unknown/incompatible modifier) 00750 */ 00751 PLS_API SceneNodeModifier *AddModifierAtIndex(const PLCore::String &sClass, const PLCore::String &sParameters = "", int nPosition = -1); 00752 00753 /** 00754 * @brief 00755 * Returns a modifier 00756 * 00757 * @param[in] sClass 00758 * Modifier class name of the modifier to return 00759 * @param[in] nIndex 00760 * Modifier index, used if sClass is empty or if there are multiple instances 00761 * of this modifier class 00762 * 00763 * @return 00764 * The requested modifier, a null pointer on error 00765 */ 00766 PLS_API SceneNodeModifier *GetModifier(const PLCore::String &sClass, PLCore::uint32 nIndex = 0) const; 00767 00768 /** 00769 * @brief 00770 * Removes a modifier by using a given reference to the modifier to remove 00771 * 00772 * @param[in] cModifier 00773 * Modifier to remove, after this method succeeded, the given reference is no longer valid 00774 * 00775 * @return 00776 * 'true' if all went fine, else 'false' (maybe invalid modifier) 00777 */ 00778 PLS_API bool RemoveModifierByReference(SceneNodeModifier &cModifier); 00779 00780 /** 00781 * @brief 00782 * Removes a modifier 00783 * 00784 * @param[in] sClass 00785 * Modifier class name of the modifier to remove 00786 * @param[in] nIndex 00787 * Modifier index, used if sClass is empty or if there are multiple instances 00788 * of this modifier class 00789 * 00790 * @return 00791 * 'true' if all went fine, else 'false' (maybe invalid modifier) 00792 */ 00793 PLS_API bool RemoveModifier(const PLCore::String &sClass, PLCore::uint32 nIndex = 0); 00794 00795 /** 00796 * @brief 00797 * Clears all modifiers 00798 */ 00799 PLS_API void ClearModifiers(); 00800 00801 00802 //[-------------------------------------------------------] 00803 //[ Public virtual SceneNode functions ] 00804 //[-------------------------------------------------------] 00805 public: 00806 /** 00807 * @brief 00808 * Returns a pointer to the mesh handler 00809 * 00810 * @return 00811 * Pointer to the mesh handler, a null pointer if there's no mesh handler 00812 * 00813 * @note 00814 * - Returns a null pointer by default, function can be implemented in derived classes 00815 * 00816 * @see 00817 * - DrawPre() 00818 */ 00819 PLS_API virtual PLMesh::MeshHandler *GetMeshHandler(); 00820 00821 /** 00822 * @brief 00823 * Get input controller 00824 * 00825 * @return 00826 * Input controller (can be a null pointer) 00827 * 00828 * @note 00829 * - The default implementation is empty 00830 * - Derived scene nodes may add a string attribute called "InputSemantic" to tell the world about 00831 * the purpose of the input controller (for example controlling a free camera) 00832 */ 00833 PLS_API virtual PLInput::Controller *GetInputController() const; 00834 00835 /** 00836 * @brief 00837 * This function is called before any solid parts of the scene are drawn 00838 * 00839 * @param[in] cRenderer 00840 * The used renderer 00841 * @param[in] pVisNode 00842 * The current visibility node of this scene node, can be a null pointer 00843 * 00844 * @remarks 00845 * The DrawPre(), DrawSolid(), DrawTransparent(), DrawDebug() and DrawPost() allows custom draw 00846 * calls inside a scene rendering process. The function names indicate when each function is called 00847 * during scene rendering. It's not predictable which render states are currently set if these functions 00848 * are called and these draw functions will NOT interact automatically with 'uniform lighting and shadowing' 00849 * performed on nodes providing a mesh. (GetMeshHandler()) So, try to avoid using these functions whenever 00850 * possible and provide a scene node mesh instead. The default implementation does only 00851 * informing the listeners, functions can be implemented in derived classes - only DrawDebug() provides a default 00852 * implementation to draw for instance the bounding box of the scene node. From outside, this draw functions 00853 * should ONLY be called if a node is active & visible & 'on the screen' & the draw function of the function is 00854 * set. (see GetDrawFunctionFlags()) It's recommended to call these functions ONLY from inside a scene renderer! 00855 * If you don't call the base implementation of a scene node draw function inside your derived draw function 00856 * or if you are rendering the mesh of the node, you should call SetDraw() to mark this node as drawn. After 00857 * the scene node was updated, this drawn-flag is reset automatically. Use this this information to avoid 00858 * useless scene node updates. For instance do not update particle effects or other dynamic meshes if they are 00859 * currently 'invisible'. 00860 * 00861 * @note 00862 * - The default implementation only emits the SignalDrawPre signal 00863 * - Should only be called if the draw function flag 'UseDrawPre' is set 00864 */ 00865 PLS_API virtual void DrawPre(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode = nullptr); 00866 00867 /** 00868 * @brief 00869 * This function is called when the solid parts of the scene are drawn 00870 * 00871 * @param[in] cRenderer 00872 * The used renderer 00873 * @param[in] pVisNode 00874 * The current visibility node of this scene node, can be a null pointer 00875 * 00876 * @note 00877 * - The default implementation only emits the SignalDrawSolid signal 00878 * 00879 * @see 00880 * - DrawPre() 00881 */ 00882 PLS_API virtual void DrawSolid(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode = nullptr); 00883 00884 /** 00885 * @brief 00886 * This function is called when the transparent parts of the scene are drawn 00887 * 00888 * @param[in] cRenderer 00889 * The used renderer 00890 * @param[in] pVisNode 00891 * The current visibility node of this scene node, can be a null pointer 00892 * 00893 * @note 00894 * - The default implementation only emits the SignalDrawTransparent signal 00895 * 00896 * @see 00897 * - DrawPre() 00898 */ 00899 PLS_API virtual void DrawTransparent(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode = nullptr); 00900 00901 /** 00902 * @brief 00903 * This function is called when the debug parts of the scene are drawn 00904 * 00905 * @param[in] cRenderer 00906 * The used renderer 00907 * @param[in] pVisNode 00908 * The current visibility node of this scene node, can be a null pointer 00909 * 00910 * @note 00911 * - Should only be called if the 'UseDrawDebug' draw flag and the 'DebugEnabled' debug flag is set 00912 * 00913 * @note 00914 * - Beside drawing scene node stuff, the default implementation emits the SignalDrawDebug signal 00915 * 00916 * @see 00917 * - DrawPre() 00918 */ 00919 PLS_API virtual void DrawDebug(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode = nullptr); 00920 00921 /** 00922 * @brief 00923 * This function is called after transparent parts of the scene are drawn 00924 * 00925 * @param[in] cRenderer 00926 * The used renderer 00927 * @param[in] pVisNode 00928 * The current visibility node of this scene node, can be a null pointer 00929 * 00930 * @note 00931 * - The default implementation only emits the SignalDrawPost signal 00932 * 00933 * @see 00934 * - DrawPre() 00935 */ 00936 PLS_API virtual void DrawPost(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode = nullptr); 00937 00938 00939 //[-------------------------------------------------------] 00940 //[ Protected functions ] 00941 //[-------------------------------------------------------] 00942 protected: 00943 /** 00944 * @brief 00945 * Default constructor 00946 */ 00947 PLS_API SceneNode(); 00948 00949 /** 00950 * @brief 00951 * Destructor 00952 */ 00953 PLS_API virtual ~SceneNode(); 00954 00955 /** 00956 * @brief 00957 * The current axis align bounding box is dirty and must be updated if used next time 00958 */ 00959 PLS_API void DirtyAABoundingBox(); 00960 00961 00962 //[-------------------------------------------------------] 00963 //[ Protected virtual SceneNode functions ] 00964 //[-------------------------------------------------------] 00965 protected: 00966 /** 00967 * @brief 00968 * This function is called when the scene node gets initialized 00969 */ 00970 PLS_API virtual void InitFunction(); 00971 00972 /** 00973 * @brief 00974 * This function is called when the scene node gets de-initialized 00975 */ 00976 PLS_API virtual void DeInitFunction(); 00977 00978 /** 00979 * @brief 00980 * Called when the scene node has been activated or deactivated 00981 * 00982 * @param[in] bActivate 00983 * 'true' if the scene node is now active, else 'false' 00984 * 00985 * @note 00986 * - The scene node "Inactive"-flag as well as the "Frozen"-flag are taken into account 00987 * - 'bActivate' will be 'true' if the scene node AND the parent scene container (recursive!) are active 00988 * - 'bActivate' will be 'false' if the scene node OR the parent scene container (recursive!) is inactive 00989 * - The default implementation calls the "OnActivate()" of all attached scene node modifiers 00990 */ 00991 PLS_API virtual void OnActivate(bool bActivate); 00992 00993 /** 00994 * @brief 00995 * Updates the axis align bounding box in 'scene node space' 00996 * 00997 * @remarks 00998 * This function is called when the axis align bounding box needs to be calculated. One can overwrite 00999 * the default implementation to calculate the axis align bounding box in another way. The default 01000 * implementation is empty. (current set axis align bounding box is still used) 01001 * 01002 * @note 01003 * - We recommend to use 'SetAABoundingBox()' inside your own implementation to set the new axis align 01004 * bounding box, this function will take care of all other required updates 01005 */ 01006 PLS_API virtual void UpdateAABoundingBox(); 01007 01008 /** 01009 * @brief 01010 * Returns the bounding sphere in 'scene node space' 01011 * 01012 * @param[out] cSphere 01013 * Receives the bounding sphere in 'scene node space' 01014 * 01015 * @remarks 01016 * This function is called when the sphere needs to be calculated. One can overwrite 01017 * the default implementation to calculate the sphere in another way. 01018 */ 01019 PLS_API virtual void GetBoundingSphere(PLMath::Sphere &cSphere); 01020 01021 /** 01022 * @brief 01023 * Returns the current bounding sphere in 'scene container space' 01024 * 01025 * @param[out] cSphere 01026 * Receives the current bounding in 'scene container space' 01027 * 01028 * @see 01029 * - GetBoundingSphere() 01030 */ 01031 PLS_API virtual void GetContainerBoundingSphere(PLMath::Sphere &cSphere); 01032 01033 /** 01034 * @brief 01035 * Called when the scene node was added to a visibility tree 01036 * 01037 * @param[in] cVisNode 01038 * Visibility node which is representing this scene node within the visibility tree 01039 * 01040 * @note 01041 * - The default implementation only emits the SignalAddedToVisibilityTree signal 01042 * - You can use this method to get informed whether or not the scene node was, for example, 01043 * rendered to the screen in order to update only seen scene nodes 01044 * - You can use this method to manipulate the world matrix of the visibility node (for example useful for billboards) 01045 */ 01046 PLS_API virtual void OnAddedToVisibilityTree(VisNode &cVisNode); 01047 01048 01049 //[-------------------------------------------------------] 01050 //[ Private definitions ] 01051 //[-------------------------------------------------------] 01052 private: 01053 /** 01054 * @brief 01055 * Flags which hold ínternal information 01056 */ 01057 enum EInternalFlags { 01058 // Recalculate 01059 RecalculateAABoundingBox = 1<<0, /**< Recalculation of the current axis align bounding box required */ 01060 RecalculateContainerAABoundingBox = 1<<1, /**< Recalculation of the current axis align bounding box in 'scene container space' required (data is derived from the axis align bounding box and is using the current scene node transformation) */ 01061 RecalculateBoundingSphere = 1<<2, /**< Recalculation of the bounding sphere in 'scene node space' required (data is derived from the axis align bounding box) */ 01062 RecalculateContainerBoundingSphere = 1<<3, /**< Recalculation of the current bounding sphere in 'scene container space' required (data is derived from the axis align bounding box and is using the current scene node transformation) */ 01063 RecalculateHierarchy = 1<<4, /**< Recalculation of the scene hierarchy for this scene node is required */ 01064 // Scene node types (to avoid RTTI checks in performance critical situations) 01065 ClassContainer = 1<<5, /**< Derived from 'SceneContainer' */ 01066 ClassCell = 1<<6, /**< Derived from 'SCCell' */ 01067 ClassPortal = 1<<7, /**< Derived from 'SNPortal' */ 01068 ClassCamera = 1<<8, /**< Derived from 'SNCamera' */ 01069 ClassLight = 1<<9, /**< Derived from 'SNLight' */ 01070 ClassFog = 1<<10, /**< Derived from 'SNFog' */ 01071 // Misc 01072 Initialized = 1<<11, /**< The scene node is initialized */ 01073 DestroyThis = 1<<12 /**< The scene node should be destroyed */ 01074 }; 01075 01076 01077 //[-------------------------------------------------------] 01078 //[ Private functions ] 01079 //[-------------------------------------------------------] 01080 private: 01081 /** 01082 * @brief 01083 * Initializes the scene node 01084 */ 01085 void InitSceneNode(); 01086 01087 /** 01088 * @brief 01089 * De-Initializes the scene node 01090 */ 01091 void DeInitSceneNode(); 01092 01093 /** 01094 * @brief 01095 * Clones the given scene node 01096 * 01097 * @param[in] cTargetSceneContainer 01098 * Scene container were to create the new scene node in 01099 * @param[in] cSceneNode 01100 * Scene node to clone 01101 * @param[in] sNameExtension 01102 * Clone name extension 01103 * @param[in] nPosition 01104 * Optional index position specifying the location within the child list where the scene node should be added, <0 for at the end 01105 * 01106 * @return 01107 * The created clone, null pointer on error 01108 * 01109 * @note 01110 * - Scene nodes and scene node modifiers with a set "Automatic"-flag will not be cloned 01111 * - The debug flags of the created clone are set to 0 01112 */ 01113 SceneNode *CloneSceneNode(SceneContainer &cTargetSceneContainer, const SceneNode &cSceneNode, const PLCore::String &sNameExtension, int nPosition = -1); 01114 01115 /** 01116 * @brief 01117 * Call this function if the scene node bounding box was changed and the 01118 * hierarchy the scene node is in needs an update 01119 * 01120 * @note 01121 * - The hierarchy refresh will be done by the scene container if the 01122 * scene hierarchy is used the next time 01123 */ 01124 void HierarchyRefreshRequired(); 01125 01126 /** 01127 * @brief 01128 * Called on position transform change 01129 */ 01130 void OnPosition(); 01131 01132 /** 01133 * @brief 01134 * Called on rotation transform change 01135 */ 01136 void OnRotation(); 01137 01138 /** 01139 * @brief 01140 * Called on scale transform change 01141 */ 01142 void OnScale(); 01143 01144 01145 //[-------------------------------------------------------] 01146 //[ Private event handlers ] 01147 //[-------------------------------------------------------] 01148 private: 01149 PLCore::EventHandler<> EventHandlerPosition; 01150 PLCore::EventHandler<> EventHandlerRotation; 01151 PLCore::EventHandler<> EventHandlerScale; 01152 01153 01154 //[-------------------------------------------------------] 01155 //[ Private data ] 01156 //[-------------------------------------------------------] 01157 private: 01158 PLCore::uint32 m_nFlags; /**< Flags */ 01159 PLCore::uint32 m_nDebugFlags; /**< Debug flags */ 01160 PLMath::AABoundingBox m_cAABoundingBox; /**< Axis align bounding box in 'scene node space' */ 01161 PLCore::uint8 m_nDrawFunctionFlags; /**< Scene node draw function flags */ 01162 PLCore::uint32 m_nCounter; /**< Internal scene node counter */ 01163 PLCore::uint16 m_nInternalFlags; /**< Internal flags */ 01164 PLMath::Transform3 m_cTransform; /**< 3D transform */ 01165 PLMath::AABoundingBox m_cContainerAABoundingBox; /**< Current axis align bounding box in 'scene container space' */ 01166 PLMath::Sphere m_cBoundingSphere; /**< Bounding sphere in 'scene node space' */ 01167 PLMath::Sphere m_cContainerBoundingSphere; /**< Current bounding sphere in 'scene container space'*/ 01168 PLCore::List<SceneNodeModifier*> m_lstModifiers; /**< List of scene node modifiers */ 01169 SceneHierarchyNodeItem *m_pFirstSceneHierarchyNodeItem; /**< The first scene hierarchy node item, can be a null pointer */ 01170 01171 01172 //[-------------------------------------------------------] 01173 //[ Public virtual PLCore::Element functions ] 01174 //[-------------------------------------------------------] 01175 public: 01176 PLS_API virtual bool Delete(bool bProtectedToo = false) override; 01177 PLS_API virtual bool SetName(const PLCore::String &sName) override; 01178 01179 01180 //[-------------------------------------------------------] 01181 //[ Private virtual PLCore::Element functions ] 01182 //[-------------------------------------------------------] 01183 private: 01184 PLS_API virtual void DeleteElement() override; 01185 01186 01187 }; 01188 01189 01190 //[-------------------------------------------------------] 01191 //[ Namespace ] 01192 //[-------------------------------------------------------] 01193 } // PLScene 01194 01195 01196 //[-------------------------------------------------------] 01197 //[ Implementation ] 01198 //[-------------------------------------------------------] 01199 #include "PLScene/Scene/SceneNode.inl" 01200 01201 01202 #endif // __PLSCENE_SCENENODE_H__
|