PixelLightAPI  .
SPScene.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SPScene.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_SCENEPAINTER_H__
00024 #define __PLSCENE_SCENEPAINTER_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLRenderer/Renderer/SurfacePainter.h>
00032 #include "PLScene/PLScene.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Forward declarations                                  ]
00037 //[-------------------------------------------------------]
00038 namespace PLRenderer {
00039     class Renderer;
00040 }
00041 namespace PLScene {
00042     class SQCull;
00043     class SNCamera;
00044     class SceneContext;
00045     class SceneRenderer;
00046     class SceneContainer;
00047     class SceneNodeHandler;
00048     class SceneQueryHandler;
00049     class SceneRendererHandler;
00050 }
00051 
00052 
00053 //[-------------------------------------------------------]
00054 //[ Namespace                                             ]
00055 //[-------------------------------------------------------]
00056 namespace PLScene {
00057 
00058 
00059 //[-------------------------------------------------------]
00060 //[ Classes                                               ]
00061 //[-------------------------------------------------------]
00062 /**
00063 *  @brief
00064 *    Scene graph surface painter class
00065 *
00066 *  @remarks
00067 *    The scene surface painter is responsible for rendering the scene by using a given camera.
00068 *
00069 *    'The scene' is normally subdivided into a 'root container' and a 'scene container' - both
00070 *    normally instances of SceneContainer. The 'root container' is responsible for clearing
00071 *    the frame buffer, drawing the 'scene container' and finally adding some additional
00072 *    things like GUI, engine information, console etc. The 'scene container' itself is
00073 *    the concrete scene - this distinction between 'root' and 'scene' is quite comfortable
00074 *    when it comes to things like rendering 'reflection/refraction' where only the 'scene'
00075 *    should be rendered without clearing the frame buffer or adding additional information
00076 *    like FPS display. Here's an example how such a root container may look like:
00077 *      SceneContainer  (Root container)
00078 *        SceneContainer  (Scene container with the 'real scene')
00079 *          SNCamera
00080 *          SNSky
00081 *          SNMesh
00082 *          ...
00083 *        SNGui
00084 *        SNEngineInformation
00085 *        SNConsole
00086 *    This make things extreme flexible. :)
00087 */
00088 class SPScene : public PLRenderer::SurfacePainter {
00089 
00090 
00091     //[-------------------------------------------------------]
00092     //[ RTTI interface                                        ]
00093     //[-------------------------------------------------------]
00094     pl_class(PLS_RTTI_EXPORT, SPScene, "PLScene", PLRenderer::SurfacePainter, "Scene graph surface painter class")
00095         // Constructors
00096         pl_constructor_1(ParameterConstructor,  PLRenderer::Renderer&,  "Parameter constructor",    "")
00097     pl_class_end
00098 
00099 
00100     //[-------------------------------------------------------]
00101     //[ Public functions                                      ]
00102     //[-------------------------------------------------------]
00103     public:
00104         /**
00105         *  @brief
00106         *    Constructor
00107         *
00108         *  @param[in] cRenderer
00109         *    Renderer to use
00110         */
00111         PLS_API SPScene(PLRenderer::Renderer &cRenderer);
00112 
00113         /**
00114         *  @brief
00115         *    Destructor
00116         */
00117         PLS_API virtual ~SPScene();
00118 
00119         /**
00120         *  @brief
00121         *    Returns the used scene context
00122         *
00123         *  @return
00124         *    The used scene context, can be a null pointer
00125         */
00126         PLS_API SceneContext *GetSceneContext() const;
00127 
00128         /**
00129         *  @brief
00130         *    Returns the scene root container
00131         *
00132         *  @return
00133         *    Scene root container, a null pointer if there's no one
00134         */
00135         PLS_API SceneContainer *GetRootContainer() const;
00136 
00137         /**
00138         *  @brief
00139         *    Sets the scene root container
00140         *
00141         *  @param[in] pContainer
00142         *    Scene root container, can be a null pointer
00143         *
00144         *  @return
00145         *    'true' if all went fine, else 'false'
00146         */
00147         PLS_API bool SetRootContainer(SceneContainer *pContainer);
00148 
00149         /**
00150         *  @brief
00151         *    Returns the scene container
00152         *
00153         *  @return
00154         *    Scene container, a null pointer if there's no one
00155         */
00156         PLS_API SceneContainer *GetSceneContainer() const;
00157 
00158         /**
00159         *  @brief
00160         *    Sets the scene container
00161         *
00162         *  @param[in] pContainer
00163         *    Scene container, can be a null pointer
00164         *
00165         *  @return
00166         *    'true' if all went fine, else 'false'
00167         */
00168         PLS_API bool SetSceneContainer(SceneContainer *pContainer);
00169 
00170         /**
00171         *  @brief
00172         *    Returns the default camera scene node
00173         *
00174         *  @return
00175         *    Default camera scene node, a null pointer if there's no one
00176         */
00177         PLS_API SNCamera *GetCamera() const;
00178 
00179         /**
00180         *  @brief
00181         *    Sets the default camera scene
00182         *
00183         *  @param[in] pCamera
00184         *    New default camera scene node, can be a null pointer
00185         */
00186         PLS_API void SetCamera(SNCamera *pCamera);
00187 
00188         /**
00189         *  @brief
00190         *    Returns the cull query
00191         *
00192         *  @return
00193         *    The cull query, a null pointer on error
00194         */
00195         PLS_API SQCull *GetCullQuery() const;
00196 
00197         /**
00198         *  @brief
00199         *    Returns the default scene renderer
00200         *
00201         *  @return
00202         *    The default scene renderer, can be a null pointer
00203         *
00204         *  @note
00205         *    - The default scene renderer is used if the used camera has
00206         *      no scene renderer set or there's no camera at all
00207         */
00208         PLS_API SceneRenderer *GetDefaultSceneRenderer() const;
00209 
00210         /**
00211         *  @brief
00212         *    Sets the default scene renderer
00213         *
00214         *  @param[in] sSceneRenderer
00215         *    Filename of the default scene renderer
00216         *
00217         *  @see
00218         *    - GetDefaultSceneRenderer()
00219         */
00220         PLS_API void SetDefaultSceneRenderer(const PLCore::String &sSceneRenderer = "Forward.sr");
00221 
00222 
00223     //[-------------------------------------------------------]
00224     //[ Private functions                                     ]
00225     //[-------------------------------------------------------]
00226     private:
00227         /**
00228         *  @brief
00229         *    Pre draw all scene nodes recursive
00230         *
00231         *  @param[in] cRenderer
00232         *    Renderer to use
00233         *  @param[in] cContainer
00234         *    Parent scene container
00235         */
00236         void DrawPre(PLRenderer::Renderer &cRenderer, SceneContainer &cContainer);
00237 
00238         /**
00239         *  @brief
00240         *    Solid draw all scene nodes recursive
00241         *
00242         *  @param[in] cRenderer
00243         *    Renderer to use
00244         *  @param[in] cContainer
00245         *    Parent scene container
00246         */
00247         void DrawSolid(PLRenderer::Renderer &cRenderer, SceneContainer &cContainer);
00248 
00249         /**
00250         *  @brief
00251         *    Transparent draw all scene nodes recursive
00252         *
00253         *  @param[in] cRenderer
00254         *    Renderer to use
00255         *  @param[in] cContainer
00256         *    Parent scene container
00257         */
00258         void DrawTransparent(PLRenderer::Renderer &cRenderer, SceneContainer &cContainer);
00259 
00260         /**
00261         *  @brief
00262         *    Debug draw all scene nodes recursive
00263         *
00264         *  @param[in] cRenderer
00265         *    Renderer to use
00266         *  @param[in] cContainer
00267         *    Parent scene container
00268         */
00269         void DrawDebug(PLRenderer::Renderer &cRenderer, SceneContainer &cContainer);
00270 
00271         /**
00272         *  @brief
00273         *    Post draw all scene nodes recursive
00274         *
00275         *  @param[in] cRenderer
00276         *    Renderer to use
00277         *  @param[in] cContainer
00278         *    Parent scene container
00279         */
00280         void DrawPost(PLRenderer::Renderer &cRenderer, SceneContainer &cContainer);
00281 
00282 
00283     //[-------------------------------------------------------]
00284     //[ Private data                                          ]
00285     //[-------------------------------------------------------]
00286     private:
00287         SceneNodeHandler     *m_pRootContainerHandler;          /**< Scene root container handler (always valid!) */
00288         SceneNodeHandler     *m_pSceneContainerHandler;         /**< Scene container handler (always valid!) */
00289         SceneQueryHandler    *m_pCullQuery;                     /**< Cull query (always valid!) */
00290         SceneNodeHandler     *m_pCameraNodeHandler;             /**< Camera scene node handler (always valid!) */
00291         PLCore::String        m_sDefaultSceneRenderer;          /**< Default scene renderer */
00292         SceneRendererHandler *m_pDefaultSceneRendererHandler;   /**< Default scene renderer handler, always valid! */
00293 
00294 
00295     //[-------------------------------------------------------]
00296     //[ Public virtual PLRenderer::SurfacePainter functions   ]
00297     //[-------------------------------------------------------]
00298     public:
00299         virtual void OnPaint(PLRenderer::Surface &cSurface) override;
00300 
00301 
00302 };
00303 
00304 
00305 //[-------------------------------------------------------]
00306 //[ Namespace                                             ]
00307 //[-------------------------------------------------------]
00308 } // PLScene
00309 
00310 
00311 #endif // __PLSCENE_SCENEPAINTER_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:03
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported