All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RTShaderSystem.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Nate Koenig
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 /* Desc: Wrapper around the OGRE RTShader system
18  * Author: Nate Koenig
19  * Date: 27 Jan 2010
20  */
21 
22 #ifndef _RTSHADERSYSTEM_HH_
23 #define _RTSHADERSYSTEM_HH_
24 
25 #include <list>
26 #include <string>
27 #include <vector>
28 
29 #include "rendering/ogre_gazebo.h"
30 #include "gazebo_config.h"
31 
32 #include "rendering/Camera.hh"
33 #include "common/SingletonT.hh"
34 
35 namespace gazebo
36 {
37  namespace rendering
38  {
39  class Visual;
40  class Scene;
41 
44 
50  class RTShaderSystem : public SingletonT<RTShaderSystem>
51  {
54  public: enum LightingModel
55  {
66  };
67 
69  private: RTShaderSystem();
70 
72  private: virtual ~RTShaderSystem();
73 
75  public: void Init();
76 
78  public: void Fini();
79 
81  public: void Clear();
82 
85  public: void AddScene(Scene *_scene);
86 
89  public: void RemoveScene(Scene *_scene);
90 
92  public: void UpdateShaders();
93 
96  public: void AttachEntity(Visual *vis);
97 
100  public: void DetachEntity(Visual *_vis);
101 
105  public: static void AttachViewport(Ogre::Viewport *_viewport,
106  Scene *_scene);
107 
111  public: static void DetachViewport(Ogre::Viewport *_viewport,
112  Scene *_scene);
113 
116  public: void SetPerPixelLighting(bool _set);
117 
120  public: void GenerateShaders(Visual *_vis);
121 
124  public: void ApplyShadows(Scene *_scene);
125 
128  public: void RemoveShadows(Scene *_scene);
129 
134  private: bool GetPaths(std::string &_coreLibsPath,
135  std::string &_cachePath);
136 
137 #if OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 7
138 
139  private: Ogre::RTShader::ShaderGenerator *shaderGenerator;
140 
142  private: Ogre::RTShader::SubRenderState *shadowRenderState;
143 #endif
144 
146  private: std::list<Visual*> entities;
147 
149  private: bool initialized;
150 
152  private: bool shadowsApplied;
153 
155  private: std::vector<Scene *> scenes;
156 
158  private: boost::mutex *entityMutex;
159 
161  private: friend class SingletonT<RTShaderSystem>;
162  };
164  }
165 }
166 #endif