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