17b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens/*!****************************************************************************
27b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
37b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @file         PVRTMisc.h
47b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @copyright    Copyright (c) Imagination Technologies Limited.
57b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @brief        Miscellaneous functions used in 3D rendering.
67b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
77b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens******************************************************************************/
87b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens#ifndef _PVRTMISC_H_
97b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens#define _PVRTMISC_H_
107b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
117b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens#include "PVRTMatrix.h"
127b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens#include "PVRTFixedPoint.h"
137b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
147b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens/****************************************************************************
157b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens** Functions
167b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens****************************************************************************/
177b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
187b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens/*!***************************************************************************
197b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @brief      	Calculates coords of the intersection of a line and an
207b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens				infinite plane
217b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[out]	pvIntersection	The point of intersection
227b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		pfPlane			Length 4 [A,B,C,D], values for plane equation
237b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		pv0				A point on the line
247b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		pv1				Another point on the line
257b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens*****************************************************************************/
267b21f276fa91ad62fd2055844688b07829f12205Nicolas Capensvoid PVRTMiscCalculateIntersectionLinePlane(
277b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens	PVRTVECTOR3			* const pvIntersection,
287b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens	const VERTTYPE		pfPlane[4],
297b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens	const PVRTVECTOR3	* const pv0,
307b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens	const PVRTVECTOR3	* const pv1);
317b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
327b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens/*!***************************************************************************
337b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @brief      	Calculates world-space coords of a screen-filling
347b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens				representation of an infinite plane The resulting vertices run
357b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens				counter-clockwise around the screen, and can be simply drawn using
367b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens				non-indexed TRIANGLEFAN
377b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[out]	pfVtx			Position of the first of 3 floats to receive
387b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens								the position of vertex 0; up to 5 vertex positions
397b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens								will be written (5 is the maximum number of vertices
407b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens								required to draw an infinite polygon clipped to screen
417b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens								and far clip plane).
427b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		nStride			Size of each vertex structure containing pfVtx
437b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		pvPlane			Length 4 [A,B,C,D], values for plane equation
447b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		pmViewProjInv	The inverse of the View Projection matrix
457b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		pFrom			Position of the camera
467b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		fFar			Far clipping distance
477b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @return		Number of vertices in the polygon fan (Can be 0, 3, 4 or 5)
487b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens*****************************************************************************/
497b21f276fa91ad62fd2055844688b07829f12205Nicolas Capensint PVRTMiscCalculateInfinitePlane(
507b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens	VERTTYPE			* const pfVtx,
517b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens	const int			nStride,
527b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens	const PVRTVECTOR4	* const pvPlane,
537b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens	const PVRTMATRIX 	* const pmViewProjInv,
547b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens	const PVRTVECTOR3	* const pFrom,
557b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens	const VERTTYPE		fFar);
567b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
577b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens/*!***************************************************************************
587b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @brief      	Creates the vertices and texture coordinates for a skybox
597b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		scale			Scale the skybox
607b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		adjustUV		Adjust or not UVs for PVRT compression
617b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		textureSize		Texture size in pixels
627b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[out]	Vertices		Array of vertices
637b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[out]	UVs				Array of UVs
647b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens*****************************************************************************/
657b21f276fa91ad62fd2055844688b07829f12205Nicolas Capensvoid PVRTCreateSkybox(float scale, bool adjustUV, int textureSize, VERTTYPE** Vertices, VERTTYPE** UVs);
667b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
677b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens/*!***************************************************************************
687b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @brief      	Destroy the memory allocated for a skybox
697b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		Vertices	    Vertices array to destroy
707b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		UVs			    UVs array to destroy
717b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens*****************************************************************************/
727b21f276fa91ad62fd2055844688b07829f12205Nicolas Capensvoid PVRTDestroySkybox(VERTTYPE* Vertices, VERTTYPE* UVs);
737b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
747b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens/*!***************************************************************************
757b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @brief      	When iTimesHigher is one, this function will return the closest
767b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens				power-of-two value above the base value.
777b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens				For every increment beyond one for the iTimesHigher value,
787b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens				the next highest power-of-two value will be calculated.
797b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		uiOriginalValue	    Base value
807b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		iTimesHigher		Multiplier
817b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens*****************************************************************************/
827b21f276fa91ad62fd2055844688b07829f12205Nicolas Capensunsigned int PVRTGetPOTHigher(unsigned int uiOriginalValue, int iTimesHigher);
837b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
847b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens/*!***************************************************************************
857b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @brief      	When iTimesLower is one, this function will return the closest
867b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens				power-of-two value below the base value.
877b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens				For every increment beyond one for the iTimesLower value,
887b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens				the next lowest power-of-two value will be calculated. The lowest
897b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens				value that can be reached is 1.
907b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		uiOriginalValue	    Base value
917b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens @param[in]		iTimesLower		    Multiplier
927b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens*****************************************************************************/
937b21f276fa91ad62fd2055844688b07829f12205Nicolas Capensunsigned int PVRTGetPOTLower(unsigned int uiOriginalValue, int iTimesLower);
947b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
957b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens#endif /* _PVRTMISC_H_ */
967b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
977b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
987b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens/*****************************************************************************
997b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens End of file (PVRTMisc.h)
1007b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens*****************************************************************************/
1017b21f276fa91ad62fd2055844688b07829f12205Nicolas Capens
102