Frustum.h 962 B

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