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