/*=========================================================================
* 3dData.h : 3dData's functions
*
*
*         3dData MUST BE REPLACE BY THE HEADER FILENAME
*
*
* Version              1.0
* Creation date        01/10/96
*	Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1996
*=======================================================================*/
 
#if !defined(__3dData_H__)
#define __3dData_H__
 
/******************************************/
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000*/
/******************************************/
 
struct tdstEngineObject_;
/***********************/
/**** Handle define ****/
/***********************/
typedef struct tdst3dData_ * MS_tdxHandleTo3dData;
 
 
#include "GAM/InitEnum.h"
#include "GAM/Header.h"
#include "GAM/GAMLst.h"
/*#include "Actions/AllActs.h"*/
#include "GAM/Structur/StdObjSt.h"
#include "GAM/actions/stdgame.h"
#include "GAM\STRUCTUR\Anim_s.h"
#undef EXTERN
#undef extern
#if !defined(D_3dData_VariableDefine)
#define EXTERN extern
#else
#define EXTERN
#endif /* D_3dData_VariableDefine */
 
#if defined(__cplusplus)
extern "C"
{
#endif /* __cplusplus */
/* JO 21/05/97*/
 
#if !defined(GLI_TEXTURE_ST_H)
#define GLI_TEXTURE_ST_H
typedef struct GLI_tdstTexture_ GLI_tdstTexture ;
#endif /* GLI_TEXTURE_ST_H */
 
/* JO fin*/
 
/*#if defined(D_3dData_StructureDefine)*/
 
typedef struct tdst3dData_
{
	/* pointer to the current state structure of the object */
#if !defined(PRESS_DEMO) /* swap members to make the engine unusable with the binarized data of another engine */
    tdxHandleToState            h_InitialState;
    tdxHandleToState            h_CurrentState;
#else
    tdxHandleToState            h_CurrentState;
    tdxHandleToState            h_InitialState;
#endif /* PRESS_DEMO */

    tdxHandleToState            h_FirstStateOfAction;
 
	/* handle to Current Objects table of Character*/
	tdxHandleToObjectsTablesList h_InitialObjectsTable;
	/* handle to Current Objects table of Character*/
	tdxHandleToObjectsTablesList h_CurrentObjectsTable;
 
	/* pointer to the object's model */
    tdxHandleToFamilyList       h_Family;
 
	/* Rotation, Scale and Translation */
#if !defined(PRESS_DEMO) /* swap members to make the engine unusable with the binarized data of another engine */
    POS_tdstCompletePosition stGLIObjectMatrix/*,stGLIObjectMatrixInit*/;
    POS_tdstCompletePosition *p_stGLIObjectAbsoluteMatrix;
#else
    POS_tdstCompletePosition *p_stGLIObjectAbsoluteMatrix;
    POS_tdstCompletePosition stGLIObjectMatrix/*,stGLIObjectMatrixInit*/;
#endif /* PRESS_DEMO */
 
	/* current animation infos*/
    unsigned short              uwCurrentFrame;               /* current frame in the current animation */
    unsigned char               ucRepeatAnimation;           /* how many animation after this one finished */
    unsigned char               ucNextEvent;
    unsigned char               *d_ucEventActivation;    /* cpt used to lauch events */
 
    tdstCouple                  *p_stCurrentHieCouples;
    /*unsigned long               ulCurrentHieNbCouples;*/
	unsigned short				wCurrentHieNbCouples;
	unsigned short				wSizeOfArrayOfElts3d;
 
/*	POS_tdstCompletePosition stControlMatrix,stResultControlMatrix;*/
/*	struct MTH3D_tdstVector_ stControlTranslationVertex;*/
 
    tdxHandleToState            h_StateInLastFrame; /* for AI*/
    tdxHandleToState            h_WantedState;
    unsigned short              uwForcedFrame;
    unsigned char               ucFlagEndState;
    unsigned char               ucFlagEndOfAnim;
 
	/* MR2503*/
	CHN_tdxHandleToChannelArray hArrayOfChannels;
    /* CHN_tdxHandleToCASList   hChannelActivationList;*/
    unsigned long               ulNumberOfChannels;
    CHN_tdxHandleToChannel      hFirstActiveChannel;
	/*CHN_tdxHandleToUCCList hChannelUnderControlList; //ANNECY BBB ne sert plus*/
	/**** structure describing the current frame for the current anim ****/
    struct tdstFrame3d_         stFrame3d;
 
 
	/*ANNECY AV {*/
    CHN_tdxHandleToMorphList    hMorphChannelList;
	/*ENDANNECY AV }*/
	/* MR2204*/
    unsigned long               ulStartTime;      /* start time for this anim... (used to compute next frame number)*/
	/* MR0605*/
    unsigned long               ulTimeDelay;      /* extra time beyond the current anim == time delay between (end of anim time) and (next computed frame time)*/
    unsigned long               ulTimePreviousFrame;
    short                       sLastFrame;               /* number of the last played frame for this anim (used to compute speeds)*/
	/* MR0705*/
    unsigned char               bStateJustModified;
    unsigned char               bSkipCurrentFrame;
 
	/* JO 12/06/97*/
/*XB unused field in U64 engine*/
#ifndef U64
	GMT_tdxHandleToGameMaterial  p_stShadowMaterial;
	GLI_tdstTexture              *p_stShadowTexture;
#endif /* U64 */
/*End XB*/

	MTH_tdxReal                  xShadowScaleX,xShadowScaleY;

/*XB unused field in U64 engine*/
#ifndef U64
	short                        xShadowQuality;
#endif /* U64 */
/*End XB*/

	/* Oliv' - moved this line for alignment purpose... - 22/06/1999 */
	/* MR1605*/
	unsigned short              uwNbEngineFrameSinceLastMechEvent;
	/* EndOfOliv' */

	/* MR0306*/
    unsigned char               ucFrameRate;
    unsigned char               ucFlagModifState;
 
	/* For Drawing */
	long lDrawMaskInit;
	long lDrawMask;
 
#ifdef D_USE_LIPSYNC
	/* MR2706 (LipsSynch)*/
	tdxHandleOfLipsSynchroTable hLipsTable;
    unsigned short              uwStartSynchroFrame;
    unsigned short              uwCurrentSynchroFrame;
#endif /* D_USE_LIPSYNC */
 
	/* JO 09/07/97 (Default test point)*/
	/* DNM_tdeFluidEnvironment eDefaultFluidEnvironment;*/
	/* BOOL bCurrentFrameIsInterpolated;*/
	/* MR1709*/
	long lLastComputeFrame;
	/*ANNECY VL 26/11/97{*/
    MTH3D_tdstVector            stLastEventGlobalPosition;
	/*ENDANNECY VL }*/
	/* ANNECY MT - 12/06/98 {*/
    unsigned char               bAnimMatrixChanged;
    unsigned char               ucUserEventFlags;
    unsigned char               ucBrainComputationFrequency;
	char						cBrainCounter;
	unsigned short				uwBrainMainCounter;
	/* END ANNECY MT }*/
 
    unsigned char               ucTransparency;
 
	/* --> Oliv' - here we've got 1 char hole (alignment) <-- */

	/* Olivier Didelot le 1 juillet 1998*/
	/* Oliv' - remove this, since the PersonalType in StdGame plays the same role - 22/06/1999 */
	/*
#if defined (U64)
	short wNumRom;
#else
	*/
	/* EndOfOliv' */

#ifndef U64
    unsigned char               ucLightComputationFrequency;
	char						cLightCounter;
	MTH3D_tdstVector			stSHWDeformationVector;
	MTH_tdxReal					xSHWHeight;
#endif /* U64*/
 
	/* For ZDX drawing */
#if defined(_DEBUG) || defined(_U64_GLI_BENCH_)	/* Oliv' - 19/05/1999 - I want to see Zdx too */
	long lZdxMask;
#endif /* _DEBUG || _U64_GLI_BENCH_ */

} tdst3dData;
 
/*#endif /* D_3dData_StructureDefine   */
 
/* Olivier Didelot le 1 juillet 1998*/
#if defined (U64)
#if defined USE_PROFILER
short fn_wGet3dDataNumRom(struct tdstEngineObject_ * p_stEngineObject);
void fn_wSet3dDataNumRom(struct tdstEngineObject_ * p_stEngineObject, short wNum);
#endif /* USE_PROFILER*/
#endif /* U64*/
 
 
/**** 3dData scripts ****/
#define C_Section3dDataDescription                "3dData"
// Shaitan => state list in the level
#define C_Entry3dDataListOfState                 "ListOfState"
// End Shaitan => state list in the level
#define C_Entry3dDataInitialState                 "InitialState"
#define C_Entry3dDataInitialObjectsTable			  "InitialObjectsTable"
#define C_Entry3dDataShadowTexture                "ShadowTexture"
#define C_Entry3dDataShadowQuality                "ShadowQuality"
#define C_Entry3dDataShadowMaterial               "ShadowMaterial"
#define C_Entry3dDataShadowScale                  "ShadowScale"
#define C_Entry3dDataShadowHeight                 "ShadowHeight"
#define C_Entry3dDataDrawMask                     "DrawMask"
#define C_Entry3dDataBrainComputationFrequency		  "BrainComputationFrequency"
#define C_Entry3dDataLightComputationFrequency		  "LightComputationFrequency"
 
/*******************************/
/**** Base functions define ****/
/*******************************/
#if !defined(U64)
extern CPA_EXPORT SCR_tde_Anl_ReturnValue fn_e3dDataScriptCallBack(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action	_eAction);
#endif /* U64 */
/*extern CPA_EXPORT void fn_v3dDataSaveMiniStructure(SCR_tdst_File_Description *p_stFile,struct tdstEngineObject_ *p_stObject);*/
extern CPA_EXPORT void fn_v3dDataAlloc(struct tdstEngineObject_ *p_stObject);
extern CPA_EXPORT MS_tdxHandleTo3dData fn_h_3dDataRealAlloc();
extern CPA_EXPORT void fn_v3dDataFree(struct tdstEngineObject_ *p_stObject);
extern CPA_EXPORT void fn_v3dDataInit(struct tdstEngineObject_ *p_stObject,enum tdeObjectTreeInit_ eObjectInit);
extern CPA_EXPORT void fn_v3dDataDesinit(struct tdstEngineObject_ *p_stObject,enum tdeObjectTreeInit_ eObjectInit);
extern CPA_EXPORT void fn_v3dDataCopyClone(struct tdstEngineObject_ * _p_stObjectDest,struct tdstEngineObject_ * _p_stObjectSrc);
extern CPA_EXPORT void fn_v3dDataInitValueSAI(MS_tdxHandleTo3dData h_3dData);
extern CPA_EXPORT void fn_v3dDataSavedValueSAI(MS_tdxHandleTo3dData h_3dData);
extern CPA_EXPORT void fn_v3dDataFreeInitValueSAI(MS_tdxHandleTo3dData h_3dData);
 
extern CPA_EXPORT unsigned long fn_ul3dDataSizeOf();
 
 
#if defined (ACTIVE_EDITOR)
extern CPA_EXPORT MTH_tdxReal fn_v3dDataGetMatrixElement(MS_tdxHandleTo3dData h_3dData,unsigned char ucInitOrLocalOrAbsolute,unsigned char ucWhichMatrix,unsigned char ucWhichVector,unsigned char ucWhichElement);
#endif
 
/* MR2608*/
#if defined (ACTIVE_EDITOR)
/*extern CPA_EXPORT void fn_v3dDataSetChannelActivationList(MS_tdxHandleTo3dData h_3dData,CHN_tdxHandleToCASList hCASList);*/
/*extern CPA_EXPORT void fn_v3dDataSetChannelUnderControlList(MS_tdxHandleTo3dData h_3dData,CHN_tdxHandleToUCCList hUCCList);*/
#endif /*ACTIVE_EDITOR*/
 
/*ANNECY VL 08/04/98{*/
/*extern CPA_EXPORT void fn_v3dDataSetDrawMaskInit(MS_tdxHandleTo3dData _h3dData,long _lDrawMaskInit);*/
#if defined (ACTIVE_EDITOR)
extern CPA_EXPORT long fn_l3dDataGetDrawMaskInit(MS_tdxHandleTo3dData _h3dData);
#endif /*ACTIVE_EDITOR*/
/*ENDANNECY VL}*/
 
/* MR0306*/
extern CPA_EXPORT void fn_v3dDataSetFrameRate(MS_tdxHandleTo3dData h_3dData,unsigned char ucFrameRate);
extern CPA_EXPORT void fn_v3dDataFactorFrameRate(MS_tdxHandleTo3dData _h3dData,unsigned long _ulFactor100);
 
 
#if defined (ACTIVE_EDITOR)
extern CPA_EXPORT GMT_tdxHandleToGameMaterial  fn_p_st3dDataGetShadowMaterial(MS_tdxHandleTo3dData _h3dData);
#endif	/*ACTIVE_EDITOR*/
 
 
extern CPA_EXPORT BOOL fn_b3dDataGetUserEventFlag(MS_tdxHandleTo3dData h_3dData, unsigned char _ucFlagIndex, MTH3D_tdstVector *_p_stPosition  );
extern CPA_EXPORT void fn_v3dDataSetUserEventFlag( MS_tdxHandleTo3dData h_3dData,unsigned char _ucFlagIndex, BOOL _bSet, MTH3D_tdstVector *_p_stPosition );
 
/* ANNECY MT - 12/06/98 {*/
extern CPA_EXPORT void fn_v3dDataSetBrainComputationFrequency(MS_tdxHandleTo3dData h_3dData,unsigned char _ucFrequency);
extern CPA_EXPORT void fn_v3dDataSetLightComputationFrequency(MS_tdxHandleTo3dData h_3dData,unsigned char _ucFrequency);
 
extern CPA_EXPORT void fn_v3dDataUpdateBrainCounter(HIE_tdxHandleToSuperObject _hCharacter);
extern CPA_EXPORT ACP_tdxBool fn_b3dDataCanComputeBrain(HIE_tdxHandleToSuperObject _hCharacter);
#if !defined(U64)	/* MT {*/
extern CPA_EXPORT void fn_v3dDataUpdateLightCounter(HIE_tdxHandleToSuperObject _hCharacter);
extern CPA_EXPORT ACP_tdxBool fn_b3dDataCanComputeLight(HIE_tdxHandleToSuperObject _hCharacter);
#endif /* U64 - MT }*/
 
/* END ANNECY MT }*/
 
/**********************************/
/**** Special functions define ****/
/**********************************/
/*extern CPA_EXPORT void fn_vUpdateDrawMaskForCharacter(HIE_tdxHandleToSuperObject _hCharacter);*/
extern CPA_EXPORT void fn_vSetCharacterInvisible(HIE_tdxHandleToSuperObject _hCharacter);
extern CPA_EXPORT void fn_vSetCharacterVisible(HIE_tdxHandleToSuperObject _hCharacter);
/* MR1605: No Last Mech Event in the anim...*/
#define LME_INVALID	65535
 
/**********************************/
/**********************************/
/* ANNECY MT - 22/09/98 {*/
extern CPA_EXPORT void fn_vAllocArrayOfElts3d(MS_tdxHandleTo3dData h_3dData,unsigned short _wNumberOfElts3d);
extern CPA_EXPORT void fn_vFreeArrayOfElts3d(MS_tdxHandleTo3dData h_3dData);
/* END ANNECY MT }*/
/**********************************/
 
 
/*NZO 25/09/97*/
#ifdef BIN_SaveBin
extern CPA_EXPORT unsigned long TdData_fn_ulWriteBinaryBloc(unsigned long _ulStructAddress, char* _p_cDestBuffer);
#endif
 
/*NZO 25/09/97*/
#ifdef BIN_LoadBin
extern CPA_EXPORT void TdData_fn_vReadBinaryBloc(unsigned long _ulStructAddress, char* _p_cDestBuffer);
#endif
 
 
 
#include "gam/Structur/Objects.h"
 
 
 
/* ================================================= */
/* ================================================= */
/* ===========   INLINE FUNCTIONS   ================ */
/* ================================================= */
/* ================================================= */
 
 
#undef M_3dData_SAIFlags
#define M_3dData_SAIFlags	(SAI_tdeFlags)(SAI_eInitWhenPlayerDead|SAI_eInitWhenReinitTheMap|SAI_eInitWhenMapLoaded/*|SAI_eInitWhenPlayerGameSavedLoaded*/)
 
 
INLINE
POS_tdstCompletePosition *fn_p_st3dDataGetMatrixInit(MS_tdxHandleTo3dData h_3dData)
{
	return(POS_tdstCompletePosition *)SAI_fn_p_vGetTableValuePointerOf((void*)&h_3dData->stGLIObjectMatrix,M_3dData_SAIFlags);
}
 
/*#undef M_3dData_SAIFlags*/
 
 
/****************************/
INLINE
tdxHandleToState fn_h3dDataGetInitialState(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->h_InitialState);
}
INLINE
tdxHandleToState fn_h3dDataGetInitialStateSO (HIE_tdxHandleToSuperObject hSuperObj)
{
	return fn_h3dDataGetInitialState (M_GetMSHandle(hSuperObj,3dData));
}
INLINE
void fn_v3dDataSetInitialState(MS_tdxHandleTo3dData h_3dData, tdxHandleToState h_InitialState)
{
	h_3dData->h_InitialState = h_InitialState;
}
/****************************/
INLINE
tdxHandleToState fn_h3dDataGetCurrentState(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->h_CurrentState);
}
INLINE
void fn_v3dDataSetCurrentState(MS_tdxHandleTo3dData h_3dData, tdxHandleToState h_CurrentState)
{
	h_3dData->h_CurrentState = h_CurrentState;
}
/****************************/
INLINE
tdxHandleToState fn_h3dDataGetFirstStateOfAction(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->h_FirstStateOfAction);
}
INLINE
void fn_v3dDataSetFirstStateOfAction(MS_tdxHandleTo3dData h_3dData, tdxHandleToState h_FirstStateOfAction)
{
	h_3dData->h_FirstStateOfAction = h_FirstStateOfAction;
}
/****************************/
INLINE
tdxHandleToObjectsTablesList fn_h3dDataGetCurrentObjectsTable(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->h_CurrentObjectsTable);
}
INLINE
void fn_v3dDataSetCurrentObjectsTable(MS_tdxHandleTo3dData h_3dData, tdxHandleToObjectsTablesList h_CurrentObjectsTable)
{
	h_3dData->h_CurrentObjectsTable = h_CurrentObjectsTable;
}
/****************************/
INLINE
tdxHandleToObjectsTablesList fn_h3dDataGetInitialObjectsTable(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->h_InitialObjectsTable);
}
INLINE
void fn_v3dDataSetInitialObjectsTable(MS_tdxHandleTo3dData h_3dData, tdxHandleToObjectsTablesList h_InitialObjectsTable)
{
	h_3dData->h_InitialObjectsTable = h_InitialObjectsTable;
}
/****************************/
INLINE
tdxHandleToFamilyList fn_h3dDataGetFamily(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->h_Family);
}
INLINE
void fn_v3dDataSetFamily(MS_tdxHandleTo3dData h_3dData,tdxHandleToFamilyList h_Family)
{
	h_3dData->h_Family = h_Family;
}
/****************************/
INLINE
POS_tdstCompletePosition *fn_p_st3dDataGetAbsoluteMatrix(MS_tdxHandleTo3dData _h_3dData)
{
	return((_h_3dData->p_stGLIObjectAbsoluteMatrix));
}
INLINE
void fn_v3dDataSetAbsoluteMatrix(MS_tdxHandleTo3dData _h_3dData,POS_tdstCompletePosition *_p_stMatrix)
{
	_h_3dData->p_stGLIObjectAbsoluteMatrix = _p_stMatrix;
}
INLINE
void fn_v3dDataCopyAbsoluteMatrix(MS_tdxHandleTo3dData _h_3dData,POS_tdstCompletePosition *_p_stMatrix)
{
	POS_fn_vCopyMatrix(_h_3dData->p_stGLIObjectAbsoluteMatrix,_p_stMatrix);
}
/****************************/
INLINE
POS_tdstCompletePosition *fn_p_st3dDataGetMatrix(MS_tdxHandleTo3dData h_3dData)
{
	return(&(h_3dData->stGLIObjectMatrix));
}
 
