652 lines
27 KiB
C++
652 lines
27 KiB
C++
//*****************************************************************************
|
|
//* _zObject.cpp *
|
|
//*****************************************************************************
|
|
//* *
|
|
//* This file contains all the methods of the ZDx_Object class *
|
|
//* and its inherited classes *
|
|
//* *
|
|
//*****************************************************************************
|
|
//* Author : Alexis Vaisse *
|
|
//*****************************************************************************
|
|
|
|
|
|
// "standard" include
|
|
#include "stdafx.h"
|
|
#include "ACP_Base.h"
|
|
|
|
#include "TFA.h" // Family dll include
|
|
|
|
#define HieFriend
|
|
#include "IncGAM.h"
|
|
#include "IncITF.h"
|
|
#include "..\Main\Inc\_EditID.h"
|
|
|
|
#include "OGD.h" // 3dGeom dll include
|
|
#include "OAC.h" // Actor dll include
|
|
#include "OPD.h" // Physical object dll include
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
#include "ozo.h"
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
|
|
|
|
// personal include
|
|
#include "_zObject.hpp"
|
|
#include "_zInterf.hpp"
|
|
|
|
|
|
//*****************************************************************************
|
|
// class ZDx_Object
|
|
//*****************************************************************************
|
|
|
|
//DeclareTemplateStatic (ACP_tdxHandleOfObject);
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - GiveZDxID
|
|
// Give the ID of a ZDx object, depending on its type
|
|
//-----------------------------------------------------------------------------
|
|
long ZDx_Object::GiveZDxID (tdeZDxType _eZDxType)
|
|
{
|
|
switch (_eZDxType)
|
|
{
|
|
case eZdd : return C_lZDD;
|
|
case eZde : return C_lZDE;
|
|
case eZdm : return C_lZDM;
|
|
case eZdr : return C_lZDR;
|
|
case eBoundingVolume : return C_lBoundingVolume;
|
|
// ANNECY AV CLEAN_MEC {
|
|
// case eTestPoint : return C_lTestPoint;
|
|
// END ANNECY AV }
|
|
default : ASSERT (0);
|
|
return C_lZDD;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - constructor
|
|
//-----------------------------------------------------------------------------
|
|
ZDx_Object::ZDx_Object (ZDx_Interface * _pZDxInterface , const CString _csZDxTypeName ,
|
|
tdeZDxType _eZDxType , tdeZDxGeometricType _eZDxGeometricType ,
|
|
CString _csZDxName , CPA_BaseObject * _pOwner ,
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
Shape3D * _pGeometric3dObject /*, ACP_tdxHandleOfElement _hHandleOfElement*/)
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
|
|
// ANNECY AV CLEAN_MEC {
|
|
: CPA_SaveObject (_pZDxInterface , _csZDxTypeName , /* _eZDxType == eTestPoint ? E_ss_NoSave : */ E_ss_Responsible , _pOwner) ,
|
|
// END ANNECY AV }
|
|
CPA_EdMot<ACP_tdxHandleOfObject> ((ACP_tdxHandleOfObject) _pGeometric3dObject -> GetData ())
|
|
{
|
|
m_pZDxShape = 0; // Because it can be used by fn_csComputeReferencedSectionName called by fn_eRename
|
|
|
|
// Initialisation for base class
|
|
|
|
SetSectionData (this);
|
|
SetDataPath ("");
|
|
SetReferencedSectionName ("");
|
|
|
|
// Internal initialisation
|
|
|
|
SetZDxType (_eZDxType);
|
|
SetZDxGeometricType (_eZDxGeometricType);
|
|
m_eDisplayType = eNotDisplayed;
|
|
m_bMotorDisplay = TRUE;
|
|
m_lIndexInList = -1;
|
|
// ANNECY AV CLEAN_MEC {
|
|
// m_pTestPoint = NULL;
|
|
// END ANNECY AV }
|
|
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
// switch (_eZDxGeometricType)
|
|
// {
|
|
// case eSphere : m_pZDxShape = new ZDx_Shape (this , _pGeometric3dObject /*, _hHandleOfElement*/); break;
|
|
// case eBox : m_pZDxShape = new ZDx_Shape (this , _pGeometric3dObject /*, _hHandleOfElement*/); break;
|
|
// case ePoint : m_pZDxShape = new ZDx_Shape (this , _pGeometric3dObject /*, _hHandleOfElement*/); break;
|
|
// case eCone : m_pZDxShape = new ZDx_Shape (this , _pGeometric3dObject /*, _hHandleOfElement*/); break;
|
|
// default: ASSERT (0); break;
|
|
// }
|
|
m_pZDxShape = new ZDx_Shape (this , _pGeometric3dObject);
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
|
|
// Set the name
|
|
|
|
if (fn_eRename (_csZDxName) != E_mc_None) SetDefaultValidName ();
|
|
fn_vUpdateSectionName ();
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - copy constructor
|
|
//-----------------------------------------------------------------------------
|
|
ZDx_Object::ZDx_Object (ZDx_Object & _pZDxObjectToCopy)
|
|
|
|
: CPA_SaveObject (_pZDxObjectToCopy)
|
|
{
|
|
SetZDxType (_pZDxObjectToCopy . GetZDxType ());
|
|
SetZDxGeometricType (_pZDxObjectToCopy . GetZDxGeometricType ());
|
|
m_eDisplayType = eNotDisplayed;
|
|
m_bMotorDisplay = TRUE;
|
|
m_lIndexInList = -1;
|
|
// ANNECY AV CLEAN_MEC {
|
|
// m_pTestPoint = NULL;
|
|
// END ANNECY AV }
|
|
|
|
// Create a new geometric object
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
//ACP_tdxHandleOfElement HandleOfElement;
|
|
Shape3D * pGeometric3dObject = ((ZDx_Interface *) GetEditor ()) ->
|
|
CreateGraphicObject (_pZDxObjectToCopy . GetZDxGeometricType () /*, & HandleOfElement */, "" , ""); //??? Remplir DataPath et ReferenceSectionName
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
|
|
SetStruct ((ACP_tdxHandleOfObject) _pZDxObjectToCopy . GetEngineStruct ());
|
|
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
MTH3D_tdstVector stPoint;
|
|
GLI_tdxValue Length;
|
|
Shape3D *pShape3DToCopy = _pZDxObjectToCopy . GetZDxShape () -> GetGeometric3dObject ();
|
|
|
|
switch (m_eZDxGeometricType)
|
|
{
|
|
case eSphere :
|
|
m_pZDxShape = new ZDx_Shape (this , pGeometric3dObject);/*, HandleOfElement ,
|
|
(ZDx_Sphere *) _pZDxObjectToCopy . GetZDxShape ());*/
|
|
stPoint = ((Sphere3D *)pShape3DToCopy) -> GetCenter ();
|
|
((Sphere3D *) pGeometric3dObject) -> SetCenter (& stPoint);
|
|
Length = ((Sphere3D *)pShape3DToCopy) -> GetRadius ();
|
|
((Sphere3D *) pGeometric3dObject) -> SetRadius (& Length);
|
|
break;
|
|
case eBox :
|
|
m_pZDxShape = new ZDx_Shape (this , pGeometric3dObject); /*, HandleOfElement ,
|
|
(ZDx_Box *) _pZDxObjectToCopy . GetZDxShape ());*/
|
|
stPoint = ((Box3D *) pShape3DToCopy) -> GetMinPoint ();
|
|
((Box3D *) pGeometric3dObject) -> SetMinPoint (& stPoint);
|
|
stPoint = ((Box3D *) pShape3DToCopy) -> GetMaxPoint ();
|
|
((Box3D *) pGeometric3dObject) -> SetMaxPoint (& stPoint);
|
|
stPoint = ((Box3D *) pShape3DToCopy) -> GetMinPoint ();
|
|
((Box3D *) pGeometric3dObject) -> SetMinPoint (& stPoint); // To be sure it is copied (because we must have Min <= Max)
|
|
break;
|
|
case ePoint :
|
|
m_pZDxShape = new ZDx_Point (this , pGeometric3dObject /*, HandleOfElement */,
|
|
(ZDx_Point *) _pZDxObjectToCopy . GetZDxShape ());
|
|
break;
|
|
case eCone :
|
|
m_pZDxShape = new ZDx_Shape (this , pGeometric3dObject); /*, HandleOfElement ,
|
|
(ZDx_Cone *) _pZDxObjectToCopy . GetZDxShape ());*/
|
|
stPoint = ((Cone3D *) pShape3DToCopy) -> GetBasePoint ();
|
|
((Cone3D *) pGeometric3dObject) -> SetBasePoint (& stPoint);
|
|
stPoint = ((Cone3D *) pShape3DToCopy) -> GetTopPoint ();
|
|
((Cone3D *) pGeometric3dObject) -> SetTopPoint (& stPoint);
|
|
Length = ((Cone3D *) pShape3DToCopy) -> GetRadius ();
|
|
((Cone3D *) pGeometric3dObject) -> SetRadius (& Length);
|
|
break;
|
|
default: ASSERT (0);
|
|
break;
|
|
}
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - destructor
|
|
//-----------------------------------------------------------------------------
|
|
ZDx_Object::~ZDx_Object ()
|
|
{
|
|
delete m_pZDxShape -> GetGeometric3dObject (); // We delete the geometric object
|
|
delete m_pZDxShape; // and the ZDx shape object
|
|
|
|
// ANNECY AV CLEAN_MEC {
|
|
// if (m_pTestPoint) delete m_pTestPoint;
|
|
// END ANNECY AV }
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - InitZDxObject
|
|
// static initialization : this function must be called once to initialize the CPA_EdMot functions
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Object::InitZDxObject ()
|
|
{
|
|
CPA_EdMot<ACP_tdxHandleOfObject>::Init (CreateZDxEngineStruct , CopyZDxEngineStruct , DeleteZDxEngineStruct);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - CreateZDxEngineStruct
|
|
// When created, a ZDx_Object has no engine object
|
|
// It will be added later
|
|
//-----------------------------------------------------------------------------
|
|
ACP_tdxHandleOfObject ZDx_Object::CreateZDxEngineStruct ()
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - CopyZDxEngineStruct
|
|
// Copy a ZDx engine structure
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Object::CopyZDxEngineStruct (ACP_tdxHandleOfObject _hDst , ACP_tdxHandleOfObject _hSrc)
|
|
{
|
|
// A ZDx can't be copied
|
|
_hDst = NULL;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - DeleteZDxEngineStruct
|
|
// Delete a ZDx engine structure
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Object::DeleteZDxEngineStruct (ACP_tdxHandleOfObject _hZDxEngineStruct)
|
|
{
|
|
// We do nothing
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - GetDataType
|
|
// Return the engine type of the ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
long ZDx_Object::GetDataType ()
|
|
{
|
|
return GiveZDxID (m_eZDxType);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - GetData
|
|
// Return the engine object of the ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
void * ZDx_Object::GetData ()
|
|
{
|
|
return GetStruct ();
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - fn_eCheckUnicity
|
|
// Check if the given name is valid or not
|
|
//-----------------------------------------------------------------------------
|
|
tdeMissingCriteria ZDx_Object::fn_eCheckUnicity (const CString csNewName)
|
|
{
|
|
// Check unicity with owner
|
|
tdeMissingCriteria eResult = fn_eCheckUnicityWithOwner (csNewName);
|
|
if (eResult != E_mc_None) return eResult;
|
|
|
|
// Check unicity for geometric object name
|
|
ZDx_Shape * pZDxShape = GetZDxShape ();
|
|
if (! pZDxShape) return E_mc_None;
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
Shape3D * pGeometric3dObject = pZDxShape -> GetGeometric3dObject ();
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
if (! pGeometric3dObject) return E_mc_None;
|
|
|
|
if (pGeometric3dObject -> GetName () . CompareNoCase (csNewName) == 0) return E_mc_None;
|
|
else return pGeometric3dObject -> fn_eCheckUnicity (csNewName);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - fn_vNotifyRename
|
|
// Called when one renames the ZDx : we also rename the geometric object
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Object::fn_vNotifyRename ()
|
|
{
|
|
SetReferencedSectionName (fn_csComputeReferencedSectionName (GetName ()));
|
|
|
|
tdeMissingCriteria eResult = GetZDxShape () -> GetGeometric3dObject () -> fn_eRename (GetName ());
|
|
ASSERT (eResult == E_mc_None);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - GetZDxTypeName
|
|
// return the name of the type of the ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
char * ZDx_Object::GetZDxTypeName ()
|
|
{
|
|
switch (m_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_Object - GetZDxName
|
|
// return the name of the ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
char * ZDx_Object::GetZDxName ()
|
|
{
|
|
// return the name of the object
|
|
return (char *) LPCTSTR (GetName ());
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - SetZDxName
|
|
// set the name of the ZDx object
|
|
// return FALSE if the name already exists
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ZDx_Object::SetZDxName (char * szNewName)
|
|
{
|
|
char * szOldName = GetZDxName ();
|
|
|
|
tdeMissingCriteria eResult = fn_eRename (szNewName);
|
|
|
|
if (eResult == E_mc_None) // If the name has changed
|
|
{
|
|
// We get the list of zone list
|
|
CPA_BaseObjectList * pListOfEdtList = GetEditor () -> GetMainWorld () -> fn_p_oGetOriginalObjectList (C_szEdtListTypeName);
|
|
|
|
for (int i = 0 ; i < pListOfEdtList -> GetCount () ; i ++)
|
|
{
|
|
EdtList * pEdtList = (EdtList *) pListOfEdtList -> GetObjectWithIndex (i);
|
|
// If the zone list contains this zone, we notify to save it
|
|
if (pEdtList -> Find (this)) pEdtList -> fn_vUpdateReference (this);
|
|
}
|
|
|
|
// We get the list of physical objects
|
|
CPA_BaseObjectList * pListOfPO = GetEditor () -> GetMainWorld () -> fn_p_oGetOriginalObjectList (C_szPhysicalObjectTypeName);
|
|
|
|
for (i = 0 ; i < pListOfPO -> GetCount () ; i ++)
|
|
{
|
|
EditorPO * pModule = (EditorPO *) pListOfPO -> GetObjectWithIndex (i);
|
|
// If the module contains this zone, we notify to save it
|
|
if (pModule -> GetZone (C_ucTypeZdd) == this ||
|
|
pModule -> GetZone (C_ucTypeZde) == this ||
|
|
pModule -> GetZone (C_ucTypeZdm) == this ||
|
|
pModule -> GetZone (C_ucTypeZdr) == this) pModule -> fn_vUpdateReference (this);
|
|
}
|
|
|
|
// We get the list of families
|
|
CPA_BaseObjectList * pListOfFamily = GetEditor () -> GetMainWorld () -> fn_p_oGetOriginalObjectList (C_szFamilyTypeName);
|
|
|
|
for (i = 0 ; i < pListOfFamily -> GetCount () ; i ++)
|
|
{
|
|
CPA_Family * pFamily = (CPA_Family *) pListOfFamily -> GetObjectWithIndex (i);
|
|
if (pFamily -> mfn_p_oGetBoundingVolume () == this) pFamily -> fn_vUpdateReference (this);
|
|
}
|
|
}
|
|
|
|
return eResult == E_mc_None;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - CallbackToCreateZDxFile
|
|
// We must add one special line in a ZDx file
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Object::CallbackToCreateZDxFile (SCR_tdst_File_Description * _pFile ,
|
|
char * _szSectionName ,
|
|
void * _pData ,
|
|
SCR_tde_Ntfy_Action _eAction)
|
|
{
|
|
switch (_eAction)
|
|
{
|
|
case SCR_EA_Ntfy_AddSection : // The ZDx file does not exist : we ad a special line
|
|
fn_v_SvL0_fputs (_pFile , "$SetCurrentFileDouble(1,1.0)\n");
|
|
break;
|
|
case SCR_EA_Ntfy_ModifySection : // The ZDx file already exists : we do nothing
|
|
break;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - fn_vNotifySave
|
|
// Virtual function from the base class called to notify to save a ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Object::fn_vNotifySave ()
|
|
{
|
|
if (! fn_bCanBeNotified ()) return;
|
|
|
|
GetZDxShape () -> GetGeometric3dObject () -> fn_vNotifySave ();
|
|
|
|
// Register the file callback
|
|
char szFileName [SCR_CV_ui_Cfg_MaxLenName];
|
|
SCR_fn_v_RdL0_SplitSectionName ((char *) (LPCTSTR) GetZDxShape () -> GetGeometric3dObject () -> GetCompleteSectionName () , szFileName , NULL , NULL);
|
|
// If the file does not exist, register a callback on it
|
|
if (_access (szFileName , 0) == -1)
|
|
SCR_fn_v_SvL1_RegisterNotify (szFileName , CallbackToCreateZDxFile , NULL , SCR_EA_Ntfy_AddOrModifySection);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - fn_vNotifyUnSave
|
|
// Virtual function from the base class called to notify to delete a ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Object::fn_vNotifyUnSave ()
|
|
{
|
|
if (! fn_bCanBeNotified ()) return;
|
|
|
|
// We notify to delete the ZDx object only if it is not shared by several modules
|
|
if (GetNumberOfModuleUsingThis () <= 1) GetZDxShape () -> GetGeometric3dObject () -> fn_vNotifyUnSave ();
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object - fn_vNotifyRestore
|
|
// Virtual function from the base class called to notify to restore a deleted ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Object::fn_vNotifyRestore ()
|
|
{
|
|
if (! fn_bCanBeNotified ()) return;
|
|
|
|
// We notify to restore a deleted ZDx object only if it is not used by another module
|
|
if (GetNumberOfModuleUsingThis () == 0) GetZDxShape () -> GetGeometric3dObject () -> fn_vNotifyRestore ();
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object : fn_csComputeReferencedSectionName
|
|
// Compte the referenced section name : use the function of the geometric 3d object
|
|
//-----------------------------------------------------------------------------
|
|
CString ZDx_Object::fn_csComputeReferencedSectionName (const CString _csNewName)
|
|
{
|
|
ZDx_Shape * pZDxShape = GetZDxShape ();
|
|
if (! pZDxShape) return "";
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
Shape3D * pGeometric3dObject = pZDxShape -> GetGeometric3dObject ();
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
if (! pGeometric3dObject) return "";
|
|
|
|
return pGeometric3dObject -> fn_csComputeReferencedSectionName (_csNewName);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object : GetNumberOfModuleUsingThis
|
|
// Get the number of modules using this ZDx object
|
|
//-----------------------------------------------------------------------------
|
|
long ZDx_Object::GetNumberOfModuleUsingThis ()
|
|
{
|
|
long lNumber = 0;
|
|
// We get the list of physical objects
|
|
CPA_BaseObjectList * pListOfPO = GetEditor () -> GetMainWorld () -> fn_p_oGetOriginalObjectList (C_szPhysicalObjectTypeName);
|
|
|
|
for (int i = 0 ; i < pListOfPO -> GetCount () ; i ++)
|
|
{
|
|
EditorPO * pModule = (EditorPO *) pListOfPO -> GetObjectWithIndex (i);
|
|
if (pModule -> GetZone (C_ucTypeZdd) == this ||
|
|
pModule -> GetZone (C_ucTypeZde) == this ||
|
|
pModule -> GetZone (C_ucTypeZdm) == this ||
|
|
pModule -> GetZone (C_ucTypeZdr) == this) lNumber++;
|
|
}
|
|
|
|
return lNumber;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Object : RedrawZDxObject
|
|
// redraw the object (in fact, redraw the whole world)
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Object::RedrawZDxObject ()
|
|
{
|
|
((ZDx_Interface *) GetEditor ()) -> IWillRefreshDisplay (C_lRedrawZDxObject);
|
|
((ZDx_Interface *) GetEditor ()) -> RefreshDisplay (C_lRedrawZDxObject);
|
|
}
|
|
|
|
|
|
//*****************************************************************************
|
|
// class ZDx_Shape
|
|
//
|
|
// The base class for the different shape of ZDx
|
|
// The inherited classes will contains methods to modify the geometric definition of the ZDx
|
|
//*****************************************************************************
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Shape - constructor
|
|
//-----------------------------------------------------------------------------
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
ZDx_Shape::ZDx_Shape (ZDx_Object * _pZDxObject , Shape3D * _pGeometric3dObject /*,
|
|
ACP_tdxHandleOfElement _HandleOfElement*/)
|
|
{
|
|
m_pZDxObject = _pZDxObject;
|
|
m_pGeometric3dObject = _pGeometric3dObject;
|
|
//m_hHandleOfElement = _HandleOfElement;
|
|
}
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Shape : RefreshData
|
|
// Recompute the center of the object from the position of the super object
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Shape::RefreshData (CPA_SuperObject * _pSuperObject)
|
|
{
|
|
// Get the matrix of the super object
|
|
GEO_tdxHandleToMatrix hHandleToMatrix = HIE_fn_hGetSuperObjectMatrix (_pSuperObject -> GetStruct ());
|
|
// Get the translation vector
|
|
MTH3D_tdstVector TranslationVector;
|
|
POS_fn_vGetTranslationVector(hHandleToMatrix , & TranslationVector);
|
|
|
|
// Add this translation vector to the center of the object
|
|
MTH3D_tdstVector Center = GetCenter ();
|
|
MTH3D_M_vAddVector (& Center , & Center , & TranslationVector);
|
|
SetCenter (& Center);
|
|
|
|
// Set the translation vector to null;
|
|
MTH3D_M_vNullVector (& TranslationVector);
|
|
POS_fn_vSetTranslationVector(hHandleToMatrix , & TranslationVector);
|
|
}
|
|
|
|
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
|
|
|
|
//*****************************************************************************
|
|
// class ZDx_Point
|
|
//
|
|
// The class to modify the geometric aspect of a ZDx of type point
|
|
//*****************************************************************************
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Point : Constructor
|
|
//-----------------------------------------------------------------------------
|
|
ZDx_Point::ZDx_Point (ZDx_Object * _pZDxObject , Shape3D * _pGeometric3dObject /*,
|
|
ACP_tdxHandleOfElement HandleOfElement */,
|
|
ZDx_Point * _pZDxPointToCopy /* = NULL */)
|
|
: ZDx_Shape (_pZDxObject , _pGeometric3dObject /*, HandleOfElement*/)
|
|
{
|
|
if (_pZDxPointToCopy)
|
|
{
|
|
MTH3D_tdstVector stPoint = ((Point3D *) _pZDxPointToCopy -> GetGeometric3dObject ()) -> GetPoint ();
|
|
((Point3D *) _pGeometric3dObject) -> SetPoint (& stPoint);
|
|
// BEGIN CPA2 Cristi Petrescu 97-12-05
|
|
// if (_pZDxObject -> GetZDxType () == eTestPoint)
|
|
// ANNECY AV CLEAN_MEC {
|
|
// UpdateTestPointPosition ();
|
|
// END ANNECY AV }
|
|
// END CPA2 Cristi Petrescu 97-12-05
|
|
}
|
|
}
|
|
|
|
/*
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Point : GetPoint
|
|
// return the 3D coordinates of the point
|
|
//-----------------------------------------------------------------------------
|
|
MTH3D_tdstVector ZDx_Point::GetPoint ()
|
|
{
|
|
MTH3D_tdstVector stPoint;
|
|
GetGeometric3dObject () -> fn_vGetPoint (0 , & stPoint);
|
|
return stPoint;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Point : SetPoint
|
|
// set the 3D coordinates of the point
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Point::SetPoint (MTH3D_tdstVector * _pPoint)
|
|
{
|
|
GetGeometric3dObject () -> fn_vSetPoint (0 , _pPoint);
|
|
|
|
if (m_pZDxObject -> GetZDxType () == eTestPoint) UpdateTestPointPosition ();
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Point : SetPointX
|
|
// set the X coordinate of the point
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Point::SetPointX (GLI_tdxValue _X)
|
|
{
|
|
MTH3D_tdstVector stPoint = GetPoint ();
|
|
MTH3D_M_vSetXofVector (& stPoint , _X);
|
|
SetPoint (& stPoint);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Point : SetPointY
|
|
// set the Y coordinate of the point
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Point::SetPointY (GLI_tdxValue _Y)
|
|
{
|
|
MTH3D_tdstVector stPoint = GetPoint ();
|
|
MTH3D_M_vSetYofVector (& stPoint , _Y);
|
|
SetPoint (& stPoint);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class ZDx_Point : SetPointZ
|
|
// set the Z coordinate of the point
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Point::SetPointZ (GLI_tdxValue _Z)
|
|
{
|
|
MTH3D_tdstVector stPoint = GetPoint ();
|
|
MTH3D_M_vSetZofVector (& stPoint , _Z);
|
|
SetPoint (& stPoint);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Point - SetColorOfPoint
|
|
// Set the color of the point : selected or not selected
|
|
//-----------------------------------------------------------------------------
|
|
void ZDx_Point::SetColorOfPoint (BOOL _bSelected)
|
|
{
|
|
GMT_tdxHandleToGameMaterial hGameMaterial = GEO_xGetGameMaterialOfElementPoints
|
|
((ACP_tdxHandleOfObject) m_pGeometric3dObject -> GetData () , m_hHandleOfElement);
|
|
ACP_tdxHandleOfMaterial hVisualMaterial = GMT_fn_hGetVisualMaterial (hGameMaterial);
|
|
GEO_tdstColor stColor;
|
|
if (_bSelected) // selected -> pink
|
|
{
|
|
stColor . xR = 1.0;
|
|
stColor . xG = 0.5;
|
|
stColor . xB = 1.0;
|
|
}
|
|
else // not selected -> white
|
|
{
|
|
stColor . xR = 1.0;
|
|
stColor . xG = 1.0;
|
|
stColor . xB = 1.0;
|
|
}
|
|
stColor . xA = 1.0;
|
|
GLI_xSetMaterialColor (hVisualMaterial , & stColor);
|
|
}
|
|
*/
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Class ZDx_Point - UpdateTestPointPosition
|
|
// Set the position of the test point with the position of the point
|
|
//-----------------------------------------------------------------------------
|
|
// ANNECY AV CLEAN_MEC {
|
|
/*
|
|
void ZDx_Point::UpdateTestPointPosition ()
|
|
{
|
|
if (m_pZDxObject -> GetZDxType () == eTestPoint)
|
|
{
|
|
MTH3D_tdstVector stPosition = ((Point3D *) GetGeometric3dObject ()) -> GetPoint ();
|
|
m_pZDxObject -> GetTestPoint () -> SetPosition (& stPosition);
|
|
}
|
|
}
|
|
*/
|
|
// END ANNECY AV }
|
|
|
|
|
|
//ENDROMTEAM WorldEditor (Cristi Petrescu)
|