/* (c) Ubi Studios 1996*/
/* See Vincent Greco for any comment or question*/
 
#ifndef __HIEEXT_H__
#define __HIEEXT_H__
 
#ifdef  __cplusplus
extern "C" {
#endif
 
/* For DLL using these function :*/
#include "cpa_expt.h" 
 
 
/*these 4 functions should not be changed into macros (we can need their address in the editors)*/
 
 
/*returns a handle to a not already used SuperObject*/
extern CPA_EXPORT HIE_tdxHandleToSuperObject HIE_fn_hCreateSuperObject(void);
/*indicates that the SuperObject referenced by this handle will not be used any more, so this handle can be returned later and reference a new SuperObject.*/
extern CPA_EXPORT void HIE_fn_vDestroySuperObject(HIE_tdxHandleToSuperObject hOldSuperObject);
/*copy the second SuperObject into the first (same linked object an type, same handle to local matrix, different handle to global matrix, but the matrix is copied, the children and the father are not copied).*/
extern CPA_EXPORT void HIE_fn_vCopySuperObject(HIE_tdxHandleToSuperObject _hDst,HIE_tdxHandleToSuperObject _hSrc);
/*that’s a creation followed by a copy !*/
extern CPA_EXPORT HIE_tdxHandleToSuperObject HIE_fn_hDuplicateSuperObject(HIE_tdxHandleToSuperObject _hSuperObject);
 
/*if you need other functions ask me !*/
extern CPA_EXPORT HIE_tdxHandleToSuperObject HIE_fn_hForceGetSuperObjectNextBrother(HIE_tdxHandleToSuperObject _hSprObj);
extern CPA_EXPORT HIE_tdxHandleToSuperObject HIE_fn_hForceGetSuperObjectPrevBrother(HIE_tdxHandleToSuperObject _hSprObj);
 
 
extern CPA_EXPORT void HIE_fn_vSwapGlobalMatrix(HIE_tdxHandleToSuperObject _hSprObj);
 
/*be carefull this matrix will be never changed*/
extern CPA_EXPORT void HIE_fn_vSetSuperObjectStaticMatrix(HIE_tdxHandleToSuperObject _hSprObj,GEO_tdxHandleToMatrix _hMatrix);
 
extern CPA_EXPORT void HIE_fn_vInvalidateAllGlobalMatrices(void);
 
/*For having the good absolute matrix :*/
/*void ExamineTree(HIE_tdxHandleToSuperObject _hFather)*/
/*{*/
/*	HIE_tdxHandleToSuperObject hChild;*/
/*	int i;*/
/*	HIE_fn_vPushMatrix(_hFather);//now the absolute matrix is valid*/
/*  //do what you want on this node before looking at its children*/
/*  HIE_M_ForEachChildOf(_hFather,hChild,i)*/
/*		ExamineTree(hChild)*/
/*  //do what you want on this node after having looked at its children*/
/*  HIE_fn_vPopMatrix();//do not use the absolute matrix any longer*/
/*}*/
extern CPA_EXPORT void HIE_fn_vPushMatrix (HIE_tdxHandleToSuperObject _hSprObj);
extern CPA_EXPORT void HIE_fn_vPopMatrix (void);
 
extern CPA_EXPORT void HIE_fn_vPushOnCameraMatrixStack(HIE_tdxHandleToSuperObject _hSprObj);
extern CPA_EXPORT void HIE_fn_vStoreOnCameraMatrixStack(HIE_tdxHandleToSuperObject _hSprObj);

extern CPA_EXPORT void HIE_fn_vPopOnCameraMatrixStack();
 
/* compute the relative matrix of the SO, without changing the absolute one */
extern CPA_EXPORT void HIE_fn_vComputeNewRelativeMatrix(HIE_tdxHandleToSuperObject _hSprObj);
 
extern CPA_EXPORT void HIE_fn_vComputeNewRelativeScaleMatrix(HIE_tdxHandleToSuperObject _hSprObj);
 
/* the SO will be the last child of its new father */
extern CPA_EXPORT void HIE_fn_vChangeFather(HIE_tdxHandleToSuperObject _hSprObj, HIE_tdxHandleToSuperObject _hNewFather, ACP_tdxBool _bAtHead);
 
/* the SO will be the next brother of its new brother */
extern CPA_EXPORT void HIE_fn_vChangeBrother(HIE_tdxHandleToSuperObject _hSprObj, HIE_tdxHandleToSuperObject _hNewPrevBrother);
 
/*for Francois only : DO NOT USE THESE 5 FUNCTIONS*/
extern CPA_EXPORT void HIE_fn_vIsolate(HIE_tdxHandleToSuperObject _hSprObj);
extern CPA_EXPORT void HIE_fn_vPseudoIsolate(HIE_tdxHandleToSuperObject _hSprObj);
extern CPA_EXPORT void HIE_fn_vInitParent(HIE_tdxHandleToSuperObject _hSprObj);
extern CPA_EXPORT HIE_tdxHandleToSuperObjectTab HIE_fn_p_stCreateSuperObjectTab(long lSize);
/*extern CPA_EXPORT HIE_tdxHandleToSuperObject HIE_fn_hGetElementFromSuperObjectTab(HIE_tdxHandleToSuperObjectTab _hTab, long lIndex);*/
/*extern CPA_EXPORT long HIE_fn_hGetIndexFromSuperObjectTabAndElement(HIE_tdxHandleToSuperObjectTab _hTab, HIE_tdxHandleToSuperObject _hElement);*/
 
extern CPA_EXPORT HIE_tdxHandleToSuperObject HIE_fn_hGetChildNumber(HIE_tdxHandleToSuperObject _hParent, long _lNumber);
extern CPA_EXPORT long HIE_fn_lGetNumberOfChild(HIE_tdxHandleToSuperObject _hParent, HIE_tdxHandleToSuperObject _hChild);
 
extern CPA_EXPORT void HIE_fn_vInvalidateOneGlobalMatrix(HIE_tdxHandleToSuperObject _hSprObj);
extern CPA_EXPORT void HIE_fn_vInitGlobalMatrixFrameCounter(long lValue);
 
/*extern CPA_EXPORT float HIE_fn_fGetSuperObjectTransparenceLevel(HIE_tdxHandleToSuperObject _hSuperObj);*/
/*extern CPA_EXPORT void HIE_fn_vSetSuperObjectTransparenceLevel(HIE_tdxHandleToSuperObject _hSuperObj,float _fTransparenceLevel);*/
 
/* Use to indicate if the transparency level of the moduleis not the same as the actor*/
extern CPA_EXPORT ACP_tdxBool HIE_fn_bGetSuperObjectTransparencyModule(HIE_tdxHandleToSuperObject _hSuperObj);
extern CPA_EXPORT void HIE_fn_vSetSuperObjectTransparencyModule(HIE_tdxHandleToSuperObject _hSuperObj, ACP_tdxBool _bTransparencyModule);
 
/* If a global matrix is invalid, it is recomputed from the local matrix*/
/* you can use HIE_fn_vInvalidateAllGlobalMatrices() before this function*/
/* to force all the global matrices to be recomputed*/
extern CPA_EXPORT void HIE_fn_vRefreshHierarchy(HIE_tdxHandleToSuperObject _hSprObj);
 
/* recursively change all frame counters of the superobjects so that the matrixes are recomputed if required*/
extern CPA_EXPORT void HIE_fn_vInvalidateHierarchy(HIE_tdxHandleToSuperObject _hSprObj);
 
/*extern CPA_EXPORT long HIE_fn_lGetSuperObjectLastComputeFrame(HIE_tdxHandleToSuperObject _hSuperObj);*/
/*extern CPA_EXPORT void HIE_fn_vSetSuperObjectLastComputeFrame(HIE_tdxHandleToSuperObject _hSuperObj,long _lLastComputeFrame);*/
 
/*macro for looking at each child of a father*/
#define HIE_M_ForEachMovingChildOf(_hSprObj,_hChild,_hNextChild,_i) \
for														\
(														\
	(_i)=0,(_hChild)=HIE_fn_hGetSuperObjectFirstChild(_hSprObj),(_hNextChild)=HIE_fn_hForceGetSuperObjectNextBrother(_hChild);		\
	HIE_fn_bIsSuperObjectValid(_hChild);									\
	(_i)++,(_hChild)=(_hNextChild),(_hNextChild)=HIE_fn_hForceGetSuperObjectNextBrother(_hChild)			\
)
 
/*macro for looking at a node and all its children*/
#define HIE_M_ForMeAndMyChildren(_hSprObj,_hChild,_i) \
for														\
(														\
	(_i)=-1,(_hChild)=(_hSprObj);		\
	HIE_fn_bIsSuperObjectValid(_hChild);									\
  (_i)++,(_hChild)=((_hChild)==(_hSprObj))?HIE_fn_hGetSuperObjectFirstChild(_hSprObj):HIE_fn_hGetSuperObjectNextBrother(_hChild)			\
)
 
#define HIE_M_InvForEachMovingChildOf(_hSprObj,_hChild,_hPrevChild,_i) \
for														\
(														\
	(_i)=HIE_fn_lGetNumberOfChildren(_hSprObj),(_hChild)=HIE_fn_hGetSuperObjectLastChild(_hSprObj),(_hPrevChild)=HIE_fn_hForceGetSuperObjectPrevBrother(_hChild);		\
	HIE_fn_bIsSuperObjectValid(_hChild);									\
	(_i)--,(_hChild)=(_hPrevChild),(_hPrevChild)=HIE_fn_hForceGetSuperObjectPrevBrother(_hChild)			\
)
 
#ifdef  __cplusplus
}/* extern "C" */
#endif
 
#endif /* __HIEEXT_H__*/