INLINE
void fn_v3dDataSetMatrix(MS_tdxHandleTo3dData h_3dData, POS_tdxHandleToPosition _hMatrix)
{
	POS_fn_vCopyMatrix(&(h_3dData->stGLIObjectMatrix), _hMatrix);
}
/****************************/
INLINE
unsigned short fn_uw3dDataGetCurrentFrame(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->uwCurrentFrame);
}
INLINE
void fn_v3dDataSetCurrentFrame(MS_tdxHandleTo3dData h_3dData,unsigned short uwCurrentFrame)
{
	h_3dData->uwCurrentFrame = uwCurrentFrame;
}
/****************************/
INLINE
tdstCouple *fn_p_st3dDataGetCurrentHieCouples(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->p_stCurrentHieCouples);
}
INLINE
void fn_v3dDataSetCurrentHieCouples(MS_tdxHandleTo3dData h_3dData,tdstCouple *_p_stCpl)
{
	h_3dData->p_stCurrentHieCouples = _p_stCpl;
}
/****************************/
/* ANNECY MT - 22/09/98 {*/
INLINE
unsigned long fn_ul3dDataGetCurrentHieNbCouples(MS_tdxHandleTo3dData h_3dData)
{
	return((unsigned long)h_3dData->wCurrentHieNbCouples);
}
INLINE
void fn_v3dDataSetCurrentHieNbCouples(MS_tdxHandleTo3dData h_3dData,unsigned long _ulNbCpl)
{
	h_3dData->wCurrentHieNbCouples = (unsigned short)_ulNbCpl;
}
/****************************/
INLINE
unsigned short fn_w3dDataGetSizeOfArrayOfElts3d(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->wSizeOfArrayOfElts3d);
}
INLINE
void fn_v3dDataSetSizeOfArrayOfElts3d(MS_tdxHandleTo3dData h_3dData,unsigned short _wSize)
{
	h_3dData->wSizeOfArrayOfElts3d = _wSize;
}
/* END ANNECY MT }*/
/****************************/
INLINE
unsigned char fn_uc3dDataGetRepeatAnimation(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->ucRepeatAnimation);
}
INLINE
void fn_v3dDataSetRepeatAnimation(MS_tdxHandleTo3dData h_3dData,unsigned char ucRepeatAnimation)
{
	h_3dData->ucRepeatAnimation = ucRepeatAnimation;
}
/****************************/
INLINE
void fn_v3dDataDecRepeatAnimation(MS_tdxHandleTo3dData h_3dData)
{
	(h_3dData->ucRepeatAnimation)--;
}
INLINE
unsigned char fn_uc3dDataGetNextEvent(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->ucNextEvent);
}
/****************************/
INLINE
void fn_v3dDataSetNextEvent(MS_tdxHandleTo3dData h_3dData,unsigned char ucNextEvent)
{
	h_3dData->ucNextEvent = ucNextEvent;
}
INLINE
void fn_v3dDataAddNextEvent(MS_tdxHandleTo3dData h_3dData,char _cNextEvent)
{
	h_3dData->ucNextEvent = (unsigned char)((long)(h_3dData->ucNextEvent)+(long)_cNextEvent);
}
INLINE
void fn_v3dDataAllocateEventActivation(MS_tdxHandleTo3dData h_3dData,unsigned long ulNumber)
{
	h_3dData->d_ucEventActivation = ( unsigned char * )TMP_M_p_Malloc(sizeof( unsigned char ) * ulNumber );
}
/****************************/
INLINE
void fn_v3dDataFreeEventActivation(MS_tdxHandleTo3dData h_3dData)
{
	if (h_3dData->d_ucEventActivation)
		TMP_M_Free(h_3dData->d_ucEventActivation );
}
INLINE
void fn_v3dDataSetEventActivationByIndex(MS_tdxHandleTo3dData h_3dData,unsigned long ulIndex,unsigned char ucValue)
{
	h_3dData->d_ucEventActivation[ulIndex] = ucValue;
}
/****************************/
INLINE
unsigned char fn_uc3dDataGetEventActivationByIndex(MS_tdxHandleTo3dData h_3dData,unsigned long ulIndex)
{
	return(h_3dData->d_ucEventActivation[ulIndex]);
}
INLINE
void fn_v3dDataAddEventActivationByIndex(MS_tdxHandleTo3dData h_3dData,unsigned long ulIndex,char _cValue)
{
	h_3dData->d_ucEventActivation[ulIndex] = (unsigned char)((long)(h_3dData->d_ucEventActivation[ulIndex])+(long)_cValue);
}
/****************************/
INLINE
struct tdstFrame3d_ *fn_p_st3dDataGetCurrentFrame(MS_tdxHandleTo3dData h_3dData)
{
	return(&h_3dData->stFrame3d);
}
/*INLINE void fn_v3dDataSetSubAnim(MS_tdxHandleTo3dData h_3dData,struct tdstSubAnim3d_ *p_stSubAnim3d)
{
	h_3dData->p_stSubAnim = p_stSubAnim3d;
}
*//****************************/
/*INLINE POS_tdstCompletePosition *fn_p_st3dDataGetControlMatrix(MS_tdxHandleTo3dData h_3dData)
{
	return(&(h_3dData->stControlMatrix));
}
*//****************************/
INLINE 
tdxHandleToState fn_h3dDataGetWantedState(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->h_WantedState);
}
INLINE
void fn_v3dDataSetWantedState(MS_tdxHandleTo3dData h_3dData,tdxHandleToState h_WantedState)
{
	h_3dData->h_WantedState = h_WantedState;
}
INLINE
void fn_v3dDataSetStateInLastFrame(MS_tdxHandleTo3dData h_3dData,tdxHandleToState h_StateInLastFrame)
{
	h_3dData->h_StateInLastFrame = h_StateInLastFrame;
}
/****************************/
INLINE
unsigned char fn_uc3dDataGetFlagModifState(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->ucFlagModifState);
}
INLINE
void fn_v3dDataSetFlagModifState(MS_tdxHandleTo3dData h_3dData,unsigned char ucFlagModifState)
{
	h_3dData->ucFlagModifState = ucFlagModifState;
}
 
/****************************/
INLINE
void fn_v3dDataSetAnimMatrixHasChanged(MS_tdxHandleTo3dData h_3dData)
{
	h_3dData->bAnimMatrixChanged = TRUE;
}
INLINE
void fn_v3dDataResetAnimMatrixHasChanged(MS_tdxHandleTo3dData h_3dData)
{
	h_3dData->bAnimMatrixChanged = FALSE;
}
 
INLINE
BOOL fn_b3dDataHasAnimMatrixChanged(MS_tdxHandleTo3dData h_3dData)
{
	return h_3dData->bAnimMatrixChanged;
}
 
/****************************/
INLINE
unsigned char fn_uc3dDataGetFlagEndOfAnim(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->ucFlagEndOfAnim);
}
INLINE
void fn_v3dDataSetFlagEndOfAnim(MS_tdxHandleTo3dData h_3dData,unsigned char ucFlagEndOfAnim)
{
	h_3dData->ucFlagEndOfAnim = ucFlagEndOfAnim;
}
/**************************  / tmp debut GIZMO*/
INLINE
unsigned short fn_uw3dDataGetForcedFrame(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->uwForcedFrame);
}
INLINE
void fn_v3dDataSetForcedFrame(MS_tdxHandleTo3dData h_3dData,unsigned short uwForcedFrame)
{
	h_3dData->uwForcedFrame = uwForcedFrame;
}
/* tmp fin GIZMO*/
/****************************/
INLINE
unsigned char fn_uc3dDataGetFlagEndState(MS_tdxHandleTo3dData h_3dData)
{
	return(h_3dData->ucFlagEndState);
}
INLINE
void fn_v3dDataSetFlagEndState(MS_tdxHandleTo3dData h_3dData,unsigned char ucFlagEndState)
{
	h_3dData->ucFlagEndState = ucFlagEndState;
}
/****************************/
/* MR2503*/
INLINE
CHN_tdxHandleToChannelArray fn_h3dDataGetChannelSOList(MS_tdxHandleTo3dData h_3dData)
{
	return (h_3dData->hArrayOfChannels);
}
 
/*INLINE CHN_tdxHandleToCASList fn_h3dDataGetChannelActivationList(MS_tdxHandleTo3dData h_3dData)
{
	return (h_3dData->hChannelActivationList);
}
*/
INLINE
CHN_tdxHandleToMorphList fn_h3dDataGetMorphList(MS_tdxHandleTo3dData h_3dData)
{
	return (h_3dData->hMorphChannelList);
}
 
INLINE
unsigned long fn_ul3dDataGetNumberOfChannels(MS_tdxHandleTo3dData h_3dData)
{
	return (h_3dData->ulNumberOfChannels);
}
 
INLINE
void fn_v3dDataSetNumberOfChannels(MS_tdxHandleTo3dData h_3dData, unsigned long ulNum)
{
	h_3dData->ulNumberOfChannels = ulNum;
}
 
INLINE
void fn_v3dDataSetChannelSOList(MS_tdxHandleTo3dData h_3dData,CHN_tdxHandleToChannelArray hArray)
{
	h_3dData->hArrayOfChannels=hArray;
}
 
 
INLINE
void fn_v3dDataSetFirstActiveChannel(MS_tdxHandleTo3dData h_3dData, CHN_tdxHandleToChannel hFirstActiveChannel)
{
	h_3dData->hFirstActiveChannel = hFirstActiveChannel;
}
 
INLINE
CHN_tdxHandleToChannel fn_h3dDataGetFirstActiveChannel(MS_tdxHandleTo3dData h_3dData)
{
	return h_3dData->hFirstActiveChannel;
}
 
INLINE
unsigned long fn_ul3dDataGetStartTime(MS_tdxHandleTo3dData h_3dData)
{
	return (h_3dData->ulStartTime);
}
 
INLINE
void fn_v3dDataSetStartTime(MS_tdxHandleTo3dData h_3dData,unsigned long ulValue)
{
	h_3dData->ulStartTime=ulValue;
}
 
INLINE
BOOL fn_b3dDataGetSkipCurrentFrame(MS_tdxHandleTo3dData h_3dData)
{
	return (h_3dData->bSkipCurrentFrame);
}
 
INLINE
void fn_v3dDataSetSkipCurrentFrame(MS_tdxHandleTo3dData h_3dData,BOOL bValue)
{
	h_3dData->bSkipCurrentFrame=(unsigned char)bValue;
}
 
INLINE
unsigned long fn_ul3dDataGetTimeDelay(MS_tdxHandleTo3dData h_3dData)
{
	return (h_3dData->ulTimeDelay);
}
 
INLINE
void fn_v3dDataSetTimeDelay(MS_tdxHandleTo3dData h_3dData,unsigned long ulValue)
{
	h_3dData->ulTimeDelay=ulValue;
}
 
