PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: SceneHierarchy.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_SCENEHIERARCHY_H__ 00024 #define __PLSCENE_SCENEHIERARCHY_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLCore/Base/Object.h> 00032 #include <PLCore/Container/Pool.h> 00033 #include "PLScene/PLScene.h" 00034 00035 00036 //[-------------------------------------------------------] 00037 //[ Forward declarations ] 00038 //[-------------------------------------------------------] 00039 namespace PLMath { 00040 class Vector3; 00041 class Matrix4x4; 00042 } 00043 namespace PLGraphics { 00044 class Color4; 00045 } 00046 namespace PLRenderer { 00047 class Renderer; 00048 } 00049 namespace PLScene { 00050 class SceneNode; 00051 class SceneContext; 00052 class SceneContainer; 00053 class SceneHierarchyNode; 00054 } 00055 00056 00057 //[-------------------------------------------------------] 00058 //[ Namespace ] 00059 //[-------------------------------------------------------] 00060 namespace PLScene { 00061 00062 00063 //[-------------------------------------------------------] 00064 //[ Classes ] 00065 //[-------------------------------------------------------] 00066 /** 00067 * @brief 00068 * Abstract scene hierarchy class (spatial database, Bounding Volume Hierarchies (BVHs)) 00069 * 00070 * @remarks 00071 * Manages scene nodes of one or more scene containers within a hierarchy. 00072 */ 00073 class SceneHierarchy : public PLCore::Object { 00074 00075 00076 //[-------------------------------------------------------] 00077 //[ Friends ] 00078 //[-------------------------------------------------------] 00079 friend class SceneNode; 00080 friend class SceneContainer; 00081 friend class SceneHierarchyNode; 00082 00083 00084 //[-------------------------------------------------------] 00085 //[ RTTI interface ] 00086 //[-------------------------------------------------------] 00087 pl_class(PLS_RTTI_EXPORT, SceneHierarchy, "PLScene", PLCore::Object, "Abstract scene hierarchy class (spatial database, Bounding Volume Hierarchies (BVHs))") 00088 pl_class_end 00089 00090 00091 //[-------------------------------------------------------] 00092 //[ Public functions ] 00093 //[-------------------------------------------------------] 00094 public: 00095 /** 00096 * @brief 00097 * Returns the scene context the scene hierarchy is in 00098 * 00099 * @return 00100 * The scene context the scene hierarchy is in, can but shouldn't be a null pointer 00101 */ 00102 PLS_API SceneContext *GetSceneContext() const; 00103 00104 /** 00105 * @brief 00106 * Returns the scene container this scene hierarchy operates on 00107 * 00108 * @return 00109 * The scene container this scene hierarchy operates on 00110 */ 00111 PLS_API SceneContainer &GetSceneContainer() const; 00112 00113 /** 00114 * @brief 00115 * Returns the scene hierarchy root node 00116 * 00117 * @return 00118 * The scene hierarchy root node 00119 */ 00120 PLS_API SceneHierarchyNode &GetRootNode() const; 00121 00122 /** 00123 * @brief 00124 * Initializes the hierarchy 00125 * 00126 * @param[in] vMin 00127 * Minimum axis aligned bounding box value 00128 * @param[in] vMax 00129 * Maximum axis aligned bounding box value 00130 * 00131 * @note 00132 * - Call this function before you add any scene nodes 00133 */ 00134 PLS_API void Init(const PLMath::Vector3 &vMin, const PLMath::Vector3 &vMax); 00135 00136 /** 00137 * @brief 00138 * Returns the maximum allowed level (tree depth) 00139 * 00140 * @return 00141 * The maximum allowed level 00142 */ 00143 PLS_API PLCore::uint32 GetMaxLevel() const; 00144 00145 /** 00146 * @brief 00147 * Sets the maximum allowed level (tree depth) 00148 * 00149 * @param[in] nMaxLevel 00150 * The maximum allowed level 00151 */ 00152 PLS_API void SetMaxLevel(PLCore::uint32 nMaxLevel = 16); 00153 00154 /** 00155 * @brief 00156 * Returns the maximum allowed number of items per scene hierarchy node 00157 * 00158 * @return 00159 * The maximum allowed number of items per scene hierarchy node 00160 */ 00161 PLS_API PLCore::uint32 GetMaxNumOfNodeItems() const; 00162 00163 /** 00164 * @brief 00165 * Sets the maximum allowed number of items per scene hierarchy node 00166 * 00167 * @param[in] nMaxNumOfNodeItems 00168 * The maximum allowed number of items per scene hierarchy node 00169 */ 00170 PLS_API void SetMaxNumOfNodeItems(PLCore::uint32 nMaxNumOfNodeItems = 16); 00171 00172 /** 00173 * @brief 00174 * Returns the total number of scene hierarchy nodes (used or currently unused) 00175 * 00176 * @return 00177 * Total number of scene hierarchy nodes 00178 */ 00179 PLS_API PLCore::uint32 GetTotalNumOfNodes() const; 00180 00181 /** 00182 * @brief 00183 * Returns the number of currently used scene hierarchy nodes 00184 * 00185 * @return 00186 * Total number of currently used scene hierarchy nodes 00187 */ 00188 PLS_API PLCore::uint32 GetNumOfNodes() const; 00189 00190 /** 00191 * @brief 00192 * Returns the number of scene nodes within this hierarchy 00193 * 00194 * @return 00195 * The number of scene nodes within this hierarchy 00196 */ 00197 PLS_API PLCore::uint32 GetNumOfSceneNodes() const; 00198 00199 /** 00200 * @brief 00201 * Draws the hierarchy 00202 * 00203 * @param[in] cRenderer 00204 * Renderer to use 00205 * @param[in] cColor 00206 * Color to use 00207 * @param[in] mWorldViewProjection 00208 * World view projection matrix to use 00209 * @param[in] fLineWidth 00210 * Line width 00211 */ 00212 PLS_API void Draw(PLRenderer::Renderer &cRenderer, const PLGraphics::Color4 &cColor, const PLMath::Matrix4x4 &mWorldViewProjection, float fLineWidth = 1.0f) const; 00213 00214 00215 //[-------------------------------------------------------] 00216 //[ Protected functions ] 00217 //[-------------------------------------------------------] 00218 protected: 00219 /** 00220 * @brief 00221 * Constructor 00222 */ 00223 PLS_API SceneHierarchy(); 00224 00225 /** 00226 * @brief 00227 * Destructor 00228 */ 00229 PLS_API virtual ~SceneHierarchy(); 00230 00231 /** 00232 * @brief 00233 * Adds a scene node 00234 * 00235 * @param[in] cSceneNode 00236 * Scene node to add 00237 * 00238 * @return 00239 * 'true' if all went fine, else 'false' 00240 * (maybe the given scene node is already within a hierarchy) 00241 */ 00242 PLS_API bool AddSceneNode(SceneNode &cSceneNode); 00243 00244 /** 00245 * @brief 00246 * Removes a scene node 00247 * 00248 * @param[in] cSceneNode 00249 * Scene node to remove 00250 * 00251 * @return 00252 * 'true' if all went fine, else 'false' 00253 */ 00254 PLS_API bool RemoveSceneNode(SceneNode &cSceneNode); 00255 00256 /** 00257 * @brief 00258 * Refreshes a scene node 00259 * 00260 * @param[in] cSceneNode 00261 * Scene node to refresh 00262 * 00263 * @return 00264 * 'true' if all went fine, else 'false' 00265 * (maybe the given scene node is within no hierarchy) 00266 */ 00267 PLS_API bool RefreshSceneNode(SceneNode &cSceneNode); 00268 00269 00270 //[-------------------------------------------------------] 00271 //[ Protected virtual SceneHierarchy functions ] 00272 //[-------------------------------------------------------] 00273 protected: 00274 /** 00275 * @brief 00276 * Creates a hierarchy node 00277 * 00278 * @return 00279 * The created scene hierarchy node 00280 */ 00281 virtual SceneHierarchyNode &CreateNode() = 0; 00282 00283 00284 //[-------------------------------------------------------] 00285 //[ Protected data ] 00286 //[-------------------------------------------------------] 00287 protected: 00288 SceneContainer *m_pSceneContainer; /**< Scene container this scene hierarchy node operates on (NEVER a null pointer!) */ 00289 SceneHierarchyNode *m_pRootNode; /**< Scene hierarchy root node (NEVER a null pointer!) */ 00290 PLCore::uint32 m_nTotalNumOfNodes; /**< Total number of scene hierarchy nodes */ 00291 PLCore::uint32 m_nNumOfSceneNodes; /**< The number of scene nodes within this hierarchy */ 00292 PLCore::uint32 m_nMaxLevel; /**< Maximum allowed level (tree depth) */ 00293 PLCore::uint32 m_nMaxNumOfNodeItems; /**< Maximum allowed number of items per scene hierarchy node */ 00294 00295 /** List of currently unused scene hierarchy nodes */ 00296 PLCore::Pool<SceneHierarchyNode*> m_lstFreeNodes; 00297 00298 00299 }; 00300 00301 00302 //[-------------------------------------------------------] 00303 //[ Namespace ] 00304 //[-------------------------------------------------------] 00305 } // PLScene 00306 00307 00308 #endif // __PLSCENE_SCENEHIERARCHY_H__
|