sgUtil.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _SGUTIL_H_
  23. #define _SGUTIL_H_
  24. #ifndef _PLATFORM_H_
  25. #include "platform/platform.h"
  26. #endif
  27. #ifndef _MPOINT3_H_
  28. #include "math/mPoint3.h"
  29. #endif
  30. class Frustum;
  31. class RectI;
  32. #ifndef USE_TEMPLATE_MATRIX
  33. class MatrixF;
  34. #else
  35. template<typename DATA_TYPE, U32 rows, U32 cols> class Matrix;
  36. typedef Matrix<F32, 4, 4> MatrixF;
  37. #endif
  38. class PlaneF;
  39. struct SGWinding
  40. {
  41. Point3F points[32];
  42. U32 numPoints;
  43. };
  44. bool sgComputeNewFrustum(const Frustum &oldFrustum,
  45. const F64 nearPlane,
  46. const F64 farPlane,
  47. const RectI& oldViewport,
  48. const SGWinding* windings,
  49. const U32 numWindings,
  50. const MatrixF& modelview,
  51. F64 *newFrustum,
  52. RectI& newViewport,
  53. const bool flippedMatrix);
  54. /// Compute frustrum planes.
  55. ///
  56. /// Frustum parameters are:
  57. /// - [0] = left
  58. /// - [1] = right
  59. /// - [2] = top
  60. /// - [3] = bottom
  61. /// - [4] = near
  62. /// - [5] = far
  63. void sgComputeOSFrustumPlanes(const F64 frustumParameters[6],
  64. const MatrixF& worldSpaceToObjectSpace,
  65. const Point3F& wsCamPoint,
  66. PlaneF& outFarPlane,
  67. PlaneF& outXMinPlane,
  68. PlaneF& outXMaxPlane,
  69. PlaneF& outYMinPlane,
  70. PlaneF& outYMaxPlane);
  71. void sgOrientClipPlanes(PlaneF * planes, const Point3F & camPos, const Point3F & leftUp, const Point3F & leftDown, const Point3F & rightUp, const Point3F & rightDown);
  72. #endif // _H_SGUTIL_