SO3Engine
SO3DynamicCubeMap.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
32#ifndef __SO3DYNAMIC_CUBE_MAP_H__
33#define __SO3DYNAMIC_CUBE_MAP_H__
34
37
38namespace SO3
39{
40
41class _SO3_Export SDynamicCubeMap : public SNode,
42 public Ogre::RenderTargetListener,
43 public Ogre::MaterialManager::Listener,
44 public Ogre::FrameListener
45{
46public:
47protected:
48private:
49 Ogre::Camera* cubeMapCamera;
50 Ogre::SceneNode* camNode;
51 Ogre::TexturePtr cubeMapTexture;
52 Ogre::RenderTarget* cubeMapTargets[6];
53 Ogre::MaterialPtr material;
54 Ogre::MaterialPtr materialTransparent;
55 Ogre::String cubeMapScheme;
56 Ogre::TexturePtr oldTexture;
57 std::string previousScheme;
58 unsigned int techIndex;
59 unsigned int passIndex;
60 unsigned int unitIndex;
61 unsigned int size;
62 bool state;
63 bool autoUpdate;
64 bool needUpdate;
65 bool needTextureUpdate;
66 bool renderingEnable;
67
68public:
71 SDynamicCubeMap(SScene* parent, const std::string& dynamicCubeMapName);
72
76
79 void SetMaterial(SMaterial* targetMaterial, const int& targetTechnique, const int& targetPass, const int& targetTextureUnit);
80
83 void SetSize(const unsigned int& newSize);
84
87 unsigned int GetSize();
88
91 void SetEnable(const bool& newState);
92
95 bool GetEnable();
96
102 void SetAutoUpdate(const bool& newAutoUpdateValue);
103
107 bool GetAutoUpdate();
108
112 void Update();
113
116 virtual void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
117
120 virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
121
124 virtual Ogre::Technique* handleSchemeNotFound(unsigned short schemeIndex, const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex, const Ogre::Renderable* rend);
125
128 virtual bool frameStarted(const Ogre::FrameEvent& evt);
129
132 virtual bool frameEnded(const Ogre::FrameEvent& evt);
133
136 virtual void windowResized(Ogre::RenderWindow* rw);
137protected:
138private:
143
146 void SetTextureUnit();
147
150 void ResetTextureUnit();
151
154 void _CreateCubeMapTexture(const unsigned int& newSize);
155
158 void _DeleteCubeMapTexture();
159
162 void EnableRendering();
163
166 void DisableRendering();
167};
168
169}
170
171#endif
librairies include