PVRTVertex.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /******************************************************************************
  2. @File PVRTVertex.h
  3. @Title PVRTVertex
  4. @Version
  5. @Copyright Copyright (C) Imagination Technologies Limited.
  6. @Platform ANSI compatible
  7. @Description Utility functions which process vertices.
  8. ******************************************************************************/
  9. #ifndef _PVRTVERTEX_H_
  10. #define _PVRTVERTEX_H_
  11. #include "PVRTError.h"
  12. /****************************************************************************
  13. ** Enumerations
  14. ****************************************************************************/
  15. enum EPVRTDataType {
  16. EPODDataNone,
  17. EPODDataFloat,
  18. EPODDataInt,
  19. EPODDataUnsignedShort,
  20. EPODDataRGBA,
  21. EPODDataARGB,
  22. EPODDataD3DCOLOR,
  23. EPODDataUBYTE4,
  24. EPODDataDEC3N,
  25. EPODDataFixed16_16,
  26. EPODDataUnsignedByte,
  27. EPODDataShort,
  28. EPODDataShortNorm,
  29. EPODDataByte,
  30. EPODDataByteNorm,
  31. EPODDataUnsignedByteNorm,
  32. EPODDataUnsignedShortNorm,
  33. EPODDataUnsignedInt
  34. };
  35. /*****************************************************************************
  36. ** Functions
  37. *****************************************************************************/
  38. /*!***************************************************************************
  39. @Function PVRTVertexRead
  40. @Output pV
  41. @Input pData
  42. @Input eType
  43. @Input nCnt
  44. @Description Read a vector
  45. *****************************************************************************/
  46. void PVRTVertexRead(
  47. PVRTVECTOR4f * const pV,
  48. const void * const pData,
  49. const EPVRTDataType eType,
  50. const int nCnt);
  51. /*!***************************************************************************
  52. @Function PVRTVertexRead
  53. @Output pV
  54. @Input pData
  55. @Input eType
  56. @Description Read an int
  57. *****************************************************************************/
  58. void PVRTVertexRead(
  59. unsigned int * const pV,
  60. const void * const pData,
  61. const EPVRTDataType eType);
  62. /*!***************************************************************************
  63. @Function PVRTVertexWrite
  64. @Output pOut
  65. @Input eType
  66. @Input nCnt
  67. @Input pV
  68. @Description Write a vector
  69. *****************************************************************************/
  70. void PVRTVertexWrite(
  71. void * const pOut,
  72. const EPVRTDataType eType,
  73. const int nCnt,
  74. const PVRTVECTOR4f * const pV);
  75. /*!***************************************************************************
  76. @Function PVRTVertexWrite
  77. @Output pOut
  78. @Input eType
  79. @Input V
  80. @Description Write an int
  81. *****************************************************************************/
  82. void PVRTVertexWrite(
  83. void * const pOut,
  84. const EPVRTDataType eType,
  85. const unsigned int V);
  86. /*!***************************************************************************
  87. @Function PVRTVertexTangentBitangent
  88. @Output pvTan
  89. @Output pvBin
  90. @Input pvNor
  91. @Input pfPosA
  92. @Input pfPosB
  93. @Input pfPosC
  94. @Input pfTexA
  95. @Input pfTexB
  96. @Input pfTexC
  97. @Description Calculates the tangent and bitangent vectors for
  98. vertex 'A' of the triangle defined by the 3 supplied
  99. 3D position coordinates (pfPosA) and 2D texture
  100. coordinates (pfTexA).
  101. *****************************************************************************/
  102. void PVRTVertexTangentBitangent(
  103. PVRTVECTOR3 * const pvTan,
  104. PVRTVECTOR3 * const pvBin,
  105. const PVRTVECTOR3 * const pvNor,
  106. const float * const pfPosA,
  107. const float * const pfPosB,
  108. const float * const pfPosC,
  109. const float * const pfTexA,
  110. const float * const pfTexB,
  111. const float * const pfTexC);
  112. /*!***************************************************************************
  113. @Function PVRTVertexGenerateTangentSpace
  114. @Output pnVtxNumOut Output vertex count
  115. @Output pVtxOut Output vertices (program must free() this)
  116. @Modified pui32Idx input AND output; index array for triangle list
  117. @Input nVtxNum Input vertex count
  118. @Input pVtx Input vertices
  119. @Input nStride Size of a vertex (in bytes)
  120. @Input nOffsetPos Offset in bytes to the vertex position
  121. @Input eTypePos Data type of the position
  122. @Input nOffsetNor Offset in bytes to the vertex normal
  123. @Input eTypeNor Data type of the normal
  124. @Input nOffsetTex Offset in bytes to the vertex texture coordinate to use
  125. @Input eTypeTex Data type of the texture coordinate
  126. @Input nOffsetTan Offset in bytes to the vertex tangent
  127. @Input eTypeTan Data type of the tangent
  128. @Input nOffsetBin Offset in bytes to the vertex bitangent
  129. @Input eTypeBin Data type of the bitangent
  130. @Input nTriNum Number of triangles
  131. @Input fSplitDifference Split a vertex if the DP3 of tangents/bitangents are below this (range -1..1)
  132. @Return PVR_FAIL if there was a problem.
  133. @Description Calculates the tangent space for all supplied vertices.
  134. Writes tangent and bitangent vectors to the output
  135. vertices, copies all other elements from input vertices.
  136. Will split vertices if necessary - i.e. if two triangles
  137. sharing a vertex want to assign it different
  138. tangent-space matrices. The decision whether to split
  139. uses fSplitDifference - of the DP3 of two desired
  140. tangents or two desired bitangents is higher than this,
  141. the vertex will be split.
  142. *****************************************************************************/
  143. EPVRTError PVRTVertexGenerateTangentSpace(
  144. unsigned int * const pnVtxNumOut,
  145. char ** const pVtxOut,
  146. unsigned int * const pui32Idx,
  147. const unsigned int nVtxNum,
  148. const char * const pVtx,
  149. const unsigned int nStride,
  150. const unsigned int nOffsetPos,
  151. EPVRTDataType eTypePos,
  152. const unsigned int nOffsetNor,
  153. EPVRTDataType eTypeNor,
  154. const unsigned int nOffsetTex,
  155. EPVRTDataType eTypeTex,
  156. const unsigned int nOffsetTan,
  157. EPVRTDataType eTypeTan,
  158. const unsigned int nOffsetBin,
  159. EPVRTDataType eTypeBin,
  160. const unsigned int nTriNum,
  161. const float fSplitDifference);
  162. #endif /* _PVRTVERTEX_H_ */
  163. /*****************************************************************************
  164. End of file (PVRTVertex.h)
  165. *****************************************************************************/