PixelLightAPI  .
VisContainer.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: VisContainer.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_VISIBILITY_VISCONTAINER_H__
00024 #define __PLSCENE_VISIBILITY_VISCONTAINER_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Container/Pool.h>
00032 #include <PLCore/Base/Event/EventHandler.h>
00033 #include <PLMath/Rectangle.h>
00034 #include "PLScene/Visibility/VisNode.h"
00035 
00036 
00037 //[-------------------------------------------------------]
00038 //[ Namespace                                             ]
00039 //[-------------------------------------------------------]
00040 namespace PLScene {
00041 
00042 
00043 //[-------------------------------------------------------]
00044 //[ Forward declarations                                  ]
00045 //[-------------------------------------------------------]
00046 class SQCull;
00047 class SceneNode;
00048 class VisPortal;
00049 class VisManager;
00050 class SceneQueryHandler;
00051 
00052 
00053 //[-------------------------------------------------------]
00054 //[ Classes                                               ]
00055 //[-------------------------------------------------------]
00056 /**
00057 *  @brief
00058 *    Container of the visibility tree
00059 */
00060 class VisContainer : public VisNode {
00061 
00062 
00063     //[-------------------------------------------------------]
00064     //[ Friends                                               ]
00065     //[-------------------------------------------------------]
00066     friend class SQCull;
00067     friend class VisPortal;
00068 
00069 
00070     //[-------------------------------------------------------]
00071     //[ Public structures                                     ]
00072     //[-------------------------------------------------------]
00073     public:
00074         /**
00075         *  @brief
00076         *    Projection information
00077         */
00078         struct Projection {
00079             PLMath::Rectangle cRectangle;   /**< Screen space rectangle */
00080             float             fZNear;       /**< Near depth value */
00081             float             fZFar;        /**< Far depth value */
00082         };
00083 
00084 
00085     //[-------------------------------------------------------]
00086     //[ Public functions                                      ]
00087     //[-------------------------------------------------------]
00088     public:
00089         /**
00090         *  @brief
00091         *    Returns the cull scene query of this visibility container
00092         *
00093         *  @return
00094         *    The cull scene query of this visibility container, a null pointer if there's no such query
00095         */
00096         PLS_API const SQCull *GetCullQuery() const;
00097 
00098         /**
00099         *  @brief
00100         *    Returns the list of visibility nodes
00101         *
00102         *  @return
00103         *    List of visibility nodes
00104         */
00105         PLS_API const PLCore::Pool<VisNode*> &GetVisNodes() const;
00106 
00107         /**
00108         *  @brief
00109         *    Returns projection information
00110         *
00111         *  @return
00112         *    Projection information
00113         */
00114         PLS_API const Projection &GetProjection() const;
00115 
00116 
00117     //[-------------------------------------------------------]
00118     //[ Private functions                                     ]
00119     //[-------------------------------------------------------]
00120     private:
00121         /**
00122         *  @brief
00123         *    Constructor
00124         *
00125         *  @param[in] pParent
00126         *    The parent visibility node, a null pointer if this is the root
00127         */
00128         VisContainer(VisNode *pParent = nullptr);
00129 
00130         /**
00131         *  @brief
00132         *    Destructor
00133         */
00134         virtual ~VisContainer();
00135 
00136         /**
00137         *  @brief
00138         *    Adds a scene node to this visibility container
00139         *
00140         *  @param[in] cSceneNode
00141         *    Scene node to add
00142         *  @param[in] fSquaredDistanceToCamera
00143         *    Squared distance of the given scene node to the camera
00144         *
00145         *  @return
00146         *    The added visibility node linking to the given scene node, a null pointer on error
00147         */
00148         VisNode *AddSceneNode(SceneNode &cSceneNode, float fSquaredDistanceToCamera);
00149 
00150         /**
00151         *  @brief
00152         *    Frees all visibility nodes
00153         */
00154         void FreeNodes();
00155 
00156         /**
00157         *  @brief
00158         *    Called when the scene node assigned with this visibility container was destroyed
00159         */
00160         void OnDestroy();
00161 
00162         /**
00163         *  @brief
00164         *    Returns the visibility manager
00165         *
00166         *  @return
00167         *    The visibility manager, a null pointer on error
00168         */
00169         VisManager *GetVisManager() const;
00170 
00171 
00172     //[-------------------------------------------------------]
00173     //[ Private event handlers                                ]
00174     //[-------------------------------------------------------]
00175     private:
00176         PLCore::EventHandler<> EventHandlerDestroy;
00177 
00178 
00179     //[-------------------------------------------------------]
00180     //[ Private data                                          ]
00181     //[-------------------------------------------------------]
00182     private:
00183         SceneQueryHandler                              *m_pQueryHandler;    /**< The cull scene query of this visibility container (always valid!) */
00184         PLCore::Pool<VisNode*>                          m_lstNodes;         /**< List of currently used visibility nodes */
00185         PLCore::HashMap<PLCore::String, VisContainer*>  m_mapContainers;    /**< Map with all child visibility containers of this container */
00186         PLCore::HashMap<PLCore::String, VisPortal*>     m_mapPortals;       /**< Map with all visibility portals of this container */
00187         Projection                                      m_sProjection;      /**< Projection information */
00188 
00189 
00190     //[-------------------------------------------------------]
00191     //[ Public virtual VisNode functions                      ]
00192     //[-------------------------------------------------------]
00193     public:
00194         PLS_API virtual bool IsContainer() const override;
00195         PLS_API virtual bool IsCell() const override;
00196 
00197 
00198 };
00199 
00200 
00201 //[-------------------------------------------------------]
00202 //[ Namespace                                             ]
00203 //[-------------------------------------------------------]
00204 } // PLScene
00205 
00206 
00207 #endif // __PLSCENE_VISIBILITY_VISCONTAINER_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:01
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported