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 (C) 2012-2014 Open Source Robotics Foundation
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 
30 #include "gazebo/gazebo_config.h"
31 
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(ScenePtr _scene);
86 
89  public: void RemoveScene(ScenePtr _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  ScenePtr _scene);
107 
111  public: static void DetachViewport(Ogre::Viewport *_viewport,
112  ScenePtr _scene);
113 
116  public: void SetPerPixelLighting(bool _set);
117 
120  public: void GenerateShaders(Visual *_vis);
121 
124  public: void ApplyShadows(ScenePtr _scene);
125 
128  public: void RemoveShadows(ScenePtr _scene);
129 
132  public: Ogre::PSSMShadowCameraSetup *GetPSSMShadowCameraSetup() const;
133 
138  private: bool GetPaths(std::string &_coreLibsPath,
139  std::string &_cachePath);
140 
141 #if OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 7
142 
143  private: Ogre::RTShader::ShaderGenerator *shaderGenerator;
144 
146  private: Ogre::RTShader::SubRenderState *shadowRenderState;
147 #endif
148 
150  private: std::list<Visual*> entities;
151 
153  private: bool initialized;
154 
156  private: bool shadowsApplied;
157 
159  private: std::vector<ScenePtr> scenes;
160 
162  private: boost::mutex *entityMutex;
163 
164  private: Ogre::PSSMShadowCameraSetup *pssmSetup;
165 
167  private: friend class SingletonT<RTShaderSystem>;
168  };
170  }
171 }
172 #endif