1 | /* |
---|
2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
3 | * > www.orxonox.net < |
---|
4 | * |
---|
5 | * |
---|
6 | * License notice: |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the GNU General Public License |
---|
10 | * as published by the Free Software Foundation; either version 2 |
---|
11 | * of the License, or (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with this program; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
21 | * |
---|
22 | * Author: |
---|
23 | * Yuning Chai |
---|
24 | * Co-authors: |
---|
25 | * Felix Schulthess |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | #ifndef _HUDRadar_H__ |
---|
30 | #define _HUDRadar_H__ |
---|
31 | |
---|
32 | #include "OrxonoxPrereqs.h" |
---|
33 | |
---|
34 | #include <OgrePrerequisites.h> |
---|
35 | #include <OgrePanelOverlayElement.h> |
---|
36 | #include "overlays/OrxonoxOverlay.h" |
---|
37 | #include "objects/Tickable.h" |
---|
38 | #include "core/BaseObject.h" |
---|
39 | #include "util/Math.h" |
---|
40 | #include "core/Debug.h" |
---|
41 | #include "Radar.h" |
---|
42 | |
---|
43 | namespace orxonox |
---|
44 | { |
---|
45 | template <class T, int Dummy> |
---|
46 | class _OrxonoxExport RadarAttribute : public BaseObject |
---|
47 | { |
---|
48 | public: |
---|
49 | RadarAttribute(); |
---|
50 | ~RadarAttribute() { } |
---|
51 | |
---|
52 | void XMLPort(Element& xmlElement, XMLPort::Mode mode); |
---|
53 | void loadAttribute(Element& xmlElement, XMLPort::Mode mode); |
---|
54 | |
---|
55 | void setAttribute(const T& attribute) { this->attribute_ = attribute; } |
---|
56 | const T& getAttribute() const { return this->attribute_; } |
---|
57 | |
---|
58 | void setIndex(unsigned int index); |
---|
59 | unsigned int getIndex() { return this->index_; } |
---|
60 | |
---|
61 | private: |
---|
62 | unsigned int index_; |
---|
63 | T attribute_; |
---|
64 | }; |
---|
65 | |
---|
66 | template <class T, int Dummy> |
---|
67 | void RadarAttribute<T, Dummy>::setIndex(unsigned int index) |
---|
68 | { |
---|
69 | if (index > 0xFF) |
---|
70 | { |
---|
71 | COUT(1) << "Shape index was larger than 255 while parsing a RadarAttribute. " |
---|
72 | << "Using random number!!!" << std::endl; |
---|
73 | this->index_ = rand() & 0xFF; |
---|
74 | } |
---|
75 | else |
---|
76 | this->index_ = index; |
---|
77 | } |
---|
78 | |
---|
79 | typedef RadarAttribute<std::string, 1> RadarShape; |
---|
80 | |
---|
81 | template <> |
---|
82 | RadarShape::RadarAttribute() : index_(0) |
---|
83 | { RegisterObject(RadarShape); } |
---|
84 | |
---|
85 | template <> |
---|
86 | void RadarShape::XMLPort(Element& xmlElement, XMLPort::Mode mode) |
---|
87 | { |
---|
88 | BaseObject::XMLPort(xmlElement, mode); |
---|
89 | XMLPortParam(RadarShape, "shape", setAttribute, getAttribute, xmlElement, mode); |
---|
90 | XMLPortParam(RadarShape, "index", setIndex, getIndex, xmlElement, mode); |
---|
91 | } |
---|
92 | |
---|
93 | |
---|
94 | class _OrxonoxExport HUDRadar : public OrxonoxOverlay, public RadarListener//, public Tickable |
---|
95 | { |
---|
96 | public: |
---|
97 | HUDRadar(); |
---|
98 | ~HUDRadar(); |
---|
99 | |
---|
100 | void XMLPort(Element& xmlElement, XMLPort::Mode mode); |
---|
101 | |
---|
102 | /*void addShape(RadarShape* shape); |
---|
103 | RadarShape* getShape(unsigned int index) const;*/ |
---|
104 | |
---|
105 | float getRadarSensitivity() const { return this->sensitivity_; } |
---|
106 | void setRadarSensitivity(float sensitivity) { this->sensitivity_ = sensitivity; } |
---|
107 | |
---|
108 | float getHalfDotSizeDistance() const { return this->halfDotSizeDistance_; } |
---|
109 | void setHalfDotSizeDistance(float distance) { this->halfDotSizeDistance_ = distance; } |
---|
110 | |
---|
111 | float getMaximumDotSize() const { return this->maximumDotSize_; } |
---|
112 | void setMaximumDotSize(float size) { this->maximumDotSize_ = size; } |
---|
113 | |
---|
114 | //void tick(float dt); |
---|
115 | |
---|
116 | //void listObjects(); |
---|
117 | |
---|
118 | private: |
---|
119 | void displayObject(RadarViewable* viewable, bool bIsMarked); |
---|
120 | void hideMarker() { this->marker_->hide(); } |
---|
121 | float getRadarSensitivity() { return 1.0f; } |
---|
122 | void radarTick(float dt); |
---|
123 | |
---|
124 | std::map<RadarViewable::Shape, std::string> shapeMaterials_; |
---|
125 | |
---|
126 | Ogre::PanelOverlayElement* background_; |
---|
127 | std::map<RadarViewable*, Ogre::PanelOverlayElement*> radarDots_; |
---|
128 | Ogre::PanelOverlayElement* marker_; |
---|
129 | |
---|
130 | float halfDotSizeDistance_; |
---|
131 | float maximumDotSize_; |
---|
132 | |
---|
133 | float sensitivity_; |
---|
134 | }; |
---|
135 | } |
---|
136 | |
---|
137 | #endif /* _HUDRadar_H__ */ |
---|