00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00035 #ifndef __SO3DYNAMIC_REFLECTION_MAP_H__
00036 #define __SO3DYNAMIC_REFLECTION_MAP_H__
00037
00038 #include "../SCOLBasic/SO3Std.h"
00039 #include "../SO3SceneGraph/SO3NodeScol.h"
00040 #include "../SO3Renderer/SO3Viewport.h"
00041
00042 namespace SO3
00043 {
00044
00045 class SDynamicReflectionMap : public SNode,
00046 public Ogre::RenderTargetListener,
00047 public Ogre::MaterialManager::Listener,
00048 public Ogre::ManualResourceLoader
00049 {
00050 public:
00051 protected:
00052 private:
00053 SViewPort* reflectionMapViewport;
00054 Ogre::Camera* reflectionMapCamera;
00055 Ogre::MovablePlane* reflectionMapPlane;
00056 Ogre::MovablePlane* cameraClipPlane;
00057 Ogre::TexturePtr reflectionMapTexture;
00058 Ogre::RenderTarget* reflectionMapTargets;
00059 Ogre::MaterialPtr material;
00060 Ogre::MaterialPtr materialTransparent;
00061 Ogre::TextureUnitState* textureUnitState;
00062 Ogre::String reflectionMapScheme;
00063
00064 Ogre::TextureUnitState::UVWAddressingMode oldAdressingMode;
00065 Ogre::TextureType oldTextureType;
00066 std::string oldTextureName;
00067 std::string previousScheme;
00068 unsigned int size;
00069 bool state;
00070 bool revertClipPlane;
00071 bool flipClipPlane;
00072 bool renderingEnable;
00073
00074 public:
00077 SDynamicReflectionMap(SScene* parent, SViewPort* viewport, std::string dynamicReflectionMapName);
00078
00081 ~SDynamicReflectionMap();
00082
00085 void SetMaterial(SMaterial* targetMaterial, int targetTechnique, int targetPass, int targetTextureUnit);
00086
00089 void SetSize(unsigned int newSize);
00090
00093 unsigned int GetSize();
00094
00097 void SetEnable(bool newState);
00098
00101 bool GetEnable();
00102
00106 void SetRevertClipPlane(bool newRevertClipPlaneValue);
00107
00111 bool GetRevertClipPlane();
00112
00116 void FlipPlane(bool newFlip);
00117
00120 virtual void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
00121
00124 virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
00125
00128 virtual Ogre::Technique* handleSchemeNotFound(unsigned short schemeIndex, const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex, const Ogre::Renderable* rend);
00129
00132 virtual void loadResource(Ogre::Resource* resource);
00133
00134 protected:
00135 private:
00139 SDynamicReflectionMap();
00140
00143 void SetTextureUnit();
00144
00147 void ResetTextureUnit();
00148
00151 void _CreateReflectionMapTexture(unsigned int newSize);
00152
00155 void _DeleteReflectionMapTexture();
00156
00159 void EnableRendering();
00160
00163 void DisableRendering();
00164 };
00165
00166 }
00167
00168 #endif