PixelLightAPI  .
SceneRendererTool.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SceneRendererTool.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 __PLENGINE_TOOLS_SCENERENDERERTOOL_H__
00024 #define __PLENGINE_TOOLS_SCENERENDERERTOOL_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Base/Object.h>
00032 #include "PLEngine/PLEngine.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Forward declarations                                  ]
00037 //[-------------------------------------------------------]
00038 namespace PLRenderer {
00039     class SurfacePainter;
00040 }
00041 namespace PLScene {
00042     class SceneRenderer;
00043     class SceneContainer;
00044     class SceneRendererPass;
00045 }
00046 
00047 
00048 //[-------------------------------------------------------]
00049 //[ Namespace                                             ]
00050 //[-------------------------------------------------------]
00051 namespace PLEngine {
00052 
00053 
00054 //[-------------------------------------------------------]
00055 //[ Classes                                               ]
00056 //[-------------------------------------------------------]
00057 /**
00058 *  @brief
00059 *    Class offering scene renderer tool functionality
00060 *
00061 *  @remarks
00062 *    Use this class for a simplified interface to the scene renderer. By writing for example
00063 *    "SetPassAttribute("BackgroundBitmap", "Material", "Data/Textures/Background.dds");"
00064 *    one can usually (on standard scene renderer configurations) set directly a background bitmap.
00065 */
00066 class SceneRendererTool : public PLCore::Object {
00067 
00068 
00069     //[-------------------------------------------------------]
00070     //[ RTTI interface                                        ]
00071     //[-------------------------------------------------------]
00072     pl_class(PL_RTTI_EXPORT, SceneRendererTool, "PLEngine", PLCore::Object, "Class offering scene renderer tool functionality")
00073         #ifdef PLENGINE_EXPORTS // The following is only required when compiling PLEngine
00074             // Methods
00075             pl_method_3(SetSceneRenderer,   pl_ret_type(bool),                          PLScene::SceneContainer*,   const PLCore::String&,  const PLCore::String&,  "Sets the used scene renderer, scene container to render as first parameter, filename of the scene renderer to use as second parameter, optional filename of a fallback scene renderer to use in case the desired scene renderer can't be used as third parameter. Returns 'true' if all went fine, else 'false'.",                                 "")
00076             pl_method_0(GetNumOfPasses,     pl_ret_type(PLCore::uint32),                                                                                            "Returns the number of scene renderer passes",                                                                                                                                                                                                                                                                                                      "")
00077             pl_method_1(GetPassByIndex,     pl_ret_type(PLScene::SceneRendererPass*),   PLCore::uint32,                                                             "Gets a scene renderer pass by index. Index of the scene renderer pass to return as first parameter. The requested scene renderer pass as result, a null pointer on error.",                                                                                                                                                                        "")
00078             pl_method_1(GetPassByName,      pl_ret_type(PLScene::SceneRendererPass*),   const PLCore::String&,                                                      "Gets a scene renderer pass by name. Name of the scene renderer pass to return as first parameter. The requested scene renderer pass as result, a null pointer on error.",                                                                                                                                                                          "")
00079             pl_method_3(SetPassAttribute,   pl_ret_type(bool),                          const PLCore::String&,  const PLCore::String&,  const PLCore::String&,      "Sets a scene renderer pass attribute value using a string, name of the scene renderer pass as first parameter, name of the scene renderer pass attribute as second parameter and value to set as third parameter",                                                                                                                                 "")
00080             pl_method_2(SetAttribute,       pl_ret_type(PLCore::uint32),                const PLCore::String&,  const PLCore::String&,                              "Sets scene renderer pass attribute values using a string. Name of the scene renderer pass attribute (e.g. \"AmbientColor\") as first parameter, value to set (e.g. \"0.2 0.2 0.2\") as second parameter. Unlike \"SetPassAttribute()\", \"SetAttribute()\" sets the <AttributeName>-attribute from all scene renderer passes to the given value.", "")
00081             pl_method_1(SetValues,          pl_ret_type(void),                          const PLCore::String&,                                                      "Values to set (e.g.: \"ColorClear=\"0 0 0 0\" AmbientColor=\"0.2 0.2 0.2\"\") as first parameter. Unlike \"SetPassAttribute()\" and \"SetAttribute()\", \"SetValues()\" sets multiple attributes from all scene renderer passes to the given value at once.",                                                                                      "")
00082             pl_method_0(SetDefaultValues,   pl_ret_type(void),                                                                                                      "Sets all scene renderer pass attribute values to their default value",                                                                                                                                                                                                                                                                             "")
00083         #endif
00084     pl_class_end
00085 
00086 
00087     //[-------------------------------------------------------]
00088     //[ Public functions                                      ]
00089     //[-------------------------------------------------------]
00090     public:
00091         /**
00092         *  @brief
00093         *    Constructor
00094         *
00095         *  @param[in] pPainter
00096         *    Surface painter
00097         */
00098         PL_API SceneRendererTool(PLRenderer::SurfacePainter *pPainter = nullptr);
00099 
00100         /**
00101         *  @brief
00102         *    Destructor
00103         */
00104         PL_API virtual ~SceneRendererTool();
00105 
00106         /**
00107         *  @brief
00108         *    Get surface painter
00109         *
00110         *  @return
00111         *    Surface painter used to access scene renderer functionality, can be a null pointer
00112         */
00113         PL_API PLRenderer::SurfacePainter *GetPainter() const;
00114 
00115         /**
00116         *  @brief
00117         *    Set surface painter
00118         *
00119         *  @param[in] pSurfacePainter
00120         *    Surface painter used to access scene renderer functionality, can be a null pointer
00121         */
00122         PL_API void SetPainter(PLRenderer::SurfacePainter *pSurfacePainter);
00123 
00124         /**
00125         *  @brief
00126         *    Returns the used scene renderer instance
00127         *
00128         *  @return
00129         *    The used scene renderer instance, can be a null pointer
00130         *
00131         *  @note
00132         *    - Same as "SceneRenderer *pSceneRenderer = ((SPScene*)GetPainter())->GetDefaultSceneRenderer()" (with security checks!)
00133         */
00134         PL_API PLScene::SceneRenderer *GetSceneRenderer() const;
00135 
00136         /**
00137         *  @brief
00138         *    Sets the used scene renderer
00139         *
00140         *  @param[in] pSceneContainer
00141         *    Scene container to render, if null, this method will return an error
00142         *  @param[in] sFilename
00143         *    Filename of the scene renderer to use
00144         *  @param[in] sFallbackFilename
00145         *    Optional filename of a fallback scene renderer to use in case the desired scene renderer can't be used
00146         *
00147         *  @return
00148         *    'true' if all went fine, else 'false'
00149         */
00150         PL_API bool SetSceneRenderer(PLScene::SceneContainer *pSceneContainer, const PLCore::String &sFilename, const PLCore::String &sFallbackFilename = "");
00151 
00152         /**
00153         *  @brief
00154         *    Returns the number of scene renderer passes
00155         *
00156         *  @return
00157         *    The number of scene renderer passes
00158         */
00159         PL_API PLCore::uint32 GetNumOfPasses() const;
00160 
00161         /**
00162         *  @brief
00163         *    Gets a scene renderer pass by index
00164         *
00165         *  @param[in] nIndex
00166         *    Index of the scene renderer pass to return
00167         *
00168         *  @return
00169         *    The requested scene renderer pass, a null pointer on error
00170         */
00171         PL_API PLScene::SceneRendererPass *GetPassByIndex(PLCore::uint32 nIndex) const;
00172 
00173         /**
00174         *  @brief
00175         *    Gets a scene renderer pass by name
00176         *
00177         *  @param[in] sName
00178         *    Name of the scene renderer pass to return
00179         *
00180         *  @return
00181         *    The requested scene renderer pass, a null pointer on error
00182         */
00183         PL_API PLScene::SceneRendererPass *GetPassByName(const PLCore::String &sName) const;
00184 
00185         /**
00186         *  @brief
00187         *    Gets a scene renderer pass attribute
00188         *
00189         *  @param[in] sSceneRendererPassName
00190         *    Name of the scene renderer pass
00191         *  @param[in] sAttributeName
00192         *    Name of the scene renderer pass attribute
00193         *
00194         *  @return
00195         *    The requested scene renderer pass attribute, a null pointer on error
00196         */
00197         PL_API PLCore::DynVar *GetPassAttribute(const PLCore::String &sSceneRendererPassName, const PLCore::String &sAttributeName) const;
00198 
00199         /**
00200         *  @brief
00201         *    Sets a scene renderer pass attribute value using a string
00202         *
00203         *  @param[in] sSceneRendererPassName
00204         *    Name of the scene renderer pass
00205         *  @param[in] sAttributeName
00206         *    Name of the scene renderer pass attribute
00207         *  @param[in] sValue
00208         *    Value to set
00209         *
00210         *  @return
00211         *    'true' if the attribute was set, else 'false'
00212         */
00213         PL_API bool SetPassAttribute(const PLCore::String &sSceneRendererPassName, const PLCore::String &sAttributeName, const PLCore::String &sValue) const;
00214 
00215         /**
00216         *  @brief
00217         *    Sets scene renderer pass attribute values using a string
00218         *
00219         *  @param[in] sAttributeName
00220         *    Name of the scene renderer pass attribute (e.g. "AmbientColor")
00221         *  @param[in] sValue
00222         *    Value to set (e.g. "0.2 0.2 0.2")
00223         *
00224         *  @return
00225         *    Number of set scene renderer pass attribute values
00226         *
00227         *  @remarks
00228         *    Unlike "SetPassAttribute()", "SetAttribute()" sets the "sAttributeName"-attribute from all
00229         *    scene renderer passes to the given value.
00230         */
00231         PL_API PLCore::uint32 SetAttribute(const PLCore::String &sAttributeName, const PLCore::String &sValue) const;
00232 
00233         /**
00234         *  @brief
00235         *    Sets scene renderer pass attribute values using a string
00236         *
00237         *  @param[in] sValues
00238         *    Values to set (e.g.: "ColorClear=\"0 0 0 0\" AmbientColor=\"0.2 0.2 0.2\"")
00239         *
00240         *  @remarks
00241         *    Unlike "SetPassAttribute()" and "SetAttribute()", "SetValues()" sets multiple attributes from all
00242         *    scene renderer passes to the given value at once.
00243         */
00244         PL_API void SetValues(const PLCore::String &sValues) const;
00245 
00246         /**
00247         *  @brief
00248         *    Sets all scene renderer pass attribute values to their default value
00249         */
00250         PL_API void SetDefaultValues() const;
00251 
00252 
00253     //[-------------------------------------------------------]
00254     //[ Private data                                          ]
00255     //[-------------------------------------------------------]
00256     private:
00257         PLRenderer::SurfacePainter  *m_pSurfacePainter; /**< Used surface painter, can be a null pointer */
00258 
00259 
00260 };
00261 
00262 
00263 //[-------------------------------------------------------]
00264 //[ Namespace                                             ]
00265 //[-------------------------------------------------------]
00266 } // PLEngine
00267 
00268 
00269 #endif // __PLENGINE_TOOLS_SCENERENDERERTOOL_H__


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