INLINE
unsigned long fn_ul3dDataGetTimePreviousFrame(MS_tdxHandleTo3dData h_3dData)
{
	return (h_3dData->ulTimePreviousFrame);
}
 
INLINE
void fn_v3dDataSetTimePreviousFrame(MS_tdxHandleTo3dData h_3dData,unsigned long ulValue)
{
	h_3dData->ulTimePreviousFrame=ulValue;
}
 
INLINE
short fn_s3dDataGetLastFrame(MS_tdxHandleTo3dData h_3dData)
{
	return (h_3dData->sLastFrame);
}
 
INLINE
void fn_v3dDataSetLastFrame(MS_tdxHandleTo3dData h_3dData,short sValue)
{
	h_3dData->sLastFrame=sValue;
}
 
INLINE
BOOL fn_b3dDataGetStateJustModified(MS_tdxHandleTo3dData h_3dData)
{
	return (h_3dData->bStateJustModified);
}
 
INLINE
void fn_v3dDataSetStateJustModified(MS_tdxHandleTo3dData h_3dData,BOOL bValue)
{
	h_3dData->bStateJustModified=(unsigned char)bValue;
}
 
INLINE
unsigned short fn_uw3dDataGetNbEngineFrameSinceLastMechEvent(MS_tdxHandleTo3dData h_3dData)
{
	return h_3dData->uwNbEngineFrameSinceLastMechEvent;
}
 
