Polyhedron.pkg 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. $#include "Polyhedron.h"
  2. /// A convex volume built from polygon faces.
  3. class Polyhedron
  4. {
  5. public:
  6. /// Construct empty.
  7. Polyhedron()
  8. {
  9. }
  10. /// Copy-construct from another polyhedron.
  11. Polyhedron(const Polyhedron& polyhedron) :
  12. faces_(polyhedron.faces_)
  13. {
  14. }
  15. /// Construct from a bounding box.
  16. Polyhedron(const BoundingBox& box)
  17. {
  18. Define(box);
  19. }
  20. /// Construct from a frustum.
  21. Polyhedron(const Frustum& frustum)
  22. {
  23. Define(frustum);
  24. }
  25. /// Destruct.
  26. ~Polyhedron();
  27. /// Define from a bounding box.
  28. void Define(const BoundingBox& box);
  29. /// Define from a frustum.
  30. void Define(const Frustum& frustum);
  31. /// Add a triangle face.
  32. void AddFace(const Vector3& v0, const Vector3& v1, const Vector3& v2);
  33. /// Add a quadrilateral face.
  34. void AddFace(const Vector3& v0, const Vector3& v1, const Vector3& v2, const Vector3& v3);
  35. /// Clip with a plane.
  36. void Clip(const Plane& plane);
  37. /// Clip with a bounding box.
  38. void Clip(const BoundingBox& box);
  39. /// Clip with a frustum.
  40. void Clip(const Frustum& box);
  41. /// Clear all faces.
  42. void Clear();
  43. /// Transform with a 3x3 matrix.
  44. void Transform(const Matrix3& transform);
  45. /// Transform with a 3x4 matrix.
  46. void Transform(const Matrix3x4& transform);
  47. /// Return transformed with a 3x3 matrix.
  48. Polyhedron Transformed(const Matrix3& transform) const;
  49. /// Return transformed with a 3x4 matrix.
  50. Polyhedron Transformed(const Matrix3x4& transform) const;
  51. /// Return whether is empty.
  52. bool Empty() const { return faces_.Empty(); }
  53. };