Project

General

Profile

SO3Engine
SO3DynamicReflectionMap.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_REFLECTION_MAP_H__
33#define __SO3DYNAMIC_REFLECTION_MAP_H__
34
37
38namespace SO3
39{
40
41class _SO3_Export SDynamicReflectionMap : public SNode,
42 public Ogre::RenderTargetListener,
43 public Ogre::MaterialManager::Listener
44{
45public:
46protected:
47private:
48 SViewPort* reflectionMapViewport;
49 Ogre::Camera* reflectionMapCamera;
50 Ogre::SceneNode* camNode;
51 Ogre::MovablePlane* reflectionMapPlane;
52 Ogre::MovablePlane* cameraClipPlane;
53 Ogre::TexturePtr reflectionMapTexture;
54 Ogre::RenderTarget* reflectionMapTargets;
55 Ogre::MaterialPtr material;
56 Ogre::MaterialPtr materialTransparent;
57 Ogre::String reflectionMapScheme;
58 unsigned int techIndex;
59 unsigned int passIndex;
60 unsigned int unitIndex;
61
62 Ogre::Sampler::UVWAddressingMode oldAdressingMode;
63 Ogre::TextureType oldTextureType;
64 Ogre::TextureUnitState::EnvMapType oldTextureEnvType;
65 bool oldTextureEnvState;
66 Ogre::TexturePtr oldTexture;
67 std::string previousScheme;
68 unsigned int size;
69 bool state;
70 bool revertClipPlane;
71 bool needTextureUpdate;
72 bool flipClipPlane;
73 bool renderingEnable;
74
75public:
78 SDynamicReflectionMap(SScene* parent, SViewPort* viewport, const std::string& dynamicReflectionMapName);
79
83
86 void SetMaterial(SMaterial* targetMaterial, const int& targetTechnique, const int& targetPass, const int& targetTextureUnit);
87
90 void SetSize(const unsigned int& newSize);
91
94 unsigned int GetSize();
95
98 void SetEnable(const bool& newState);
99
102 bool GetEnable();
103
107 void SetRevertClipPlane(const bool& newRevertClipPlaneValue);
108
112 bool GetRevertClipPlane();
113
117 void FlipPlane(const bool& newFlip);
118
121 virtual void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
122
125 virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
126
129 virtual Ogre::Technique* handleSchemeNotFound(unsigned short schemeIndex, const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex, const Ogre::Renderable* rend);
130
131protected:
132private:
137
140 void SetTextureUnit();
141
144 void ResetTextureUnit();
145
148 void _CreateReflectionMapTexture(const unsigned int& newSize);
149
152 void _DeleteReflectionMapTexture();
153
156 void EnableRendering();
157
160 void DisableRendering();
161};
162
163}
164
165#endif
librairies include