Gazebo Rendering

API Reference

7.4.2
gz/rendering/ogre2/Ogre2MaterialSwitcher.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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 
18 #ifndef GZ_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_
19 #define GZ_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_
20 
21 #include <map>
22 #include <string>
23 #include <unordered_map>
24 #include <utility>
25 #include <vector>
26 
27 #include <gz/math/Color.hh>
28 #include "gz/rendering/config.hh"
29 #include "gz/rendering/ogre2/Export.hh"
31 
32 #ifdef _MSC_VER
33  #pragma warning(push, 0)
34 #endif
35 #include <OgreCamera.h>
36 #include <OgreMaterial.h>
37 #ifdef _MSC_VER
38  #pragma warning(pop)
39 #endif
40 
41 namespace gz
42 {
43  namespace rendering
44  {
45  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
46  //
47  // forward declarations
48  class Ogre2SelectionBuffer;
49 
51  class GZ_RENDERING_OGRE2_VISIBLE Ogre2MaterialSwitcher :
52  public Ogre::Camera::Listener
53  {
55  public: explicit Ogre2MaterialSwitcher(Ogre2ScenePtr _scene);
56 
58  public: ~Ogre2MaterialSwitcher();
59 
62  public: std::string EntityName(
63  const gz::math::Color &_color) const;
64 
66  public: void Reset();
67 
71  public: virtual void cameraPreRenderScene(
72  Ogre::Camera *_cam) override;
73 
77  public: virtual void cameraPostRenderScene(Ogre::Camera *_cam) override;
78 
80  private: gz::math::Color currentColor;
81 
84  private: std::map<unsigned int, std::string> colorDict;
85 
87  private: std::unordered_map<Ogre::HlmsDatablock *,
88  const Ogre::HlmsBlendblock *> datablockMap;
89 
93  private:
95 
98  private: void NextColor();
99 
102  public: friend class Ogre2SelectionBuffer;
103 
105  private: Ogre2ScenePtr scene;
106  };
107  }
108  }
109 }
110 #endif