]>
Dogcows Code - chaz/yoink/blob - src/moof/entity.hh
2 /*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
3 **] All rights reserved.
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.
8 *****************************************************************************/
10 #ifndef _MOOF_ENTITY_HH_
11 #define _MOOF_ENTITY_HH_
13 #include <boost/shared_ptr.hpp>
15 #include <moof/aabb.hh>
16 #include <moof/cullable.hh>
17 #include <moof/drawable.hh>
18 #include <moof/sphere.hh>
23 * Interface class for cullable and drawable objects.
29 // forward declarations
33 * Interface for game objects that can be drawn to the screen and have a
34 * specified volume (take up space).
36 class entity
: public cullable
, public drawable
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
48 * \param frustum The camera frustum for determining visibility.
51 draw_if_visible(scalar alpha
, const frustum
& frustum
) const
53 if (is_visible(frustum
)) draw(alpha
);
57 * Get whether or not the entity is within a frustum. The default
58 * implementation returns the visibility of the bounding sphere and
60 * \param frustum The camera frustum.
61 * \return True if the entity is visible, false otherwise.
63 virtual bool is_visible(const frustum
& frustum
) const
65 return sphere_
.is_visible(frustum
) && aabb_
.is_visible(frustum
);
69 * Get the axis-aligned bounding box surrounding the entity.
72 const moof::aabb3
& aabb() const
77 /** Get the bounding sphere surrounding the entity.
80 const moof::sphere3
& sphere() const
88 moof::sphere3 sphere_
;
91 typedef boost::shared_ptr
<entity
> entity_ptr
;
96 #endif // _MOOF_ENTITY_HH_
This page took 0.034576 seconds and 4 git commands to generate.