Frustum.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef FRUSTUM_H
  2. #define FRUSTUM_H
  3. #include "math/Matrix.h"
  4. #include "utils/Size.h"
  5. #include "utils/Array.h"
  6. #include "math/Plane.h"
  7. #include "utils/StringBuffer.h"
  8. class Frustum final {
  9. Matrix projection;
  10. const Size& size;
  11. Array<Plane, 6> planes;
  12. public:
  13. float fieldOfView;
  14. float nearClip;
  15. float farClip;
  16. Frustum(float fieldOfView, float nearClip, float farClip, const Size& size);
  17. Matrix& updateProjection();
  18. void updatePlanes(const Vector3& pos, const Vector3& right, const Vector3& up, const Vector3& front);
  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(", width = ").append(size.width);
  27. s.append(", height = ").append(size.height);
  28. s.append(')');
  29. }
  30. };
  31. #endif