RTShaderSystem.hh
00001 /* 00002 * Copyright 2011 Nate Koenig & Andrew Howard 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 */ 00017 /* Desc: Wrapper around the OGRE RTShader system 00018 * Author: Nate Koenig 00019 * Date: 27 Jan 2010 00020 */ 00021 00022 #ifndef RTSHADERSYSTEM_HH 00023 #define RTSHADERSYSTEM_HH 00024 00025 #include "rendering/ogre.h" 00026 00027 #include <list> 00028 #include "gazebo_config.h" 00029 00030 #include "rendering/Camera.hh" 00031 #include "common/SingletonT.hh" 00032 00033 namespace gazebo 00034 { 00035 namespace rendering 00036 { 00037 class Visual; 00038 class Scene; 00039 00042 00044 class RTShaderSystem : public SingletonT<RTShaderSystem> 00045 { 00046 public: enum LightingModel 00047 { 00048 SSLM_PerVertexLighting, 00049 SSLM_PerPixelLighting, 00050 SSLM_NormalMapLightingTangentSpace, 00051 SSLM_NormalMapLightingObjectSpace 00052 }; 00053 00055 private: RTShaderSystem(); 00056 00058 private: virtual ~RTShaderSystem(); 00059 00061 public: void Init(); 00062 00064 public: void Fini(); 00065 00066 public: void Clear(); 00067 00069 public: void AddScene(Scene *_scene); 00070 00072 public: void RemoveScene( Scene *scene ); 00073 00075 public: void UpdateShaders(); 00076 00078 public: void AttachEntity(Visual *vis); 00079 00081 public: void DetachEntity(Visual *vis); 00082 00084 public: static void AttachViewport(Ogre::Viewport *viewport, Scene *scene); 00085 00086 public: static void DetachViewport(Ogre::Viewport *_viewport, Scene *_scene); 00087 00089 public: void SetPerPixelLighting( bool s); 00090 00092 public: void GenerateShaders(Visual *vis); 00093 00094 public: void ApplyShadows(Scene *scene); 00095 public: void RemoveShadows(Scene *_scene); 00096 00098 private: bool GetPaths(std::string &coreLibsPath, std::string &cachePath); 00099 00100 #if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR >= 7 00101 private: Ogre::RTShader::ShaderGenerator *shaderGenerator; 00102 private: std::list<Visual*> entities; 00103 #endif 00104 00105 private: bool initialized; 00106 00107 private: std::vector<Scene *> scenes; 00108 private: Ogre::RTShader::SubRenderState *shadowRenderState; 00109 00110 private: boost::mutex *entityMutex; 00111 private: friend class SingletonT<RTShaderSystem>; 00112 }; 00114 00115 } 00116 00117 } 00118 #endif

1.7.5.1