// definition of special world class for the 3DTool Dll

#ifndef __T3DWORLD_HPP__
#define __T3DWORLD_HPP__

#ifdef ACTIVE_EDITOR

#include "T3DInterf.hpp"
#include "X:\Cpa\Main\inc\_EditID.h"


class CPA_MainWorld;
class Evt_Editor;
class CPA_ObjectDLLBase;
class CPA_List;
class CPA_BaseObject;

typedef enum
{
    C_eNone,
    C_eActor,
    C_eSuperObject,
    C_eGridActor,
    C_eGridList,
    C_eObject,
    C_eViewer,
    C_eAnimOK,
    C_eAnimTemp
} tde_WorldType;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class Tool3D_World : public CPA_World
{

protected:
public:
    CPA_SuperObject      *m_p_oBaseFromAnim;
    tde_WorldType         m_eWorldType;
	CPA_List<CPA_SuperObject>	m_oListOfSO;
	POSITION			  m_xLastSOUsedPosition;
    tdstEngineObject     *m_p_stEngineObject;
	tdstState			  m_stState;	
    CPA_Interface        *m_p_oInterface;
    CPA_EditorBase       *m_p_oDLLPO;
    CPA_SuperObject      *m_p_oRootFromAnim;

public:

    
	Tool3D_World(CPA_MainWorld *_p_oMainWorld);
    ~Tool3D_World();
//  Editor Messages Functions overload
    BOOL fn_bAcceptModifDelete      (CPA_ObjectDLLBase *pDLLBase)   { return mfn_bAcceptModif( pDLLBase ); }
    BOOL fn_bAcceptModifParent      (CPA_ObjectDLLBase *pDLLBase)   { return mfn_bAcceptModif( pDLLBase ); }
// ALX
    BOOL fn_bAcceptModifCopy        (CPA_ObjectDLLBase *pDLLBase)   { return TRUE; }
// End ALX
    BOOL fn_bAcceptModifTranslate   (CPA_ObjectDLLBase *pDLLBase)   { return mfn_bAcceptModif( pDLLBase ); }
    BOOL fn_bAcceptModifRotate      (CPA_ObjectDLLBase *pDLLBase)   { return mfn_bAcceptModif( pDLLBase ); }
    BOOL fn_bAcceptModifScale       (CPA_ObjectDLLBase *pDLLBase)   { return mfn_bAcceptModif( pDLLBase ); }
    BOOL fn_bAcceptModifInsert      (CPA_ObjectDLLBase *pDLLBase)   { return mfn_bAcceptModif( pDLLBase ); }
    BOOL fn_bAcceptModifName        (CPA_ObjectDLLBase *pDLLBase)   { return FALSE;}
    BOOL fn_bAcceptSelect           (CPA_ObjectDLLBase *pDLLBase)   { return TRUE; }
    BOOL fn_bAcceptMultiSelect      (void)                          { return TRUE; }
    // Called before editor timer execution
    BOOL fn_bAcceptToRunTimerEngine (void)                          { return TRUE; };

public:
    void mfn_vCreateHierarchyFromActor          (CPA_SuperObject *_p_oSprObj);
    void mfn_vCreateHierarchyFromSuperObject    (CPA_SuperObject *_p_oSprObj);
    void mfn_vCreateHierarchyFromObject         (CPA_BaseObject *_p_oObject);
    void mfn_vCreateGridHierarchyFromActor      (CPA_SuperObject *_p_oSprObj);
    void mfn_vCreateGridHierarchyFromList       (CPA_List<CPA_BaseObject> *_p_oList, CPA_MainWorld *_p_oMainWorld);
    void mfn_vCreateGridHierarchyFromTable      (CPA_BaseObject *_p_oTable, CPA_MainWorld *_p_oMainWorld);
    void mfn_vCreateViewerHierarchyFromVWOIList (CPA_List<tdst_VW_ObjInfo> *_p_oListOfVWOI, CPA_MainWorld *_p_oMainWorld);
    //
    CPA_SuperObject *mfn_p_oCreateHierarchyFromAnim (CPA_SuperObject *_p_oSprObjActor);
    void mfn_vUpdateHierarchyFromAnim               (struct tdstAnim3d_* _pstAnim, unsigned short _uwFrame);
    void mfn_vPlayAnim                              (struct tdstAnim3d_* _pstAnim, unsigned short _uwFrame);
    //
    void mfn_vResetWorld                        (void);
    void mfn_vComputeSuperObjectPosFromViewer   (void);
    MTH_tdxReal m_fn_xGetSphereBoxRadius        (CPA_SuperObject *_p_oSprObj);
    BOOL m_fn_bGetSphereBoxCenter               (CPA_SuperObject *_p_oSprObj, MTH3D_tdstVector *_p_stCenter);

    BOOL mfn_bComputeCenterAndRadiusBoundingBox (CPA_SuperObject *_p_oSprObj, MTH3D_tdstVector *_p_stCenter = NULL, MTH_tdxReal *_xRadius = NULL);

protected:
    BOOL        mfn_bAcceptModif                    (CPA_ObjectDLLBase *pDLLBase);
    void        mfn_vDuplicateHierarchy             (CPA_SuperObject *_p_oNewFather, CPA_SuperObject *_p_oPreviousFather);
    void        mfn_vLinearizeHierarchy             (CPA_SuperObject *_p_oNewFather, CPA_SuperObject *_p_oPreviousFather);
    void        mfn_vDeleteHierarchy                (CPA_SuperObject *_p_oFather );
    MTH_tdxReal m_fn_vComputeMaxSphereBoxRadius     (void);
    //
    void            mfn_vResetHierarchy             (CPA_SuperObject *_p_oRootSO);
    void            mfn_vFillHierarchyWithEngineAnim(CPA_SuperObject *_p_oRootSO, BOOL _bWithObject = TRUE);
    void            mfn_vFillHierarchy              (CPA_SuperObject *_p_oRootSO, BOOL _bWithObject = TRUE);
    void            mfn_vClearHierarchy             (CPA_SuperObject *p_oRootSO, BOOL _bDelete = FALSE);
};

#endif //ACTIVE_EDITOR

#endif //__T3DWORLD_HPP__