2283 lines
105 KiB
PHP
2283 lines
105 KiB
PHP
//*****************************************************************************
|
|
//* _zInterf.inc *
|
|
//*****************************************************************************
|
|
//* *
|
|
//* This file is included by _zInterf.cpp *
|
|
//* It contains internal functions of the ZDx_Interface class *
|
|
//* *
|
|
//*****************************************************************************
|
|
//* Author : Alexis Vaisse *
|
|
//*****************************************************************************
|
|
|
|
|
|
//*****************************************************************************
|
|
// Personal low-level functions
|
|
//*****************************************************************************
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ConvertVectorGlobalToLocal
|
|
// Temporary function to convert a vector from the global repere to a local repere
|
|
// pSource and pDest must be different
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ConvertVectorGlobalToLocal (MTH3D_tdstVector * pDest , POS_tdstCompletePosition * pAbsoluteMatrix , MTH3D_tdstVector * pSource)
|
|
{
|
|
// Compute the invert matrix
|
|
POS_tdstCompletePosition InvMatrix;
|
|
POS_fn_vInvertIsoMatrix(& InvMatrix , pAbsoluteMatrix);
|
|
|
|
// Put the translation to 0
|
|
MTH3D_tdstVector NullVector;
|
|
MTH3D_M_vNullVector (& NullVector);
|
|
POS_fn_vSetTranslationVector(& InvMatrix , & NullVector);
|
|
|
|
POS_fn_vMulMatrixVertex(pDest , & InvMatrix , pSource);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ConvertVectorLocalToGlobal
|
|
// Temporary function to convert a vector from a local repere to the global repere
|
|
// pSource and pDest must be different
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ConvertVectorLocalToGlobal (MTH3D_tdstVector * pDest , POS_tdstCompletePosition * pAbsoluteMatrix , MTH3D_tdstVector * pSource)
|
|
{
|
|
// Keep a copy of the translation vector
|
|
MTH3D_tdstVector BackupTranslation;
|
|
POS_fn_vGetTranslationVector(pAbsoluteMatrix , & BackupTranslation);
|
|
|
|
// Put the translation to 0
|
|
MTH3D_tdstVector NullVector;
|
|
MTH3D_M_vNullVector (& NullVector);
|
|
POS_fn_vSetTranslationVector(pAbsoluteMatrix , & NullVector);
|
|
|
|
POS_fn_vMulMatrixVertex(pDest , pAbsoluteMatrix , pSource);
|
|
|
|
POS_fn_vSetTranslationVector(pAbsoluteMatrix , & BackupTranslation);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ConvertPointGlobalToLocal
|
|
// Temporary function to convert a point from the global repere to a local repere
|
|
// pSource and pDest must be different
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ConvertPointGlobalToLocal (MTH3D_tdstVector * pDest , POS_tdstCompletePosition * pAbsoluteMatrix , MTH3D_tdstVector * pSource)
|
|
{
|
|
// Compute the invert matrix
|
|
POS_tdstCompletePosition InvMatrix;
|
|
POS_fn_vInvertIsoMatrix(& InvMatrix , pAbsoluteMatrix);
|
|
|
|
POS_fn_vMulMatrixVertex(pDest , & InvMatrix , pSource);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ConvertPointLocalToGlobal
|
|
// Temporary function to convert a point from a local repere to the global repere
|
|
// pSource and pDest must be different
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ConvertPointLocalToGlobal (MTH3D_tdstVector * pDest , POS_tdstCompletePosition * pAbsoluteMatrix , MTH3D_tdstVector * pSource)
|
|
{
|
|
POS_fn_vMulMatrixVertex(pDest , pAbsoluteMatrix , pSource);
|
|
}
|
|
|
|
|
|
//*****************************************************************************
|
|
// Various functions
|
|
//*****************************************************************************
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - GetZDxTypeName
|
|
// return the name ("Zdd"...) of the ZDx type
|
|
//-----------------------------------------------------------------------------
|
|
char * ZDx_Interface::GetZDxTypeName (tdeZDxType _eZDxType)
|
|
{
|
|
switch (_eZDxType)
|
|
{
|
|
case eZdd : return C_szZddName;
|
|
case eZde : return C_szZdeName;
|
|
case eZdm : return C_szZdmName;
|
|
case eZdr : return C_szZdrName;
|
|
case eBoundingVolume : return C_szBoundingVolumeName;
|
|
// ANNECY AV CLEAN_MEC {
|
|
// case eTestPoint : return C_szTestPointName;
|
|
// END ANNECY AV }
|
|
default : ASSERT (0);
|
|
return "";
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - GetSelectedActorSuperObject
|
|
// Return the selected actor super object. NULL if none
|
|
//-----------------------------------------------------------------------------
|
|
CPA_SuperObject * ZDx_Interface::GetSelectedActorSuperObject ()
|
|
{
|
|
if (M_GetCountSelected () != 1) return NULL;
|
|
|
|
// We look if the selected object is an actor
|
|
CPA_SuperObject * pSelectedSuperObject = M_GetSingleSelection ();
|
|
CPA_BaseObject * pSelectedObject = pSelectedSuperObject -> GetObject ();
|
|
|
|
if (! pSelectedObject) return NULL;
|
|
if (pSelectedObject -> fn_bIsOfType (C_szActorInstanceTypeName)) return pSelectedSuperObject;
|
|
|
|
// We look if the father is an actor
|
|
pSelectedSuperObject = pSelectedSuperObject -> GetSuperObjectFather ();
|
|
if (! pSelectedSuperObject) return NULL;
|
|
|
|
pSelectedObject = pSelectedSuperObject -> GetObject ();
|
|
if (! pSelectedObject) return NULL;
|
|
if (pSelectedObject -> fn_bIsOfType (C_szActorInstanceTypeName)) return pSelectedSuperObject;
|
|
|
|
return NULL;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ConvertZDxTypeToEngineType
|
|
// Convert a ZDx type to a type used by the engine
|
|
//-----------------------------------------------------------------------------
|
|
unsigned char ZDx_Interface::ConvertZDxTypeToEngineType (tdeZDxType _eZDxType)
|
|
{
|
|
switch (_eZDxType)
|
|
{
|
|
case eZdd : return C_ucTypeZdd;
|
|
case eZde : return C_ucTypeZde;
|
|
case eZdm : return C_ucTypeZdm;
|
|
case eZdr : return C_ucTypeZdr;
|
|
default : ASSERT (0);
|
|
return C_ucTypeZdd;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - GetZDxSuperObject
|
|
// Look at all childs of _pParentSuperObject to find the super object
|
|
// associated with the given ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
CPA_SuperObject * ZDx_Interface::GetZDxSuperObject (ZDx_Object * _pZDxObject , CPA_SuperObject * _pParentSuperObject)
|
|
{
|
|
CPA_SuperObject * pSuperObject = _pParentSuperObject -> GetSuperObjectFirstChild ();
|
|
while (pSuperObject)
|
|
{
|
|
if (pSuperObject -> GetObject () == _pZDxObject) return pSuperObject;
|
|
pSuperObject = _pParentSuperObject -> GetSuperObjectNextChild (pSuperObject);
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
|
|
//*****************************************************************************
|
|
// Personal functions for models
|
|
//*****************************************************************************
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - AddModelOfZDx
|
|
// Add all the models of ZDx into the model window
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::AddModelOfZDx ()
|
|
{
|
|
for (int i = 0 ; i < NumberOfZDxModels ; i ++)
|
|
{
|
|
GetInterface () -> fn_bAddANewModel (new EDT_Model
|
|
(this , ListOfZDxModels [i] . szZDxModelName ,
|
|
ListOfZDxModels [i] . szZDxModelName ,
|
|
ListOfZDxModels [i] . szBitmapName , GetInterface()) , C_szZDxListName , this);
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - RemoveModelOfZDx
|
|
// Remove all the models of ZDx from the model window
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::RemoveModelOfZDx ()
|
|
{
|
|
for (int i = 0 ; i < NumberOfZDxModels ; i ++)
|
|
{
|
|
GetInterface () -> fn_bRemoveAModel (ListOfZDxModels [i] . szZDxModelName , C_szZDxListName);
|
|
}
|
|
}
|
|
|
|
|
|
//*****************************************************************************
|
|
// Personal functions for ZDx creation
|
|
//*****************************************************************************
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - CreateSuperObject
|
|
// Create a super object
|
|
//-----------------------------------------------------------------------------
|
|
CPA_SuperObject * ZDx_Interface::CreateSuperObject ()
|
|
{
|
|
// Create a super object
|
|
CPA_SuperObject * pSuperObject = GetInterface () -> GetNewSuperObject (E_ss_NoSave);
|
|
|
|
// Create the matrix of the super object
|
|
HIE_fn_vSetSuperObjectMatrix (pSuperObject -> GetStruct () , (POS_tdstCompletePosition *) malloc (sizeof (POS_tdstCompletePosition )));
|
|
POS_fn_vSetIdentityMatrix(HIE_fn_hGetSuperObjectMatrix (pSuperObject -> GetStruct ()));
|
|
pSuperObject -> GetStruct () -> hGlobalMatrix = (POS_tdstCompletePosition *) malloc (sizeof (POS_tdstCompletePosition ));
|
|
POS_fn_vSetIdentityMatrix(HIE_fn_hGetSuperObjectGlobalMatrix (pSuperObject -> GetStruct ()));
|
|
|
|
return pSuperObject;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - CreateGraphicObject
|
|
// Create a graphic object (sphere, aligned box...)
|
|
// Return a Geometry3D object and a handle to the element
|
|
//-----------------------------------------------------------------------------
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
|
|
Shape3D * ZDx_Interface::CreateGraphicObject (tdeZDxGeometricType _eZDxGeometricType /*, ACP_tdxHandleOfElement * _pHandle */,
|
|
char * _szDataPath , const CString _csReferenceSectionName)
|
|
{
|
|
// Get the owner of the geometric object which is a CPA_BaseObject associated with the file name
|
|
CPA_DLLBase * pOgdDll = GetMainWorld () -> GetObjectDLLWithName (C_szDLLGeometryName);
|
|
ASSERT (pOgdDll);
|
|
CString csCompleteName = _szDataPath;
|
|
csCompleteName += "\\" + _csReferenceSectionName;
|
|
CPA_FileObject * pOwnerFile = GetInterface () -> GetFileObject (csCompleteName);
|
|
|
|
tdeSaveStatus eSaveStatus = _csReferenceSectionName . IsEmpty () ? E_ss_NoSave : E_ss_Responsible;
|
|
Shape3D * pGeometric3dObject;
|
|
|
|
switch (_eZDxGeometricType)
|
|
{
|
|
case eSphere: {
|
|
/*
|
|
pGeometric3dObject = new Geometry3D (pOgdDll , 1 , 1, pOwnerFile , "" , _szDataPath , eSaveStatus); // 1 point, 1 element
|
|
MTH3D_tdstVector stCenterPoint = { 0 , 0 , 0 };
|
|
pGeometric3dObject -> fn_vSetListOfPoints (1 , & stCenterPoint);
|
|
* _pHandle = pGeometric3dObject -> fn_hCreateElementSpheres (1);
|
|
pGeometric3dObject -> fn_eSetIndexedSphere (* _pHandle , 0 , 0 , (float) 0.1);
|
|
*/
|
|
pGeometric3dObject = new Sphere3D (TRUE, pOgdDll, pOwnerFile , "" , _szDataPath , eSaveStatus);
|
|
|
|
}
|
|
break;
|
|
|
|
case eBox: {
|
|
/*
|
|
pGeometric3dObject = new Geometry3D (pOgdDll , 2 , 1, pOwnerFile , "" , _szDataPath , eSaveStatus); // 2 points, 1 element
|
|
MTH3D_tdstVector stMinMaxPoints [2] = {{ (float) -0.1 , (float) -0.1 , (float) -0.1 } ,
|
|
{ (float) 0.1 , (float) 0.1 , (float) 0.1 }};
|
|
pGeometric3dObject -> fn_vSetListOfPoints (2 , stMinMaxPoints);
|
|
* _pHandle = pGeometric3dObject -> fn_hCreateElementAlignedBox (1);
|
|
pGeometric3dObject -> fn_eSetAlignedBox (* _pHandle, 0 , 0 , 1);
|
|
*/
|
|
pGeometric3dObject = new Box3D (TRUE, pOgdDll, pOwnerFile , "" , _szDataPath , eSaveStatus);
|
|
}
|
|
break;
|
|
|
|
case ePoint: {
|
|
/*
|
|
pGeometric3dObject = new Geometry3D (pOgdDll , 1 , 1, pOwnerFile , "" , _szDataPath , eSaveStatus); // 1 point, 1 element
|
|
MTH3D_tdstVector stPoint = { 0 , 0 , 0 };
|
|
pGeometric3dObject -> fn_vSetListOfPoints (1 , & stPoint);
|
|
* _pHandle = pGeometric3dObject -> fn_hCreateElementPoints (1);
|
|
pGeometric3dObject -> fn_eSetIndexedPoint (* _pHandle , 0 , 0);
|
|
pGeometric3dObject -> fn_eSetFatnessOfElementPoint (* _pHandle , (float) 8.0);
|
|
|
|
*/
|
|
pGeometric3dObject = new Point3D (pOgdDll, pOwnerFile , "" , _szDataPath , eSaveStatus);
|
|
}
|
|
break;
|
|
|
|
case eCone: {
|
|
/*
|
|
pGeometric3dObject = new Geometry3D (pOgdDll , 2 , 1, pOwnerFile , "" , _szDataPath , eSaveStatus); // 2 points, 1 element
|
|
MTH3D_tdstVector stPoints [2] = {{ 0 , 0 , 0 } , { 0 , 0 , 1 }};
|
|
pGeometric3dObject -> fn_vSetListOfPoints (2 , stPoints);
|
|
* _pHandle = pGeometric3dObject -> fn_hCreateElementCone (1);
|
|
pGeometric3dObject -> fn_eSetCone (* _pHandle , 0 , 0 , 1 , (float) 0.1);
|
|
*/
|
|
|
|
pGeometric3dObject = new Cone3D (TRUE, pOgdDll, pOwnerFile , "" , _szDataPath , eSaveStatus);
|
|
}
|
|
break;
|
|
|
|
default: ASSERT (0); break;
|
|
}
|
|
//pGeometric3dObject -> fn_vEndCreation ();
|
|
pGeometric3dObject -> fn_vEndCreation ();
|
|
pGeometric3dObject -> fn_vAllocAndComputeListOfPointsMaterial ();
|
|
|
|
return pGeometric3dObject;
|
|
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - CreateGraphicSuperObject
|
|
// Create a graphic super object (sphere, aligned box...)
|
|
// Return a super object and a handle to the element
|
|
//-----------------------------------------------------------------------------
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
|
|
CPA_SuperObject * ZDx_Interface::CreateGraphicSuperObject (tdeZDxGeometricType _eZDxGeometricType /*, ACP_tdxHandleOfElement * pHandle */,
|
|
char * _szDataPath , const CString _csReferenceSectionName)
|
|
{
|
|
CPA_SuperObject * pSuperObject = CreateSuperObject ();
|
|
Shape3D * pGeometric3dObject = CreateGraphicObject (_eZDxGeometricType /*, pHandle */, _szDataPath , _csReferenceSectionName);
|
|
|
|
pSuperObject -> SetObject (pGeometric3dObject);
|
|
pSuperObject -> SetTypeSO (C_Protected);
|
|
|
|
pGeometric3dObject->SetSuperObject (pSuperObject);
|
|
|
|
return pSuperObject;
|
|
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - GetFamilyForNewInstance
|
|
// Give the family of a new created ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
CPA_BaseObject * ZDx_Interface::GetFamilyForNewInstance (CPA_BaseObject * _pParent)
|
|
{
|
|
// We find the family of the actor
|
|
CPA_BaseObject * pActor;
|
|
if (m_pList1Window -> IsEditingZDxOfModule ()) pActor = m_pList1Window -> GetSelectedActor(); // ZDx of module : we get the parent from the List1Window
|
|
else pActor = _pParent; // ZDx of actor : the actor is the parent
|
|
ASSERT (pActor);
|
|
CPA_BaseObject * pModel = pActor -> GetOwner ();
|
|
ASSERT (pModel);
|
|
CPA_BaseObject * pFamily = pModel -> GetOwner ();
|
|
ASSERT (pFamily);
|
|
|
|
return pFamily;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ComputeSectionNameForNewInstance
|
|
// Compute the data path and the reference section name to give to a created ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ComputeSectionNameForNewInstance (char * * _p_szDataPath , CString * _p_csReferenceSectionName ,
|
|
CPA_BaseObject * _pParent)
|
|
{
|
|
CPA_BaseObject * pFamily = GetFamilyForNewInstance (_pParent);
|
|
|
|
* _p_szDataPath = fn_szGetLevelsDataPath ();
|
|
|
|
// ANNECY AV CLEAN_MEC {
|
|
/*
|
|
if (m_pList1Window -> IsEditingTestPoint ()) // ZDx object that are test points are not saved
|
|
{
|
|
* _p_csReferenceSectionName = "";
|
|
return;
|
|
}
|
|
*/
|
|
// END ANNECY AV }
|
|
|
|
if (m_pList1Window -> IsEditingBoundingVolume ()) // Set the file name for the bounding volume
|
|
{
|
|
* _p_csReferenceSectionName = "_Common\\Families\\" + pFamily -> GetName () + "\\" + pFamily -> GetName () + C_szBoundingVolumeFileExtension;
|
|
return;
|
|
}
|
|
|
|
if (m_pList1Window -> IsEditingZDxOfModule ()) // Zone of module
|
|
{
|
|
CPA_BaseObject * pObjectTable = _pParent -> GetOwner ();
|
|
ASSERT (pObjectTable);
|
|
CString csObjectTableName = pObjectTable -> GetName ();
|
|
int PosPoint = csObjectTableName . Find ('.');
|
|
if (PosPoint != -1) csObjectTableName = csObjectTableName . Left (PosPoint);
|
|
* _p_csReferenceSectionName = pFamily -> GetName () + "\\" + csObjectTableName + C_szModuleZDxFileExtension;
|
|
* _p_szDataPath = fn_szGetFamiliesDataPath ();
|
|
}
|
|
else // Set the file name for a zone of actor
|
|
{
|
|
// We get the selected position in the list 2, and we check if it is empty
|
|
tdeZDxType eZDxType;
|
|
long lPosition;
|
|
if (m_pList2Window -> GetSelectedZDx (& eZDxType , & lPosition) != NULL || lPosition == -1)
|
|
{
|
|
// if not, we select an empty position
|
|
m_pList2Window -> SelectZDx (NULL , TRUE);
|
|
m_pList2Window -> GetSelectedZDx (& eZDxType , & lPosition);
|
|
}
|
|
// Get the name list
|
|
CPA_tdoNameList * pNameList = GetNameList (_pParent , eZDxType);
|
|
// Get the name associated to the ZDx object to insert
|
|
POSITION Pos = pNameList -> GetHeadPosition ();
|
|
tdoObjectName * pName;
|
|
while (lPosition-- >= 0)
|
|
pName = pNameList -> GetNext (Pos);
|
|
|
|
if (pName -> m_eGetShareMode () == E_sm_Virge) // Specific name
|
|
{
|
|
char szTmp [SCR_CV_ui_Cfg_MaxLenName];
|
|
fn_zsGetActualLevelFilename (szTmp , ""); // szSectionName = "GameData\Level\Cave\Cave."
|
|
char * p = strrchr (szTmp , '.');
|
|
if (p) * p = 0; // If there is a '.' at the end of the name, remove it
|
|
p = strrchr (szTmp , '\\') + 1; // p = "Cave"
|
|
|
|
* _p_csReferenceSectionName = p;
|
|
* _p_csReferenceSectionName += "\\Families\\" + pFamily -> GetName () + "\\" + pFamily -> GetName () + C_szActorZDxFileExtension;
|
|
}
|
|
else
|
|
{
|
|
* _p_csReferenceSectionName = "_Common\\Families\\" + pFamily -> GetName () + "\\" + pFamily -> GetName () + C_szActorZDxFileExtension;
|
|
}
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - GetNewInstanceWithSameZDxObject
|
|
// Same function as GetNewInstance, but use an existing ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
CPA_SuperObject * ZDx_Interface::GetNewInstanceWithSameZDxObject (ZDx_Object * pZDxObject ,
|
|
char * szZDxGeometricTypeName)
|
|
{
|
|
// Create a super object for the graphic object
|
|
CPA_SuperObject * pGraphicSuperObject = CreateSuperObject ();
|
|
|
|
//ANNECY TQ 29/04/98{
|
|
if(pZDxObject -> GetZDxType () == eZdm)
|
|
pGraphicSuperObject -> fn_vHasALinkedZDM(TRUE);
|
|
else
|
|
pGraphicSuperObject -> fn_vHasALinkedZDM(FALSE);
|
|
//ENDANNECY TQ}
|
|
|
|
HIE_fn_vSetSuperObjectTransparenceLevel(pGraphicSuperObject->GetStruct(), 100);
|
|
|
|
// Create a super object
|
|
CPA_SuperObject * pSuperObject = CreateSuperObject ();
|
|
|
|
// Give it the graphic super object as child
|
|
pGraphicSuperObject -> SetEditProtected (TRUE); // So the user cannot move it
|
|
pGraphicSuperObject -> SetSuperObjectOwner (pSuperObject);
|
|
pSuperObject -> AddTail (pGraphicSuperObject);
|
|
|
|
// set the model name of the super object
|
|
pSuperObject -> SetModelName (szZDxGeometricTypeName);
|
|
|
|
// Give the graphic object of the ZDx object to the graphic super object
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
Shape3D * pGeometric3dObject = pZDxObject -> GetZDxShape () -> GetGeometric3dObject ();
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
pGraphicSuperObject -> SetObject (pGeometric3dObject);
|
|
|
|
// Give the ZDx object to the super object
|
|
pSuperObject -> SetObject (pZDxObject);
|
|
|
|
// Set the type of the super object and the graphic super object
|
|
pSuperObject -> SetTypeSO (C_Protected);
|
|
pGraphicSuperObject -> SetTypeSO (C_Protected);
|
|
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
pGeometric3dObject -> SetSuperObject (pGraphicSuperObject);
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
|
|
return pSuperObject;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - CreateZdxObject
|
|
// Create a new Zdx with an existing engine zone (no NotifySave because it is for loading)
|
|
//-----------------------------------------------------------------------------
|
|
ZDx_Object * ZDx_Interface::CreateZdxObject (LPARAM lParam)
|
|
{
|
|
tdstCreateZoneMess * p_stCreateZoneMess = (tdstCreateZoneMess *) lParam;
|
|
|
|
CString csTypeName = p_stCreateZoneMess -> csTypeName;
|
|
ACP_tdxHandleOfObject hEngineZone = (ACP_tdxHandleOfObject) p_stCreateZoneMess -> hEngineZone;
|
|
CString csZDxName = p_stCreateZoneMess -> csName;
|
|
CPA_BaseObject * pOwner = p_stCreateZoneMess -> pOwner;
|
|
char * szDataPath = p_stCreateZoneMess -> szDataPath;
|
|
CString csReferenceSectionName = p_stCreateZoneMess -> csReferenceSectionName;
|
|
if (csReferenceSectionName . Find (SCR_CC_sz_Cfg_NameSeparator) == -1)
|
|
csReferenceSectionName += SCR_CC_sz_Cfg_NameSeparator;
|
|
|
|
tdeZDxType eZDxType = ConvertListTypeToZDxType (csTypeName);
|
|
|
|
// We check if there is already a ZDx object with this engine zone
|
|
ZDx_Object * pExistingZDxObject = (ZDx_Object *) GetMainWorld () -> fn_p_oFindObjectWithEngine (hEngineZone , csTypeName);
|
|
if (pExistingZDxObject) return pExistingZDxObject;
|
|
|
|
// Compute the ZDx geometric type
|
|
tdeZDxGeometricType eZDxGeometricType;
|
|
switch (GEO_xGetElementType (hEngineZone , 0))
|
|
{
|
|
case GEO_C_xElementSpheres : eZDxGeometricType = eSphere; break;
|
|
case GEO_C_xElementAlignedBoxes : eZDxGeometricType = eBox; break;
|
|
case GEO_C_xElementPoints : eZDxGeometricType = ePoint; break;
|
|
case GEO_C_xElementCones : eZDxGeometricType = eCone; break;
|
|
default : { // The object has itself or another PO as Zdr
|
|
CPA_BaseObjectList * pPoList = GetMainWorld () -> fn_p_oGetOriginalObjectList (C_szPhysicalObjectTypeName);
|
|
ASSERT (pPoList);
|
|
|
|
Position Pos = pPoList -> GetHeadPosition ();
|
|
while (Pos)
|
|
{
|
|
EditorPO * pPo = (EditorPO *) pPoList -> GetNext (Pos);
|
|
Geometry3D * pGeometricObject = pPo -> m_fnp_oGetGeometricWithDistance (0);
|
|
if (pGeometricObject && pGeometricObject -> GetData () == hEngineZone)
|
|
return (ZDx_Object *) pPo;
|
|
}
|
|
|
|
return NULL; // Not found
|
|
}
|
|
}
|
|
|
|
// Create the geometric 3d object
|
|
char szShortFileName [SCR_CV_ui_Cfg_MaxLenName];
|
|
SCR_fn_v_RdL0_SplitSectionName ( (char *) (LPCTSTR) csReferenceSectionName , szShortFileName , NULL , NULL);
|
|
|
|
CPA_DLLBase * pOgdDll = GetMainWorld () -> GetObjectDLLWithName (C_szDLLGeometryName);
|
|
ASSERT (pOgdDll );
|
|
CString csCompleteName = szDataPath;
|
|
csCompleteName += "\\";
|
|
csCompleteName += szShortFileName;
|
|
CPA_FileObject * pOwnerFile = GetInterface () -> GetFileObject (csCompleteName);
|
|
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
// create the right geom object
|
|
Shape3D * pGeometric3dObject;
|
|
switch (eZDxGeometricType)
|
|
{
|
|
case eSphere:
|
|
pGeometric3dObject = new Sphere3D (TRUE, pOgdDll , pOwnerFile , hEngineZone , csZDxName , szDataPath , E_ss_Responsible);
|
|
break;
|
|
case eBox:
|
|
pGeometric3dObject = new Box3D (TRUE, pOgdDll , pOwnerFile , hEngineZone , csZDxName , szDataPath , E_ss_Responsible);
|
|
break;
|
|
case eCone:
|
|
pGeometric3dObject = new Cone3D (TRUE, pOgdDll , pOwnerFile , hEngineZone , csZDxName , szDataPath , E_ss_Responsible);
|
|
break;
|
|
case ePoint:
|
|
pGeometric3dObject = new Point3D (pOgdDll , pOwnerFile , hEngineZone , csZDxName , szDataPath , E_ss_Responsible);
|
|
break;
|
|
default:
|
|
ASSERT (FALSE);
|
|
//pGeometric3dObject = new Shape3D (TRUE, pOgdDll , pOwnerFile , hEngineZone , csZDxName , szDataPath , E_ss_Responsible);
|
|
}
|
|
|
|
// Create the ZDx object
|
|
ZDx_Object * pNewZDxObject = new ZDx_Object (this , csTypeName , eZDxType , eZDxGeometricType , csZDxName ,
|
|
pOwner , pGeometric3dObject /*, 0*/);
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
return pNewZDxObject;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - CreateZdxTestPoints
|
|
// For each test point in the given list, create an associated ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
// ANNECY AV CLEAN_MEC {
|
|
/*
|
|
void ZDx_Interface::CreateZdxTestPoints (CPA_TestPointsList * _pTestPointList)
|
|
{
|
|
// Get the Geometry dll
|
|
CPA_DLLBase * pOgdDll = GetMainWorld () -> GetObjectDLLWithName (C_szDLLGeometryName);
|
|
ASSERT (pOgdDll );
|
|
|
|
POSITION Pos = _pTestPointList -> m_oListOfTestPoints . GetHeadPosition ();
|
|
while (Pos)
|
|
{
|
|
// We get one Test Point from the list
|
|
CPA_TestPointNode * pTestPoint = _pTestPointList -> m_oListOfTestPoints . GetNext (Pos);
|
|
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
// Create the geometric 3d object
|
|
// Shape3D * pGeometric3dObject = new Shape3D (TRUE, pOgdDll , 1 , 1);
|
|
// MTH3D_tdstVector stPoint;
|
|
// pTestPoint -> mfn_vGetPosition (& stPoint);
|
|
// pGeometric3dObject -> fn_vSetListOfPoints (1 , & stPoint);
|
|
// ACP_tdxHandleOfElement hHandleOfElement = pGeometric3dObject -> fn_hCreateElementPoints (1);
|
|
// pGeometric3dObject -> fn_eSetIndexedPoint (hHandleOfElement , 0 , 0);
|
|
// pGeometric3dObject -> fn_eSetFatnessOfElementPoint (hHandleOfElement , (float) 8.0);
|
|
|
|
Point3D * pGeometric3dObject = new Point3D (pOgdDll);
|
|
MTH3D_tdstVector stPoint;
|
|
pTestPoint -> mfn_vGetPosition (& stPoint);
|
|
pGeometric3dObject -> SetPoint (& stPoint);
|
|
//never true!
|
|
//if (m_pZDxObject -> GetZDxType () == eTestPoint) UpdateTestPointPosition ();
|
|
|
|
// Create the ZDx object
|
|
ZDx_Object * pNewZDxObject = new ZDx_Object (this , C_szTestPointName , eTestPoint , ePoint , "" , NULL , pGeometric3dObject ); //, hHandleOfElement);
|
|
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
// Give the created ZDx object to the test point
|
|
pTestPoint -> SetZdxObject (pNewZDxObject);
|
|
pNewZDxObject -> SetTestPoint (pTestPoint);
|
|
}
|
|
}
|
|
*/
|
|
// END ANNECY AV }
|
|
|
|
//*****************************************************************************
|
|
// Communication with hierarchy editor
|
|
//*****************************************************************************
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - AskHierarchyEditorToSelectObject
|
|
// Ask the hierarchy editor to select an object (NULL to cancel the selection)
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::AskHierarchyEditorToSelectObject (CPA_SuperObject * _pSuperObject)
|
|
{
|
|
if (m_bIsSelectingObject) return;
|
|
|
|
m_bIsAskingToSelectObject = TRUE;
|
|
|
|
GetInterface () -> fn_vCancelCurrentSelection (FALSE);
|
|
if (_pSuperObject) GetInterface () -> fn_vAddSelectedObject (_pSuperObject , FALSE);
|
|
|
|
m_bIsAskingToSelectObject = FALSE;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - InsertZDxObjectIntoHierarchy
|
|
// Ask the hierarchy editor to insert a ZDx object into the hierarchy
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::InsertZDxObjectIntoHierarchy (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pParentSuperObject)
|
|
{
|
|
m_bIsInsertingZDxObject = TRUE;
|
|
|
|
GetInterface () -> fn_bInsertObjectInHierarchy (_pZDxSuperObject , _pParentSuperObject , FALSE , FALSE);
|
|
|
|
m_bIsInsertingZDxObject = FALSE;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - DeleteZDxObjectFromHierarchy
|
|
// Ask the hierarchy editor to delete a ZDx object from the hierarchy
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::DeleteZDxObjectFromHierarchy (CPA_SuperObject * _pZDxSuperObject)
|
|
{
|
|
m_bIsDeletingZDxObject = TRUE;
|
|
|
|
// We call the hierarchy editor to delete the ZDx super object from the hierarchy
|
|
GetInterface () -> fn_bDeleteObjectInHierarchy (_pZDxSuperObject , FALSE , FALSE);
|
|
|
|
m_bIsDeletingZDxObject = FALSE;
|
|
}
|
|
|
|
|
|
//*****************************************************************************
|
|
// Show / Hide ZDx objects
|
|
//*****************************************************************************
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - SetDisplayFlag
|
|
// Set the display flag of all ZDx of the list
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::SetDisplayFlag (EdtList * _pListOfZDx , tdeZDxDisplayType _eDisplayType)
|
|
{
|
|
POSITION PosZDx = _pListOfZDx -> GetHeadPosition();
|
|
while (PosZDx)
|
|
{
|
|
ZDx_Object * pZDxObject = (ZDx_Object *) _pListOfZDx -> GetNext (PosZDx);
|
|
if (pZDxObject) pZDxObject -> SetDisplay (_eDisplayType);
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - SetDisplayFlag
|
|
// Set the display zone flag of all test points of the list
|
|
//-----------------------------------------------------------------------------
|
|
// ANNECY AV CLEAN_MEC {
|
|
/*
|
|
void ZDx_Interface::SetDisplayFlag (CPA_TestPointsList * _pListOfTestPoint , tdeZDxDisplayType _eDisplayType)
|
|
{
|
|
POSITION Pos = _pListOfTestPoint -> m_oListOfTestPoints . GetHeadPosition ();
|
|
while (Pos)
|
|
{
|
|
CPA_TestPointNode * pTestPoint = _pListOfTestPoint -> m_oListOfTestPoints . GetNext (Pos);
|
|
ASSERT (pTestPoint);
|
|
|
|
ZDx_Object * pZDxObject = pTestPoint -> mfn_p_oGetZdxObject ();
|
|
ASSERT (pZDxObject);
|
|
|
|
pZDxObject -> SetDisplay (_eDisplayType);
|
|
}
|
|
}
|
|
*/
|
|
// END ANNECY AV }
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - SetDisplayFlagOfAllActors
|
|
// Set the display zone flag of all actors
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::SetDisplayFlagOfAllActors (BOOL _bNewFlag)
|
|
{
|
|
CPA_BaseObjectList * pListOfActor = GetMainWorld () -> fn_p_oGetOriginalObjectList (C_szActorInstanceTypeName);
|
|
|
|
for (int i = 0 ; i < pListOfActor -> GetCount () ; i ++)
|
|
{
|
|
CPA_Actor * pActor = (CPA_Actor *) pListOfActor -> GetObjectWithIndex (i);
|
|
pActor -> SetDisplayZone (_bNewFlag);
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - SetAspectOfZDx
|
|
// Set the graphical aspect of a ZDx : selected or not selected
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::SetAspectOfZDx (CPA_SuperObject * _pSuperObject , BOOL _bSelected)
|
|
{
|
|
// Sometimes, _pSuperObject can be NULL, because we try to set the aspect of a ZDx object which is not shown
|
|
if (_pSuperObject == NULL) return;
|
|
|
|
// long lDrawMask = _bSelected ? 0 // Wired
|
|
// : C_lGouraudElement; // Gouraud
|
|
|
|
long lDrawMask = 0x4ddc037e; //Gouraud with Outline and Wire
|
|
|
|
HIE_fn_vSetSuperObjectDrawMask (_pSuperObject -> GetStruct () , lDrawMask);
|
|
|
|
// Special treatment for the points
|
|
ZDx_Object * pZDxObject = (ZDx_Object *) _pSuperObject -> GetObject ();
|
|
if (pZDxObject && pZDxObject -> GetZDxGeometricType () == ePoint)
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
((Point3D *)((ZDx_Point *) pZDxObject -> GetZDxShape ()) -> GetGeometric3dObject ()) -> SetColorOfPoint (_bSelected);
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
|
|
// We also change the draw mask of the actor for the zones to be showed
|
|
CPA_SuperObject * pParent = _pSuperObject -> GetSuperObjectFather ();
|
|
if (pParent) HIE_fn_vSetSuperObjectDrawMask (pParent -> GetStruct () ,
|
|
GLI_C_lAllIsEnable ^ GLI_C_lIsNotDrawCollideInformation);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - PutZDxIntoHierarchy
|
|
// Put a ZDx as child of a super object into the hierarchy
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::PutZDxIntoHierarchy (CPA_SuperObject * _pFatherSuperObject ,
|
|
ZDx_Object * _pZDxObject ,
|
|
BOOL _bSelectZDx ,
|
|
BOOL _bSetEditProtected /* = FALSE */)
|
|
{
|
|
char * szGeometricTypeName;
|
|
switch (_pZDxObject -> GetZDxGeometricType ())
|
|
{
|
|
case eSphere : szGeometricTypeName = C_szZDxSphereName; break;
|
|
case eBox : szGeometricTypeName = C_szZDxBoxName; break;
|
|
case ePoint : szGeometricTypeName = C_szZDxPointName; break;
|
|
case eCone : szGeometricTypeName = C_szZDxConeName; break;
|
|
default: ASSERT (0); break;
|
|
}
|
|
|
|
CPA_SuperObject * pSuperObject = GetNewInstanceWithSameZDxObject (_pZDxObject , szGeometricTypeName);
|
|
pSuperObject -> SetEditProtected (_bSetEditProtected);
|
|
|
|
GetInterface () -> fn_bInsertObjectInHierarchy (pSuperObject , _pFatherSuperObject , FALSE , FALSE, FALSE);
|
|
SetAspectOfZDx (pSuperObject , _bSelectZDx); // must be called when the ZDx has a father
|
|
_pZDxObject -> SetDisplay (eDisplayed);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - CheckAndPutZDxIntoHierarchy
|
|
// Check if the ZDx must be put into the hierarchy
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::CheckAndPutZDxIntoHierarchy (CPA_SuperObject * _pFatherSuperObject ,
|
|
ZDx_Object * _pZDxObject ,
|
|
BOOL _bSelectZDx ,
|
|
BOOL _bSetEditProtected /* = FALSE */)
|
|
{
|
|
if (_pZDxObject == NULL) return;
|
|
switch (_pZDxObject -> GetDisplay ())
|
|
{
|
|
case eNotDisplayed : PutZDxIntoHierarchy (_pFatherSuperObject , _pZDxObject , _bSelectZDx , _bSetEditProtected);
|
|
break;
|
|
|
|
case eDisplayed : {
|
|
//??? A FAIRE CORRECTEMENT PLUS TARD CAR METHODE TROP LENTE
|
|
CPA_SuperObject * pZDxSuperObject = GetZDxSuperObject (_pZDxObject , _pFatherSuperObject);
|
|
SetAspectOfZDx (pZDxSuperObject , _bSelectZDx);
|
|
}
|
|
break;
|
|
|
|
default : ASSERT (0);
|
|
break;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - PutListOfZDxIntoHierarchy
|
|
// Put a list of ZDx as childs of a super object into the hierarchy
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::PutListOfZDxIntoHierarchy (EdtList * _pListOfZDx ,
|
|
CPA_SuperObject * _pFatherSuperObject ,
|
|
ZDx_Object * _pZDxObjectToSelect ,
|
|
BOOL _bUseDisplayFlag ,
|
|
BOOL _bSetEditProtected /* = FALSE */)
|
|
{
|
|
POSITION PosZDx = _pListOfZDx -> GetHeadPosition ();
|
|
while (PosZDx)
|
|
{
|
|
ZDx_Object * pZDxObject = (ZDx_Object *) _pListOfZDx -> GetNext (PosZDx);
|
|
if (_bUseDisplayFlag && pZDxObject && pZDxObject -> GetMotorDisplay () == FALSE && pZDxObject != _pZDxObjectToSelect)
|
|
continue;
|
|
|
|
CheckAndPutZDxIntoHierarchy (_pFatherSuperObject , pZDxObject , pZDxObject == _pZDxObjectToSelect , _bSetEditProtected);
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - PutListOfTestPointIntoHierarchy
|
|
// Put a list of test points as childs of a super object into the hierarchy
|
|
//-----------------------------------------------------------------------------
|
|
// ANNECY AV CLEAN_MEC {
|
|
/*
|
|
void ZDx_Interface::PutListOfTestPointIntoHierarchy (CPA_TestPointsList * _pListOfTestPoint ,
|
|
CPA_SuperObject * _pFatherSuperObject ,
|
|
ZDx_Object * _pZDxObjectToSelect ,
|
|
BOOL _bUseDisplayFlag ,
|
|
BOOL _bSetEditProtected)
|
|
{
|
|
POSITION Pos = _pListOfTestPoint -> m_oListOfTestPoints . GetHeadPosition ();
|
|
while (Pos)
|
|
{
|
|
CPA_TestPointNode * pTestPoint = _pListOfTestPoint -> m_oListOfTestPoints . GetNext (Pos);
|
|
ZDx_Object * pZDxObject = pTestPoint -> mfn_p_oGetZdxObject ();
|
|
if (_bUseDisplayFlag && pZDxObject && pZDxObject -> GetMotorDisplay () == FALSE) continue;
|
|
|
|
CheckAndPutZDxIntoHierarchy (_pFatherSuperObject , pZDxObject , pZDxObject == _pZDxObjectToSelect , _bSetEditProtected);
|
|
}
|
|
}
|
|
*/
|
|
// END ANNECY AV }
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ShowZDxOfActor
|
|
// Show the ZDx of a instance (insert ZDx objects in the hierarchy)
|
|
// Return TRUE if something has been modified
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ShowZDxOfActor (CPA_SuperObject * _pActorSuperObject , unsigned char _ucZDxToShow ,
|
|
ZDx_Object * _pZDxToSelect /* = NULL */ ,
|
|
BOOL _bUseDisplayFlag /* = TRUE */ ,
|
|
BOOL _bSetEditProtected /* = FALSE */)
|
|
{
|
|
CPA_BaseObject * pActor = _pActorSuperObject -> GetObject ();
|
|
|
|
if (m_pActorSuperObjectToUnselect && m_pActorSuperObjectToUnselect != _pActorSuperObject) // One actor to unselect
|
|
{
|
|
CPA_Actor * pActorToUnselect = (CPA_Actor *) m_pActorSuperObjectToUnselect -> GetObject ();
|
|
unsigned char ucZDxToShow;
|
|
tdeDisplayType eDisplayForAllActors = m_pDisplayControlWindow -> GetDisplayForAllActors ();
|
|
switch (eDisplayForAllActors)
|
|
{
|
|
case eNoZone :
|
|
case eOff : ucZDxToShow = C_ucHideAllZDx; break;
|
|
case eOn : ucZDxToShow = C_ucShowAllZDx; break;
|
|
case eSelected : if (pActorToUnselect -> GetDisplayZone ()) ucZDxToShow = C_ucShowAllZDx;
|
|
else ucZDxToShow = C_ucHideAllZDx;
|
|
break;
|
|
}
|
|
ShowZDxOfActor (m_pActorSuperObjectToUnselect , ucZDxToShow , NULL ,
|
|
eDisplayForAllActors == eSelected ? (int) pActorToUnselect -> GetDisplayZone () == 2 : FALSE);
|
|
HideModuleZDxOfActor (m_pActorSuperObjectToUnselect);
|
|
m_pActorSuperObjectToUnselect = NULL;
|
|
}
|
|
|
|
m_bIsShowingOrHidingZDx = TRUE;
|
|
|
|
BOOL bShowZdd = (_ucZDxToShow & C_ucShowZDD) != 0;
|
|
BOOL bShowZde = (_ucZDxToShow & C_ucShowZDE) != 0;
|
|
BOOL bShowZdm = (_ucZDxToShow & C_ucShowZDM) != 0;
|
|
BOOL bShowZdr = (_ucZDxToShow & C_ucShowZDR) != 0;
|
|
// ANNECY AV CLEAN_MEC {
|
|
// BOOL bShowTestPoint = (_ucZDxToShow & C_ucShowTestPoint) != 0;
|
|
// END ANNECY AV }
|
|
|
|
// Set all display flags to eNotDisplayed
|
|
EdtList * pListOfZdd = GetZDxList (pActor , eZdd);
|
|
EdtList * pListOfZde = GetZDxList (pActor , eZde);
|
|
EdtList * pListOfZdm = GetZDxList (pActor , eZdm);
|
|
EdtList * pListOfZdr = GetZDxList (pActor , eZdr);
|
|
// ANNECY AV CLEAN_MEC {
|
|
// CPA_TestPointsList * pListOfTestPoint = NULL;
|
|
// if (m_pList1Window -> IsEditingTestPoint ()) pListOfTestPoint = m_pList2Window -> GetListOfTestPoint ();
|
|
// END ANNECY AV }
|
|
|
|
if (pListOfZdd ) SetDisplayFlag (pListOfZdd , eNotDisplayed);
|
|
if (pListOfZde ) SetDisplayFlag (pListOfZde , eNotDisplayed);
|
|
if (pListOfZdm ) SetDisplayFlag (pListOfZdm , eNotDisplayed);
|
|
if (pListOfZdr ) SetDisplayFlag (pListOfZdr , eNotDisplayed);
|
|
// ANNECY AV CLEAN_MEC {
|
|
// if (pListOfTestPoint) SetDisplayFlag (pListOfTestPoint , eNotDisplayed);
|
|
// END ANNECY AV }
|
|
|
|
// We look for all ZDx child of the actors :
|
|
// For each ZDx, we set its Display flag, and we remove it from the hierarchy if it must not be shown
|
|
CPA_SuperObject * pSuperObject = _pActorSuperObject -> GetSuperObjectFirstChild ();
|
|
CPA_SuperObject * pNextChild;
|
|
while (pSuperObject)
|
|
{
|
|
pNextChild = _pActorSuperObject -> GetSuperObjectNextChild (pSuperObject);
|
|
|
|
// No object or not a ZDx -> go to the next child
|
|
CPA_BaseObject * pObject = pSuperObject -> GetObject ();
|
|
if (pObject == NULL || ! M_bIsThisObjectAZDx (pObject))
|
|
{
|
|
pSuperObject = pNextChild;
|
|
continue;
|
|
}
|
|
|
|
ZDx_Object * pZDxObject = (ZDx_Object *) pObject;
|
|
long lEngineType = pZDxObject -> GetDataType ();
|
|
|
|
if (!m_pList1Window -> IsEditingBoundingVolume() &&
|
|
((lEngineType == C_lZDD && ! bShowZdd) // if the ZDx must not be shown
|
|
|| (lEngineType == C_lZDE && ! bShowZde)
|
|
|| (lEngineType == C_lZDM && ! bShowZdm)
|
|
|| (lEngineType == C_lZDR && ! bShowZdr)
|
|
|| (lEngineType == C_lBoundingVolume)
|
|
// ANNECY AV CLEAN_MEC {
|
|
// || (lEngineType == C_lTestPoint && ! bShowTestPoint)
|
|
// END ANNECY AV }
|
|
|| (_bUseDisplayFlag && pZDxObject -> GetMotorDisplay () == FALSE && pZDxObject != _pZDxToSelect))
|
|
)
|
|
{
|
|
pZDxObject -> SetDisplay (eNotDisplayed);
|
|
|
|
// Remove the object from the hierarchy
|
|
GetInterface () -> fn_bDeleteObjectInHierarchy (pSuperObject , FALSE , FALSE);
|
|
}
|
|
else
|
|
{
|
|
pZDxObject -> SetDisplay (eDisplayed);
|
|
SetAspectOfZDx (pSuperObject , pZDxObject == _pZDxToSelect);
|
|
pSuperObject -> SetEditProtected (_bSetEditProtected);
|
|
}
|
|
|
|
pSuperObject = pNextChild;
|
|
}
|
|
|
|
if (bShowZdd && pListOfZdd)
|
|
PutListOfZDxIntoHierarchy (pListOfZdd , _pActorSuperObject , _pZDxToSelect , _bUseDisplayFlag , _bSetEditProtected);
|
|
|
|
if (bShowZde && pListOfZde)
|
|
PutListOfZDxIntoHierarchy (pListOfZde , _pActorSuperObject , _pZDxToSelect , _bUseDisplayFlag , _bSetEditProtected);
|
|
|
|
if (bShowZdm && pListOfZdm)
|
|
PutListOfZDxIntoHierarchy (pListOfZdm , _pActorSuperObject , _pZDxToSelect , _bUseDisplayFlag , _bSetEditProtected);
|
|
|
|
if (bShowZdr && pListOfZdr)
|
|
PutListOfZDxIntoHierarchy (pListOfZdr , _pActorSuperObject , _pZDxToSelect , _bUseDisplayFlag , _bSetEditProtected);
|
|
|
|
// ANNECY AV CLEAN_MEC {
|
|
// if (bShowTestPoint && pListOfTestPoint)
|
|
// PutListOfTestPointIntoHierarchy (pListOfTestPoint , _pActorSuperObject , _pZDxToSelect , _bUseDisplayFlag , _bSetEditProtected);
|
|
// END ANNECY AV }
|
|
|
|
// If there is a ZDx object to select, we select it
|
|
if (_pZDxToSelect && ((GetInterface()->GetSelectMode() == "All Types") || (GetInterface()->GetSelectMode() == C_szZddName)
|
|
|| (GetInterface()->GetSelectMode() == C_szZdeName)
|
|
|| (GetInterface()->GetSelectMode() == C_szZdmName)
|
|
|| (GetInterface()->GetSelectMode() == C_szZdrName)))
|
|
{
|
|
CPA_SuperObject * pSuperObjectToSelect = GetZDxSuperObject (_pZDxToSelect , _pActorSuperObject);
|
|
if (pSuperObjectToSelect)
|
|
{
|
|
GetInterface () -> fn_vCancelCurrentSelection (FALSE);
|
|
GetInterface () -> fn_vAddSelectedObject (pSuperObjectToSelect , FALSE);
|
|
}
|
|
}
|
|
|
|
m_bIsShowingOrHidingZDx = FALSE;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - ShowAllZDxOfAllActors
|
|
// Insert all ZDx of all actors into the hierarchy
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ShowAllZDxOfAllActors (unsigned char _ucZDxToShow , BOOL _bShowOnlySelected)
|
|
{
|
|
IWillRefreshDisplay (C_lShowZDxOfAllActors);
|
|
|
|
m_pActorSuperObjectToUnselect = NULL;
|
|
|
|
CPA_List<CPA_SuperObject> * pListOfActorSuperObject = GetInterface () -> GetObjectListByType (C_szActorInstanceTypeName);
|
|
|
|
POSITION Pos = pListOfActorSuperObject -> GetHeadPosition ();
|
|
while (Pos)
|
|
{
|
|
CPA_SuperObject * pActorSuperObject = pListOfActorSuperObject -> GetNext (Pos);
|
|
CPA_Actor * pActor = (CPA_Actor *) pActorSuperObject -> GetObject ();
|
|
|
|
unsigned char ucZDxToShow = _ucZDxToShow;
|
|
if (_bShowOnlySelected && pActor -> GetDisplayZone () == FALSE) ucZDxToShow = C_ucHideAllZDx;
|
|
|
|
// If _bShowOnlySelected, show only the zones that are selected, otherwise show all zones
|
|
ShowZDxOfActor (pActorSuperObject , ucZDxToShow , NULL , _bShowOnlySelected ? (int) pActor -> GetDisplayZone () == 2 : FALSE);
|
|
}
|
|
|
|
RefreshDisplay (C_lShowZDxOfAllActors);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ShowZDxOfModule
|
|
// Show the ZDx of the modules of an instance (insert ZDx objects in the hierarchy)
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ShowZDxOfModule (CPA_SuperObject * _pModuleSuperObject , unsigned char _ucZDxToShow ,
|
|
ZDx_Object * _pZDxToSelect , BOOL _bSetEditProtected /* = FALSE */)
|
|
{
|
|
if (m_pModuleSuperObjectToUnselect && m_pModuleSuperObjectToUnselect != _pModuleSuperObject)
|
|
{
|
|
ShowZDxOfModule (m_pModuleSuperObjectToUnselect , C_ucHideAllZDx , NULL);
|
|
m_pModuleSuperObjectToUnselect = NULL;
|
|
}
|
|
|
|
m_bIsShowingOrHidingZDx = TRUE;
|
|
|
|
EditorPO * pModule = (EditorPO *) _pModuleSuperObject -> GetObject ();
|
|
if (! pModule) return;
|
|
|
|
BOOL bShowZdd = (_ucZDxToShow & C_ucShowZDD) != 0;
|
|
BOOL bShowZde = (_ucZDxToShow & C_ucShowZDE) != 0;
|
|
BOOL bShowZdm = (_ucZDxToShow & C_ucShowZDM) != 0;
|
|
BOOL bShowZdr = (_ucZDxToShow & C_ucShowZDR) != 0;
|
|
|
|
ZDx_Object * pZdd = (ZDx_Object *) pModule -> GetZone (C_ucTypeZdd);
|
|
ZDx_Object * pZde = (ZDx_Object *) pModule -> GetZone (C_ucTypeZde);
|
|
ZDx_Object * pZdm = (ZDx_Object *) pModule -> GetZone (C_ucTypeZdm);
|
|
ZDx_Object * pZdr = (ZDx_Object *) pModule -> GetZone (C_ucTypeZdr);
|
|
if (pZdr && pZdr -> fn_bIsOfType (C_szZdrName) == FALSE) pZdr = NULL;
|
|
|
|
if (pZdd) pZdd -> SetDisplay (eNotDisplayed);
|
|
if (pZde) pZde -> SetDisplay (eNotDisplayed);
|
|
if (pZdm) pZdm -> SetDisplay (eNotDisplayed);
|
|
if (pZdr) pZdr -> SetDisplay (eNotDisplayed);
|
|
|
|
// We look for all ZDx child of the module :
|
|
// For each ZDx, we set its Display flag, and we remove it from the hierarachy if it must not be shown
|
|
CPA_SuperObject * pSuperObject = _pModuleSuperObject -> GetSuperObjectFirstChild ();
|
|
CPA_SuperObject * pNextChild;
|
|
while (pSuperObject)
|
|
{
|
|
pNextChild = _pModuleSuperObject -> GetSuperObjectNextChild (pSuperObject);
|
|
|
|
// No object or not a ZDx -> go to the next child
|
|
CPA_BaseObject * pObject = pSuperObject -> GetObject ();
|
|
if (pObject == NULL || ! M_bIsThisObjectAZDx (pObject))
|
|
{
|
|
pSuperObject = pNextChild;
|
|
continue;
|
|
}
|
|
ZDx_Object * pZDxObject = (ZDx_Object *) pObject;
|
|
|
|
long lEngineType = pZDxObject -> GetDataType ();
|
|
|
|
if ((lEngineType == C_lZDD && ! bShowZdd) // if the ZDx must not be shown
|
|
|| (lEngineType == C_lZDE && ! bShowZde)
|
|
|| (lEngineType == C_lZDM && ! bShowZdm)
|
|
|| (lEngineType == C_lZDR && ! bShowZdr))
|
|
{
|
|
pZDxObject -> SetDisplay (eNotDisplayed);
|
|
|
|
// Remove the object from the hierarchy
|
|
GetInterface () -> fn_bDeleteObjectInHierarchy (pSuperObject , FALSE , FALSE);
|
|
}
|
|
else
|
|
{
|
|
pZDxObject -> SetDisplay (eDisplayed);
|
|
SetAspectOfZDx (pSuperObject , pZDxObject == _pZDxToSelect);
|
|
pSuperObject -> SetEditProtected (_bSetEditProtected);
|
|
}
|
|
|
|
pSuperObject = pNextChild;
|
|
}
|
|
|
|
if (bShowZdd) CheckAndPutZDxIntoHierarchy (_pModuleSuperObject , pZdd , pZdd == _pZDxToSelect , _bSetEditProtected);
|
|
if (bShowZde) CheckAndPutZDxIntoHierarchy (_pModuleSuperObject , pZde , pZde == _pZDxToSelect , _bSetEditProtected);
|
|
if (bShowZdm) CheckAndPutZDxIntoHierarchy (_pModuleSuperObject , pZdm , pZdm == _pZDxToSelect , _bSetEditProtected);
|
|
if (bShowZdr) CheckAndPutZDxIntoHierarchy (_pModuleSuperObject , pZdr , pZdr == _pZDxToSelect , _bSetEditProtected);
|
|
|
|
if (m_pList1Window -> IsEditingZDxOfModule ())
|
|
{
|
|
// If there is a ZDx object to select, we select it, else we select the Module
|
|
// (if the user is not editing the zdx of module, we select nothing)
|
|
CPA_SuperObject * pSuperObjectToSelect = _pZDxToSelect ? GetZDxSuperObject (_pZDxToSelect , _pModuleSuperObject) : _pModuleSuperObject;
|
|
GetInterface () -> fn_vCancelCurrentSelection (FALSE);
|
|
GetInterface () -> fn_vAddSelectedObject (pSuperObjectToSelect , FALSE);
|
|
|
|
long DrawMask = GLI_C_lAllIsEnable ^ GLI_C_lIsNotDrawCollideInformation;
|
|
if (_ucZDxToShow == C_ucHideAllZDx) // If we hide the zone of the module, one can select the module
|
|
{
|
|
_pModuleSuperObject -> SetEditProtected (FALSE);
|
|
} // If we show the zone of the module
|
|
else
|
|
{
|
|
_pModuleSuperObject -> SetEditProtected (TRUE); // One cannot select the module
|
|
DrawMask &= ~ GLI_C_lIsNotGrided; // and it is transparent
|
|
}
|
|
HIE_fn_vSetSuperObjectDrawMask (_pModuleSuperObject -> GetStruct () , DrawMask);
|
|
}
|
|
|
|
m_bIsShowingOrHidingZDx = FALSE;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ShowBoundingVolume
|
|
// Show the bounding volume of an actor
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ShowBoundingVolume (CPA_SuperObject * _pActorSuperObject , ZDx_Object * _pBoundingVolume , BOOL _bSelectZDx)
|
|
{
|
|
m_bIsShowingOrHidingZDx = TRUE;
|
|
|
|
PutZDxIntoHierarchy (_pActorSuperObject , _pBoundingVolume , _bSelectZDx);
|
|
|
|
m_bIsShowingOrHidingZDx = FALSE;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - ShowModuleZDxRecursiv
|
|
// Show all zdx of a module and of all of its module childs
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ShowModuleZDxRecursiv (CPA_SuperObject * _pModuleSuperObject)
|
|
{
|
|
// The object
|
|
CPA_BaseObject * pObject = _pModuleSuperObject -> GetObject ();
|
|
if (pObject && pObject -> fn_bIsOfType (C_szPhysicalObjectTypeName))
|
|
ShowZDxOfModule (_pModuleSuperObject , C_ucShowAllZDx , NULL , TRUE);
|
|
|
|
// The childs
|
|
CPA_SuperObject * pChildSuperObject = _pModuleSuperObject -> GetSuperObjectFirstChild ();
|
|
while (pChildSuperObject)
|
|
{
|
|
ShowModuleZDxRecursiv (pChildSuperObject);
|
|
pChildSuperObject = _pModuleSuperObject -> GetSuperObjectNextChild (pChildSuperObject);
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - ShowModuleZDxOfActor
|
|
// Show all zdx of all modules of an actor
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ShowModuleZDxOfActor (CPA_SuperObject * _pActorSuperObject)
|
|
{
|
|
if (_pActorSuperObject)
|
|
{
|
|
IWillRefreshDisplay (C_lShowModuleZDxActor);
|
|
|
|
// We look for all child of the actor :
|
|
CPA_SuperObject * pSuperObject = _pActorSuperObject -> GetSuperObjectFirstChild ();
|
|
while (pSuperObject)
|
|
{
|
|
ShowModuleZDxRecursiv (pSuperObject);
|
|
pSuperObject = _pActorSuperObject -> GetSuperObjectNextChild (pSuperObject);
|
|
}
|
|
|
|
RefreshDisplay (C_lShowModuleZDxActor);
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - HideModuleZDxRecursiv
|
|
// Hide all zdx of a module and of all of its module childs
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::HideModuleZDxRecursiv (CPA_SuperObject * _pModuleSuperObject)
|
|
{
|
|
// The object
|
|
CPA_BaseObject * pObject = _pModuleSuperObject -> GetObject ();
|
|
if (pObject && pObject -> fn_bIsOfType (C_szPhysicalObjectTypeName))
|
|
ShowZDxOfModule (_pModuleSuperObject , C_ucHideAllZDx);
|
|
|
|
// The childs
|
|
CPA_SuperObject * pChildSuperObject = _pModuleSuperObject -> GetSuperObjectFirstChild ();
|
|
while (pChildSuperObject)
|
|
{
|
|
HideModuleZDxRecursiv (pChildSuperObject);
|
|
pChildSuperObject = _pModuleSuperObject -> GetSuperObjectNextChild (pChildSuperObject);
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - HideModuleZDxOfActor
|
|
// Hide all zdx of all modules of an actor
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::HideModuleZDxOfActor (CPA_SuperObject * _pActorSuperObject)
|
|
{
|
|
if (_pActorSuperObject)
|
|
{
|
|
IWillRefreshDisplay (C_lHideModuleZDxActor);
|
|
|
|
// We look for all child of the actor :
|
|
CPA_SuperObject * pSuperObject = _pActorSuperObject -> GetSuperObjectFirstChild ();
|
|
while (pSuperObject)
|
|
{
|
|
HideModuleZDxRecursiv (pSuperObject);
|
|
pSuperObject = _pActorSuperObject -> GetSuperObjectNextChild (pSuperObject);
|
|
}
|
|
|
|
RefreshDisplay (C_lHideModuleZDxActor);
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ShowZDxOfAllModule
|
|
// Show or hide the ZDx of all modules in the world
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ShowZDxOfAllModule (unsigned char _ucZDxToShow)
|
|
{
|
|
IWillRefreshDisplay (C_lShowZDxOfAllModule);
|
|
|
|
CPA_List<CPA_SuperObject> * pListOfPhysicalSuperObject = GetInterface () -> GetObjectListByType (C_szPhysicalObjectTypeName);
|
|
|
|
POSITION Pos = pListOfPhysicalSuperObject -> GetHeadPosition ();
|
|
while (Pos)
|
|
{
|
|
CPA_SuperObject * pSuperObject = pListOfPhysicalSuperObject -> GetNext (Pos);
|
|
ShowZDxOfModule (pSuperObject , _ucZDxToShow);
|
|
}
|
|
|
|
RefreshDisplay (C_lShowZDxOfAllModule);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - ShowZDxOfSelectedActor
|
|
// Show all zdx of selected actor
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ShowZDxOfSelectedActor ()
|
|
{
|
|
CPA_SuperObject * pSelectedActorSuperObject = GetSelectedActorSuperObject ();
|
|
if (! pSelectedActorSuperObject) return;
|
|
|
|
IWillRefreshDisplay (C_lShowZDxSelectedActor);
|
|
|
|
switch (m_pDisplayControlWindow -> GetDisplayForAllActors ())
|
|
{
|
|
case eNoZone :
|
|
case eOff : m_pDisplayControlWindow -> SetDisplayForAllActors (eSelected);
|
|
SetDisplayFlagOfAllActors (FALSE);
|
|
break;
|
|
case eOn : break;
|
|
case eSelected : break;
|
|
}
|
|
|
|
((CPA_Actor *) pSelectedActorSuperObject -> GetObject ()) -> SetDisplayZone (TRUE);
|
|
ShowZDxOfActor (pSelectedActorSuperObject , C_ucShowAllZDx);
|
|
|
|
RefreshDisplay (C_lShowZDxSelectedActor);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - HideZDxOfSelectedActor
|
|
// Hide all zdx of selected actor
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::HideZDxOfSelectedActor ()
|
|
{
|
|
CPA_SuperObject * pSelectedActorSuperObject = GetSelectedActorSuperObject ();
|
|
if (! pSelectedActorSuperObject) return;
|
|
|
|
IWillRefreshDisplay (C_lHideZDxSelectedActor);
|
|
|
|
switch (m_pDisplayControlWindow -> GetDisplayForAllActors ())
|
|
{
|
|
case eNoZone :
|
|
case eOff : break;
|
|
case eOn : m_pDisplayControlWindow -> SetDisplayForAllActors (eSelected);
|
|
SetDisplayFlagOfAllActors (TRUE);
|
|
break;
|
|
case eSelected : break;
|
|
}
|
|
|
|
((CPA_Actor *) pSelectedActorSuperObject -> GetObject ()) -> SetDisplayZone (FALSE);
|
|
ShowZDxOfActor (pSelectedActorSuperObject , C_ucHideAllZDx);
|
|
|
|
RefreshDisplay (C_lHideZDxSelectedActor);
|
|
}
|
|
|
|
|
|
//*****************************************************************************
|
|
// Refresh display
|
|
//*****************************************************************************
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - IWillRefreshDisplay
|
|
// Someone say he will refresh the display later (to prevent multiple refreshes)
|
|
// Return TRUE if nobody else has asked it before
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::IWillRefreshDisplay (long _lCallerID)
|
|
{
|
|
if (! m_lRefreshDisplayCallerID)
|
|
{
|
|
m_lRefreshDisplayCallerID = _lCallerID;
|
|
return TRUE;
|
|
}
|
|
else return FALSE;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - RefreshDisplay
|
|
// Refresh the display if the caller has asked it before (to prevent multiple refreshes)
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::RefreshDisplay (long _lCallerID , BOOL _bRefreshDisplay)
|
|
{
|
|
if (m_lRefreshDisplayCallerID == _lCallerID)
|
|
{
|
|
if (_bRefreshDisplay) GetInterface () -> fn_vUpdateAll (E_mc_JustDraw);
|
|
|
|
m_lRefreshDisplayCallerID = 0;
|
|
return TRUE;
|
|
}
|
|
else return FALSE;
|
|
}
|
|
|
|
|
|
//*****************************************************************************
|
|
// Check if ZDx are displayed
|
|
//*****************************************************************************
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - AreZDxOfActorDisplayed
|
|
// Return if the ZDx of the actor are displayed or not
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::AreZDxOfActorDisplayed (CPA_SuperObject * _pActorSuperObject)
|
|
{
|
|
// We look for all child of the actor :
|
|
CPA_SuperObject * pSuperObject = _pActorSuperObject -> GetSuperObjectFirstChild ();
|
|
while (pSuperObject)
|
|
{
|
|
CPA_BaseObject * pObject = pSuperObject -> GetObject ();
|
|
if (pObject && M_bIsThisObjectAZDx (pObject)) return TRUE; // One ZDx object found -> return TRUE
|
|
|
|
pSuperObject = _pActorSuperObject -> GetSuperObjectNextChild (pSuperObject);
|
|
}
|
|
|
|
return FALSE; // No ZDx object found -> return FALSE
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - AreZDxOfModuleDisplayed
|
|
// Return if the module has a ZDx object displayed or not
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::AreZDxOfModuleDisplayed (CPA_SuperObject * _pModuleSuperObject)
|
|
{
|
|
// We look for all childs of the module
|
|
CPA_SuperObject * pChildSuperObject = _pModuleSuperObject -> GetSuperObjectFirstChild ();
|
|
while (pChildSuperObject)
|
|
{
|
|
CPA_BaseObject * pObject = pChildSuperObject -> GetObject ();
|
|
if (pObject && M_bIsThisObjectAZDx (pObject)) return TRUE; // One ZDx object found -> return TRUE;
|
|
|
|
pChildSuperObject = _pModuleSuperObject -> GetSuperObjectNextChild (pChildSuperObject);
|
|
}
|
|
|
|
return FALSE; // No ZDx object found -> return FALSE
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - AreZDxOfAllModuleDisplayed
|
|
// Return TRUE if at least one ZDx of one module in the world is displayed
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::AreZDxOfAllModuleDisplayed ()
|
|
{
|
|
CPA_List<CPA_SuperObject> * pListOfPhysicalSuperObject = GetInterface () -> GetObjectListByType (C_szPhysicalObjectTypeName);
|
|
|
|
POSITION Pos = pListOfPhysicalSuperObject -> GetHeadPosition ();
|
|
while (Pos)
|
|
{
|
|
CPA_SuperObject * pModuleSuperObject = pListOfPhysicalSuperObject -> GetNext (Pos);
|
|
if (AreZDxOfModuleDisplayed (pModuleSuperObject)) return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - AreZDxOfModuleDisplayedRecursiv
|
|
// Return if the ZDx of the given module and of all its module childs are displayed or not
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::AreZDxOfModuleDisplayedRecursiv (CPA_SuperObject * _pModuleSuperObject)
|
|
{
|
|
CPA_SuperObject * pChildSuperObject = _pModuleSuperObject -> GetSuperObjectFirstChild ();
|
|
while (pChildSuperObject)
|
|
{
|
|
CPA_BaseObject * pObject = pChildSuperObject -> GetObject ();
|
|
if (pObject)
|
|
{
|
|
if (M_bIsThisObjectAZDx (pObject)) return TRUE; // One ZDx object found -> return TRUE
|
|
if (pObject -> fn_bIsOfType (C_szPhysicalObjectTypeName))
|
|
if (AreZDxOfModuleDisplayedRecursiv (pChildSuperObject)) return TRUE;
|
|
}
|
|
|
|
pChildSuperObject = _pModuleSuperObject -> GetSuperObjectNextChild (pChildSuperObject);
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - AreModuleZDxOfActorDisplayed
|
|
// Return if the module ZDx of the actor are displayed or not
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::AreModuleZDxOfActorDisplayed (CPA_SuperObject * _pActorSuperObject)
|
|
{
|
|
// We look for all child of the actor :
|
|
CPA_SuperObject * pSuperObject = _pActorSuperObject -> GetSuperObjectFirstChild ();
|
|
while (pSuperObject)
|
|
{
|
|
CPA_BaseObject * pObject = pSuperObject -> GetObject ();
|
|
if (pObject && pObject -> fn_bIsOfType (C_szPhysicalObjectTypeName)) // If it is a module
|
|
if (AreZDxOfModuleDisplayedRecursiv (pSuperObject)) return TRUE;
|
|
pSuperObject = _pActorSuperObject -> GetSuperObjectNextChild (pSuperObject);
|
|
}
|
|
|
|
return FALSE; // No ZDx object found -> return FALSE
|
|
}
|
|
|
|
|
|
//*****************************************************************************
|
|
// Check if an actor has ZDx
|
|
//*****************************************************************************
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - DoesActorHaveZDx
|
|
// Return if an actor has some ZDx or not
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::DoesActorHaveZDx (CPA_BaseObject * _pActor)
|
|
{
|
|
return GetNumberOfZDxInList (GetZDxList (_pActor , eZdd)) > 0 ||
|
|
GetNumberOfZDxInList (GetZDxList (_pActor , eZde)) > 0 ||
|
|
GetNumberOfZDxInList (GetZDxList (_pActor , eZdm)) > 0 ||
|
|
GetNumberOfZDxInList (GetZDxList (_pActor , eZdr)) > 0;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - DoesActorHaveModuleZDx
|
|
// Return if an actor has some module ZDx or not
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::DoesActorHaveModuleZDx (CPA_SuperObject * _pActorSuperObject)
|
|
{
|
|
// We look for all child of the actor :
|
|
CPA_SuperObject * pSuperObject = _pActorSuperObject -> GetSuperObjectFirstChild ();
|
|
while (pSuperObject)
|
|
{
|
|
CPA_BaseObject * pObject = pSuperObject -> GetObject ();
|
|
if (pObject && pObject -> fn_bIsOfType (C_szPhysicalObjectTypeName)) // If it is a module
|
|
{
|
|
if (DoesModuleHaveZDxRecursiv (pSuperObject)) return TRUE; // and if the module has some ZDx -> return TRUE
|
|
}
|
|
|
|
pSuperObject = _pActorSuperObject -> GetSuperObjectNextChild (pSuperObject);
|
|
}
|
|
|
|
return FALSE; // No ZDx -> return FALSE;
|
|
}
|
|
|
|
|
|
//*****************************************************************************
|
|
// List of zones
|
|
//*****************************************************************************
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - GetNumberOfZDxInList
|
|
// Get the number of existing ZDx in a list
|
|
//-----------------------------------------------------------------------------
|
|
long ZDx_Interface::GetNumberOfZDxInList (EdtList * _pEdtList)
|
|
{
|
|
if (! _pEdtList) return 0;
|
|
|
|
long lNumber = 0;
|
|
|
|
POSITION Pos = _pEdtList -> GetHeadPosition ();
|
|
while (Pos)
|
|
{
|
|
if (_pEdtList -> GetNext (Pos)) lNumber++;
|
|
}
|
|
|
|
return lNumber;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ConvertZDxTypeToListType
|
|
// Convert a ZDx type to a list type
|
|
//-----------------------------------------------------------------------------
|
|
CString ZDx_Interface::ConvertZDxTypeToListType (tdeZDxType _eZDxType)
|
|
{
|
|
switch (_eZDxType)
|
|
{
|
|
case eZdd : return C_szZddName;
|
|
case eZde : return C_szZdeName;
|
|
case eZdm : return C_szZdmName;
|
|
case eZdr : return C_szZdrName;
|
|
case eBoundingVolume : return C_szBoundingVolumeName;
|
|
// ANNECY AV CLEAN_MEC {
|
|
// case eTestPoint : return C_szTestPointName;
|
|
// END ANNECY AV }
|
|
default : ASSERT (0);
|
|
return C_szZddName;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ConvertListTypeToZDxType
|
|
// Convert a list type to a ZDx type
|
|
//-----------------------------------------------------------------------------
|
|
tdeZDxType ZDx_Interface::ConvertListTypeToZDxType (CString _szListType)
|
|
{
|
|
if (_szListType == C_szZddName) return eZdd;
|
|
if (_szListType == C_szZdeName) return eZde;
|
|
if (_szListType == C_szZdmName) return eZdm;
|
|
if (_szListType == C_szZdrName) return eZdr;
|
|
if (_szListType == C_szBoundingVolumeName) return eBoundingVolume;
|
|
// ANNECY AV CLEAN_MEC {
|
|
// if (_szListType == C_szTestPointName) return eTestPoint;
|
|
// END ANNECY AV }
|
|
|
|
ASSERT (0);
|
|
return eZdd;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - GetNameList
|
|
// Call the Actors dll to get the list of names of an actor for a specific type
|
|
//-----------------------------------------------------------------------------
|
|
CPA_tdoNameList * ZDx_Interface::GetNameList (CPA_BaseObject * _pActor , tdeZDxType _eZDxType)
|
|
{
|
|
tdstEdtListMess stEdtListMess;
|
|
|
|
stEdtListMess . csListType = ConvertZDxTypeToListType (_eZDxType);
|
|
stEdtListMess . pActor = _pActor;
|
|
stEdtListMess . eConstraintType = eNormal;
|
|
|
|
return (CPA_tdoNameList *) GetMainWorld () -> GetObjectDLLWithName (C_szDLLActorName) ->
|
|
OnQueryAction (this , C_uiActor_GetANameList , (long) & stEdtListMess);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - CreateANewZDxList
|
|
// Call the Actors dll to get a new list of objects of type zone
|
|
//-----------------------------------------------------------------------------
|
|
EdtList * ZDx_Interface::CreateANewZDxList (CPA_BaseObject * _pActor , tdeZDxType _eZDxType)
|
|
{
|
|
tdstEdtListMess stEdtListMess;
|
|
|
|
stEdtListMess . csListType = ConvertZDxTypeToListType (_eZDxType);
|
|
stEdtListMess . pActor = _pActor;
|
|
stEdtListMess . eConstraintType = eNormal;
|
|
|
|
return (EdtList *) GetMainWorld () -> GetObjectDLLWithName (C_szDLLActorName) ->
|
|
OnQueryAction (this , C_uiActor_CreateANewObjectList , (long) & stEdtListMess);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - GetZDxList
|
|
// Call the Actors dll to get the list of given type of an actor
|
|
//-----------------------------------------------------------------------------
|
|
EdtList * ZDx_Interface::GetZDxList (CPA_BaseObject * _pActor , tdeZDxType _eZDxType)
|
|
{
|
|
tdstEdtListMess stEdtListMess;
|
|
|
|
stEdtListMess . csListType = ConvertZDxTypeToListType (_eZDxType);
|
|
stEdtListMess . pActor = _pActor;
|
|
stEdtListMess . eConstraintType = eNormal;
|
|
|
|
return (EdtList *) GetMainWorld () -> GetObjectDLLWithName (C_szDLLActorName) ->
|
|
OnQueryAction (this , C_uiActor_GetAnObjectList , (long) & stEdtListMess);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - SetZDxList
|
|
// Call the Actors dll to set the list of given type of an actor
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::SetZDxList (CPA_BaseObject * _pActor , tdeZDxType _eZDxType , EdtList * _pZDxList)
|
|
{
|
|
tdstEdtListMess stEdtListMess;
|
|
|
|
stEdtListMess . csListType = ConvertZDxTypeToListType (_eZDxType);
|
|
stEdtListMess . pActor = _pActor;
|
|
stEdtListMess . pList = _pZDxList;
|
|
stEdtListMess . eConstraintType = eNormal;
|
|
|
|
GetMainWorld () -> GetObjectDLLWithName (C_szDLLActorName) ->
|
|
OnQueryAction (this , C_uiActor_SetAnObjectList , (long) & stEdtListMess);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - DeleteZDxList
|
|
// Call the Actors dll to delete a list of ZDx of an actor ; return FALSE if failure
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::DeleteZDxList (CPA_BaseObject * _pActor , tdeZDxType _eZDxType)
|
|
{
|
|
tdstEdtListMess stEdtListMess;
|
|
|
|
stEdtListMess . csListType = ConvertZDxTypeToListType (_eZDxType);
|
|
stEdtListMess . pActor = _pActor;
|
|
stEdtListMess . eConstraintType = eNormal;
|
|
|
|
// We make to delete notification for each ZDx object of the list
|
|
EdtList * pEdtList = GetZDxList (_pActor , _eZDxType);
|
|
POSITION Pos = pEdtList -> GetHeadPosition ();
|
|
while (Pos)
|
|
{
|
|
ZDx_Object * pZDxObject = (ZDx_Object *) pEdtList -> GetNext (Pos);
|
|
if (pZDxObject) pZDxObject -> fn_vNotifyUnSave ();
|
|
}
|
|
|
|
BOOL bListDeleted = GetMainWorld () -> GetObjectDLLWithName (C_szDLLActorName) ->
|
|
OnQueryAction (this , C_uiActor_DeleteAnObjectList , (long) & stEdtListMess) == 0;
|
|
|
|
// If the list has not been deleted, we undo the delete notification
|
|
if (! bListDeleted)
|
|
{
|
|
POSITION Pos = pEdtList -> GetHeadPosition ();
|
|
while (Pos)
|
|
{
|
|
ZDx_Object * pZDxObject = (ZDx_Object *) pEdtList -> GetNext (Pos);
|
|
if (pZDxObject) pZDxObject -> fn_vNotifyRestore ();
|
|
}
|
|
}
|
|
|
|
return bListDeleted;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - SetZDxObjectInList
|
|
// Call the Actors dll to set a ZDx in a list of ZDx of an actor
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::SetZDxObjectInList (CPA_BaseObject * _pActor , tdeZDxType _eZDxType ,
|
|
long _lIndexInList , ZDx_Object * _pZDxObject ,
|
|
tdeZDxConstraintType _eZDxConstraintType)
|
|
{
|
|
tdstEdtListMess stEdtListMess;
|
|
|
|
stEdtListMess . csListType = ConvertZDxTypeToListType (_eZDxType);
|
|
stEdtListMess . pActor = _pActor;
|
|
stEdtListMess . ulIndexInList = _lIndexInList;
|
|
stEdtListMess . pObject = _pZDxObject;
|
|
switch (_eZDxConstraintType)
|
|
{
|
|
case eZDxNormal : stEdtListMess . eConstraintType = eNormal; break;
|
|
case eZDxModifyAllActors : stEdtListMess . eConstraintType = eModifyAllActors; break;
|
|
case eZDxModifyOneActor : stEdtListMess . eConstraintType = eModifyOneActor; break;
|
|
default : ASSERT (0); break;
|
|
}
|
|
|
|
if (_pZDxObject) _pZDxObject -> SetIndexInList (_lIndexInList);
|
|
|
|
GetMainWorld () -> GetObjectDLLWithName (C_szDLLActorName) ->
|
|
OnQueryAction (this , C_uiActor_SetAnObjectInObjectList , (long) & stEdtListMess);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - InsertZDxIntoList
|
|
// Insert a ZDx object into a list at a specific position (first position is 0)
|
|
// If Position = -1, insert it at the first unused position
|
|
// Failure -> return FALSE (no more unused position)
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::InsertZDxIntoList (EdtList * _pList , ZDx_Object * _pZDxObject , long * _plPosition ,
|
|
CPA_BaseObject * _pActor , tdeZDxConstraintType _eZDxConstraintType)
|
|
{
|
|
POSITION Pos;
|
|
if (* _plPosition == -1)
|
|
{
|
|
// Search for an unused position
|
|
Pos = _pList -> GetHeadPosition ();
|
|
* _plPosition = 0;
|
|
while (Pos && _pList -> GetAt (Pos))
|
|
{
|
|
(* _plPosition) ++;
|
|
_pList -> GetNext (Pos);
|
|
}
|
|
// If there is no unused position, return FALSE
|
|
if (! Pos) return FALSE;
|
|
}
|
|
|
|
SetZDxObjectInList (_pActor , _pZDxObject -> GetZDxType () , * _plPosition ,_pZDxObject , _eZDxConstraintType);
|
|
return TRUE;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - RemoveZDxFromList
|
|
// Remove a ZDx object from a list
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::RemoveZDxFromList (EdtList * _pList , ZDx_Object * _pZDxObject , CPA_BaseObject * _pActor ,
|
|
BOOL _bEnableListCreation /* = FALSE */)
|
|
{
|
|
// Search the ZDx object in the list
|
|
long lPosition = 0;
|
|
POSITION Pos = _pList -> GetHeadPosition ();
|
|
while (_pList -> GetAt (Pos) != _pZDxObject)
|
|
{
|
|
lPosition ++;
|
|
_pList -> GetNext (Pos);
|
|
// We must find the ZDx object before we reach the end of the list
|
|
ASSERT (Pos);
|
|
}
|
|
|
|
// We save the position into the ZDx object
|
|
_pZDxObject -> SetIndexInList (lPosition);
|
|
|
|
// In fact, set a NULL ZDx object at the given position
|
|
SetZDxObjectInList (_pActor , ConvertListTypeToZDxType (_pList -> fn_csGetListType ()) , lPosition , NULL ,
|
|
_bEnableListCreation ? eZDxNormal : eZDxModifyAllActors);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - AZDxHasBeenChangedInList
|
|
// Called when a ZDx has been changed in a list of ZDx
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::AZDxHasBeenChangedInList (void * _pEdtListMess)
|
|
{
|
|
tdstEdtListMess * pEdtListMess = (tdstEdtListMess *) _pEdtListMess;
|
|
// We get the actor
|
|
CPA_BaseObject * pActor = pEdtListMess -> pActor;
|
|
// We get the engine list
|
|
ZDX_tdxHandleToZdxList hEngineList = (ZDX_tdxHandleToZdxList) pEdtListMess -> pList -> fn_hGetMotorList ();
|
|
// Models don't have engine list, so hEngineList can be NULL. In this case, we do nothing
|
|
if (! hEngineList) return;
|
|
// We get the type of the list
|
|
tdeZDxType eZDxType = ConvertListTypeToZDxType (pEdtListMess -> csListType);
|
|
unsigned char ucEngineType = ConvertZDxTypeToEngineType (eZDxType);
|
|
// We get the index of the object in the list
|
|
long lIndexInList = pEdtListMess -> ulIndexInList;
|
|
// We get the new ZDx object;
|
|
POSITION Position = pEdtListMess -> pList -> FindIndex (lIndexInList);
|
|
ZDx_Object * pZDxObject = (ZDx_Object *) pEdtListMess -> pList -> GetAt (Position);
|
|
// We get the engine geometric object
|
|
ACP_tdxHandleOfObject hGeometricEngineObject = pZDxObject ? pZDxObject -> GetZDxShape () ->
|
|
GetGeometric3dObject () -> GetStruct () : NULL;
|
|
// We put the new ZDx object into the engine list
|
|
ZDX_fn_vSetGeometricZdxInListAtIndex ((unsigned short) lIndexInList , hEngineList , hGeometricEngineObject);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - IsObjectInList
|
|
// Return TRUE if the given object is in a list of ZDx
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::IsObjectInList (CPA_BaseObject * _pObject, CPA_BaseObject * _pActor , tdeZDxType _eZDxType)
|
|
{
|
|
EdtList * pEdtList = GetZDxList (_pActor , _eZDxType);
|
|
if (! pEdtList) return FALSE;
|
|
|
|
POSITION Pos = pEdtList -> GetHeadPosition ();
|
|
while (Pos)
|
|
{
|
|
CPA_BaseObject * pZDxObject = pEdtList -> GetNext (Pos);
|
|
if (pZDxObject == _pObject) return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
// Physical objects
|
|
//*****************************************************************************
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - GetZDxOfPhysicalObject
|
|
// return the ZDx object of a given type of a physical object
|
|
//-----------------------------------------------------------------------------
|
|
ZDx_Object * ZDx_Interface::GetZDxOfPhysicalObject (EditorPO * _pPhysicalObject , tdeZDxType _eZDxType)
|
|
{
|
|
switch (_eZDxType)
|
|
{
|
|
case eZdd : return (ZDx_Object *) _pPhysicalObject -> GetZone (C_ucTypeZdd);
|
|
case eZde : return (ZDx_Object *) _pPhysicalObject -> GetZone (C_ucTypeZde);
|
|
case eZdm : return (ZDx_Object *) _pPhysicalObject -> GetZone (C_ucTypeZdm);
|
|
case eZdr : {
|
|
CPA_BaseObject * pZdr = _pPhysicalObject -> GetZone (C_ucTypeZdr);
|
|
return pZdr && pZdr -> fn_bIsOfType (C_szZdrName) ? (ZDx_Object *) pZdr : NULL;
|
|
}
|
|
default : ASSERT (0);
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - SetZDxOfPhysicalObject
|
|
// set the ZDx object (can be NULL) of a given type for a physical object
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::SetZDxOfPhysicalObject (EditorPO * _pPhysicalObject , ZDx_Object * _pZDxObject , tdeZDxType _eZDxType)
|
|
{
|
|
// If the ZDX_Object exists, it must has the same ZDx type
|
|
ASSERT (_pZDxObject == NULL || _pZDxObject -> GetZDxType () == _eZDxType);
|
|
|
|
switch (_eZDxType)
|
|
{
|
|
case eZdd : _pPhysicalObject -> SetZone (C_ucTypeZdd , _pZDxObject); break;
|
|
case eZde : _pPhysicalObject -> SetZone (C_ucTypeZde , _pZDxObject); break;
|
|
case eZdm : _pPhysicalObject -> SetZone (C_ucTypeZdm , _pZDxObject); break;
|
|
case eZdr : _pPhysicalObject -> SetZone (C_ucTypeZdr , _pZDxObject); break;
|
|
default : ASSERT (0); break;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - DoesModuleHaveZDx
|
|
// Return if a module has some ZDx or not
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::DoesModuleHaveZDx (EditorPO * _pModule)
|
|
{
|
|
return GetZDxOfPhysicalObject (_pModule , eZdd) != NULL ||
|
|
GetZDxOfPhysicalObject (_pModule , eZde) != NULL ||
|
|
GetZDxOfPhysicalObject (_pModule , eZdm) != NULL ||
|
|
GetZDxOfPhysicalObject (_pModule , eZdr) != NULL;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - DoesModuleHaveZDxRecursiv
|
|
// Return if a module or one of its module childs has some ZDx or not
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::DoesModuleHaveZDxRecursiv (CPA_SuperObject * _pModuleSuperObject)
|
|
{
|
|
// The module
|
|
if (DoesModuleHaveZDx ((EditorPO *) _pModuleSuperObject -> GetObject ())) return TRUE;
|
|
|
|
// The childs
|
|
CPA_SuperObject * pChildSuperObject = _pModuleSuperObject -> GetSuperObjectFirstChild ();
|
|
while (pChildSuperObject)
|
|
{
|
|
CPA_BaseObject * pBaseObject = pChildSuperObject -> GetObject ();
|
|
if (pBaseObject && pBaseObject -> fn_bIsOfType (C_szPhysicalObjectTypeName))
|
|
if (DoesModuleHaveZDxRecursiv (pChildSuperObject)) return TRUE;
|
|
|
|
pChildSuperObject = _pModuleSuperObject -> GetSuperObjectNextChild (pChildSuperObject);
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Interface - DoesAtLeastOneModuleHaveZDx
|
|
// Return TRUE if at least one module in the world has some ZDx
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Interface::DoesAtLeastOneModuleHaveZDx ()
|
|
{
|
|
CPA_List<CPA_SuperObject> * pListOfPhysicalSuperObject = GetInterface () -> GetObjectListByType (C_szPhysicalObjectTypeName);
|
|
|
|
POSITION Pos = pListOfPhysicalSuperObject -> GetHeadPosition ();
|
|
while (Pos)
|
|
{
|
|
EditorPO * pModule = (EditorPO *) pListOfPhysicalSuperObject -> GetNext (Pos) -> GetObject ();
|
|
if (DoesModuleHaveZDx (pModule)) return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
//*****************************************************************************
|
|
// Personal functions for size changing
|
|
//*****************************************************************************
|
|
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
/*
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ChangeSizeZDxSphereObject
|
|
// Called by the function OnMouseMove when changing the size of a ZDx sphere object
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ChangeSizeZDxSphereObject (MTH3D_tdstVector * pDeplacement)
|
|
{
|
|
ZDx_Object * pZDxObject = (ZDx_Object *) m_stSizeChangingMode . pSelectedZDxSuperObject -> GetObject ();
|
|
ZDx_Sphere * pSphere = (ZDx_Sphere *) pZDxObject -> GetZDxShape ();
|
|
|
|
MTH3D_M_vAddVector (& m_stSizeChangingMode . GlobalSelectedPoint ,
|
|
& m_stSizeChangingMode . GlobalSelectedPoint , pDeplacement);
|
|
MTH3D_tdstVector RadiusVertex;
|
|
MTH3D_M_vSubVector (& RadiusVertex , & m_stSizeChangingMode . GlobalSelectedPoint ,
|
|
& m_stSizeChangingMode . CenterInMousePlane);
|
|
GLI_tdxValue NewRadius = MTH3D_M_xNormVector (& RadiusVertex);
|
|
pSphere -> SetRadius (& NewRadius);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ChangeSizeZDxBoxObject
|
|
// Called by the function OnMouseMove when changing the size of a ZDx box object
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ChangeSizeZDxBoxObject (MTH3D_tdstVector * pDeplacement)
|
|
{
|
|
CPA_SuperObject * pZDxSuperObject = m_stSizeChangingMode . pSelectedZDxSuperObject;
|
|
ZDx_Object * pZDxObject = (ZDx_Object *) pZDxSuperObject -> GetObject ();
|
|
ZDx_Box * pBoxObject = (ZDx_Box *) pZDxObject -> GetZDxShape ();
|
|
|
|
MTH3D_tdstVector OldSize;
|
|
MTH3D_M_vSetVectorElements (& OldSize , pBoxObject -> GetLength () ,
|
|
pBoxObject -> GetWidth () ,
|
|
pBoxObject -> GetHeight ());
|
|
|
|
// Calculate the deplacement in the local repere
|
|
MTH3D_tdstVector LocalDeplacement;
|
|
ConvertVectorGlobalToLocal (& LocalDeplacement ,
|
|
HIE_fn_hGetSuperObjectGlobalMatrix (pZDxSuperObject -> GetStruct ()) ,
|
|
pDeplacement);
|
|
|
|
MTH3D_tdstVector Point = m_stSizeChangingMode . LocalSelectedPoint;
|
|
|
|
// Set the new dimensions of the ZDx box object by moving one vertex
|
|
if (Point . xX > 0) pBoxObject -> IncMaxPointX (& LocalDeplacement . xX);
|
|
else pBoxObject -> IncMinPointX (& LocalDeplacement . xX);
|
|
if (Point . xY > 0) pBoxObject -> IncMaxPointY (& LocalDeplacement . xY);
|
|
else pBoxObject -> IncMinPointY (& LocalDeplacement . xY);
|
|
if (Point . xZ > 0) pBoxObject -> IncMaxPointZ (& LocalDeplacement . xZ);
|
|
else pBoxObject -> IncMinPointZ (& LocalDeplacement . xZ);
|
|
|
|
// Calculate the real move and return it in pDeplacement
|
|
MTH3D_tdstVector NewSize;
|
|
MTH3D_M_vSetVectorElements (& NewSize , pBoxObject -> GetLength () ,
|
|
pBoxObject -> GetWidth () ,
|
|
pBoxObject -> GetHeight ());
|
|
MTH3D_tdstVector DeltaSize;
|
|
MTH3D_M_vSubVector (& DeltaSize , & NewSize , & OldSize);
|
|
if (Point . xX < 0) DeltaSize . xX = - DeltaSize.xX;
|
|
if (Point . xY < 0) DeltaSize . xY = - DeltaSize.xY;
|
|
if (Point . xZ < 0) DeltaSize . xZ = - DeltaSize.xZ;
|
|
|
|
ConvertVectorLocalToGlobal (pDeplacement ,
|
|
HIE_fn_hGetSuperObjectGlobalMatrix (pZDxSuperObject -> GetStruct ()) ,
|
|
& DeltaSize);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ChangeSizeZDxConeObject
|
|
// Called by the function OnMouseMove when changing the size of a ZDx cone object
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ChangeSizeZDxConeObject (MTH3D_tdstVector * pDeplacement)
|
|
{
|
|
CPA_SuperObject * pZDxSuperObject = m_stSizeChangingMode . pSelectedZDxSuperObject;
|
|
ZDx_Object * pZDxObject = (ZDx_Object *) pZDxSuperObject -> GetObject ();
|
|
ZDx_Cone * pConeObject = (ZDx_Cone *) pZDxObject -> GetZDxShape ();
|
|
|
|
MTH3D_tdstVector LocalDeplacement;
|
|
ConvertVectorGlobalToLocal (& LocalDeplacement ,
|
|
HIE_fn_hGetSuperObjectGlobalMatrix (pZDxSuperObject -> GetStruct ()) ,
|
|
pDeplacement);
|
|
|
|
if (m_stSizeChangingMode . bChangeTopPointOfCone) // We change the top point
|
|
{
|
|
MTH3D_tdstVector TopPoint = pConeObject -> GetTopPoint ();
|
|
MTH3D_M_vAddVector (& TopPoint , & TopPoint , & LocalDeplacement);
|
|
pConeObject -> SetTopPoint (& TopPoint);
|
|
}
|
|
else // We change the radius and the base point
|
|
{
|
|
MTH3D_tdstVector BasePoint = pConeObject -> GetBasePoint ();
|
|
MTH3D_tdstVector TopPoint = pConeObject -> GetTopPoint ();
|
|
// We splt the deplacement into radius change and base point change
|
|
MTH3D_tdstVector BaseTopVector;
|
|
MTH3D_M_vSubVector (& BaseTopVector , & TopPoint , & BasePoint);
|
|
MTH_tdxReal DotProduct = MTH3D_M_xDotProductVector (& BaseTopVector , & LocalDeplacement);
|
|
MTH3D_tdstVector ProjectedVector; // Projected into the axe
|
|
MTH3D_M_vMulScalarVector (& ProjectedVector , DotProduct , & BaseTopVector);
|
|
MTH3D_M_vDivScalarVector (& ProjectedVector , & ProjectedVector , MTH3D_M_xSqrVector (& BaseTopVector));
|
|
|
|
// We change the base point
|
|
MTH3D_M_vAddVector (& BasePoint , & BasePoint , & ProjectedVector);
|
|
pConeObject -> SetBasePoint (& BasePoint);
|
|
|
|
// We change the radius
|
|
MTH3D_M_vAddVector (& m_stSizeChangingMode . LocalSelectedPoint ,
|
|
& m_stSizeChangingMode . LocalSelectedPoint , & LocalDeplacement);
|
|
MTH3D_M_vSubVector (& m_stSizeChangingMode . LocalSelectedPoint ,
|
|
& m_stSizeChangingMode . LocalSelectedPoint , & ProjectedVector);
|
|
MTH_tdxReal NewRadius = MTH3D_M_xVectorGap (& m_stSizeChangingMode . LocalSelectedPoint , & BasePoint);
|
|
pConeObject -> SetRadius (& NewRadius);
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - OnBeginChangingSize
|
|
// This function is called when the user begins to change the size of a ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::OnBeginChangingSize (ACP_tdxIndex xIndex , HIE_tdstPickInfo * p_stObject)
|
|
{
|
|
// we ask if there is a pointed zdd, zde, zdm, zdr or bounding volume
|
|
CString TypeList [5] = { C_szZddName , C_szZdeName , C_szZdmName , C_szZdrName , C_szBoundingVolumeName};
|
|
CPA_List<CPA_SuperObject> * pSelectedSuperObjectList = GetInterface () -> GetMouseSelection (xIndex , p_stObject , TypeList , 5);
|
|
// if the list is empty, we do nothing
|
|
if (pSelectedSuperObjectList -> IsEmpty ()) return;
|
|
// else, we select the first super object in the list
|
|
CPA_SuperObject * pSelectedSuperObject = pSelectedSuperObjectList -> GetHeadElement ();
|
|
|
|
ZDx_Object * pZDxObject = (ZDx_Object *) pSelectedSuperObject -> GetObject ();
|
|
|
|
// one can only change the size of a sphere, box or cone ZDx object
|
|
tdeZDxGeometricType eZDxType = pZDxObject -> GetZDxGeometricType ();
|
|
if (eZDxType != eSphere && eZDxType != eBox && eZDxType != eCone) return;
|
|
|
|
// if the pointed ZDx object is not the actual selected ZDx object, we select it
|
|
if (pZDxObject != m_pEditWindow -> GetZDxObjectEdited ())
|
|
{
|
|
GetInterface () -> fn_vCancelCurrentSelection (FALSE);
|
|
GetInterface () -> fn_vAddSelectedObject (pSelectedSuperObject , TRUE);
|
|
}
|
|
|
|
|
|
// enter the "size changing" mode
|
|
m_stSizeChangingMode . bActiveMode = TRUE;
|
|
m_stSizeChangingMode . pSelectedZDxSuperObject = pSelectedSuperObject;
|
|
m_stSizeChangingMode . GlobalSelectedPoint = p_stObject->stPickedObject.aDEF_stDataOfElement->stHit;
|
|
|
|
switch (pZDxObject -> GetZDxGeometricType ())
|
|
{
|
|
case eSphere:
|
|
{
|
|
// Get the center of the sphere
|
|
ZDx_Sphere * pSphere = (ZDx_Sphere *) pZDxObject -> GetZDxShape ();
|
|
MTH3D_tdstVector SphereCenter;
|
|
// Compute coordinates in the global repere
|
|
ConvertPointLocalToGlobal (& SphereCenter ,
|
|
HIE_fn_hGetSuperObjectGlobalMatrix (m_stSizeChangingMode .
|
|
pSelectedZDxSuperObject -> GetStruct ()) , & pSphere -> GetCenter ());
|
|
|
|
// Get the matrix of the camera
|
|
GLI_tdxHandleToCamera hHandleToCamera = GetInterface () -> GetMultiDevice () -> GetFocusDevice () -> GetCamera ();
|
|
POS_tdstCompletePosition CameraMatrix , InvMatrix;
|
|
GLI_xGetCameraMatrix (hHandleToCamera , & CameraMatrix);
|
|
POS_fn_vInvertIsoMatrix(& InvMatrix , & CameraMatrix);
|
|
// Get the coordinates of the Z axe
|
|
MTH3D_tdstVector ZAxe , DummyVector;
|
|
POS_fn_vGetRotationMatrix(& InvMatrix , & DummyVector , & DummyVector , & ZAxe);
|
|
// Compute the sphere center, projected into the plane where the mouse moves into
|
|
MTH3D_M_vSubVector (& SphereCenter , & SphereCenter , & m_stSizeChangingMode . GlobalSelectedPoint);
|
|
GLI_tdxValue DotProduct = MTH3D_M_xDotProductVector (& ZAxe , & SphereCenter);
|
|
MTH3D_M_vMulScalarVector (& ZAxe , DotProduct , & ZAxe);
|
|
MTH3D_M_vSubVector (& SphereCenter , & SphereCenter , & ZAxe);
|
|
MTH3D_M_vAddVector (& m_stSizeChangingMode . CenterInMousePlane ,
|
|
& SphereCenter , & m_stSizeChangingMode . GlobalSelectedPoint);
|
|
}
|
|
break;
|
|
|
|
case eBox:
|
|
{
|
|
ZDx_Box * pBox = (ZDx_Box *) pZDxObject -> GetZDxShape ();
|
|
|
|
ConvertPointGlobalToLocal (& m_stSizeChangingMode . LocalSelectedPoint ,
|
|
HIE_fn_hGetSuperObjectGlobalMatrix (pSelectedSuperObject -> GetStruct ()) ,
|
|
& m_stSizeChangingMode . GlobalSelectedPoint);
|
|
MTH3D_M_vSubVector (& m_stSizeChangingMode . LocalSelectedPoint , & m_stSizeChangingMode . LocalSelectedPoint ,
|
|
& pBox -> GetCenter ());
|
|
m_stSizeChangingMode . LocalSelectedPoint . xX /= pBox -> GetLength ();
|
|
m_stSizeChangingMode . LocalSelectedPoint . xY /= pBox -> GetWidth ();
|
|
m_stSizeChangingMode . LocalSelectedPoint . xZ /= pBox -> GetHeight ();
|
|
}
|
|
break;
|
|
|
|
case eCone:
|
|
{
|
|
ZDx_Cone * pCone = (ZDx_Cone *) pZDxObject -> GetZDxShape ();
|
|
|
|
ConvertPointGlobalToLocal (& m_stSizeChangingMode . LocalSelectedPoint ,
|
|
HIE_fn_hGetSuperObjectGlobalMatrix (pSelectedSuperObject -> GetStruct ()) ,
|
|
& m_stSizeChangingMode . GlobalSelectedPoint);
|
|
|
|
// We see if we must change the top point or the radius of the cone
|
|
MTH3D_tdstVector TopPoint = pCone -> GetTopPoint ();
|
|
MTH3D_tdstVector BasePoint = pCone -> GetBasePoint ();
|
|
MTH_tdxReal SquareDistanceToTopPoint = MTH3D_M_xVectorGapSqr (& m_stSizeChangingMode . LocalSelectedPoint , & TopPoint);
|
|
MTH_tdxReal SquareDistanceToBasePoint = MTH3D_M_xVectorGapSqr (& m_stSizeChangingMode . LocalSelectedPoint , & BasePoint);
|
|
if (SquareDistanceToTopPoint < SquareDistanceToBasePoint)
|
|
{
|
|
m_stSizeChangingMode . bChangeTopPointOfCone = TRUE;
|
|
}
|
|
else
|
|
{
|
|
m_stSizeChangingMode . bChangeTopPointOfCone = FALSE;
|
|
|
|
// We project the picked point into the base plane
|
|
MTH3D_tdstVector BaseTopVector;
|
|
MTH3D_M_vSubVector (& BaseTopVector , & TopPoint , & BasePoint);
|
|
MTH3D_tdstVector BasePointVector;
|
|
MTH3D_M_vSubVector (& BasePointVector , & m_stSizeChangingMode . LocalSelectedPoint , & BasePoint);
|
|
MTH_tdxReal DotProduct = MTH3D_M_xDotProductVector (& BaseTopVector , & BasePointVector);
|
|
MTH3D_tdstVector ProjectedVector;
|
|
MTH3D_M_vMulScalarVector (& ProjectedVector , DotProduct , & BaseTopVector);
|
|
MTH3D_M_vDivScalarVector (& ProjectedVector , & ProjectedVector , MTH3D_M_xSqrVector (& BaseTopVector));
|
|
MTH3D_M_vAddVector (& m_stSizeChangingMode . LocalSelectedPoint ,
|
|
& m_stSizeChangingMode . LocalSelectedPoint , & ProjectedVector);
|
|
}
|
|
break;
|
|
}
|
|
|
|
default:
|
|
ASSERT (0);
|
|
break;
|
|
}
|
|
|
|
// we create a modif for the Undo
|
|
m_stSizeChangingMode.pZDxModif =
|
|
new ZDx_Modif ((ZDx_Object *) m_stSizeChangingMode . pSelectedZDxSuperObject -> GetObject () , "Changing ZDx size");
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - OnEndChangingSize
|
|
// This function is called when the user has finished to change the size of a ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::OnEndChangingSize ()
|
|
{
|
|
// we leave the "size changing" mode
|
|
m_stSizeChangingMode . bActiveMode = FALSE;
|
|
|
|
// we must undo the modifications (without refreshing the window) ...
|
|
m_stSizeChangingMode . pZDxModif -> Undo (FALSE);
|
|
// ... because the edit manager redoes them
|
|
GetInterface () -> GetMultiDevice () -> GetEditManager () -> AskFor (m_stSizeChangingMode . pZDxModif);
|
|
}
|
|
*/
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
|
|
//*****************************************************************************
|
|
// Compute dimension of objects
|
|
//*****************************************************************************
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ComputeBoundingBoxOfObject
|
|
// Compute the bounding box of a geometric object, and return its limits in _pMinPoint and _pMaxPoint
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ComputeBoundingBoxOfObject (CPA_BaseObject * _pObject , POS_tdstCompletePosition * _pGlobalMatrix , POS_tdstCompletePosition * _pLocalMatrix ,
|
|
MTH3D_tdstVector * _pMinPoint, MTH3D_tdstVector * _pMaxPoint)
|
|
{
|
|
MTH3D_M_vSetVectorElements (_pMinPoint , 1E6 , 1E6 , 1E6);
|
|
MTH3D_M_vSetVectorElements (_pMaxPoint , -1E6 , -1E6 , -1E6);
|
|
|
|
if (_pObject == NULL) return;
|
|
|
|
ACP_tdxHandleOfObject hObject;
|
|
if (_pObject -> fn_bIsOfType (C_szGeometricObjectTypeName))
|
|
{
|
|
hObject = (ACP_tdxHandleOfObject) _pObject -> GetData ();
|
|
}
|
|
else
|
|
if (_pObject -> fn_bIsOfType (C_szPhysicalObjectTypeName))
|
|
{
|
|
hObject = (ACP_tdxHandleOfObject) ((EditorPO *) _pObject) -> m_fnp_oGetGeometricWithDistance (0.0) -> GetData ();
|
|
}
|
|
else return;
|
|
|
|
for (ACP_tdxIndex xNumPoint = 0 ; xNumPoint < GEO_xGetGeometricObjectNumberOfPoints (hObject) ; xNumPoint++)
|
|
{
|
|
MTH3D_tdstVector Point;
|
|
GEO_vGetPointOfObject (hObject , & Point, xNumPoint);
|
|
POS_fn_vMulMatrixVertex(& Point , _pLocalMatrix , & Point);
|
|
POS_fn_vMulMatrixVector (& Point , _pGlobalMatrix , & Point);
|
|
|
|
MTH3D_M_vSetVectorElements (_pMinPoint ,
|
|
MTH_M_xMin (MTH3D_M_xGetXofVector (_pMinPoint) , MTH3D_M_xGetXofVector (& Point)) ,
|
|
MTH_M_xMin (MTH3D_M_xGetYofVector (_pMinPoint) , MTH3D_M_xGetYofVector (& Point)) ,
|
|
MTH_M_xMin (MTH3D_M_xGetZofVector (_pMinPoint) , MTH3D_M_xGetZofVector (& Point)));
|
|
|
|
MTH3D_M_vSetVectorElements (_pMaxPoint ,
|
|
MTH_M_xMax (MTH3D_M_xGetXofVector (_pMaxPoint) , MTH3D_M_xGetXofVector (& Point)) ,
|
|
MTH_M_xMax (MTH3D_M_xGetYofVector (_pMaxPoint) , MTH3D_M_xGetYofVector (& Point)) ,
|
|
MTH_M_xMax (MTH3D_M_xGetZofVector (_pMaxPoint) , MTH3D_M_xGetZofVector (& Point)));
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ComputeBoundingBoxOfObjectAndChilds
|
|
// Compute the bounding box of an object and all of its childs, and return the limits in _pMinPoint and _pMaxPoint
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ComputeBoundingBoxOfObjectAndChilds (CPA_SuperObject * _pSuperObject ,
|
|
MTH3D_tdstVector * _pMinPoint, MTH3D_tdstVector *_pMaxPoint)
|
|
{
|
|
// The object
|
|
CPA_BaseObject * pObject = _pSuperObject -> GetObject ();
|
|
if (pObject)
|
|
{
|
|
POS_tdstCompletePosition IdentityMatrix;
|
|
POS_fn_vSetIdentityMatrix(& IdentityMatrix);
|
|
|
|
ComputeBoundingBoxOfObject (pObject, & IdentityMatrix , &IdentityMatrix, _pMinPoint, _pMaxPoint);
|
|
}
|
|
|
|
// The childs
|
|
POS_tdstCompletePosition * pGlobalMatrix = HIE_fn_hGetSuperObjectGlobalMatrix (_pSuperObject -> GetStruct ());
|
|
|
|
CPA_SuperObject * pChildSuperObject = _pSuperObject -> GetSuperObjectFirstChild ();
|
|
while (pChildSuperObject)
|
|
{
|
|
MTH3D_tdstVector ChildMinPoint , ChildMaxPoint;
|
|
|
|
POS_tdstCompletePosition * pLocalMatrix = HIE_fn_hGetSuperObjectMatrix (pChildSuperObject -> GetStruct ());
|
|
if(pChildSuperObject->GetObject())
|
|
{
|
|
ComputeBoundingBoxOfObject (pChildSuperObject -> GetObject () , pGlobalMatrix , pLocalMatrix, & ChildMinPoint , & ChildMaxPoint);
|
|
MTH3D_M_vSetVectorElements (_pMinPoint,
|
|
MTH_M_xMin (MTH3D_M_xGetXofVector (_pMinPoint) , MTH3D_M_xGetXofVector (& ChildMinPoint)) ,
|
|
MTH_M_xMin (MTH3D_M_xGetYofVector (_pMinPoint) , MTH3D_M_xGetYofVector (& ChildMinPoint)) ,
|
|
MTH_M_xMin (MTH3D_M_xGetZofVector (_pMinPoint) , MTH3D_M_xGetZofVector (& ChildMinPoint)));
|
|
|
|
MTH3D_M_vSetVectorElements (_pMaxPoint,
|
|
MTH_M_xMax (MTH3D_M_xGetXofVector (_pMaxPoint) , MTH3D_M_xGetXofVector (& ChildMaxPoint)) ,
|
|
MTH_M_xMax (MTH3D_M_xGetYofVector (_pMaxPoint) , MTH3D_M_xGetYofVector (& ChildMaxPoint)) ,
|
|
MTH_M_xMax (MTH3D_M_xGetZofVector (_pMaxPoint) , MTH3D_M_xGetZofVector (& ChildMaxPoint)));
|
|
|
|
}
|
|
else
|
|
{
|
|
CPA_SuperObject * pSPOChild = pChildSuperObject -> GetSuperObjectFirstChild();
|
|
POS_tdstCompletePosition * pSPOLocalMatrix = HIE_fn_hGetSuperObjectMatrix(pChildSuperObject -> GetStruct());
|
|
|
|
while(pSPOChild)
|
|
{
|
|
MTH3D_tdstVector SPOChildMinPoint , SPOChildMaxPoint;
|
|
POS_tdstCompletePosition stSPOTransformMatrix;
|
|
POS_tdstCompletePosition * pSPOScaleMatrix = HIE_fn_hGetSuperObjectMatrix (pSPOChild -> GetStruct ());
|
|
|
|
POS_fn_vSetIdentityMatrix(&stSPOTransformMatrix);
|
|
POS_fn_vMulMatrixMatrix(&stSPOTransformMatrix, pSPOLocalMatrix, pSPOScaleMatrix);
|
|
|
|
ComputeBoundingBoxOfObject (pSPOChild -> GetObject () , pGlobalMatrix , &stSPOTransformMatrix, & SPOChildMinPoint , & SPOChildMaxPoint);
|
|
|
|
MTH3D_M_vSetVectorElements (_pMinPoint,
|
|
MTH_M_xMin (MTH3D_M_xGetXofVector (_pMinPoint) , MTH3D_M_xGetXofVector (& SPOChildMinPoint)) ,
|
|
MTH_M_xMin (MTH3D_M_xGetYofVector (_pMinPoint) , MTH3D_M_xGetYofVector (& SPOChildMinPoint)) ,
|
|
MTH_M_xMin (MTH3D_M_xGetZofVector (_pMinPoint) , MTH3D_M_xGetZofVector (& SPOChildMinPoint)));
|
|
|
|
MTH3D_M_vSetVectorElements (_pMaxPoint,
|
|
MTH_M_xMax (MTH3D_M_xGetXofVector (_pMaxPoint) , MTH3D_M_xGetXofVector (& SPOChildMaxPoint)) ,
|
|
MTH_M_xMax (MTH3D_M_xGetYofVector (_pMaxPoint) , MTH3D_M_xGetYofVector (& SPOChildMaxPoint)) ,
|
|
MTH_M_xMax (MTH3D_M_xGetZofVector (_pMaxPoint) , MTH3D_M_xGetZofVector (& SPOChildMaxPoint)));
|
|
|
|
pSPOChild = pChildSuperObject -> GetSuperObjectNextChild (pSPOChild);
|
|
}
|
|
}
|
|
pChildSuperObject = _pSuperObject -> GetSuperObjectNextChild (pChildSuperObject);
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ComputeInitialSizeOfBox
|
|
// Compute the bounding box dimension of an object and all of its childs
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Interface::ComputeInitialSizeOfBox (CPA_SuperObject * _pSuperObject ,
|
|
MTH3D_tdstVector * MinPoint , MTH3D_tdstVector * MaxPoint)
|
|
{
|
|
ComputeBoundingBoxOfObjectAndChilds (_pSuperObject , MinPoint , MaxPoint);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Interface - ComputeInitialSizeOfSphere
|
|
// Compute the bounding sphere radius of an object and all of its childs
|
|
//-----------------------------------------------------------------------------
|
|
MTH_tdxReal ZDx_Interface::ComputeInitialSizeOfSphere (CPA_SuperObject * _pSuperObject , MTH3D_tdstVector * Center)
|
|
{
|
|
// Compute min and max points
|
|
MTH3D_tdstVector MinPoint , MaxPoint;
|
|
|
|
|
|
ComputeBoundingBoxOfObjectAndChilds (_pSuperObject , & MinPoint , & MaxPoint);
|
|
|
|
/* Now the function ComputeBoundingBoxOfObjectAndChilds returns a Min and a Max point
|
|
that are computed in the global axis system WITHOUT the translation of the object */
|
|
/* There could be some bug if the Z axis was not the same for a character and for the world */
|
|
|
|
// Compute the center
|
|
MTH3D_M_vMiddleVector (Center , & MinPoint , & MaxPoint);
|
|
|
|
// Compute and return the radius
|
|
MTH3D_tdstVector Difference;
|
|
MTH3D_M_vSubVector (& Difference , & MaxPoint , & MinPoint);
|
|
MTH3D_M_vMulScalarVector (& Difference , (float) 0.5 , & Difference);
|
|
|
|
return MTH_M_xMax (MTH_M_xMax (MTH3D_M_xGetXofVector (& Difference) , MTH3D_M_xGetYofVector (& Difference)) ,
|
|
MTH3D_M_xGetZofVector (& Difference));
|
|
}
|