Ignition Rendering

API Reference

4.1.0
OgreMaterialSwitcher.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_OGRE_OGREMATERIALSWITCHER_HH_
19 #define IGNITION_RENDERING_OGRE_OGREMATERIALSWITCHER_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/ogre/Export.hh"
29 
30 namespace ignition
31 {
32  namespace rendering
33  {
34  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
35  //
36  // forward declarations
37  class OgreSelectionBuffer;
38 
40  class IGNITION_RENDERING_OGRE_VISIBLE OgreMaterialSwitcher :
41  public Ogre::MaterialManager::Listener, Ogre::RenderTargetListener
42  {
44  public: OgreMaterialSwitcher();
45 
47  public: ~OgreMaterialSwitcher();
48 
51  public: std::string EntityName(
52  const ignition::math::Color &_color) const;
53 
55  public: void Reset();
56 
67  public: virtual Ogre::Technique *handleSchemeNotFound(
68  uint16_t _schemeIndex, const Ogre::String &_schemeName,
69  Ogre::Material *_originalMaterial, uint16_t _lodIndex,
70  const Ogre::Renderable *_rend);
71 
75  public: virtual void preRenderTargetUpdate(
76  const Ogre::RenderTargetEvent &_evt);
77 
81  public: virtual void postRenderTargetUpdate(
82  const Ogre::RenderTargetEvent &_evt);
83 
85  private: ignition::math::Color currentColor;
86 
88  private: std::string lastEntity;
89 
91  private: Ogre::Technique *lastTechnique = nullptr;
92 
95  private: std::map<unsigned int, std::string> colorDict;
96 
99  private: void NextColor();
100 
103  public: friend class OgreSelectionBuffer;
104 
106  private: Ogre::Technique *plainTechnique = nullptr;
107 
109  private: Ogre::Technique *overlayTechnique = nullptr;
110  };
111  }
112  }
113 }
114 #endif
Helper class to assign unique colors to renderables.
Definition: OgreMaterialSwitcher.hh:40
STL class.
Generates a selection buffer object for a given camera. The selection buffer is used of entity select...
Definition: OgreSelectionBuffer.hh:47