xoreos  0.0.5
renderable.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef GRAPHICS_RENDERABLE_H
26 #define GRAPHICS_RENDERABLE_H
27 
28 #include <boost/noncopyable.hpp>
29 
30 #include "glm/mat4x4.hpp"
31 
32 #include "src/common/ustring.h"
33 
34 #include "src/common/ustring.h"
35 
36 #include "src/graphics/types.h"
37 #include "src/graphics/queueable.h"
38 
39 namespace Graphics {
40 
42 class Renderable : boost::noncopyable, public Queueable {
43 public:
45  ~Renderable();
46 
47  bool operator<(const Queueable &q) const;
48 
50  virtual void calculateDistance() = 0;
51 
53  virtual void advanceTime(float dt);
54 
56  virtual void render(RenderPass pass) = 0;
57 
59  virtual void renderImmediate(const glm::mat4 &UNUSED(parentTransform)) {}
60 
62  virtual void queueRender(const glm::mat4 &UNUSED(parentTransform)) {}
63 
65  double getDistance() const;
66 
68  uint32 getID() const;
69 
71  bool isClickable() const;
73  void setClickable(bool clickable);
74 
76  const Common::UString &getTag() const;
78  void setTag(const Common::UString &tag);
79 
80  bool isVisible() const;
81 
82  virtual void show();
83  virtual void hide();
84 
86  virtual bool isIn(float x, float y) const;
88  virtual bool isIn(float x, float y, float z) const;
90  virtual bool isIn(float x1, float y1, float z1, float x2, float y2, float z2) const;
91 
92 protected:
95 
97 
98  bool _clickable;
100 
101  double _distance;
102 
103  void resort();
104 
105  void lockFrame();
106  void unlockFrame();
107 
108  void lockFrameIfVisible();
109  void unlockFrameIfVisible();
110 };
111 
112 } // End of namespace Graphics
113 
114 #endif // GRAPHICS_RENDERABLE_H
const Common::UString & getTag() const
Get the object&#39;s tag.
Definition: renderable.cpp:98
virtual void show()
Show the object.
Definition: renderable.cpp:114
virtual void hide()
Hide the object.
Definition: renderable.cpp:123
RenderableType
Definition: types.h:89
A class holding an UTF-8 string.
Definition: ustring.h:48
double _distance
The distance of the object from the viewer.
Definition: renderable.h:101
Basic graphics types.
double getDistance() const
Get the distance of the object from the viewer.
Definition: renderable.cpp:82
virtual void calculateDistance()=0
Calculate the object&#39;s distance.
QueueType _queueVisible
Definition: renderable.h:94
Common::UString _tag
Definition: renderable.h:99
virtual void renderImmediate(const glm::mat4 &parentTransform)
For shader based systems, don&#39;t sort anything, render this right_now.
Definition: renderable.h:59
virtual void queueRender(const glm::mat4 &parentTransform)
Queue the object for later rendering.
Definition: renderable.h:62
RenderPass
Definition: types.h:97
void setClickable(bool clickable)
Set the object&#39;s clickable state.
Definition: renderable.cpp:94
#define UNUSED(x)
Definition: system.h:170
QueueType
Definition: types.h:71
virtual void advanceTime(float dt)
Advance time (used by renderables with animations).
Definition: renderable.cpp:79
QueueType _queueExists
Definition: renderable.h:93
virtual bool isIn(float x, float y) const
Is that point within the object?
Definition: renderable.cpp:127
Unicode string handling.
An object that can be displayed by the graphics manager.
Definition: renderable.h:42
uint32 getID() const
Get the object&#39;s unique ID.
Definition: renderable.cpp:86
bool isVisible() const
Is the object visible?
Definition: renderable.cpp:106
uint32_t uint32
Definition: types.h:204
An object that can be stored in a queue.
bool operator<(const Queueable &q) const
Definition: renderable.cpp:75
void setTag(const Common::UString &tag)
Set the object&#39;s tag.
Definition: renderable.cpp:102
#define pass
Definition: fft.cpp:257
Renderable(RenderableType type)
Definition: renderable.cpp:33
bool isClickable() const
Is the object clickable?
Definition: renderable.cpp:90
virtual void render(RenderPass pass)=0
Render the object.