INLINE
void fn_v3dDataSetNbEngineFrameSinceLastMechEvent(MS_tdxHandleTo3dData h_3dData,unsigned short uwValue)
{
	h_3dData->uwNbEngineFrameSinceLastMechEvent=uwValue;
}
 
INLINE
unsigned char fn_uc3dDataGetFrameRate(MS_tdxHandleTo3dData h_3dData)
{
	return h_3dData->ucFrameRate;
}
INLINE
MTH_tdxReal fn_x3dDataGetShadowScaleX(MS_tdxHandleTo3dData _h3dData)
{
	return _h3dData->xShadowScaleX;
}
INLINE
void fn_v3dDataSetShadowScaleX(MS_tdxHandleTo3dData _h3dData, MTH_tdxReal _xScaleX)
{
	_h3dData->xShadowScaleX=_xScaleX;
}
 
INLINE
MTH_tdxReal fn_x3dDataGetShadowScaleY(MS_tdxHandleTo3dData _h3dData)
{
	return _h3dData->xShadowScaleY;
}
INLINE
void fn_v3dDataSetShadowScaleY(MS_tdxHandleTo3dData _h3dData, MTH_tdxReal _xScaleY)
{
	_h3dData->xShadowScaleY=_xScaleY;
}
 
/*XB unused field in U64 engine*/
#ifndef U64
INLINE
short fn_x3dDataGetShadowQuality(MS_tdxHandleTo3dData _h3dData)
{
	return _h3dData->xShadowQuality;
}
INLINE
void fn_v3dDataSetShadowQuality(MS_tdxHandleTo3dData _h3dData, short _xQuality)
{
	_h3dData->xShadowQuality=_xQuality;
}
#endif /* U64 */
/*End XB*/
 
 
/*XB unused field in U64 engine*/
#ifndef U64
INLINE
void fn_v3dDataSetShadowTexture(MS_tdxHandleTo3dData _h3dData,GLI_tdstTexture * _p_stShadowTexture)
{
	_h3dData->p_stShadowTexture = _p_stShadowTexture;
}
 
INLINE
void fn_v3dDataSetShadowMaterial(MS_tdxHandleTo3dData _h3dData,GMT_tdxHandleToGameMaterial _p_stShadowMaterial)
{
	_h3dData->p_stShadowMaterial = _p_stShadowMaterial;
}
#endif /* U64 */
/*End XB*/
 
INLINE
MTH_tdxReal fn_x3dDataGetShadowScaleXFromSO(HIE_tdxHandleToSuperObject _hSO)
{
	return M_GetMSHandle(_hSO,3dData)->xShadowScaleX;
}
INLINE
void fn_v3dDataSetShadowScaleXInSO(HIE_tdxHandleToSuperObject _hSO, MTH_tdxReal _xScaleX)
{
	M_GetMSHandle(_hSO,3dData)->xShadowScaleX=_xScaleX;
}
 
INLINE
MTH_tdxReal fn_x3dDataGetShadowScaleYFromSO(HIE_tdxHandleToSuperObject _hSO)
{
	return M_GetMSHandle(_hSO,3dData)->xShadowScaleY;
}
INLINE
void fn_v3dDataSetShadowScaleYInSO(HIE_tdxHandleToSuperObject _hSO, MTH_tdxReal _xScaleY)
{
	M_GetMSHandle(_hSO,3dData)->xShadowScaleY=_xScaleY;
}
 
/*XB unused field in U64 engine*/
#ifndef U64
INLINE
short fn_x3dDataGetShadowQualityFromSO(HIE_tdxHandleToSuperObject _hSO)
{
	return M_GetMSHandle(_hSO,3dData)->xShadowQuality;
}
 
INLINE
GMT_tdxHandleToGameMaterial fn_x3dDataGetShadowMaterialFromSO(HIE_tdxHandleToSuperObject _hSO)
{
	return M_GetMSHandle(_hSO,3dData)->p_stShadowMaterial;
}
#endif /* U64 */
/*End XB*/
 
/****************************/
#if !defined(U64)	/* MT {*/
INLINE
MTH3D_tdstVector	*fn_p_st3dDataGetSHWDeformationVector(MS_tdxHandleTo3dData _h3dData)
{
	return &(_h3dData->stSHWDeformationVector);
}
 
INLINE
MTH_tdxReal	*fn_p_x3dDataGetSHWHeight(MS_tdxHandleTo3dData _h3dData)
{
	return &(_h3dData->xSHWHeight);
}
 
INLINE
MTH3D_tdstVector	*fn_p_st3dDataGetSHWDeformationVectorFromSO(HIE_tdxHandleToSuperObject _hSO)
{
	return &(M_GetMSHandle(_hSO,3dData)->stSHWDeformationVector);
}
 
INLINE
MTH_tdxReal	*fn_p_x3dDataGetSHWHeightFromSO(HIE_tdxHandleToSuperObject _hSO)
{
	return &(M_GetMSHandle(_hSO,3dData)->xSHWHeight);
}
#endif /* U64 - MT }*/
 
/****************************/
/* Oliv' - 19/05/1999 - I want to see Zdx too */
#if defined(_DEBUG) || defined(_U64_GLI_BENCH_)
/* EndOfOliv' */
 
INLINE
long fn_l3dDataGetZdxMask(MS_tdxHandleTo3dData _h3dData)
{
	return _h3dData->lZdxMask;
}
 
