00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __PLSCENE_SCENENODE_RENDERTOTEXTURE_H__
00024 #define __PLSCENE_SCENENODE_RENDERTOTEXTURE_H__
00025 #pragma once
00026
00027
00028
00029
00030
00031 #include "PLScene/Scene/SceneContainer.h"
00032 #include "PLScene/Scene/SceneNodeHandler.h"
00033
00034
00035
00036
00037
00038 namespace PLRenderer {
00039 class Texture;
00040 class TextureHandler;
00041 class SurfaceTextureBuffer;
00042 }
00043
00044
00045
00046
00047
00048 namespace PLScene {
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 class SCRenderToTexture : public SceneContainer {
00069
00070
00071
00072
00073
00074 public:
00075
00076
00077
00078
00079 enum EDebugFlags {
00080 DebugNoTexturePreview = 1<<8
00081 };
00082 pl_enum(EDebugFlags)
00083 pl_enum_base(SceneContainer::EDebugFlags)
00084 pl_enum_value(DebugNoTexturePreview, "Do not draw the texture preview")
00085 pl_enum_end
00086
00087
00088
00089
00090
00091 enum EFormat {
00092 R8G8B8 = 0,
00093 R8G8B8A8 = 1
00094 };
00095 pl_enum(EFormat)
00096 pl_enum_value(R8G8B8, "8 bits per red, green and blue component")
00097 pl_enum_value(R8G8B8A8, "8 bits per red, green, blue and alpha component")
00098 pl_enum_end
00099
00100
00101
00102
00103
00104 enum ESurfaceFlags {
00105 Depth = 1<<0,
00106 Stencil = 1<<1,
00107 Mipmaps = 1<<2
00108 };
00109 pl_enum(ESurfaceFlags)
00110 pl_enum_value(Depth, "Surface has a depth buffer")
00111 pl_enum_value(Stencil, "Surface has a stencil buffer")
00112 pl_enum_value(Mipmaps, "Surface has mipmaps")
00113 pl_enum_end
00114
00115
00116
00117
00118
00119 pl_class(PLS_RTTI_EXPORT, SCRenderToTexture, "PLScene", PLScene::SceneContainer, "Render to texture scene container")
00120
00121 pl_attribute(Cube, bool, false, ReadWrite, GetSet, "Render to cube texture? If 'true', only 'Width' is used which must be a power of two", "")
00122 pl_attribute(Width, PLCore::uint16, 512, ReadWrite, GetSet, "Texture width", "Min='16'")
00123 pl_attribute(Height, PLCore::uint16, 512, ReadWrite, GetSet, "Texture height", "Min='16'")
00124 pl_attribute(Format, pl_enum_type(EFormat), R8G8B8A8, ReadWrite, GetSet, "Texture format", "")
00125 pl_attribute(SurfaceFlags, pl_flag_type(ESurfaceFlags), Depth|Mipmaps, ReadWrite, GetSet, "Texture surface flags", "")
00126 pl_attribute(TextureName, PLCore::String, "", ReadWrite, GetSet, "Name of the resulting texture", "")
00127 pl_attribute(FPSLimit, float, 30.0f, ReadWrite, DirectValue, "Frames per second limitation, if 0, there's no limitation", "Min='0.0'")
00128 pl_attribute(Painter, PLCore::String, "PLScene::SPScene", ReadWrite, GetSet, "Name of the used surface painter", "")
00129 pl_attribute(SceneRenderer, PLCore::String, "Forward.sr", ReadWrite, GetSet, "Name of the used scene renderer, only used if the painter is derived of 'SPScene'", "")
00130 pl_attribute(SceneName, PLCore::String, "Parent", ReadWrite, GetSet, "Name of the scene to renderer, only used if the painter is derived of 'SPScene'", "")
00131 pl_attribute(CameraName, PLCore::String, "", ReadWrite, DirectValue, "Name of the camera to use, only used if the painter is derived of 'SPScene'", "")
00132
00133 pl_attribute(Flags, pl_flag_type(EFlags), NoCulling|NoRecursion, ReadWrite, GetSet, "Flags", "")
00134 pl_attribute(DebugFlags, pl_flag_type(EDebugFlags), 0, ReadWrite, GetSet, "Debug flags", "")
00135
00136 pl_constructor_0(DefaultConstructor, "Default constructor", "")
00137 pl_class_end
00138
00139
00140
00141
00142
00143 public:
00144 PLS_API bool GetCube() const;
00145 PLS_API void SetCube(bool bValue);
00146 PLS_API PLCore::uint16 GetWidth() const;
00147 PLS_API void SetWidth(PLCore::uint16 nValue);
00148 PLS_API PLCore::uint16 GetHeight() const;
00149 PLS_API void SetHeight(PLCore::uint16 nValue);
00150 PLS_API EFormat GetFormat() const;
00151 PLS_API void SetFormat(EFormat nValue);
00152 PLS_API PLCore::uint32 GetSurfaceFlags() const;
00153 PLS_API void SetSurfaceFlags(PLCore::uint32 nValue);
00154 PLS_API PLCore::String GetTextureName() const;
00155 PLS_API void SetTextureName(const PLCore::String &sValue);
00156 PLS_API PLCore::String GetPainter() const;
00157 PLS_API void SetPainter(const PLCore::String &sValue);
00158 PLS_API PLCore::String GetSceneRenderer() const;
00159 PLS_API void SetSceneRenderer(const PLCore::String &sValue);
00160 PLS_API PLCore::String GetSceneName() const;
00161 PLS_API void SetSceneName(const PLCore::String &sValue);
00162
00163
00164
00165
00166
00167 public:
00168
00169
00170
00171
00172 PLS_API SCRenderToTexture();
00173
00174
00175
00176
00177
00178 PLS_API virtual ~SCRenderToTexture();
00179
00180
00181
00182
00183
00184
00185
00186
00187 PLS_API PLRenderer::SurfaceTextureBuffer *GetSurfaceTextureBuffer() const;
00188
00189
00190
00191
00192
00193
00194
00195
00196 PLS_API PLRenderer::Texture *GetTexture() const;
00197
00198
00199
00200
00201
00202 protected:
00203 bool m_bCube;
00204 PLCore::uint16 m_nWidth;
00205 PLCore::uint16 m_nHeight;
00206 EFormat m_nFormat;
00207 PLCore::uint32 m_nSurfaceFlags;
00208 PLCore::String m_sTextureName;
00209 PLCore::String m_sPainter;
00210 PLCore::String m_sSceneRenderer;
00211 PLCore::String m_sSceneName;
00212 PLCore::uint64 m_nFPSLimitLastTime;
00213 PLRenderer::SurfaceTextureBuffer *m_pSurfaceTextureBuffer;
00214 PLRenderer::TextureHandler *m_pTextureHandler;
00215
00216
00217
00218
00219
00220 private:
00221
00222
00223
00224
00225 void CreateSurfaceTexture();
00226
00227
00228
00229
00230
00231 public:
00232 PLS_API virtual void DrawPre(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode = nullptr) override;
00233 PLS_API virtual void DrawDebug(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode = nullptr) override;
00234
00235
00236
00237
00238
00239 protected:
00240 PLS_API virtual void InitFunction() override;
00241
00242
00243 };
00244
00245
00246
00247
00248
00249 }
00250
00251
00252 #endif // __PLSCENE_SCENENODE_RENDERTOTEXTURE_H__