Project

General

Profile

SO3Engine
SO3SubEntitySelectorMaterialSwitcher.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
32#ifndef __SO3_NODE_SELECTOR_MATERIAL_SWITCHER_H__
33#define __SO3_NODE_SELECTOR_MATERIAL_SWITCHER_H__
34
36
37namespace SO3
38{
39
40// Debug stuff
41#define SO3_SUBENTITY_SELECTOR_DEBUG_OVERLAY 0
42#if SO3_SUBENTITY_SELECTOR_DEBUG_OVERLAY
43# define SO3_SUBENTITY_SELECTOR_RANDOM_COLORS 1
44#else
45# define SO3_SUBENTITY_SELECTOR_RANDOM_COLORS 0
46#endif
47
48class _SO3_Export SSubEntitySelectorMaterialSwitcher : public Ogre::MaterialManager::Listener
49{
50public:
51protected:
52private:
53 struct ColourCompare
54 {
55 bool operator()(const Ogre::ColourValue& a, const Ogre::ColourValue& b) const
56 {
57 return a.getAsBGRA() < b.getAsBGRA();
58 }
59 };
60 struct SubEntityInformations
61 {
62 std::string entityName;
63 Ogre::Entity* entity;
64 std::string sceneManagerName;
65 Ogre::SubEntity* subEntity;
66 };
67 struct SceneManagerInformations
68 {
69 Ogre::FogMode fogMode;
70 Ogre::ColourValue fogColour;
71 Ogre::Real fogDensity;
72 Ogre::Real fogStart;
73 Ogre::Real fogEnd;
74 };
75 const Ogre::ColourValue resetColour;
76 Ogre::ColourValue currentColour;
77 typedef std::map<Ogre::ColourValue, SubEntityInformations, ColourCompare> ColorIndexedSubEntitiesMap;
78 ColorIndexedSubEntitiesMap colorIndexedSubEntitiesMap;
79 typedef std::map<Ogre::Entity*, Ogre::uint8> PriorizedEntityMap;
80 PriorizedEntityMap priorizedEntityList;
81 typedef std::map<Ogre::SceneManager*, SceneManagerInformations> SceneManagerList;
82 SceneManagerList sceneManagerList;
83 typedef std::map<Ogre::Renderable*, Ogre::Technique*> ProcessedRenderables;
84 ProcessedRenderables processedRenderables;
85 Ogre::MaterialPtr materialPlainColour;
86 Ogre::MaterialPtr materialPlainColorForeground;
87 Ogre::MaterialPtr materialPlainColourSP;
88 Ogre::MaterialPtr materialPlainColorForegroundSP;
89 Ogre::MaterialPtr materialTransparent;
90 Ogre::MaterialPtr materialDots;
91 Ogre::MaterialPtr materialDotsSP;
92
93public:
96 SSubEntitySelectorMaterialSwitcher(const std::string& baseResourceName, bool useDepth = false);
97
101
105 virtual Ogre::Technique* handleSchemeNotFound(unsigned short schemeIndex, const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex, const Ogre::Renderable* rend);
106
109 void ResetSwitcher();
110
113 void ResetPriorizedObject();
114
117 Ogre::SubEntity* GetSubEntity(const Ogre::ColourValue& searchedColour);
118protected:
119private:
122 void GetNextColour();
123
128};
129
130}
131
132#endif
librairies include