Frustum.h 955 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef FRUSTUM_H
  2. #define FRUSTUM_H
  3. #include "data/Array.h"
  4. #include "math/Matrix.h"
  5. #include "math/Plane.h"
  6. #include "utils/StringBuffer.h"
  7. class Frustum final {
  8. Matrix projection;
  9. Array<Plane, 6> planes;
  10. public:
  11. float fieldOfView;
  12. float nearClip;
  13. float farClip;
  14. Frustum(float fieldOfView, float nearClip, float farClip);
  15. const Matrix& updateProjection(const IntVector2& size);
  16. void updatePlanes(const Vector3& pos, const Vector3& right,
  17. const Vector3& up, const Vector3& front,
  18. const IntVector2& size);
  19. bool isInside(const Vector3& pos) const;
  20. bool isInside(const Vector3& pos, float radius) const;
  21. template<int L>
  22. void toString(StringBuffer<L>& s) const {
  23. s.append("(fieldOfView = ").append(fieldOfView);
  24. s.append(", nearClip = ").append(nearClip);
  25. s.append(", farClip = ").append(farClip);
  26. s.append(')');
  27. }
  28. };
  29. #endif