PVRTMisc.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /******************************************************************************
  2. @File PVRTMisc.h
  3. @Title PVRTMisc
  4. @Version
  5. @Copyright Copyright (C) Imagination Technologies Limited.
  6. @Platform ANSI compatible
  7. @Description Miscellaneous functions used in 3D rendering.
  8. ******************************************************************************/
  9. #ifndef _PVRTMISC_H_
  10. #define _PVRTMISC_H_
  11. #include "PVRTMatrix.h"
  12. #include "PVRTFixedPoint.h"
  13. /****************************************************************************
  14. ** Functions
  15. ****************************************************************************/
  16. /*!***************************************************************************
  17. @Function PVRTMiscCalculateIntersectionLinePlane
  18. @Input pfPlane Length 4 [A,B,C,D], values for plane
  19. equation
  20. @Input pv0 A point on the line
  21. @Input pv1 Another point on the line
  22. @Output pvIntersection The point of intersection
  23. @Description Calculates coords of the intersection of a line and an
  24. infinite plane
  25. *****************************************************************************/
  26. void PVRTMiscCalculateIntersectionLinePlane(
  27. PVRTVECTOR3 * const pvIntersection,
  28. const VERTTYPE pfPlane[4],
  29. const PVRTVECTOR3 * const pv0,
  30. const PVRTVECTOR3 * const pv1);
  31. /*!***************************************************************************
  32. @Function PVRTMiscCalculateInfinitePlane
  33. @Input nStride Size of each vertex structure containing pfVtx
  34. @Input pvPlane Length 4 [A,B,C,D], values for plane equation
  35. @Input pmViewProjInv The inverse of the View Projection matrix
  36. @Input pFrom Position of the camera
  37. @Input fFar Far clipping distance
  38. @Output pfVtx Position of the first of 3 floats to receive
  39. the position of vertex 0; up to 5 vertex positions
  40. will be written (5 is the maximum number of vertices
  41. required to draw an infinite polygon clipped to screen
  42. and far clip plane).
  43. @Returns Number of vertices in the polygon fan (Can be 0, 3, 4 or 5)
  44. @Description Calculates world-space coords of a screen-filling
  45. representation of an infinite plane The resulting vertices run
  46. counter-clockwise around the screen, and can be simply drawn using
  47. non-indexed TRIANGLEFAN
  48. *****************************************************************************/
  49. int PVRTMiscCalculateInfinitePlane(
  50. VERTTYPE * const pfVtx,
  51. const int nStride,
  52. const PVRTVECTOR4 * const pvPlane,
  53. const PVRTMATRIX * const pmViewProjInv,
  54. const PVRTVECTOR3 * const pFrom,
  55. const VERTTYPE fFar);
  56. /*!***************************************************************************
  57. @Function PVRTCreateSkybox
  58. @Input scale Scale the skybox
  59. @Input adjustUV Adjust or not UVs for PVRT compression
  60. @Input textureSize Texture size in pixels
  61. @Output Vertices Array of vertices
  62. @Output UVs Array of UVs
  63. @Description Creates the vertices and texture coordinates for a skybox
  64. *****************************************************************************/
  65. void PVRTCreateSkybox(float scale, bool adjustUV, int textureSize, VERTTYPE** Vertices, VERTTYPE** UVs);
  66. /*!***************************************************************************
  67. @Function PVRTDestroySkybox
  68. @Input Vertices Vertices array to destroy
  69. @Input UVs UVs array to destroy
  70. @Description Destroy the memory allocated for a skybox
  71. *****************************************************************************/
  72. void PVRTDestroySkybox(VERTTYPE* Vertices, VERTTYPE* UVs);
  73. /*!***************************************************************************
  74. @Function GetPOTHigher
  75. @Input uiOriginalValue Base value
  76. @Input iTimesHigher Multiplier
  77. @Description When iTimesHigher is one, this function will return the closest
  78. power-of-two value above the base value.
  79. For every increment beyond one for the iTimesHigher value,
  80. the next highest power-of-two value will be calculated.
  81. *****************************************************************************/
  82. unsigned int GetPOTHigher(unsigned int uiOriginalValue, int iTimesHigher);
  83. /*!***************************************************************************
  84. @Function GetPOTLower
  85. @Input uiOriginalValue Base value
  86. @Input iTimesLower Multiplier
  87. @Description When iTimesLower is one, this function will return the closest
  88. power-of-two value below the base value.
  89. For every increment beyond one for the iTimesLower value,
  90. the next lowest power-of-two value will be calculated. The lowest
  91. value that can be reached is 1.
  92. *****************************************************************************/
  93. unsigned int GetPOTLower(unsigned int uiOriginalValue, int iTimesLower);
  94. #endif /* _PVRTMISC_H_ */
  95. /*****************************************************************************
  96. End of file (PVRTMisc.h)
  97. *****************************************************************************/