reman3/Rayman_X/cpa/public/POS/PosProto.h

588 lines
26 KiB
C

/* (c) Ubi R&D 1996*/
/* See Alain Robin or Philippe Vimont for any comment or question*/
#ifndef __MATRIXPR_H__
#define __MATRIXPR_H__
#ifdef __cplusplus
extern "C" {
#endif
/* For DLLs who are using this module : */
#include "CPA_expt.h"
/* For Global declaration in C files : */
#ifdef POS_GLOBALS
#define __POS_EXTERN extern
#else /* !POS_GLOBALS */
#define __POS_EXTERN
#endif /* !POS_GLOBALS */
/*XB*/
/*Coz' of Scr2Bin*/
#ifndef M_CheckPointer
#define M_CheckPointer(a)
#endif /* M_CheckPointer */
/*End XB*/
#define POS_C_ulInvalidHandle 0xcdcdcdcd
/****************************************************************************/
/* PUBLIC MACROS */
/****************************************************************************/
INLINE
ACP_tdxBool POS_M_xIsIdentity (POS_tdxHandleToPosition _hPosition)
{
return (ACP_tdxBool)((_hPosition->ulType == POS_C_ulIdentityMatrixFlag) ? TRUE : FALSE);
}
/*INLINE
ACP_tdxBool POS_M_xIsZoomed(POS_tdxHandleToPosition _hPosition)
{
return (ACP_tdxBool)((_hPosition->ulType >= POS_C_ulZoomMatrixFlag) ? TRUE : FALSE);
}*/
INLINE
ACP_tdxBool POS_fn_ulIsNotScaledMatrix(POS_tdxHandleToPosition _hPosition)
{
return (ACP_tdxBool)((_hPosition->ulType <= POS_C_ulRotationMatrixFlag ) ? TRUE : FALSE);
}
/****************************************************************************/
/* BASIC FUNCTIONS */
/****************************************************************************/
/*----------------------------------------------------------------------------
// Description : POS_fn_vInitPos
// Init Error & Memory
----------------------------------------------------------------------------//
// Input :
// Output :
----------------------------------------------------------------------------*/
extern CPA_EXPORT void POS_fn_vFirstInit();
extern CPA_EXPORT void POS_fn_vInitPos();
extern CPA_EXPORT void POS_fn_vInitPosMemory(unsigned long _ulMemorySize);
#define POS_M_GameFree GEO_M_CPAFree
/* Macros to return vectors in a matrix - not worth calling a function really*/
#define USE_POS_MACROS
#ifdef USE_POS_MACROS
INLINE
void
POS_fn_vGetTransformMatrixCol0 (POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_Vec)
{
MTH3D_M_vGetColumn0InMatrix(_p_Vec,&(_hMatrix->stTransformMatrix));
}
INLINE void
POS_fn_vGetTransformMatrixCol1 (POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_Vec)
{
MTH3D_M_vGetColumn1InMatrix(_p_Vec,&(_hMatrix->stTransformMatrix));
}
INLINE void
POS_fn_vGetTransformMatrixCol2 (POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_Vec)
{
MTH3D_M_vGetColumn2InMatrix(_p_Vec,&(_hMatrix->stTransformMatrix));
}
#endif /* USE_POS_MACROS*/
/*----------------------------------------------------------------------------
// Description : GEO_fn_vCopyMatrix
// Used to copy an existing matrix
----------------------------------------------------------------------------//
// Input : _hSrc : source matrix
// Output : _hDst : copied matrix
----------------------------------------------------------------------------*/
INLINE
void POS_fn_vCopyMatrix (POS_tdxHandleToPosition _hDst, POS_tdxHandleToPosition _hSrc)
{
M_CheckPointer(_hDst);
M_CheckPointer(_hSrc);
memcpy (_hDst , _hSrc , sizeof (POS_tdstCompletePosition));
}
/*----------------------------------------------------------------------------
// Description : POS_M_b_lIsValid
// Used to know if a handle is volid or not
----------------------------------------------------------------------------//
// Input : _hPosition : handle to the position
// Output : true if valid and false else
----------------------------------------------------------------------------*/
INLINE
ACP_tdxBool POS_M_b_lIsValid(POS_tdxHandleToPosition _hPosition)
{
return (ACP_tdxBool)((_hPosition)!=(POS_tdxHandleToPosition)POS_C_ulInvalidHandle);
}
/*----------------------------------------------------------------------------
// Description : POS_fn_uwGetType
// To get to type of the position (private function)
----------------------------------------------------------------------------//
// Input : _hMatrix : handle to the position
// Output : The type
----------------------------------------------------------------------------*/
INLINE
unsigned long POS_fn_ulGetType(POS_tdxHandleToPosition _hMatrix)
{
return (_hMatrix -> ulType);
}
/*----------------------------------------------------------------------------
// Description : POS_fn_vSetMatricToIdentityConst
// To set given handle to the Identity Matrix (the matrix can't be modifier later)
----------------------------------------------------------------------------//
// Input : _hMatrix : a pointer to the handle to a position
// Output :
----------------------------------------------------------------------------*/
extern CPA_EXPORT void POS_fn_vSetMatrixToIdentityConst(POS_tdxHandleToPosition *_p_hMatrix);
/*----------------------------------------------------------------------------
// Description : POS_fn_vIsMatrixIdentityConst
//
----------------------------------------------------------------------------//
// Input : _hMatrix : a pointer to the handle to a position
// Output :
----------------------------------------------------------------------------*/
extern CPA_EXPORT ACP_tdxBool POS_fn_vIsMatrixIdentityConst(POS_tdxHandleToPosition _hMatrix);
/*----------------------------------------------------------------------------
// Description : POS_fn_hGetMatrixIdentityConst
//
----------------------------------------------------------------------------//
// Input : _hMatrix : a pointer to the handle to a position
// Output :
----------------------------------------------------------------------------*/
extern CPA_EXPORT POS_tdxHandleToPosition POS_fn_hGetMatrixIdentityConst();
/****************************************************************************/
/* INITIALISATION FUNCTIONS */
/****************************************************************************/
/*----------------------------------------------------------------------------
// Description : POS_fn_vResetScaleMatrix
// reset the scale of a matrix
----------------------------------------------------------------------------//
// Input : _hMatrix : matrix to be initialized
// Output : None
----------------------------------------------------------------------------*/
extern CPA_EXPORT void POS_fn_vResetScaleMatrix ( POS_tdxHandleToPosition _hMatrix );
/*----------------------------------------------------------------------------
// Description : POS_fn_vSetIdentityMatrix
// SETTING A MATRIX TO IDENTITY
----------------------------------------------------------------------------//
// Input : _hMatrix : matrix to be initialized
// Output : error code (not used for the moment)
----------------------------------------------------------------------------*/
extern CPA_EXPORT void POS_fn_vSetIdentityMatrix ( POS_tdxHandleToPosition _hMatrix );
/****************************************************************************/
/* MORE COMPLEX FUNCTIONS */
/****************************************************************************/
/*----------------------------------------------------------------------------
// Description : POS_fn_vMulMatrixVertex
// Multiply a position with a vertex
----------------------------------------------------------------------------//
// Input : _hMatrix : handle to the position
// _p_stSource : pointer to the source vector
// Output : _p_stDest : result of the operation
----------------------------------------------------------------------------*/
extern CPA_EXPORT void
POS_fn_vMulMatrixVertex ( MTH3D_tdstVector *_p_stDest ,
POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_stSource ) ;
/*----------------------------------------------------------------------------
// Description : POS_M_vFastMulMatrixVertex
// Multiply a position with a vertex (the position must be decompressed)
----------------------------------------------------------------------------//
// Input : hMatrix : handle to the position
// p_stSource : pointer to the source vector
// Output : p_stDest : result of the operation
----------------------------------------------------------------------------*/
#define POS_M_vFastMulMatrixVertex( p_stDest, hMatrix, p_stSource) \
MTH3D_M_vTransformVectorWithoutBuffer(p_stDest,&((hMatrix)->stTransformMatrix),p_stSource, &((hMatrix)->stTranslationVector))
/*----------------------------------------------------------------------------
// Description : POS_fn_vMulMatrixVector
// Multiply a position with a vector
----------------------------------------------------------------------------//
// Input : _hMatrix : handle to the position
// _p_stSource : pointer to the source vector
// Output : _p_stDest : result of the operation
----------------------------------------------------------------------------*/
extern CPA_EXPORT void POS_fn_vMulMatrixVector ( MTH3D_tdstVector *_p_stDest ,
POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_stSource );
/*----------------------------------------------------------------------------
// Description : POS_fn_vRotateVector
// ROTATE A VECTOR
----------------------------------------------------------------------------//
// Input : _hMatrix : matrix
// _p_stSource : source vertor
// Output : _p_stDest : pointer to the transformed vertor
----------------------------------------------------------------------------*/
extern CPA_EXPORT void POS_fn_vRotateVector ( MTH3D_tdstVector *_p_stDest ,
POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_stSource );
/*----------------------------------------------------------------------------
// Description : POS_fn_vMulInvMatrixMatrix
// _hDest = inv(_hA) * _hB
----------------------------------------------------------------------------//
// Input : _hA : first matrix
// _hB : second matrix
// Output : _hDest : pointer to the product matrix
----------------------------------------------------------------------------*/
extern CPA_EXPORT void POS_fn_vMulInvMatrixMatrix ( POS_tdxHandleToPosition _hDest ,
POS_tdxHandleToPosition _hA ,
POS_tdxHandleToPosition _hB );
/*----------------------------------------------------------------------------
// Description : POS_fn_vInvertIsoMatrix
// Invert an isometric position
----------------------------------------------------------------------------//
// Input : _hSource : position to be inverted
// Output : _hDest : handle to result
----------------------------------------------------------------------------*/
extern CPA_EXPORT void
POS_fn_vInvertIsoMatrix ( POS_tdxHandleToPosition _hDest ,
POS_tdxHandleToPosition _hSource ) ;
/*----------------------------------------------------------------------------
// Description : POS_fn_vInvertIsoMatrix
// Invert an isometric position
----------------------------------------------------------------------------//
// Input : _hSource : position to be inverted
// Output : _hDest : handle to result
----------------------------------------------------------------------------*/
extern CPA_EXPORT void
POS_fn_vInvertMatrix ( POS_tdxHandleToPosition _hDest ,
POS_tdxHandleToPosition _hSource );
/*----------------------------------------------------------------------------
// Description : POS_fn_vNormalizeMatrix
// Normalize a position
----------------------------------------------------------------------------//
// Input : _hMatrix : position to be normalized
// Output :
----------------------------------------------------------------------------*/
extern CPA_EXPORT void
POS_fn_vNormalizeMatrix ( POS_tdxHandleToPosition _hMatrix ) ;
/*----------------------------------------------------------------------------
// Description : POS_fn_vMulMatrixMatrix
// Multiply 2 positions
----------------------------------------------------------------------------//
// Input : _hA & _hB : handle to the 2 positions
// Output : _hDest : handle to result
----------------------------------------------------------------------------*/
extern CPA_EXPORT void
POS_fn_vMulMatrixMatrix ( POS_tdxHandleToPosition _hDest ,
POS_tdxHandleToPosition _hA ,
POS_tdxHandleToPosition _hB ) ;
/*----------------------------------------------------------------------------
// Description : POS_fn_ulIsIdentityMatrix
// Returns the identity flag
----------------------------------------------------------------------------//
// Input : _hMatrix : position
// Output :
----------------------------------------------------------------------------*/
#define POS_fn_ulIsIdentityMatrix(_hMatrix) ((unsigned long)POS_M_xIsIdentity(_hMatrix))
/*----------------------------------------------------------------------------
// Description : POS_fn_vRotatePositionAroundAxis
// Rotate a position around an axis passing by the origin with a given angle
------------------------------------------------------------------------------
// Input : _hPos : Position to be rotated
// _p_stAxisVector : components of the axis
// _xAngle : Angle of the rotation
// WARNING : THE VECTOR (X,Y,Z) must be normed and the angle is defined with
// the antitrigonometric sense
// Output :
----------------------------------------------------------------------------*/
extern CPA_EXPORT void POS_fn_vRotatePositionAroundAxis(POS_tdxHandleToPosition _hPos,
MTH3D_tdstVector* _p_stAxisVector,
MTH_tdxReal _xAngle);
/*----------------------------------------------------------------------------
// Description : POS_fn_vRotatePositionAroundAxis
// Rotate a position around an axis passing by the origin with a given angle
------------------------------------------------------------------------------
// Input : _hPos : Position to be rotated
// _p_stAxisVector : components of the axis
// _xAngle : Angle of the rotation
// WARNING : THE VECTOR (X,Y,Z) must be normed and the angle is defined with
// the antitrigonometric sense
// Output :
----------------------------------------------------------------------------*/
/*ANNECY BBB {*/
extern CPA_EXPORT void POS_fn_vRotatePositionAroundAxisNoTranslation(POS_tdxHandleToPosition _hPos,
MTH3D_tdstVector* _p_stAxisVector,
MTH_tdxReal _xAngle);
extern CPA_EXPORT void POS_fn_vRotateX(POS_tdxHandleToPosition hMatrix, MTH_tdxReal xXAngle);
extern CPA_EXPORT void POS_fn_vRotateY(POS_tdxHandleToPosition hMatrix,MTH_tdxReal xYAngle);
extern CPA_EXPORT void POS_fn_vRotateZ(POS_tdxHandleToPosition hMatrix,MTH_tdxReal xZAngle);
/****************************************************************************/
/* ACCESSORS */
/****************************************************************************/
/*****************************************************************************
// Description : POS_fn_vSetRotMatrix
// Used to set the rotation part of the complete matrix
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the complete matrix
// _p_stI, _p_stJ, _p_stK : pointers to the rotation matrix
// Output :
******************************************************************************/
extern CPA_EXPORT void
POS_fn_vSetRotationMatrix ( POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_stI ,
MTH3D_tdstVector *_p_stJ ,
MTH3D_tdstVector *_p_stK );
/*****************************************************************************
// Description : POS_fn_vGetRotationMatrixCol2
// Used to get the rotation matrix
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the matrix
// Output : _p_stCol2: pointer to the second column of the rotation matrix
******************************************************************************/
extern CPA_EXPORT void
POS_fn_vGetRotationMatrixCol2(POS_tdxHandleToPosition _hMatrix,
MTH3D_tdstVector *_p_stCol2);
/*****************************************************************************
// Description : POS_fn_vGetRotationMatrix
// Used to get the rotation matrix
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the matrix
// Output : _p_stI, _p_stJ, _p_stK : pointers to the rotation matrix
******************************************************************************/
extern CPA_EXPORT void
POS_fn_vGetRotationMatrix ( POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_stI ,
MTH3D_tdstVector *_p_stJ ,
MTH3D_tdstVector *_p_stK );
/*****************************************************************************
// Description : POS_fn_vGetRotationVector
// Used to get the rotation matrix
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the matrix
// Output : _p_p_stI, _p_p_stJ, _p_p_stK : pointers to the rotation matrix
******************************************************************************/
extern CPA_EXPORT void
POS_fn_vGetRotationVector ( POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector **_p_p_stI ,
MTH3D_tdstVector **_p_p_stJ ,
MTH3D_tdstVector **_p_p_stK );
/*****************************************************************************
// Description : POS_fn_xGetXScale
// Used to get the X component of the scale matrix
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the matrix
// Output : the X component of the scale matrix
******************************************************************************/
extern CPA_EXPORT MTH_tdxReal
POS_fn_xGetXScale( POS_tdxHandleToPosition _hMatrix );
/*****************************************************************************
// Description : POS_fn_xGetXScale
// Used to get the X component of the scale matrix
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the matrix
// Output : the X component of the scale matrix
******************************************************************************/
extern CPA_EXPORT MTH_tdxReal
POS_fn_xGetYScale( POS_tdxHandleToPosition _hMatrix );
/*****************************************************************************
// Description : POS_fn_xGetXScale
// Used to get the X component of the scale matrix
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the matrix
// Output : the X component of the scale matrix
******************************************************************************/
extern CPA_EXPORT MTH_tdxReal
POS_fn_xGetZScale( POS_tdxHandleToPosition _hMatrix );
/*****************************************************************************
// Description : POS_fn_vSetScaleMatrix
// Used to set the scale part of the complete matrix
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the complete matrix
// _p_stI, _p_stJ, _p_stK : pointer to the scale matrix
// Output :
******************************************************************************/
extern CPA_EXPORT void
POS_fn_vSetScaleMatrix ( POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_stI ,
MTH3D_tdstVector *_p_stJ ,
MTH3D_tdstVector *_p_stK );
/*****************************************************************************
// Description : POS_fn_vGetScaleMatrix
// Used to get the scale matrix
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the matrix
// Output : _p_stI, _p_stJ, _p_stK : pointers to the scale matrix
******************************************************************************/
extern CPA_EXPORT void
POS_fn_vGetScaleMatrix ( POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_stI ,
MTH3D_tdstVector *_p_stJ ,
MTH3D_tdstVector *_p_stK );
/*****************************************************************************
// Description : POS_fn_vSetZoomMatrixx
// Used to set the Zoom factor
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the matrix
// _xZoom : zoom factor
// Output : _hMatrix : Handle to the matrix
******************************************************************************/
extern CPA_EXPORT void
POS_fn_vSetZoomMatrix( POS_tdxHandleToPosition _hMatrix , MTH_tdxReal _xZoom);
/*****************************************************************************
// Description : POS_fn_hGetTransformMatrix
// Used to get the transform matrix
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the matrix
// Output : _p_stI, _p_stJ, _p_stK : pointers to the transform matrix
******************************************************************************/
extern CPA_EXPORT void
POS_fn_vGetTransformMatrix ( POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_stI ,
MTH3D_tdstVector *_p_stJ ,
MTH3D_tdstVector *_p_stK );
/*****************************************************************************
// Description : POS_fn_vSetTransformMatrix
// Used to set the transform part (calculated matrix) of the complete matrix
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the complete matrix
// _p_stI, _p_stJ, _p_stK : pointer to the transformation matrix
// Output :
******************************************************************************/
extern CPA_EXPORT void
POS_fn_vSetTransformMatrix ( POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_stI ,
MTH3D_tdstVector *_p_stJ ,
MTH3D_tdstVector *_p_stK );
/*****************************************************************************
// Description : POS_fn_vSetTranslationVector
// Used to set the translation part of the complete matrix
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the complete matrix
// _p_stTrs : pointer to the translation vector
// Output :
******************************************************************************/
extern CPA_EXPORT void
POS_fn_vSetTranslationVector ( POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_stTrs );
/*****************************************************************************
// Description : POS_fn_vGetTranslationVector
// Used to get the translation vector
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the matrix
// Output : _p_stTrs : pointer to the vector
******************************************************************************/
extern CPA_EXPORT void
POS_fn_vGetTranslationVector( POS_tdxHandleToPosition _hMatrix ,
MTH3D_tdstVector *_p_stTrs );
/*****************************************************************************
// Description : POS_fn_p_stGetTranslationVector
// Used to get the translation vector
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the matrix
******************************************************************************/
/*extern CPA_EXPORT MTH3D_tdstVector*
POS_fn_p_stGetTranslationVector ( POS_tdxHandleToPosition _hMatrix );*/
INLINE
MTH3D_tdstVector *POS_fn_p_stGetTranslationVector( POS_tdxHandleToPosition _hMatrix )
{
return &(_hMatrix->stTranslationVector);
}
/*****************************************************************************
// Description : POS_fn_xGetMaxScale
// Used to get the maximum scale factor of the 3 axes
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the complete matrix
// Output : the maximum scale factor
******************************************************************************/
extern CPA_EXPORT MTH_tdxReal POS_fn_xGetMaxScale(POS_tdxHandleToPosition _hMatrix );
/*****************************************************************************
// Description : POS_fn_vUpdateMatrixType
// Recompute the real type of the matrix
//////////////////////////////////////////////////////////////////////////////
// Input : _hMatrix : Handle to the matrix
// Output : None
******************************************************************************/
extern CPA_EXPORT void
POS_fn_vUpdateMatrixType(POS_tdxHandleToPosition _hMatrix);
/*----------------------------------------------------------------------------
// Description : POS_fn_vPrintUsedStaticMemory
// Display the information about the memory used
----------------------------------------------------------------------------//
// Input :
// Output :
----------------------------------------------------------------------------*/
extern CPA_EXPORT void POS_fn_vPrintUsedStaticMemory();
/*----------------------------------------------------------------------------
----------------------------------------------------------------------------*/
extern CPA_EXPORT void POS_fn_vQuatToMat(MTH3D_tdstMatrix* _p_stMatrix, MTH_tdxReal _xX,
MTH_tdxReal _xY,
MTH_tdxReal _xZ,
MTH_tdxReal _xW);
/*----------------------------------------------------------------------------
----------------------------------------------------------------------------*/
/* deleted functions and define */
/*
#define POS_fn_vSetType(_hMatrix,xType) //#pragma message("POS_fn_vSetType unused")
#define POS_C_xCompletion
#define POS_fn_vInitPositionFlag(_hMatrix)
*/
/* to remove when the anim player will be cleaned */
#define POS_fn_vHalfRotation(p_stDest) /*#pragma message("POS_fn_vHalfRotation unused")*/
#define POS_fn_vInterpolatePosition(_hDest,_hPrevPos,_hNextPos) /*#pragma message("POS_fn_vInterpolatePosition unused")*/
#define POS_fn_vSavePosition(_hPos,_p_xFile,_xMode) /*#pragma message("POS_fn_vSavePosition unused")*/
#define POS_fn_vLoadRestOfPosition(_p_xFile, _hPos, _uwType) /*#pragma message("POS_fn_vLoadRestOfPosition unused")*/
#define POS_fn_vLoadRestOfPositionFromBuffer(_p_cBuffer, _hPos, _uwType) /*#pragma message("POS_fn_vLoadRestOfPositionFromBuffer unused")*/
#ifdef __cplusplus
}/* extern "C" */
#endif
#endif /* __MATRIXPR_H__*/