Ignition Rendering

API Reference

5.0.0
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 IGNITION_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_
19 #define IGNITION_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_
20 
21 #include <map>
22 #include <string>
23 
24 #include <ignition/math/Color.hh>
25 #include "ignition/rendering/config.hh"
26 #include "ignition/rendering/ogre2/Export.hh"
28 
29 #ifdef _MSC_VER
30  #pragma warning(push, 0)
31 #endif
32 #include <OgreMaterial.h>
33 #include <OgreRenderTargetListener.h>
34 #ifdef _MSC_VER
35  #pragma warning(pop)
36 #endif
37 
38 namespace ignition
39 {
40  namespace rendering
41  {
42  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
43  //
44  // forward declarations
45  class Ogre2SelectionBuffer;
46 
48  class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2MaterialSwitcher :
49  public Ogre::RenderTargetListener
50  {
52  public: explicit Ogre2MaterialSwitcher(Ogre2ScenePtr _scene);
53 
55  public: ~Ogre2MaterialSwitcher();
56 
59  public: std::string EntityName(
60  const ignition::math::Color &_color) const;
61 
63  public: void Reset();
64 
68  public: virtual void preRenderTargetUpdate(
69  const Ogre::RenderTargetEvent &_evt);
70 
74  public: virtual void postRenderTargetUpdate(
75  const Ogre::RenderTargetEvent &_evt);
76 
78  private: ignition::math::Color currentColor;
79 
82  private: std::map<unsigned int, std::string> colorDict;
83 
86 
89  private: Ogre::MaterialPtr plainMaterial;
90 
94  private: Ogre::MaterialPtr plainOverlayMaterial;
95 
98  private: void NextColor();
99 
102  public: friend class Ogre2SelectionBuffer;
103 
105  private: Ogre2ScenePtr scene;
106  };
107  }
108  }
109 }
110 #endif
Generates a selection buffer object for a given camera. The selection buffer is used of entity select...
Definition: Ogre2SelectionBuffer.hh:47
Helper class to assign unique colors to renderables.
Definition: Ogre2MaterialSwitcher.hh:48
STL class.