INLINE
void fn_v3dDataSetZdxMask(MS_tdxHandleTo3dData _h3dData,long _lState)
{
	_h3dData->lZdxMask = _lState;
}
/* Oliv' - 19/05/1999 - I want to see Zdx too */
#endif /* _DEBUG || _U64_GLI_BENCH_ */
/* EndOfOliv' */
 
/****************************/
INLINE
void fn_v3dDataSetDrawMask(MS_tdxHandleTo3dData _h3dData,long _lDrawMask)
{
	_h3dData->lDrawMask = _lDrawMask;
}
 
INLINE
long fn_l3dDataGetDrawMask(MS_tdxHandleTo3dData _h3dData)
{
	return _h3dData->lDrawMask;
}
 
/****************************/
INLINE
unsigned char fn_uc3dDataGetBrainComputationFrequency(MS_tdxHandleTo3dData h_3dData)
{
	return(unsigned char)(h_3dData ? h_3dData->ucBrainComputationFrequency : 1);
}
 
INLINE
unsigned char fn_uc3dDataGetBrainComputationFrequencySO(HIE_tdxHandleToSuperObject _hCharacter)
{
	return(unsigned char)(_hCharacter ? fn_uc3dDataGetBrainComputationFrequency( M_GetMSHandle(_hCharacter,3dData) ) : 1);
}
 
/****************************/
#if !defined(U64) /*MT*/
INLINE
unsigned char fn_uc3dDataGetLightComputationFrequency(MS_tdxHandleTo3dData h_3dData)
{
	return(unsigned char)(h_3dData ? h_3dData->ucLightComputationFrequency : 1);
}
 
INLINE
unsigned char fn_uc3dDataGetLightComputationFrequencySO(HIE_tdxHandleToSuperObject _hCharacter)
{
	return(unsigned char)(_hCharacter ? fn_uc3dDataGetLightComputationFrequency( M_GetMSHandle(_hCharacter,3dData) ) : 1);
}
#endif /*U64*/
/****************************/
#ifdef D_USE_LIPSYNC
INLINE
void fn_v3dDataSetLipsTable(MS_tdxHandleTo3dData h_3dData,tdxHandleOfLipsSynchroTable hLipsTable)
{
	h_3dData->hLipsTable=hLipsTable;
}
 
INLINE
tdxHandleOfLipsSynchroTable fn_x3dDataGetLipsTable(MS_tdxHandleTo3dData h_3dData)
{
	return h_3dData->hLipsTable;
}
 
INLINE
void fn_v3dDataSetStartSynchroFrame(MS_tdxHandleTo3dData h_3dData,unsigned short uwStartSynchroframe)
{
	h_3dData->uwStartSynchroFrame=uwStartSynchroframe;
}
 
INLINE
unsigned short fn_uw3dDataGetStartSynchroFrame(MS_tdxHandleTo3dData h_3dData)
{
	return h_3dData->uwStartSynchroFrame;
}
 
INLINE
void fn_v3dDataSetCurrentSynchroFrame(MS_tdxHandleTo3dData h_3dData,unsigned short uwCurrentSynchroframe)
{
	h_3dData->uwCurrentSynchroFrame=uwCurrentSynchroframe;
}
 
INLINE
unsigned short fn_uw3dDataGetCurrentSynchroFrame(MS_tdxHandleTo3dData h_3dData)
{
	return h_3dData->uwCurrentSynchroFrame;
}
#endif /* D_USE_LIPSYNC */
 
/* MR1007*/
/*INLINE BOOL fn_b3dDataIsCurrentFrameInterpolated(MS_tdxHandleTo3dData h_3dData)
{
	return h_3dData->bCurrentFrameIsInterpolated;
}
 
INLINE
void fn_v3dDataSetCurrentFrameInterpolated(MS_tdxHandleTo3dData h_3dData,BOOL bInter)
{
	h_3dData->bCurrentFrameIsInterpolated=bInter;
}
*/
/* GARBAGE: TO REMOVE */
INLINE
void fn_vInitBubbleEffect()
{
}
 
INLINE
BOOL fn_l3dDataGetLastComputeEngineFrame(MS_tdxHandleTo3dData h_3dData)
{
	return h_3dData->lLastComputeFrame;
}
 
INLINE
void fn_v3dDataSetLastComputeEngineFrame(MS_tdxHandleTo3dData h_3dData,long lLastComputeFrame)
{
	h_3dData->lLastComputeFrame=lLastComputeFrame;
}
 
INLINE
unsigned char fn_uc3dDataGetUserEventFlags(MS_tdxHandleTo3dData h_3dData)
{
	return h_3dData->ucUserEventFlags;
}
 
INLINE
void fn_v3dDataSetUserEventFlags(MS_tdxHandleTo3dData h_3dData,unsigned char _ucFlags)
{
	h_3dData->ucUserEventFlags = _ucFlags;
}
 
 
INLINE
void fn_v3dDataUpdateMainBrainCounter(MS_tdxHandleTo3dData h_3dData)
{
	if(h_3dData) h_3dData->uwBrainMainCounter++;
}
 
INLINE
unsigned short fn_uw3dDataGetMainBrainCounter(MS_tdxHandleTo3dData h_3dData)
{
	return(unsigned short)(h_3dData ? h_3dData->uwBrainMainCounter : 0);
}
 
 
 
 
 
#if defined(__cplusplus)
}
#endif /* __cplusplus */
 
#endif /* __3dData_H__ */
