]>
Dogcows Code - chaz/yoink/blob - src/moof/entity.hh
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
10 **************************************************************************/
12 #ifndef _MOOF_ENTITY_HH_
13 #define _MOOF_ENTITY_HH_
17 * Interface class for cullable and drawable objects.
20 #include <boost/shared_ptr.hpp>
22 #include <moof/aabb.hh>
23 #include <moof/cullable.hh>
24 #include <moof/drawable.hh>
25 #include <moof/sphere.hh>
39 typedef boost::shared_ptr
<entity
> entity_ptr
;
43 * Interface for game objects that can be drawn to the screen and have a
44 * specified volume (take up space).
46 class entity
: public cullable
, public drawable
53 * Draw the entity only if it is visible. This method melds the
54 * cullable and drawable interfaces, and the default implementation is
55 * usually on the money.
56 * \param alpha The fraction between the last timestep and the next
58 * \param frustum The camera frustum for determining visibility.
60 virtual void draw_if_visible(scalar alpha
, const frustum
& frustum
) const
62 if (is_visible(frustum
)) draw(alpha
);
66 * Get whether or not the entity is within a frustum. The default
67 * implementation returns the visibility of the bounding sphere and
69 * \param frustum The camera frustum.
70 * \return True if the entity is visible, false otherwise.
72 virtual bool is_visible(const frustum
& frustum
) const
74 return sphere_
.is_visible(frustum
) && aabb_
.is_visible(frustum
);
79 * Get the axis-aligned bounding box surrounding the entity.
82 const moof::aabb3
& aabb() const
87 /** Get the bounding sphere surrounding the entity.
90 const moof::sphere3
& sphere() const
99 moof::sphere3 sphere_
;
105 #endif // _MOOF_ENTITY_HH_
This page took 0.044359 seconds and 4 git commands to generate.