PVRTTrans.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /******************************************************************************
  2. @File PVRTTrans.h
  3. @Title PVRTTrans
  4. @Version
  5. @Copyright Copyright (C) Imagination Technologies Limited.
  6. @Platform ANSI compatible
  7. @Description Set of functions used for 3D transformations and projections.
  8. ******************************************************************************/
  9. #ifndef _PVRTTRANS_H_
  10. #define _PVRTTRANS_H_
  11. /****************************************************************************
  12. ** Typedefs
  13. ****************************************************************************/
  14. typedef struct PVRTBOUNDINGBOX_TAG
  15. {
  16. PVRTVECTOR3 Point[8];
  17. } PVRTBOUNDINGBOX, *LPPVRTBOUNDINGBOX;
  18. /****************************************************************************
  19. ** Functions
  20. ****************************************************************************/
  21. /*!***************************************************************************
  22. @Function PVRTBoundingBoxCompute
  23. @Output pBoundingBox
  24. @Input pV
  25. @Input nNumberOfVertices
  26. @Description Calculate the eight vertices that surround an object.
  27. This "bounding box" is used later to determine whether
  28. the object is visible or not.
  29. This function should only be called once to determine the
  30. object's bounding box.
  31. *****************************************************************************/
  32. void PVRTBoundingBoxCompute(
  33. PVRTBOUNDINGBOX * const pBoundingBox,
  34. const PVRTVECTOR3 * const pV,
  35. const int nNumberOfVertices);
  36. /*!***************************************************************************
  37. @Function PVRTBoundingBoxComputeInterleaved
  38. @Output pBoundingBox
  39. @Input pV
  40. @Input nNumberOfVertices
  41. @Input i32Offset
  42. @Input i32Stride
  43. @Description Calculate the eight vertices that surround an object.
  44. This "bounding box" is used later to determine whether
  45. the object is visible or not.
  46. This function should only be called once to determine the
  47. object's bounding box.
  48. Takes interleaved data using the first vertex's offset
  49. and the stride to the next vertex thereafter
  50. *****************************************************************************/
  51. void PVRTBoundingBoxComputeInterleaved(
  52. PVRTBOUNDINGBOX * const pBoundingBox,
  53. const unsigned char * const pV,
  54. const int nNumberOfVertices,
  55. const int i32Offset,
  56. const int i32Stride);
  57. /*!******************************************************************************
  58. @Function PVRTBoundingBoxIsVisible
  59. @Output pNeedsZClipping
  60. @Input pBoundingBox
  61. @Input pMatrix
  62. @Return TRUE if the object is visible, FALSE if not.
  63. @Description Determine if a bounding box is "visible" or not along the
  64. Z axis.
  65. If the function returns TRUE, the object is visible and should
  66. be displayed (check bNeedsZClipping to know if Z Clipping needs
  67. to be done).
  68. If the function returns FALSE, the object is not visible and thus
  69. does not require to be displayed.
  70. bNeedsZClipping indicates whether the object needs Z Clipping
  71. (i.e. the object is partially visible).
  72. - *pBoundingBox is a pointer to the bounding box structure.
  73. - *pMatrix is the World, View & Projection matrices combined.
  74. - *bNeedsZClipping is TRUE if Z clipping is required.
  75. *****************************************************************************/
  76. bool PVRTBoundingBoxIsVisible(
  77. const PVRTBOUNDINGBOX * const pBoundingBox,
  78. const PVRTMATRIX * const pMatrix,
  79. bool * const pNeedsZClipping);
  80. /*!***************************************************************************
  81. @Function Name PVRTTransformVec3Array
  82. @Output pOut Destination for transformed vectors
  83. @Input nOutStride Stride between vectors in pOut array
  84. @Input pV Input vector array
  85. @Input nInStride Stride between vectors in pV array
  86. @Input pMatrix Matrix to transform the vectors
  87. @Input nNumberOfVertices Number of vectors to transform
  88. @Description Transform all vertices [X Y Z 1] in pV by pMatrix and
  89. store them in pOut.
  90. *****************************************************************************/
  91. void PVRTTransformVec3Array(
  92. PVRTVECTOR4 * const pOut,
  93. const int nOutStride,
  94. const PVRTVECTOR3 * const pV,
  95. const int nInStride,
  96. const PVRTMATRIX * const pMatrix,
  97. const int nNumberOfVertices);
  98. /*!***************************************************************************
  99. @Function PVRTTransformArray
  100. @Output pTransformedVertex Destination for transformed vectors
  101. @Input pV Input vector array
  102. @Input nNumberOfVertices Number of vectors to transform
  103. @Input pMatrix Matrix to transform the vectors
  104. @Input fW W coordinate of input vector (e.g. use 1 for position, 0 for normal)
  105. @Description Transform all vertices in pVertex by pMatrix and store them in
  106. pTransformedVertex
  107. - pTransformedVertex is the pointer that will receive transformed vertices.
  108. - pVertex is the pointer to untransformed object vertices.
  109. - nNumberOfVertices is the number of vertices of the object.
  110. - pMatrix is the matrix used to transform the object.
  111. *****************************************************************************/
  112. void PVRTTransformArray(
  113. PVRTVECTOR3 * const pTransformedVertex,
  114. const PVRTVECTOR3 * const pV,
  115. const int nNumberOfVertices,
  116. const PVRTMATRIX * const pMatrix,
  117. const VERTTYPE fW = f2vt(1.0f));
  118. /*!***************************************************************************
  119. @Function PVRTTransformArrayBack
  120. @Output pTransformedVertex
  121. @Input pVertex
  122. @Input nNumberOfVertices
  123. @Input pMatrix
  124. @Description Transform all vertices in pVertex by the inverse of pMatrix
  125. and store them in pTransformedVertex.
  126. - pTransformedVertex is the pointer that will receive transformed vertices.
  127. - pVertex is the pointer to untransformed object vertices.
  128. - nNumberOfVertices is the number of vertices of the object.
  129. - pMatrix is the matrix used to transform the object.
  130. *****************************************************************************/
  131. void PVRTTransformArrayBack(
  132. PVRTVECTOR3 * const pTransformedVertex,
  133. const PVRTVECTOR3 * const pVertex,
  134. const int nNumberOfVertices,
  135. const PVRTMATRIX * const pMatrix);
  136. /*!***************************************************************************
  137. @Function PVRTTransformBack
  138. @Output pOut
  139. @Input pV
  140. @Input pM
  141. @Description Transform vertex pV by the inverse of pMatrix
  142. and store in pOut.
  143. *****************************************************************************/
  144. void PVRTTransformBack(
  145. PVRTVECTOR4 * const pOut,
  146. const PVRTVECTOR4 * const pV,
  147. const PVRTMATRIX * const pM);
  148. /*!***************************************************************************
  149. @Function PVRTTransform
  150. @Output pOut
  151. @Input pV
  152. @Input pM
  153. @Description Transform vertex pV by pMatrix and store in pOut.
  154. *****************************************************************************/
  155. void PVRTTransform(
  156. PVRTVECTOR4 * const pOut,
  157. const PVRTVECTOR4 * const pV,
  158. const PVRTMATRIX * const pM);
  159. #endif /* _PVRTTRANS_H_ */
  160. /*****************************************************************************
  161. End of file (PVRTTrans.h)
  162. *****************************************************************************/