 
/**********************************************************
 *                                                        *
 *                   Morphing                             *
 *                                                        *
 * This file is the public file of the Morphing module    *
 *                                                        *
 * Author : Ubi China - Alexis Vaisse                     *
 *                                                        *
 **********************************************************/
 
 
#ifndef __MOR_MORPH_H__
#define __MOR_MORPH_H__
 
 
#ifdef __cplusplus
    extern "C" {
#endif
 
/* AR980213 DONT INCLUDE HEADER FILES INTO PUBLIC HEADERS !!!*/
 
/* Constant for the morphing type */
 
#define MORPH_STOPATEND                 1                 /* 'One-way' morphing and then stop the morphing (the original object in the channel is restored)*/
#define MORPH_WAITATEND					2                 /* 'One-way' morphing but the 'end' physical object stays in the channel until the 'StopMorph' function is called*/
#define MORPH_ROLLBACKATEND				3                 /* 'loop' morphing : from 'start' to 'end' and 'end' to 'start' until the 'StopMorph' function is called*/
#define MORPH_WAITATEND_ANIM			4				  /* Wait at end and controlled by the anim player */
 
/* Definition of a list which will contains one element for each object currently morphed */
 
#define MAX_MORPH_TASKS                50                 /* 50 objects can morph simultaneously*/
 
/* AR980414 : STRUCTURE DEFINED INTO THE SPECIFIC FILES*/
#include "MOR/Specif/morph.h"
 
/* Alloc/free Macros */
 
#define MOR_M_pvMalloc(Var,cast,Size)				(Var) = (cast) TMP_M_p_Malloc(Size)
#define MOR_M_Free(Var)								TMP_M_Free(Var)
 
/*************************************/
/*         Public functions          */
/*************************************/
 
/* Begin a morphing task (will be called by the AI module)*/
ACP_tdxIndex MOR_fn_xPrepareMorph (HIE_tdxHandleToSuperObject _hActorSuperObject ,
                                   ACP_tdxIndex _xStartIndexInObjectTable , ACP_tdxIndex _xEndIndexInObjectTable   ,
								   int _iNbMillisecond , int _iStart , int _iEnd ,
                                   unsigned char _ucMorphType , ACP_tdxIndex _xChannelIndex);
 
/* End a morphing task (will be called by the AI module)*/
ACP_tdxIndex MOR_fn_xStopMorph    (HIE_tdxHandleToSuperObject _hActorSuperObject , ACP_tdxIndex _xChannelNumber);
 
/* Morph an object (will be called by the AI module)*/
ACP_tdxIndex MOR_fn_xMorphing (HIE_tdxHandleToSuperObject _hActorSuperObject ,
                               ACP_tdxIndex _xStartIndexInObjectTable , ACP_tdxIndex _xEndIndexInObjectTable   ,
							   int _iRatio , ACP_tdxIndex _xChannelIndex);
 
/* Initialization of the Morphing module*/
#ifndef U64
void  MOR_fn_vFirstInitMorphTaskList();
#else
void  MOR_fn_vFirstInitMorphTaskList(unsigned short _uwNbMorphTasks,
										unsigned short _uwNbMorphElements,
										unsigned short _uwNbMorphPoints,
										unsigned short _uwQuality);
#endif
 
/* Desinitialization of the Morphing module*/
void  MOR_fn_vLastDeinitMorphTaskList();
 
/* Call each frame*/
void MOR_fn_vMorphAddInMainLoop();
 
 
 
/*************************************/
/*         Private functions         */
/*************************************/
 
/* Make a copy of a geometric object*/
ACP_tdxHandleOfObject MOR_fn_xCopyGeometricObjectForMorph (GEO_tdstGeometricObject * _pGeometricObjectToCopy);
 
/* Delete a geometric object*/
void MOR_fn_vDeleteGeometricObject (ACP_tdxHandleOfObject * _pGeometricObject);
 
/* Delete a physical object*/
void MOR_fn_vDeletePhysicalObject (PO_tdxHandleToPhysicalObject _pPhysicalObject);
 
/* Clean one element of the list*/
void MOR_fn_vCleanMorph (MOR_tdstMorphStruct * _mp);
 
/* Clean all elements of the list*/
void MOR_fn_vRemoveAllMorphedObjects (void);
 
/* Return TRUE if the object in the given channel of the given actor is morphing*/
ACP_tdxBool MOR_fn_bIsChannelMorphed (HIE_tdxHandleToSuperObject _hActorSuperObject , ACP_tdxIndex _xChannelIndex);
 
/* Recursiv function to remove and replace an object in the hierarchy*/
ACP_tdxBool MOR_fn_bRemoveMorphedObjectFromHierarchy (HIE_tdxHandleToSuperObject _hSuperObject ,
                                                      PO_tdxHandleToPhysicalObject _ptPhysicalObjectToRemove ,
                                                      PO_tdxHandleToPhysicalObject _ptPhysicalObjectToPut);
 
/* Return the morphed object of an element in the list*/
PO_tdxHandleToPhysicalObject MOR_fn_hGetMorphedObject (ACP_tdxIndex _xIndex);
 
/*----------------------------------------------------------------------------
 
--  Description : MOR_fn_vDoMorph
--  Execute the morphing operation corresponding to an index into the morph
--  task list
------------------------------------------------------------------------------
--  Methods : Use the morphto function
------------------------------------------------------------------------------
--  Input :		_xIndex : Index of the task
--  Output :    
----------------------------------------------------------------------------*/
void MOR_fn_vDoMorph(ACP_tdxIndex _xIndex);
 
#ifdef __cplusplus
    };
#endif
 
 
#endif  /*__MOR_MORPH_H__*/
