/*=========================================================================
* ChanList.h : ChanList's functions
*
*
*         ChanList MUST BE REPLACE BY THE HEADER FILENAME
*
*
* Version              1.0
* Creation date        25/03/97
*	Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1997
*=======================================================================*/
 
#if !defined(__ChanList_H__)
#define __ChanList_H__
 
/******************************************/
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000 */
/******************************************/
 
#if defined(__cplusplus)
extern "C"
{
#endif /* __cplusplus */
 
struct tdstElement3d_;
#include "GAM/Header.h"
/* ANNECY AV {*/
#include "PO/POHandl.h"
/* ENDANNECY AV }*/
 
 
#define C_ucUnknownChannel	(unsigned char)0xFF
#define C_wMaskForZoom			((unsigned short)0x8000)
 
struct tdstEngineObject_;
 
 
 
 
typedef struct tdstAChannel_
{
	HIE_tdxHandleToSuperObject	hSupObject;
/*	POS_tdstCompletePosition	stAnimMatrix;			// animation matrix*/
	HIE_tdxHandleToSuperObject	hZoomSupObject;			/* superobject used for symetric channels*/
	struct tdstAChannel_		*p_stNextActiveChannel;	/* link for active channels*/
	struct tdstAChannel_		*p_stFatherChannel;		/* hierarchy info*/
	ACP_tdxBool					bControlledChannel; /* channel position is modified by the AI, and should not be updated by the anim player */
	ACP_tdxBool					bActiveChannel; /* the AI wants the channel to be ignored */
} tdstAChannel;
 
 
EXTERN unsigned short fn_uwGetChannelOfSuperObject(CHN_tdxHandleToChannelArray hChannelArray, HIE_tdxHandleToSuperObject hSO, unsigned long ulNumberOfChannels);
extern CPA_EXPORT void fn_vInitCSOList(CHN_tdxHandleToChannelArray *p_hChannelArray, unsigned long ulNumberOfChannels);
extern CPA_EXPORT void fn_vFreeCSOList(CHN_tdxHandleToChannelArray *p_hChannelArray/*, unsigned long ulNumberOfChannels*/);
 
 
 
EXTERN void fn_vTakeControlOfChannel(struct tdstEngineObject_ *_hActor,unsigned short uwChannel, ACP_tdxBool _bControlled);
EXTERN void fn_vActivateChannel(HIE_tdxHandleToSuperObject _hPerso,unsigned short uwChannel,ACP_tdxBool _bActivate);
EXTERN void fn_vUpdateSPOFlagsOfChannelForActivation ( HIE_tdxHandleToSuperObject _hSOChannel, ACP_tdxBool _bActivate);
/*EXTERN void fn_vUpdateMatrixOfControledChannels(struct tdstEngineObject_ *_hActor);*/
 
 
 
/* ANNECY AV {*/
/* ---------------------------------------------------------------------------------------------*/
/* Definition of CHN_tdxHandleToMorphList, which is a list of Morph channels.*/
/* If a channel is morphing, it could be rotated or translated, as one wants...*/
 
typedef struct tdstMorphChannelList_
{
	LST2_M_DynamicElementDeclaration(CHN_tdxHandleToMorphElement)
	unsigned short uwChannelNumber;
	ACP_tdxIndex	MorphListIndex;
} tdstMorphChannelList;
 
tdstMorphChannelList* fn_p_stCreateMorphListElement();
void fn_vFreeMorphListElement(tdstMorphChannelList *p_stMorphList);
extern CPA_EXPORT void fn_vInitMorphList(CHN_tdxHandleToMorphList *p_hMorphList);
extern CPA_EXPORT void fn_vFreeMorphList(CHN_tdxHandleToMorphList *p_hMorphList);
EXTERN CPA_EXPORT	void fn_vPutMorphElementInChannel(CHN_tdxHandleToMorphList hMorphList,unsigned short uwChannel,ACP_tdxIndex IndexOfMorphList);
EXTERN CPA_EXPORT void fn_vRemoveChannelFromMorphList(CHN_tdxHandleToMorphList hMorphList,unsigned short uwChannel);
EXTERN CPA_EXPORT	ACP_tdxIndex fn_hMorphListIndex(CHN_tdxHandleToMorphList hMorphList,unsigned short uwChannel);
PO_tdxHandleToPhysicalObject fn_hGetMorphedObjectInChannel (CHN_tdxHandleToMorphList hMorphList,unsigned short uwChannel);
/* ENDANNECY AV }*/
 
 
 
/*****************************************/
/********** inline functions *************/
/*****************************************/
INLINE
CHN_tdxHandleToChannel fn_hGetCSOForChannel(CHN_tdxHandleToChannelArray hChannelArray,unsigned short uwChannel)
{
	return &hChannelArray[uwChannel];
}
 
 
INLINE
void fn_vPutSuperObjectInChannel(CHN_tdxHandleToChannelArray hChannelArray,unsigned short uwChannelNumber,HIE_tdxHandleToSuperObject hSO)
{
	/* assumes that the given channel number is good !*/
	hChannelArray[uwChannelNumber].hSupObject = hSO;
}
 
 
INLINE
HIE_tdxHandleToSuperObject fn_hGetSuperObjectInChannel(CHN_tdxHandleToChannelArray hChannelArray, unsigned short uwChannelNumber)
{
	return (hChannelArray) ? hChannelArray[uwChannelNumber].hSupObject : NULL;
}
 
 
INLINE
HIE_tdxHandleToSuperObject fn_hGetZoomSuperObjectInChannel(CHN_tdxHandleToChannelArray hChannelArray, unsigned short uwChannelNumber)
{
	return (hChannelArray) ? hChannelArray[uwChannelNumber].hZoomSupObject : NULL;
}
 
 
#if defined(__cplusplus)
}
#endif /* __cplusplus */
 
#endif /* __ChanList_H__ */
