]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Entity.hh
cade lab fixes
[chaz/yoink] / src / Moof / Entity.hh
index 738e13785b0f3d77bcb09580ce83288dc1d02ffe..ee0f8602c6fd8585090251b9d89cab8f753aefd6 100644 (file)
 #include <boost/shared_ptr.hpp>
 
 #include <Moof/Aabb.hh>
-#include <Moof/Drawable.hh>
 #include <Moof/Cullable.hh>
+#include <Moof/Drawable.hh>
+#include <Moof/Sphere.hh>
 
 
 namespace Mf {
 
 
+class Entity;
+typedef boost::shared_ptr<Entity> EntityP;
+
+class Frustum;
+
+
 /**
- * Interface for game objects that can be drawn to the screen and half a
- * specified size.
+ * Interface for game objects that can be drawn to the screen and have a
+ * specified volume (take up space).
  */
 
-class Entity : public Drawable, public Cullable
+class Entity : public Cullable, public Drawable
 {
+protected:
+
+       Aabb<3>         mAabb;
+       Sphere<3>       mSphere;
+
 public:
-       const Aabb& getAabb() const
+
+       virtual ~Entity() {}
+
+       virtual void drawIfVisible(Scalar alpha, const Frustum& frustum) const
        {
-               return aabb_;
+               if (isVisible(frustum)) draw(alpha);
        }
 
-protected:
-       Aabb aabb_;
-};
+       virtual bool isVisible(const Frustum& frustum) const
+       {
+               return mSphere.isVisible(frustum) && mAabb.isVisible(frustum);
+       }
+
+       const Aabb<3>& getAabb() const
+       {
+               return mAabb;
+       }
 
-typedef boost::shared_ptr<Entity> EntityPtr;
+       const Sphere<3>& getSphere() const
+       {
+               return mSphere;
+       }
+};
 
 
 } // namespace Mf
This page took 0.019216 seconds and 4 git commands to generate.