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_CUBE_MAP_H__
00036 #define __SO3DYNAMIC_CUBE_MAP_H__
00037
00038 #include "../SCOLBasic/SO3Std.h"
00039 #include "../SO3SceneGraph/SO3NodeScol.h"
00040
00041 namespace SO3
00042 {
00043
00044 class SDynamicCubeMap : public SNode,
00045 public Ogre::RenderTargetListener,
00046 public Ogre::MaterialManager::Listener,
00047 public Ogre::FrameListener,
00048 public Ogre::ManualResourceLoader,
00049 public Ogre::WindowEventListener
00050 {
00051 public:
00052 protected:
00053 private:
00054 Ogre::Camera* cubeMapCamera;
00055 Ogre::TexturePtr cubeMapTexture;
00056 Ogre::RenderTarget* cubeMapTargets[6];
00057 Ogre::MaterialPtr material;
00058 Ogre::MaterialPtr materialTransparent;
00059 Ogre::TextureUnitState* textureUnitState;
00060 Ogre::String cubeMapScheme;
00061
00062 std::string oldTextureName;
00063 std::string previousScheme;
00064 unsigned int size;
00065 bool state;
00066 bool autoUpdate;
00067 bool needUpdate;
00068 bool renderingEnable;
00069
00070 public:
00073 SDynamicCubeMap(SScene* parent, std::string dynamicCubeMapName);
00074
00077 ~SDynamicCubeMap();
00078
00081 void SetMaterial(SMaterial* targetMaterial, int targetTechnique, int targetPass, int targetTextureUnit);
00082
00085 void SetSize(unsigned int newSize);
00086
00089 unsigned int GetSize();
00090
00093 void SetEnable(bool newState);
00094
00097 bool GetEnable();
00098
00104 void SetAutoUpdate(bool newAutoUpdateValue);
00105
00109 bool GetAutoUpdate();
00110
00114 void Update();
00115
00118 virtual void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
00119
00122 virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
00123
00126 virtual Ogre::Technique* handleSchemeNotFound(unsigned short schemeIndex, const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex, const Ogre::Renderable* rend);
00127
00130 virtual bool frameStarted(const Ogre::FrameEvent& evt);
00131
00134 virtual bool frameEnded(const Ogre::FrameEvent& evt);
00135
00138 virtual void loadResource(Ogre::Resource* resource);
00139
00142 virtual void windowResized(Ogre::RenderWindow* rw);
00143 protected:
00144 private:
00148 SDynamicCubeMap();
00149
00152 void SetTextureUnit();
00153
00156 void ResetTextureUnit();
00157
00160 void _CreateCubeMapTexture(unsigned int newSize);
00161
00164 void _DeleteCubeMapTexture();
00165
00168 void EnableRendering();
00169
00172 void DisableRendering();
00173 };
00174
00175 }
00176
00177 #endif