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 
51  class GAZEBO_VISIBLE RTShaderSystem : public SingletonT<RTShaderSystem>
52  {
55  public: enum LightingModel
56  {
66  SSLM_NormalMapLightingObjectSpace
67  };
68 
70  private: RTShaderSystem();
71 
73  private: virtual ~RTShaderSystem();
74 
76  public: void Init();
77 
79  public: void Fini();
80 
82  public: void Clear();
83 
86  public: void AddScene(ScenePtr _scene);
87 
90  public: void RemoveScene(ScenePtr _scene);
91 
93  public: void UpdateShaders();
94 
97  public: void AttachEntity(Visual *vis);
98 
101  public: void DetachEntity(Visual *_vis);
102 
106  public: static void AttachViewport(Ogre::Viewport *_viewport,
107  ScenePtr _scene);
108 
112  public: static void DetachViewport(Ogre::Viewport *_viewport,
113  ScenePtr _scene);
114 
117  public: void SetPerPixelLighting(bool _set);
118 
121  public: void GenerateShaders(Visual *_vis);
122 
125  public: void ApplyShadows(ScenePtr _scene);
126 
129  public: void RemoveShadows(ScenePtr _scene);
130 
133  public: Ogre::PSSMShadowCameraSetup *GetPSSMShadowCameraSetup() const;
134 
139  private: bool GetPaths(std::string &_coreLibsPath,
140  std::string &_cachePath);
141 
142 #if OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 7
143  private: Ogre::RTShader::ShaderGenerator *shaderGenerator;
145 
147  private: Ogre::RTShader::SubRenderState *shadowRenderState;
148 #endif
149 
151  private: std::list<Visual*> entities;
152 
154  private: bool initialized;
155 
157  private: bool shadowsApplied;
158 
160  private: std::vector<ScenePtr> scenes;
161 
163  private: boost::mutex *entityMutex;
164 
166  private: Ogre::ShadowCameraSetupPtr pssmSetup;
167 
169  private: friend class SingletonT<RTShaderSystem>;
170  };
172  }
173 }
174 #endif
Singleton template class.
Definition: SingletonT.hh:33
Per-Vertex lighting: best performance.
Definition: RTShaderSystem.hh:58
LightingModel
Definition: RTShaderSystem.hh:55
Normal Map lighting: lighting calculations have been stored in a light map (texture) using tangent sp...
Definition: RTShaderSystem.hh:63
A renderable object.
Definition: Visual.hh:62
Implements Ogre's Run-Time Shader system.
Definition: RTShaderSystem.hh:51
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:74
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
Per-Pixel lighting: best look.
Definition: RTShaderSystem.hh:60
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48