RTShaderSystem.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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 #include "gazebo/util/system.hh"
35 
36 namespace gazebo
37 {
38  namespace rendering
39  {
40  class Visual;
41  class Scene;
42 
45 
52  public SingletonT<RTShaderSystem>
53  {
56  public: enum LightingModel
57  {
67  SSLM_NormalMapLightingObjectSpace
68  };
69 
71  private: RTShaderSystem();
72 
74  private: virtual ~RTShaderSystem();
75 
77  public: void Init();
78 
80  public: void Fini();
81 
83  public: void Clear();
84 
87  public: void AddScene(ScenePtr _scene);
88 
91  public: void RemoveScene(ScenePtr _scene);
92 
95  public: void RemoveScene(const std::string &_scene);
96 
98  public: void UpdateShaders();
99 
102  public: void AttachEntity(Visual *vis);
103 
106  public: void DetachEntity(Visual *_vis);
107 
111  public: static void AttachViewport(Ogre::Viewport *_viewport,
112  ScenePtr _scene);
113 
117  public: static void DetachViewport(Ogre::Viewport *_viewport,
118  ScenePtr _scene);
119 
122  public: void SetPerPixelLighting(bool _set);
123 
126  public: void GenerateShaders(Visual *_vis);
127 
130  public: void ApplyShadows(ScenePtr _scene);
131 
134  public: void RemoveShadows(ScenePtr _scene);
135 
138  public: Ogre::PSSMShadowCameraSetup *GetPSSMShadowCameraSetup() const;
139 
144  private: bool GetPaths(std::string &_coreLibsPath,
145  std::string &_cachePath);
146 
147 #if OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 7
148  private: Ogre::RTShader::ShaderGenerator *shaderGenerator;
150 
152  private: Ogre::RTShader::SubRenderState *shadowRenderState;
153 #endif
154 
156  private: std::list<Visual*> entities;
157 
159  private: bool initialized;
160 
162  private: bool shadowsApplied;
163 
165  private: std::vector<ScenePtr> scenes;
166 
168  private: boost::mutex *entityMutex;
169 
171  private: Ogre::ShadowCameraSetupPtr pssmSetup;
172 
174  private: friend class SingletonT<RTShaderSystem>;
175  };
177  }
178 }
179 #endif
Singleton template class.
Definition: SingletonT.hh:33
Per-Vertex lighting: best performance.
Definition: RTShaderSystem.hh:59
LightingModel
Definition: RTShaderSystem.hh:56
Normal Map lighting: lighting calculations have been stored in a light map (texture) using tangent sp...
Definition: RTShaderSystem.hh:64
A renderable object.
Definition: Visual.hh:58
#define GZ_RENDERING_VISIBLE
Definition: system.hh:241
Implements Ogre's Run-Time Shader system.
Definition: RTShaderSystem.hh:51
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:79
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
Per-Pixel lighting: best look.
Definition: RTShaderSystem.hh:61