Frapper  1.0a
ShadowMapRenderNode.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of FRAPPER
4 research.animationsinstitut.de
5 sourceforge.net/projects/frapper
6 
7 Copyright (c) 2008-2010 Filmakademie Baden-Wuerttemberg, Institute of Animation
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
12 version.
13 
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License along with
19 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21 http://www.gnu.org/copyleft/lesser.txt.
22 -----------------------------------------------------------------------------
23 */
24 
33 
34 #ifndef SHADOWMAPRENDERNODE_H
35 #define SHADOWMAPRENDERNODE_H
36 
37 #include "GeometryRenderNode.h"
38 #include "OgreTools.h"
39 
40 // OGRE
41 #include <Ogre.h>
42 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32)
43 #include <windows.h>
44 #endif
45 
46 #define LIGHT_DEBUG
47 
48 namespace ShadowMapRenderNode {
49 using namespace Frapper;
50 
54 class MaterialSwitcher : public Ogre::MaterialManager::Listener
55 {
56 
57 public: // constructors and destructors
58 
63 
71  virtual ~MaterialSwitcher ();
72 
73 public: // methods
74 
80  Ogre::Technique* handleSchemeNotFound(unsigned short schemeIndex,
81  const Ogre::String& schemeName,
82  Ogre::Material* originalMaterial,
83  unsigned short lodIndex,
84  const Ogre::Renderable* rend);
85 
86 protected: // data
87 
88  Ogre::Technique *m_shadowTechnique;
89 };
90 
91 class ShadowListener : public Ogre::SceneManager::Listener
92 {
93 public:
94 
97 
98  void shadowTextureCasterPreViewProj (Ogre::Light *light, Ogre::Camera *camera, size_t iteration);
99 };
100 
101 
106 {
107 
108  Q_OBJECT
109 
110 public: // constructors and destructors
111 
118  ShadowMapRenderNode ( const QString &name, ParameterGroup *parameterRoot );
119 
127  virtual ~ShadowMapRenderNode ();
128 
129 private slots:
130 
139  void loadLightDescriptionFile ();
140 
144  void setLightScale ();
145 
149  void setShaderParameter ();
150 
154  void setNbrLights();
155 
156 
157 public slots: //
158 
162  void processOutputImage ();
163 
164 public:
165 
166  void redrawTriggered();
167 
168 
169 private: // functions
170 
175  float greatestComponent(const Ogre::Vector3 &vec) const;
176 
180  static bool greaterThan(const QPair<Ogre::Vector3, Ogre::Vector3> &d1, const QPair<Ogre::Vector3, Ogre::Vector3> &d2);
181 
182 protected: // data
183 
187  Ogre::Light *m_sceneLight;
188 
192  Ogre::Camera *m_cameraCopy;
193 
198 
203 
207  QList<QPair<Ogre::Vector3, Ogre::Vector3>> m_lightPositions;
208 
213 
214 #ifdef LIGHT_DEBUG
215 
216 
217 
219 #endif
220 
221 };
222 
223 } // namespace ShadowMapRenderNode
224 
225 #endif