Home | History | Annotate | Download | only in Tools
      1 /*!****************************************************************************
      2 
      3  @file         PVRTModelPOD.h
      4  @copyright    Copyright (c) Imagination Technologies Limited.
      5  @brief        Code to load POD files - models exported from MAX.
      6 
      7 ******************************************************************************/
      8 #ifndef _PVRTMODELPOD_H_
      9 #define _PVRTMODELPOD_H_
     10 
     11 #include "PVRTVector.h"
     12 #include "PVRTError.h"
     13 #include "PVRTVertex.h"
     14 #include "PVRTBoneBatch.h"
     15 
     16 /****************************************************************************
     17 ** Defines
     18 ****************************************************************************/
     19 #define PVRTMODELPOD_VERSION	("AB.POD.2.0") /*!< POD file version string */
     20 
     21 // PVRTMODELPOD Scene Flags
     22 #define PVRTMODELPODSF_FIXED	(0x00000001)   /*!< PVRTMODELPOD Fixed-point 16.16 data (otherwise float) flag */
     23 
     24 /****************************************************************************
     25 ** Enumerations
     26 ****************************************************************************/
     27 /*!****************************************************************************
     28  @struct      EPODLightType
     29  @brief       Enum for the POD format light types
     30 ******************************************************************************/
     31 enum EPODLightType
     32 {
     33 	ePODPoint=0,	 /*!< Point light */
     34 	ePODDirectional, /*!< Directional light */
     35 	ePODSpot,		 /*!< Spot light */
     36 	eNumPODLightTypes
     37 };
     38 
     39 /*!****************************************************************************
     40  @struct      EPODPrimitiveType
     41  @brief       Enum for the POD format primitive types
     42 ******************************************************************************/
     43 enum EPODPrimitiveType
     44 {
     45 	ePODTriangles=0, /*!< Triangles */
     46 	eNumPODPrimitiveTypes
     47 };
     48 
     49 /*!****************************************************************************
     50  @struct      EPODAnimationData
     51  @brief       Enum for the POD format animation types
     52 ******************************************************************************/
     53 enum EPODAnimationData
     54 {
     55 	ePODHasPositionAni	= 0x01,	/*!< Position animation */
     56 	ePODHasRotationAni	= 0x02, /*!< Rotation animation */
     57 	ePODHasScaleAni		= 0x04, /*!< Scale animation */
     58 	ePODHasMatrixAni	= 0x08  /*!< Matrix animation */
     59 };
     60 
     61 /*!****************************************************************************
     62  @struct      EPODMaterialFlags
     63  @brief       Enum for the material flag options
     64 ******************************************************************************/
     65 enum EPODMaterialFlag
     66 {
     67 	ePODEnableBlending	= 0x01	/*!< Enable blending for this material */
     68 };
     69 
     70 /*!****************************************************************************
     71  @struct      EPODBlendFunc
     72  @brief       Enum for the POD format blend functions
     73 ******************************************************************************/
     74 enum EPODBlendFunc
     75 {
     76 	ePODBlendFunc_ZERO=0,
     77 	ePODBlendFunc_ONE,
     78 	ePODBlendFunc_BLEND_FACTOR,
     79 	ePODBlendFunc_ONE_MINUS_BLEND_FACTOR,
     80 
     81 	ePODBlendFunc_SRC_COLOR = 0x0300,
     82 	ePODBlendFunc_ONE_MINUS_SRC_COLOR,
     83 	ePODBlendFunc_SRC_ALPHA,
     84 	ePODBlendFunc_ONE_MINUS_SRC_ALPHA,
     85 	ePODBlendFunc_DST_ALPHA,
     86 	ePODBlendFunc_ONE_MINUS_DST_ALPHA,
     87 	ePODBlendFunc_DST_COLOR,
     88 	ePODBlendFunc_ONE_MINUS_DST_COLOR,
     89 	ePODBlendFunc_SRC_ALPHA_SATURATE,
     90 
     91 	ePODBlendFunc_CONSTANT_COLOR = 0x8001,
     92 	ePODBlendFunc_ONE_MINUS_CONSTANT_COLOR,
     93 	ePODBlendFunc_CONSTANT_ALPHA,
     94 	ePODBlendFunc_ONE_MINUS_CONSTANT_ALPHA
     95 };
     96 
     97 /*!****************************************************************************
     98  @struct      EPODBlendOp
     99  @brief       Enum for the POD format blend operation
    100 ******************************************************************************/
    101 enum EPODBlendOp
    102 {
    103 	ePODBlendOp_ADD = 0x8006,
    104 	ePODBlendOp_MIN,
    105 	ePODBlendOp_MAX,
    106 	ePODBlendOp_SUBTRACT = 0x800A,
    107 	ePODBlendOp_REVERSE_SUBTRACT
    108 };
    109 
    110 /****************************************************************************
    111 ** Structures
    112 ****************************************************************************/
    113 /*!****************************************************************************
    114  @class      CPODData
    115  @brief      A class for representing POD data
    116 ******************************************************************************/
    117 class CPODData {
    118 public:
    119 	/*!***************************************************************************
    120 	@fn			Reset
    121 	@brief		Resets the POD Data to NULL
    122 	*****************************************************************************/
    123 	void Reset();
    124 
    125 public:
    126 	EPVRTDataType	eType;		/*!< Type of data stored */
    127 	PVRTuint32		n;			/*!< Number of values per vertex */
    128 	PVRTuint32		nStride;	/*!< Distance in bytes from one array entry to the next */
    129 	PVRTuint8		*pData;		/*!< Actual data (array of values); if mesh is interleaved, this is an OFFSET from pInterleaved */
    130 };
    131 
    132 /*!****************************************************************************
    133  @struct      SPODCamera
    134  @brief       Struct for storing POD camera data
    135 ******************************************************************************/
    136 struct SPODCamera {
    137 	PVRTint32			nIdxTarget;	/*!< Index of the target object */
    138 	VERTTYPE	fFOV;				/*!< Field of view */
    139 	VERTTYPE	fFar;				/*!< Far clip plane */
    140 	VERTTYPE	fNear;				/*!< Near clip plane */
    141 	VERTTYPE	*pfAnimFOV;			/*!< 1 VERTTYPE per frame of animation. */
    142 };
    143 
    144 /*!****************************************************************************
    145  @struct      SPODLight
    146  @brief       Struct for storing POD light data
    147 ******************************************************************************/
    148 struct SPODLight {
    149 	PVRTint32			nIdxTarget;		/*!< Index of the target object */
    150 	VERTTYPE			pfColour[3];	/*!< Light colour (0.0f -> 1.0f for each channel) */
    151 	EPODLightType		eType;			/*!< Light type (point, directional, spot etc.) */
    152 	PVRTfloat32			fConstantAttenuation;	/*!< Constant attenuation */
    153 	PVRTfloat32			fLinearAttenuation;		/*!< Linear atternuation */
    154 	PVRTfloat32			fQuadraticAttenuation;	/*!< Quadratic attenuation */
    155 	PVRTfloat32			fFalloffAngle;			/*!< Falloff angle (in radians) */
    156 	PVRTfloat32			fFalloffExponent;		/*!< Falloff exponent */
    157 };
    158 
    159 /*!****************************************************************************
    160  @struct      SPODMesh
    161  @brief       Struct for storing POD mesh data
    162 ******************************************************************************/
    163 struct SPODMesh {
    164 	PVRTuint32			nNumVertex;		/*!< Number of vertices in the mesh */
    165 	PVRTuint32			nNumFaces;		/*!< Number of triangles in the mesh */
    166 	PVRTuint32			nNumUVW;		/*!< Number of texture coordinate channels per vertex */
    167 	CPODData			sFaces;			/*!< List of triangle indices */
    168 	PVRTuint32			*pnStripLength;	/*!< If mesh is stripped: number of tris per strip. */
    169 	PVRTuint32			nNumStrips;		/*!< If mesh is stripped: number of strips, length of pnStripLength array. */
    170 	CPODData			sVertex;		/*!< List of vertices (x0, y0, z0, x1, y1, z1, x2, etc...) */
    171 	CPODData			sNormals;		/*!< List of vertex normals (Nx0, Ny0, Nz0, Nx1, Ny1, Nz1, Nx2, etc...) */
    172 	CPODData			sTangents;		/*!< List of vertex tangents (Tx0, Ty0, Tz0, Tx1, Ty1, Tz1, Tx2, etc...) */
    173 	CPODData			sBinormals;		/*!< List of vertex binormals (Bx0, By0, Bz0, Bx1, By1, Bz1, Bx2, etc...) */
    174 	CPODData			*psUVW;			/*!< List of UVW coordinate sets; size of array given by 'nNumUVW' */
    175 	CPODData			sVtxColours;	/*!< A colour per vertex */
    176 	CPODData			sBoneIdx;		/*!< nNumBones*nNumVertex ints (Vtx0Idx0, Vtx0Idx1, ... Vtx1Idx0, Vtx1Idx1, ...) */
    177 	CPODData			sBoneWeight;	/*!< nNumBones*nNumVertex floats (Vtx0Wt0, Vtx0Wt1, ... Vtx1Wt0, Vtx1Wt1, ...) */
    178 
    179 	PVRTuint8			*pInterleaved;	/*!< Interleaved vertex data */
    180 
    181 	CPVRTBoneBatches	sBoneBatches;	/*!< Bone tables */
    182 
    183 	EPODPrimitiveType	ePrimitiveType;	/*!< Primitive type used by this mesh */
    184 
    185 	PVRTMATRIX			mUnpackMatrix;	/*!< A matrix used for unscaling scaled vertex data created with PVRTModelPODScaleAndConvertVtxData*/
    186 };
    187 
    188 /*!****************************************************************************
    189  @struct      SPODNode
    190  @brief       Struct for storing POD node data
    191 ******************************************************************************/
    192 struct SPODNode {
    193 	PVRTint32			nIdx;				/*!< Index into mesh, light or camera array, depending on which object list contains this Node */
    194 	PVRTchar8			*pszName;			/*!< Name of object */
    195 	PVRTint32			nIdxMaterial;		/*!< Index of material used on this mesh */
    196 
    197 	PVRTint32			nIdxParent;		/*!< Index into MeshInstance array; recursively apply ancestor's transforms after this instance's. */
    198 
    199 	PVRTuint32			nAnimFlags;		/*!< Stores which animation arrays the POD Node contains */
    200 
    201 	PVRTuint32			*pnAnimPositionIdx;
    202 	VERTTYPE			*pfAnimPosition;	/*!< 3 floats per frame of animation. */
    203 
    204 	PVRTuint32			*pnAnimRotationIdx;
    205 	VERTTYPE			*pfAnimRotation;	/*!< 4 floats per frame of animation. */
    206 
    207 	PVRTuint32			*pnAnimScaleIdx;
    208 	VERTTYPE			*pfAnimScale;		/*!< 7 floats per frame of animation. */
    209 
    210 	PVRTuint32			*pnAnimMatrixIdx;
    211 	VERTTYPE			*pfAnimMatrix;		/*!< 16 floats per frame of animation. */
    212 
    213 	PVRTuint32			nUserDataSize;
    214 	PVRTchar8			*pUserData;
    215 };
    216 
    217 /*!****************************************************************************
    218  @struct      SPODTexture
    219  @brief       Struct for storing POD texture data
    220 ******************************************************************************/
    221 struct SPODTexture {
    222 	PVRTchar8	*pszName;			/*!< File-name of texture */
    223 };
    224 
    225 /*!****************************************************************************
    226  @struct      SPODMaterial
    227  @brief       Struct for storing POD material data
    228 ******************************************************************************/
    229 struct SPODMaterial {
    230 	PVRTchar8		*pszName;				/*!< Name of material */
    231 	PVRTint32		nIdxTexDiffuse;			/*!< Idx into pTexture for the diffuse texture */
    232 	PVRTint32		nIdxTexAmbient;			/*!< Idx into pTexture for the ambient texture */
    233 	PVRTint32		nIdxTexSpecularColour;	/*!< Idx into pTexture for the specular colour texture */
    234 	PVRTint32		nIdxTexSpecularLevel;	/*!< Idx into pTexture for the specular level texture */
    235 	PVRTint32		nIdxTexBump;			/*!< Idx into pTexture for the bump map */
    236 	PVRTint32		nIdxTexEmissive;		/*!< Idx into pTexture for the emissive texture */
    237 	PVRTint32		nIdxTexGlossiness;		/*!< Idx into pTexture for the glossiness texture */
    238 	PVRTint32		nIdxTexOpacity;			/*!< Idx into pTexture for the opacity texture */
    239 	PVRTint32		nIdxTexReflection;		/*!< Idx into pTexture for the reflection texture */
    240 	PVRTint32		nIdxTexRefraction;		/*!< Idx into pTexture for the refraction texture */
    241 	VERTTYPE		fMatOpacity;			/*!< Material opacity (used with vertex alpha ?) */
    242 	VERTTYPE		pfMatAmbient[3];		/*!< Ambient RGB value */
    243 	VERTTYPE		pfMatDiffuse[3];		/*!< Diffuse RGB value */
    244 	VERTTYPE		pfMatSpecular[3];		/*!< Specular RGB value */
    245 	VERTTYPE		fMatShininess;			/*!< Material shininess */
    246 	PVRTchar8		*pszEffectFile;			/*!< Name of effect file */
    247 	PVRTchar8		*pszEffectName;			/*!< Name of effect in the effect file */
    248 
    249 	EPODBlendFunc	eBlendSrcRGB;		/*!< Blending RGB source value */
    250 	EPODBlendFunc	eBlendSrcA;			/*!< Blending alpha source value */
    251 	EPODBlendFunc	eBlendDstRGB;		/*!< Blending RGB destination value */
    252 	EPODBlendFunc	eBlendDstA;			/*!< Blending alpha destination value */
    253 	EPODBlendOp		eBlendOpRGB;		/*!< Blending RGB operation */
    254 	EPODBlendOp		eBlendOpA;			/*!< Blending alpha operation */
    255 	VERTTYPE		pfBlendColour[4];	/*!< A RGBA colour to be used in blending */
    256 	VERTTYPE		pfBlendFactor[4];	/*!< An array of blend factors, one for each RGBA component */
    257 
    258 	PVRTuint32		nFlags;				/*!< Stores information about the material e.g. Enable blending */
    259 
    260 	PVRTuint32		nUserDataSize;
    261 	PVRTchar8		*pUserData;
    262 };
    263 
    264 /*!****************************************************************************
    265  @struct      SPODScene
    266  @brief       Struct for storing POD scene data
    267 ******************************************************************************/
    268 struct SPODScene {
    269 	VERTTYPE		fUnits;					/*!< Distance in metres that a single unit of measurement represents */
    270 	VERTTYPE		pfColourBackground[3];	/*!< Background colour */
    271 	VERTTYPE		pfColourAmbient[3];		/*!< Ambient colour */
    272 
    273 	PVRTuint32		nNumCamera;				/*!< The length of the array pCamera */
    274 	SPODCamera		*pCamera;				/*!< Camera nodes array */
    275 
    276 	PVRTuint32		nNumLight;				/*!< The length of the array pLight */
    277 	SPODLight		*pLight;				/*!< Light nodes array */
    278 
    279 	PVRTuint32		nNumMesh;				/*!< The length of the array pMesh */
    280 	SPODMesh		*pMesh;					/*!< Mesh array. Meshes may be instanced several times in a scene; i.e. multiple Nodes may reference any given mesh. */
    281 
    282 	PVRTuint32		nNumNode;		/*!< Number of items in the array pNode */
    283 	PVRTuint32		nNumMeshNode;	/*!< Number of items in the array pNode which are objects */
    284 	SPODNode		*pNode;			/*!< Node array. Sorted as such: objects, lights, cameras, Everything Else (bones, helpers etc) */
    285 
    286 	PVRTuint32		nNumTexture;	/*!< Number of textures in the array pTexture */
    287 	SPODTexture		*pTexture;		/*!< Texture array */
    288 
    289 	PVRTuint32		nNumMaterial;	/*!< Number of materials in the array pMaterial */
    290 	SPODMaterial		*pMaterial;		/*!< Material array */
    291 
    292 	PVRTuint32		nNumFrame;		/*!< Number of frames of animation */
    293 	PVRTuint32		nFPS;			/*!< The frames per second the animation should be played at */
    294 
    295 	PVRTuint32		nFlags;			/*!< PVRTMODELPODSF_* bit-flags */
    296 
    297 	PVRTuint32		nUserDataSize;
    298 	PVRTchar8		*pUserData;
    299 };
    300 
    301 struct SPVRTPODImpl;	// Internal implementation data
    302 
    303 /*!***************************************************************************
    304 @class CPVRTModelPOD
    305 @brief A class for loading and storing data from POD files/headers
    306 *****************************************************************************/
    307 class CPVRTModelPOD : public SPODScene{
    308 public:
    309 	/*!***************************************************************************
    310 	 @brief     	Constructor for CPVRTModelPOD class
    311 	*****************************************************************************/
    312 	CPVRTModelPOD();
    313 
    314 	/*!***************************************************************************
    315 	 @brief     	Destructor for CPVRTModelPOD class
    316 	*****************************************************************************/
    317 	~CPVRTModelPOD();
    318 
    319 	/*!***************************************************************************
    320 	@fn       			ReadFromFile
    321 	@param[in]			pszFileName		Filename to load
    322 	@param[out]			pszExpOpt		String in which to place exporter options
    323 	@param[in]			count			Maximum number of characters to store.
    324 	@param[out]			pszHistory		String in which to place the pod file history
    325 	@param[in]			historyCount	Maximum number of characters to store.
    326 	@return			    PVR_SUCCESS if successful, PVR_FAIL if not
    327 	@brief     		    Loads the specified ".POD" file; returns the scene in
    328 						pScene. This structure must later be destroyed with
    329 						PVRTModelPODDestroy() to prevent memory leaks.
    330 						".POD" files are exported using the PVRGeoPOD exporters.
    331 						If pszExpOpt is NULL, the scene is loaded; otherwise the
    332 						scene is not loaded and pszExpOpt is filled in. The same
    333 						is true for pszHistory.
    334 	*****************************************************************************/
    335 	EPVRTError ReadFromFile(
    336 		const char		* const pszFileName,
    337 		char			* const pszExpOpt = NULL,
    338 		const size_t	count = 0,
    339 		char			* const pszHistory = NULL,
    340 		const size_t	historyCount = 0);
    341 
    342 	/*!***************************************************************************
    343 	@brief     		    Loads the supplied pod data. This data can be exported
    344 						directly to a header using one of the pod exporters.
    345 						If pszExpOpt is NULL, the scene is loaded; otherwise the
    346 						scene is not loaded and pszExpOpt is filled in. The same
    347 						is true for pszHistory.
    348 	@param[in]			pData			Data to load
    349 	@param[in]			i32Size			Size of data
    350 	@param[out]			pszExpOpt		String in which to place exporter options
    351 	@param[in]			count			Maximum number of characters to store.
    352 	@param[out]			pszHistory		String in which to place the pod file history
    353 	@param[in]			historyCount	Maximum number of characters to store.
    354 	@return	 		    PVR_SUCCESS if successful, PVR_FAIL if not
    355 	*****************************************************************************/
    356 	EPVRTError ReadFromMemory(
    357 		const char		* pData,
    358 		const size_t	i32Size,
    359 		char			* const pszExpOpt = NULL,
    360 		const size_t	count = 0,
    361 		char			* const pszHistory = NULL,
    362 		const size_t	historyCount = 0);
    363 
    364 	/*!***************************************************************************
    365 	 @brief     	Sets the scene data from the supplied data structure. Use
    366 					when loading from .H files.
    367 	 @param[in]		scene			Scene data from the header file
    368 	 @return		PVR_SUCCESS if successful, PVR_FAIL if not
    369 	*****************************************************************************/
    370 	EPVRTError ReadFromMemory(
    371 		const SPODScene &scene);
    372 
    373 	/*!***************************************************************************
    374 	 @fn       		CopyFromMemory
    375 	 @param[in]			scene			Scene data from the header file
    376 	 @return		PVR_SUCCESS if successful, PVR_FAIL if not
    377 	 @brief     	Copies the scene data from the supplied data structure. Use
    378 					when loading from .H files where you want to modify the data.
    379 	*****************************************************************************/
    380 	EPVRTError CopyFromMemory(
    381 		const SPODScene &scene);
    382 
    383 #if defined(_WIN32)
    384 	/*!***************************************************************************
    385 	 @fn       		ReadFromResource
    386 	 @param[in]		pszName			Name of the resource to load from
    387 	 @return		PVR_SUCCESS if successful, PVR_FAIL if not
    388 	 @brief     	Loads the specified ".POD" file; returns the scene in
    389 					pScene. This structure must later be destroyed with
    390 					PVRTModelPODDestroy() to prevent memory leaks.
    391 					".POD" files are exported from 3D Studio MAX using a
    392 					PowerVR plugin.
    393 	*****************************************************************************/
    394 	EPVRTError ReadFromResource(
    395 		const TCHAR * const pszName);
    396 #endif
    397 
    398 	/*!***********************************************************************
    399 	 @fn       		InitImpl
    400 	 @brief     	Used by the Read*() fns to initialise implementation
    401 					details. Should also be called by applications which
    402 					manually build data in the POD structures for rendering;
    403 					in this case call it after the data has been created.
    404 					Otherwise, do not call this function.
    405 	*************************************************************************/
    406 	EPVRTError InitImpl();
    407 
    408 	/*!***********************************************************************
    409 	 @fn       		DestroyImpl
    410 	 @brief     	Used to free memory allocated by the implementation.
    411 	*************************************************************************/
    412 	void DestroyImpl();
    413 
    414 	/*!***********************************************************************
    415 	 @fn       		FlushCache
    416 	 @brief     	Clears the matrix cache; use this if necessary when you
    417 					edit the position or animation of a node.
    418 	*************************************************************************/
    419 	void FlushCache();
    420 
    421 	/*!***********************************************************************
    422 	@fn       		IsLoaded
    423 	@brief     	Boolean to check whether a POD file has been loaded.
    424 	*************************************************************************/
    425 	bool IsLoaded();
    426 
    427 	/*!***************************************************************************
    428 	 @fn       		Destroy
    429 	 @brief     	Frees the memory allocated to store the scene in pScene.
    430 	*****************************************************************************/
    431 	void Destroy();
    432 
    433 	/*!***************************************************************************
    434 	 @fn       		SetFrame
    435 	 @param[in]			fFrame			Frame number
    436 	 @brief     	Set the animation frame for which subsequent Get*() calls
    437 					should return data.
    438 	*****************************************************************************/
    439 	void SetFrame(
    440 		const VERTTYPE fFrame);
    441 
    442 	/*!***************************************************************************
    443 	 @brief     	Generates the world matrix for the given Mesh Instance;
    444 					applies the parent's transform too. Uses animation data.
    445 	 @param[out]	mOut			Rotation matrix
    446 	 @param[in]		node			Node to get the rotation matrix from
    447 	*****************************************************************************/
    448 	void GetRotationMatrix(
    449 		PVRTMATRIX		&mOut,
    450 		const SPODNode	&node) const;
    451 
    452 	/*!***************************************************************************
    453 	 @brief     	Generates the world matrix for the given Mesh Instance;
    454 					applies the parent's transform too. Uses animation data.
    455 	 @param[in]		node			Node to get the rotation matrix from
    456 	 @return		Rotation matrix
    457 	*****************************************************************************/
    458 	PVRTMat4 GetRotationMatrix(
    459 		const SPODNode	&node) const;
    460 
    461 	/*!***************************************************************************
    462 	 @brief     	Generates the world matrix for the given Mesh Instance;
    463 					applies the parent's transform too. Uses animation data.
    464 	 @param[out]	mOut			Scaling matrix
    465 	 @param[in]		node			Node to get the rotation matrix from
    466 	*****************************************************************************/
    467 	void GetScalingMatrix(
    468 		PVRTMATRIX		&mOut,
    469 		const SPODNode	&node) const;
    470 
    471 	/*!***************************************************************************
    472 	 @brief     	Generates the world matrix for the given Mesh Instance;
    473 					applies the parent's transform too. Uses animation data.
    474 	 @param[in]		node			Node to get the rotation matrix from
    475 	 @return		Scaling matrix
    476 	*****************************************************************************/
    477 	PVRTMat4 GetScalingMatrix(
    478 		const SPODNode	&node) const;
    479 
    480 	/*!***************************************************************************
    481 	 @brief     	Generates the translation vector for the given Mesh
    482 					Instance. Uses animation data.
    483 	 @param[out]	V				Translation vector
    484 	 @param[in]		node			Node to get the translation vector from
    485 	*****************************************************************************/
    486 	void GetTranslation(
    487 		PVRTVECTOR3		&V,
    488 		const SPODNode	&node) const;
    489 
    490 	/*!***************************************************************************
    491 	 @brief     	Generates the translation vector for the given Mesh
    492 					Instance. Uses animation data.
    493 	 @param[in]		node			Node to get the translation vector from
    494 	  @return		Translation vector
    495 	*****************************************************************************/
    496 	PVRTVec3 GetTranslation(
    497 		const SPODNode	&node) const;
    498 
    499 	/*!***************************************************************************
    500 	 @brief     	Generates the world matrix for the given Mesh Instance;
    501 					applies the parent's transform too. Uses animation data.
    502 	 @param[out]	mOut			Translation matrix
    503 	 @param[in]		node			Node to get the translation matrix from
    504 	*****************************************************************************/
    505 	void GetTranslationMatrix(
    506 		PVRTMATRIX		&mOut,
    507 		const SPODNode	&node) const;
    508 
    509 	/*!***************************************************************************
    510 	 @brief     	Generates the world matrix for the given Mesh Instance;
    511 					applies the parent's transform too. Uses animation data.
    512 	 @param[in]		node			Node to get the translation matrix from
    513 	 @return		Translation matrix
    514 	*****************************************************************************/
    515 	PVRTMat4 GetTranslationMatrix(
    516 		const SPODNode	&node) const;
    517 
    518     /*!***************************************************************************
    519 	 @brief     	Generates the world matrix for the given Mesh Instance;
    520 					applies the parent's transform too. Uses animation data.
    521 	 @param[out]	mOut			Transformation matrix
    522 	 @param[in]		node			Node to get the transformation matrix from
    523 	*****************************************************************************/
    524 	void GetTransformationMatrix(PVRTMATRIX &mOut, const SPODNode &node) const;
    525 
    526 	/*!***************************************************************************
    527 	 @brief     	Generates the world matrix for the given Mesh Instance;
    528 					applies the parent's transform too. Uses animation data.
    529 	 @param[out]	mOut			World matrix
    530 	 @param[in]		node			Node to get the world matrix from
    531 	*****************************************************************************/
    532 	void GetWorldMatrixNoCache(
    533 		PVRTMATRIX		&mOut,
    534 		const SPODNode	&node) const;
    535 
    536 	/*!***************************************************************************
    537 	@brief     	    Generates the world matrix for the given Mesh Instance;
    538 					applies the parent's transform too. Uses animation data.
    539 	@param[in]		node			Node to get the world matrix from
    540 	@return		    World matrix
    541 	*****************************************************************************/
    542 	PVRTMat4 GetWorldMatrixNoCache(
    543 		const SPODNode	&node) const;
    544 
    545 	/*!***************************************************************************
    546 	 @brief     	Generates the world matrix for the given Mesh Instance;
    547 					applies the parent's transform too. Uses animation data.
    548 	 @param[out]	mOut			World matrix
    549 	 @param[in]		node			Node to get the world matrix from
    550 	*****************************************************************************/
    551 	void GetWorldMatrix(
    552 		PVRTMATRIX		&mOut,
    553 		const SPODNode	&node) const;
    554 
    555 	/*!***************************************************************************
    556 	@brief     	    Generates the world matrix for the given Mesh Instance;
    557 					applies the parent's transform too. Uses animation data.
    558 	@param[in]		node			Node to get the world matrix from
    559 	@return		    World matrix
    560 	*****************************************************************************/
    561 	PVRTMat4 GetWorldMatrix(const SPODNode& node) const;
    562 
    563 	/*!***************************************************************************
    564 	 @brief     	Generates the world matrix for the given bone.
    565 	 @param[out]	mOut			Bone world matrix
    566 	 @param[in]		NodeMesh		Mesh to take the world matrix from
    567 	 @param[in]		NodeBone		Bone to take the matrix from
    568 	*****************************************************************************/
    569 	void GetBoneWorldMatrix(
    570 		PVRTMATRIX		&mOut,
    571 		const SPODNode	&NodeMesh,
    572 		const SPODNode	&NodeBone);
    573 
    574 	/*!***************************************************************************
    575 	@brief     	    Generates the world matrix for the given bone.
    576 	@param[in]		NodeMesh		Mesh to take the world matrix from
    577 	@param[in]		NodeBone		Bone to take the matrix from
    578 	@return		    Bone world matrix
    579 	*****************************************************************************/
    580 	PVRTMat4 GetBoneWorldMatrix(
    581 		const SPODNode	&NodeMesh,
    582 		const SPODNode	&NodeBone);
    583 
    584 	/*!***************************************************************************
    585 	 @fn       		GetCamera
    586 	 @param[out]	vFrom			Position of the camera
    587 	 @param[out]	vTo				Target of the camera
    588 	 @param[out]	vUp				Up direction of the camera
    589 	 @param[in]		nIdx			Camera number
    590 	 @return		Camera horizontal FOV
    591 	 @brief     	Calculate the From, To and Up vectors for the given
    592 					camera. Uses animation data.
    593 					Note that even if the camera has a target, *pvTo is not
    594 					the position of that target. *pvTo is a position in the
    595 					correct direction of the target, one unit away from the
    596 					camera.
    597 	*****************************************************************************/
    598 	VERTTYPE GetCamera(
    599 		PVRTVECTOR3			&vFrom,
    600 		PVRTVECTOR3			&vTo,
    601 		PVRTVECTOR3			&vUp,
    602 		const unsigned int	nIdx) const;
    603 
    604 	/*!***************************************************************************
    605 	 @fn       		GetCameraPos
    606 	 @param[out]	vFrom			Position of the camera
    607 	 @param[out]	vTo				Target of the camera
    608 	 @param[in]		nIdx			Camera number
    609 	 @return		Camera horizontal FOV
    610 	 @brief     	Calculate the position of the camera and its target. Uses
    611 					animation data.
    612 					If the queried camera does not have a target, *pvTo is
    613 					not changed.
    614 	*****************************************************************************/
    615 	VERTTYPE GetCameraPos(
    616 		PVRTVECTOR3			&vFrom,
    617 		PVRTVECTOR3			&vTo,
    618 		const unsigned int	nIdx) const;
    619 
    620 	/*!***************************************************************************
    621 	 @fn       		GetLight
    622 	 @param[out]	vPos			Position of the light
    623 	 @param[out]	vDir			Direction of the light
    624 	 @param[in]		nIdx			Light number
    625 	 @brief     	Calculate the position and direction of the given Light.
    626 					Uses animation data.
    627 	*****************************************************************************/
    628 	void GetLight(
    629 		PVRTVECTOR3			&vPos,
    630 		PVRTVECTOR3			&vDir,
    631 		const unsigned int	nIdx) const;
    632 
    633 	/*!***************************************************************************
    634 	 @fn       		GetLightPosition
    635 	 @param[in]		u32Idx			Light number
    636 	 @return		PVRTVec4 position of light with w set correctly
    637 	 @brief     	Calculate the position the given Light. Uses animation data.
    638 	*****************************************************************************/
    639 	PVRTVec4 GetLightPosition(const unsigned int u32Idx) const;
    640 
    641 	/*!***************************************************************************
    642 	@fn       		GetLightDirection
    643 	@param[in]		u32Idx			Light number
    644 	@return			PVRTVec4 direction of light with w set correctly
    645 	@brief     	Calculate the direction of the given Light. Uses animation data.
    646 	*****************************************************************************/
    647 	PVRTVec4 GetLightDirection(const unsigned int u32Idx) const;
    648 
    649 	/*!***************************************************************************
    650 	 @fn       		CreateSkinIdxWeight
    651 	 @param[out]	pIdx				Four bytes containing matrix indices for vertex (0..255) (D3D: use UBYTE4)
    652 	 @param[out]	pWeight				Four bytes containing blend weights for vertex (0.0 .. 1.0) (D3D: use D3DCOLOR)
    653 	 @param[in]		nVertexBones		Number of bones this vertex uses
    654 	 @param[in]		pnBoneIdx			Pointer to 'nVertexBones' indices
    655 	 @param[in]		pfBoneWeight		Pointer to 'nVertexBones' blend weights
    656 	 @brief     	Creates the matrix indices and blend weights for a boned
    657 					vertex. Call once per vertex of a boned mesh.
    658 	*****************************************************************************/
    659 	EPVRTError CreateSkinIdxWeight(
    660 		char			* const pIdx,
    661 		char			* const pWeight,
    662 		const int		nVertexBones,
    663 		const int		* const pnBoneIdx,
    664 		const VERTTYPE	* const pfBoneWeight);
    665 
    666 	/*!***************************************************************************
    667 	 @fn       		SavePOD
    668 	 @param[in]		pszFilename		Filename to save to
    669 	 @param[in]		pszExpOpt		A string containing the options used by the exporter
    670 	 @param[in]		pszHistory		A string containing the history of the exported pod file
    671 	 @brief     	Save a binary POD file (.POD).
    672 	*****************************************************************************/
    673 	EPVRTError SavePOD(const char * const pszFilename, const char * const pszExpOpt = 0, const char * const pszHistory = 0);
    674 
    675 private:
    676 	SPVRTPODImpl	*m_pImpl;	/*!< Internal implementation data */
    677 };
    678 
    679 /****************************************************************************
    680 ** Declarations
    681 ****************************************************************************/
    682 
    683 /*!***************************************************************************
    684  @fn       		PVRTModelPODDataTypeSize
    685  @param[in]		type		Type to get the size of
    686  @return		Size of the data element
    687  @brief     	Returns the size of each data element.
    688 *****************************************************************************/
    689 PVRTuint32 PVRTModelPODDataTypeSize(const EPVRTDataType type);
    690 
    691 /*!***************************************************************************
    692  @fn       		PVRTModelPODDataTypeComponentCount
    693  @param[in]		type		Type to get the number of components from
    694  @return		number of components in the data element
    695  @brief     	Returns the number of components in a data element.
    696 *****************************************************************************/
    697 PVRTuint32 PVRTModelPODDataTypeComponentCount(const EPVRTDataType type);
    698 
    699 /*!***************************************************************************
    700  @fn       		PVRTModelPODDataStride
    701  @param[in]		data		Data elements
    702  @return		Size of the vector elements
    703  @brief     	Returns the size of the vector of data elements.
    704 *****************************************************************************/
    705 PVRTuint32 PVRTModelPODDataStride(const CPODData &data);
    706 
    707 /*!***************************************************************************
    708  @fn       			PVRTModelPODGetAnimArraySize
    709  @param[in]			pAnimDataIdx
    710  @param[in]			ui32Frames
    711  @param[in]			ui32Components
    712  @return			Size of the animation array
    713  @brief     		Calculates the size of an animation array
    714 *****************************************************************************/
    715 PVRTuint32 PVRTModelPODGetAnimArraySize(PVRTuint32 *pAnimDataIdx, PVRTuint32 ui32Frames, PVRTuint32 ui32Components);
    716 
    717 /*!***************************************************************************
    718  @fn       		PVRTModelPODScaleAndConvertVtxData
    719  @Modified		mesh		POD mesh to scale and convert the mesh data
    720  @param[in]		eNewType	The data type to scale and convert the vertex data to
    721  @return		PVR_SUCCESS on success and PVR_FAIL on failure.
    722  @brief     	Scales the vertex data to fit within the range of the requested
    723 				data type and then converts the data to that type. This function
    724 				isn't currently compiled in for fixed point builds of the tools.
    725 *****************************************************************************/
    726 #if !defined(PVRT_FIXED_POINT_ENABLE)
    727 EPVRTError PVRTModelPODScaleAndConvertVtxData(SPODMesh &mesh, const EPVRTDataType eNewType);
    728 #endif
    729 /*!***************************************************************************
    730  @fn       		PVRTModelPODDataConvert
    731  @Modified		data		Data elements to convert
    732  @param[in]		eNewType	New type of elements
    733  @param[in]		nCnt		Number of elements
    734  @brief     	Convert the format of the array of vectors.
    735 *****************************************************************************/
    736 void PVRTModelPODDataConvert(CPODData &data, const unsigned int nCnt, const EPVRTDataType eNewType);
    737 
    738 /*!***************************************************************************
    739  @fn       			PVRTModelPODDataShred
    740  @Modified			data		Data elements to modify
    741  @param[in]			nCnt		Number of elements
    742  @param[in]			pChannels	A list of the wanted channels, e.g. {'x', 'y', 0}
    743  @brief     		Reduce the number of dimensions in 'data' using the requested
    744 					channel array. The array should have a maximum length of 4
    745 					or be null terminated if less channels are wanted. Supported
    746 					elements are 'x','y','z' and 'w'. They must be defined in lower
    747 					case. It is also possible to negate an element, e.g. {'x','y', -'z'}.
    748 *****************************************************************************/
    749 void PVRTModelPODDataShred(CPODData &data, const unsigned int nCnt, const int *pChannels);
    750 
    751 /*!***************************************************************************
    752  @fn       			PVRTModelPODReorderFaces
    753  @Modified			mesh		The mesh to re-order the faces of
    754  @param[in]			i32El1		The first index to be written out
    755  @param[in]			i32El2		The second index to be written out
    756  @param[in]			i32El3		The third index to be written out
    757  @brief     		Reorders the face indices of a mesh.
    758 *****************************************************************************/
    759 void PVRTModelPODReorderFaces(SPODMesh &mesh, const int i32El1, const int i32El2, const int i32El3);
    760 
    761 /*!***************************************************************************
    762  @fn       		PVRTModelPODToggleInterleaved
    763  @Modified		mesh		Mesh to modify
    764  @param[in]		ui32AlignToNBytes Align the interleaved data to this no. of bytes.
    765  @brief     	Switches the supplied mesh to or from interleaved data format.
    766 *****************************************************************************/
    767 void PVRTModelPODToggleInterleaved(SPODMesh &mesh, unsigned int ui32AlignToNBytes = 1);
    768 
    769 /*!***************************************************************************
    770  @fn       		PVRTModelPODDeIndex
    771  @Modified		mesh		Mesh to modify
    772  @brief     	De-indexes the supplied mesh. The mesh must be
    773 				Interleaved before calling this function.
    774 *****************************************************************************/
    775 void PVRTModelPODDeIndex(SPODMesh &mesh);
    776 
    777 /*!***************************************************************************
    778  @fn       		PVRTModelPODToggleStrips
    779  @Modified		mesh		Mesh to modify
    780  @brief     	Converts the supplied mesh to or from strips.
    781 *****************************************************************************/
    782 void PVRTModelPODToggleStrips(SPODMesh &mesh);
    783 
    784 /*!***************************************************************************
    785  @fn       		PVRTModelPODCountIndices
    786  @param[in]		mesh		Mesh
    787  @return		Number of indices used by mesh
    788  @brief     	Counts the number of indices of a mesh
    789 *****************************************************************************/
    790 unsigned int PVRTModelPODCountIndices(const SPODMesh &mesh);
    791 
    792 /*!***************************************************************************
    793  @fn       			PVRTModelPODCopyCPODData
    794  @param[in]			in
    795  @param[out]		out
    796  @param[in]			ui32No
    797  @param[in]			bInterleaved
    798  @brief     		Used to copy a CPODData of a mesh
    799 *****************************************************************************/
    800 void PVRTModelPODCopyCPODData(const CPODData &in, CPODData &out, unsigned int ui32No, bool bInterleaved);
    801 
    802 /*!***************************************************************************
    803  @fn       			PVRTModelPODCopyNode
    804  @param[in]			in
    805  @param[out]		out
    806  @param[in]			nNumFrames The number of animation frames
    807  @brief     		Used to copy a pod node
    808 *****************************************************************************/
    809 void PVRTModelPODCopyNode(const SPODNode &in, SPODNode &out, int nNumFrames);
    810 
    811 /*!***************************************************************************
    812  @fn       			PVRTModelPODCopyMesh
    813  @param[in]			in
    814  @param[out]		out
    815  @brief     		Used to copy a pod mesh
    816 *****************************************************************************/
    817 void PVRTModelPODCopyMesh(const SPODMesh &in, SPODMesh &out);
    818 
    819 /*!***************************************************************************
    820  @fn       			PVRTModelPODCopyTexture
    821  @param[in]			in
    822  @param[out]		out
    823  @brief     		Used to copy a pod texture
    824 *****************************************************************************/
    825 void PVRTModelPODCopyTexture(const SPODTexture &in, SPODTexture &out);
    826 
    827 /*!***************************************************************************
    828  @fn       			PVRTModelPODCopyMaterial
    829  @param[in]			in
    830  @param[out]		out
    831  @brief     		Used to copy a pod material
    832 *****************************************************************************/
    833 void PVRTModelPODCopyMaterial(const SPODMaterial &in, SPODMaterial &out);
    834 
    835 /*!***************************************************************************
    836  @fn       			PVRTModelPODCopyCamera
    837  @param[in]			in
    838  @param[out]		out
    839  @param[in]			nNumFrames The number of animation frames
    840  @brief     		Used to copy a pod camera
    841 *****************************************************************************/
    842 void PVRTModelPODCopyCamera(const SPODCamera &in, SPODCamera &out, int nNumFrames);
    843 
    844 /*!***************************************************************************
    845  @fn       			PVRTModelPODCopyLight
    846  @param[in]			in
    847  @param[out]		out
    848  @brief     		Used to copy a pod light
    849 *****************************************************************************/
    850 void PVRTModelPODCopyLight(const SPODLight &in, SPODLight &out);
    851 
    852 /*!***************************************************************************
    853  @fn       			PVRTModelPODFlattenToWorldSpace
    854  @param[in]			in - Source scene. All meshes must not be interleaved.
    855  @param[out]		out
    856  @brief     		Used to flatten a pod scene to world space. All animation
    857 					and skinning information will be removed. The returned
    858 					position, normal, binormals and tangent data if present
    859 					will be returned as floats regardless of the input data
    860 					type.
    861 *****************************************************************************/
    862 EPVRTError PVRTModelPODFlattenToWorldSpace(CPVRTModelPOD &in, CPVRTModelPOD &out);
    863 
    864 
    865 /*!***************************************************************************
    866  @fn       			PVRTModelPODMergeMaterials
    867  @param[in]			src - Source scene
    868  @param[out]		dst - Destination scene
    869  @brief     		This function takes two scenes and merges the textures,
    870 					PFX effects and blending parameters from the src materials
    871 					into the dst materials if they have the same material name.
    872 *****************************************************************************/
    873 EPVRTError PVRTModelPODMergeMaterials(const CPVRTModelPOD &src, CPVRTModelPOD &dst);
    874 
    875 #endif /* _PVRTMODELPOD_H_ */
    876 
    877 /*****************************************************************************
    878  End of file (PVRTModelPOD.h)
    879 *****************************************************************************/
    880 
    881