]> Dogcows Code - chaz/yoink/blob - src/moof/entity.hh
remove some unused stlplus modules
[chaz/yoink] / src / moof / entity.hh
1
2 /*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
3 **] All rights reserved.
4 *
5 * Distributable under the terms and conditions of the 2-clause BSD license;
6 * see the file COPYING for a complete text of the license.
7 *
8 *****************************************************************************/
9
10 #ifndef _MOOF_ENTITY_HH_
11 #define _MOOF_ENTITY_HH_
12
13 /**
14 * \file entity.hh
15 * Interface class for cullable and drawable objects.
16 */
17
18 #include <boost/shared_ptr.hpp>
19
20 #include <moof/aabb.hh>
21 #include <moof/cullable.hh>
22 #include <moof/drawable.hh>
23 #include <moof/sphere.hh>
24
25
26 namespace moof {
27
28
29 // forward declarations
30 class frustum;
31
32 /**
33 * Interface for game objects that can be drawn to the screen and have a
34 * specified volume (take up space).
35 */
36 class entity : public cullable, public drawable
37 {
38 public:
39
40 virtual ~entity() {}
41
42 /**
43 * Draw the entity only if it is visible. This method melds the
44 * cullable and drawable interfaces, and the default implementation is
45 * usually on the money.
46 * \param alpha The fraction between the last timestep and the next
47 * timestep.
48 * \param frustum The camera frustum for determining visibility.
49 */
50 virtual void
51 draw_if_visible(scalar alpha, const frustum& frustum) const
52 {
53 if (is_visible(frustum)) draw(alpha);
54 }
55
56 /**
57 * Get whether or not the entity is within a frustum. The default
58 * implementation returns the visibility of the bounding sphere and
59 * box.
60 * \param frustum The camera frustum.
61 * \return True if the entity is visible, false otherwise.
62 */
63 virtual bool is_visible(const frustum& frustum) const
64 {
65 return sphere_.is_visible(frustum) && aabb_.is_visible(frustum);
66 }
67
68 /**
69 * Get the axis-aligned bounding box surrounding the entity.
70 * \return The AABB.
71 */
72 const moof::aabb3& aabb() const
73 {
74 return aabb_;
75 }
76
77 /** Get the bounding sphere surrounding the entity.
78 * \return The sphere.
79 */
80 const moof::sphere3& sphere() const
81 {
82 return sphere_;
83 }
84
85 protected:
86
87 moof::aabb3 aabb_;
88 moof::sphere3 sphere_;
89 };
90
91 typedef boost::shared_ptr<entity> entity_ptr;
92
93
94 } // namespace moof
95
96 #endif // _MOOF_ENTITY_HH_
97
This page took 0.036348 seconds and 4 git commands to generate.