816 lines
23 KiB
C++
816 lines
23 KiB
C++
/*
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description : WPObj.cpp
|
|
//
|
|
// Definition of the waypoint editors objects
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// inherit from : CPA_Object
|
|
// CPA_EdMot<ACP_tdxHandleOfLink>
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Creation date: 21 jan 1997 Author: J Thénoz
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification date: Author:
|
|
//
|
|
//
|
|
//
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
#include "acp_base.h"
|
|
#include "resource.h"
|
|
#include "incdpt.h"
|
|
#include "incitf.h"
|
|
#include "incgam.h"
|
|
#include "incai.h"
|
|
#include "WPObj.hpp"
|
|
//ANNECY Shaitan Nettoyage (12/05/98) {
|
|
/*
|
|
#include "WayObj.hpp"
|
|
#include "LinkObj.hpp"
|
|
*/
|
|
//ENDANNECY Shaitan Nettoyage }
|
|
#include "Inter.hpp"
|
|
#include "WPMod.hpp"
|
|
#include "WPDia.hpp"
|
|
#include "x:\cpa\main\inc\_editid.h"
|
|
|
|
|
|
|
|
//--------------------------------------- Script definition
|
|
static char* pszWaypointAction = "Waypoint";
|
|
|
|
//----------------------------------------------- static variables
|
|
BOOL WayPoint::ms_bRealDraw = TRUE;
|
|
BOOL WayPoint::ms_bGlobalDraw = FALSE;
|
|
BOOL WayPoint::ms_bOnScreen=TRUE;
|
|
DiaWP* WayPoint::ms_poDiaWP;
|
|
BOOL WayPoint::ms_bNotifyHeader;
|
|
BOOL WayPoint::ms_bDrawJustIsolateWaypoint;
|
|
CPA_List<WayPoint> WayPoint::ms_oListOfWaypoint;
|
|
Waypoint_Interface* WayPoint::ms_poInterface;
|
|
|
|
|
|
|
|
|
|
DeclareTemplateStatic(WP_tdhWayPoint);
|
|
|
|
|
|
void WayPoint::fn_vSetDialog ( DiaWP* poDiaWP )
|
|
{
|
|
ms_poDiaWP=poDiaWP;
|
|
ms_poDiaWP->fn_vInitDialog ();
|
|
}
|
|
|
|
|
|
void del(WP_tdhWayPoint h)
|
|
{
|
|
if (M_GetMainApp()->m_bLeavingApplication == TRUE)
|
|
return;
|
|
WP_fnv_WayPoint_Destroy(h);
|
|
}
|
|
|
|
|
|
void WayPoint::fn_vInitObject (Waypoint_Interface* poInterface)
|
|
{
|
|
// init Edmot
|
|
CPA_EdMot<WP_tdhWayPoint>::Init (WP_fnh_WayPoint_Create, WP_fnv_WayPoint_Copy, del);
|
|
ms_bNotifyHeader=FALSE;
|
|
ms_poInterface = poInterface;
|
|
|
|
ms_bOnScreen = TRUE;
|
|
ms_bDrawJustIsolateWaypoint = TRUE;
|
|
}
|
|
|
|
|
|
void WayPoint::fn_vRefreshWaypoint (void)
|
|
{
|
|
POSITION xPos;
|
|
WayPoint* poWaypoint;
|
|
CPA_SuperObject* poSuperObject;
|
|
CPA_List<CPA_SuperObject>* pListOfWaypointInHierarchy;
|
|
CPA_List<WayPoint> oListOfWaypointToRetreive;
|
|
CPA_BaseObjectList oListOfAllWaypoint;
|
|
|
|
// serach invisible ways in hierarchy
|
|
pListOfWaypointInHierarchy = GetInterface()->GetInterface()->GetObjectListByType("Waypoint");
|
|
if (pListOfWaypointInHierarchy->GetCount())
|
|
{
|
|
for ( poSuperObject=pListOfWaypointInHierarchy->GetHeadElement (xPos); xPos; poSuperObject=pListOfWaypointInHierarchy->GetNextElement (xPos) )
|
|
{
|
|
if (poSuperObject)
|
|
{
|
|
poWaypoint = (WayPoint*)(poSuperObject->GetObject());
|
|
if (!poWaypoint->fn_bIsWaypointDrawable()) oListOfWaypointToRetreive.AddTail (poWaypoint);
|
|
}
|
|
}
|
|
}
|
|
|
|
// and retreive them now
|
|
GetInterface()->fn_vSetRefreshWay (TRUE);
|
|
for ( poWaypoint=oListOfWaypointToRetreive.GetHeadElement (xPos); xPos; poWaypoint=oListOfWaypointToRetreive.GetNextElement (xPos) )
|
|
{
|
|
GetInterface()->fn_vSetModifDeleteOk (TRUE);
|
|
GetInterface()->GetInterface()->fn_bDeleteObjectInHierarchy (poWaypoint->GetSuperObject(),FALSE,FALSE,FALSE,FALSE);
|
|
GetInterface()->fn_vSetModifDeleteOk (FALSE);
|
|
}
|
|
|
|
// Add the way that are not in hierarchy and should be
|
|
if (ms_oListOfWaypoint.GetCount())
|
|
{
|
|
for (poWaypoint=ms_oListOfWaypoint.GetHeadElement(xPos); poWaypoint; poWaypoint=ms_oListOfWaypoint.GetNextElement(xPos) )
|
|
// the waypoint is virtual ?
|
|
if (poWaypoint->GetSuperObject())
|
|
{
|
|
// the waypoint is not in the hierarchy
|
|
if (!poWaypoint->GetSuperObject()->GetParent())
|
|
{
|
|
if (poWaypoint->fn_bIsWaypointDrawable ())
|
|
if (poWaypoint->fn_pGetFather())
|
|
// local waypoint
|
|
GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy (poWaypoint->GetSuperObject(), poWaypoint->fn_pGetFather(),FALSE,FALSE,FALSE );
|
|
else
|
|
// absolute waypoint
|
|
GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy (poWaypoint->GetSuperObject(), GetInterface()->GetInterface()->GetSpecificInterface()->GetDynamicRoot(),FALSE,FALSE,FALSE );
|
|
}
|
|
}
|
|
}
|
|
GetInterface()->fn_vSetRefreshWay (FALSE);
|
|
GetInterface()->GetInterface()->fn_vCancelCurrentSelection (FALSE);
|
|
}
|
|
|
|
BOOL WayPoint::fn_bCheckWaypointCoherence (CPA_List<WayPoint> *poWaypointList)
|
|
{
|
|
POSITION xPos;
|
|
WayPoint* poWaypoint;
|
|
BOOL bCheckWaypointCoherence = TRUE;
|
|
|
|
|
|
for ( poWaypoint=ms_oListOfWaypoint.GetHeadElement(xPos); xPos; poWaypoint=ms_oListOfWaypoint.GetNextElement(xPos) )
|
|
{
|
|
if (!poWaypoint->fn_bCheckCoherence())
|
|
{
|
|
if (poWaypointList) poWaypointList->AddTail (poWaypoint);
|
|
bCheckWaypointCoherence = FALSE;
|
|
}
|
|
}
|
|
return bCheckWaypointCoherence;
|
|
}
|
|
|
|
|
|
|
|
WayPoint::WayPoint (CPA_ObjectDLLBase *p_oDLL, BOOL bAlone, CString csName, BOOL bSave):
|
|
CPA_SaveObject ( p_oDLL, C_szWayPointTypeName, E_ss_Responsible )
|
|
{
|
|
m_bAbsoluteCoordinate=FALSE;
|
|
MTH_tdxReal stInitialValueRadius = 1.f;
|
|
WP_fnv_WayPoint_SetRadius ((WP_tdhWayPoint)GetEngineStruct(), stInitialValueRadius);
|
|
|
|
m_bCurrentDraw=FALSE;
|
|
m_bRealDraw=FALSE;
|
|
m_bSave=bSave;
|
|
m_bAlone = bAlone;
|
|
m_bOnScreen = FALSE;
|
|
m_poSuperObject = NULL;
|
|
// Shaitan Correction {
|
|
m_pSymbolicalGraphic = GetInterface()->fn_pGetNewSymbolicalGraphicObject();
|
|
m_pSymbolicalGraphic->SetEditProtected (TRUE);
|
|
m_pRealGraphic = GetInterface()->fn_pGetNewSphericalGraphicObject();
|
|
m_pRealGraphic->SetEditProtected (TRUE);
|
|
//End Shaitan Correction }
|
|
|
|
m_poDynamicFather = NULL;
|
|
|
|
|
|
ms_oListOfWaypoint.AddTail (this);
|
|
|
|
char szLevelFileName [256];
|
|
char szSectionName [SCR_CV_ui_Cfg_MaxLenName];
|
|
fn_zsGetActualLevelFilename (szLevelFileName,"wp");
|
|
long lSizePath = strlen ( fn_szGetLevelsDataPath() );
|
|
CString csLevelName = szLevelFileName+lSizePath+1;
|
|
csLevelName += "^";
|
|
csLevelName += m_bAlone ? C_SubSectionIsolateWayPointDescription : C_SubSectionInWayWayPointDescription;
|
|
|
|
// section object
|
|
SetSectionData ( this ) ;
|
|
SetCallBackSave ( fn_vCallbackSave ) ;
|
|
SetDataPath ( fn_szGetLevelsDataPath() ) ;
|
|
SCR_fn_v_RdL0_ComputeSectionName ( szSectionName, (char *)(LPCSTR)csLevelName, pszWaypointAction, " ");
|
|
SetReferencedSectionName (szSectionName);
|
|
|
|
// name
|
|
if ( fn_eRename (csName) != E_mc_None)
|
|
SetDefaultValidName ( ) ;
|
|
|
|
fn_vUpdateSectionName ( ) ;
|
|
|
|
SetExistingSection (FALSE) ;
|
|
|
|
// update link table
|
|
SCR_fnp_st_Link_SetValue (WP_fnp_WayPoint_GetLinkTable(),
|
|
(char*)(LPCSTR)GetCompleteSectionName(),
|
|
(unsigned long)GetEngineStruct());
|
|
fn_vNotifySave ();
|
|
}
|
|
|
|
|
|
WayPoint::WayPoint ( CPA_ObjectDLLBase *p_oDLL, WP_tdhWayPoint hEngineWP, CString csName, CString csFileName, CString csSectionName ):
|
|
CPA_SaveObject ( p_oDLL, C_szWayPointTypeName, E_ss_Responsible ),
|
|
CPA_EdMot<WP_tdhWayPoint>(hEngineWP)
|
|
{
|
|
char szSectionName [SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
m_bAbsoluteCoordinate=WP_fnb_WayPoint_IsStatic (hEngineWP);
|
|
m_bCurrentDraw=FALSE;
|
|
m_bRealDraw=FALSE;
|
|
m_bSave=TRUE;
|
|
m_bOnScreen = FALSE;
|
|
m_poSuperObject = NULL;
|
|
// Shaitan Correction {
|
|
m_pSymbolicalGraphic = GetInterface()->fn_pGetNewSymbolicalGraphicObject();
|
|
m_pSymbolicalGraphic->SetEditProtected (TRUE);
|
|
m_pRealGraphic = GetInterface()->fn_pGetNewSphericalGraphicObject();
|
|
m_pRealGraphic->SetEditProtected (TRUE);
|
|
//End Shaitan Correction }
|
|
|
|
m_poDynamicFather = NULL;
|
|
|
|
ms_oListOfWaypoint.AddTail (this);
|
|
|
|
// section object
|
|
SetSectionData ( this ) ;
|
|
SetCallBackSave ( fn_vCallbackSave ) ;
|
|
SetDataPath ( fn_szGetLevelsDataPath() ) ;
|
|
SCR_fn_v_RdL0_ComputeSectionName ( szSectionName, (char *)(LPCSTR)csFileName, (char *)(LPCSTR)csSectionName, " ");
|
|
SetReferencedSectionName (szSectionName);
|
|
|
|
// name
|
|
if ( fn_eRename (csName) != E_mc_None)
|
|
SetDefaultValidName ( ) ;
|
|
|
|
fn_vUpdateSectionName ( ) ;
|
|
|
|
SetExistingSection (TRUE) ;
|
|
}
|
|
|
|
|
|
WayPoint::WayPoint( WayPoint& rWayPoint):
|
|
CPA_SaveObject ( ms_poInterface, C_szWayPointTypeName, E_ss_Responsible ),
|
|
CPA_EdMot<WP_tdhWayPoint>()
|
|
{
|
|
m_bAbsoluteCoordinate=rWayPoint.m_bAbsoluteCoordinate;
|
|
m_poFather=rWayPoint.m_poFather;
|
|
m_bCurrentDraw=rWayPoint.m_bCurrentDraw;
|
|
m_bRealDraw=rWayPoint.m_bRealDraw;
|
|
m_bSave=rWayPoint.m_bSave;
|
|
m_bOnScreen = FALSE;
|
|
m_poSuperObject = NULL;
|
|
// Shaitan Correction {
|
|
m_pSymbolicalGraphic = GetInterface()->fn_pGetNewSymbolicalGraphicObject();
|
|
m_pSymbolicalGraphic->SetEditProtected (TRUE);
|
|
m_pRealGraphic = GetInterface()->fn_pGetNewSphericalGraphicObject();
|
|
m_pRealGraphic->SetEditProtected (TRUE);
|
|
//End Shaitan Correction }
|
|
|
|
ms_oListOfWaypoint.AddTail (this);
|
|
|
|
WP_fnv_WayPoint_Copy (GetStruct(), rWayPoint.GetStruct());
|
|
|
|
|
|
// section object
|
|
SetSectionData ( this ) ;
|
|
SetCallBackSave ( fn_vCallbackSave ) ;
|
|
SetDataPath ( fn_szGetLevelsDataPath() ) ;
|
|
|
|
SetReferencedSectionName ( rWayPoint.GetReferencedSectionName() );
|
|
|
|
// name
|
|
if ( fn_eRename (rWayPoint.GetName() ) != E_mc_None)
|
|
SetDefaultValidName ( ) ;
|
|
|
|
fn_vUpdateSectionName ( ) ;
|
|
}
|
|
|
|
|
|
WayPoint::~WayPoint(void)
|
|
{
|
|
POSITION DeletePos = ms_oListOfWaypoint.Find( this );
|
|
ms_oListOfWaypoint.RemoveAt (DeletePos);
|
|
}
|
|
|
|
WayPoint& WayPoint::operator= (WayPoint& rWayPoint)
|
|
{
|
|
m_bAbsoluteCoordinate=rWayPoint.m_bAbsoluteCoordinate;
|
|
m_poFather=rWayPoint.m_poFather;
|
|
m_bCurrentDraw=rWayPoint.m_bCurrentDraw;
|
|
m_bRealDraw=rWayPoint.m_bRealDraw;
|
|
m_bSave=rWayPoint.m_bSave;
|
|
|
|
WP_fnv_WayPoint_Copy (GetStruct(), rWayPoint.GetStruct());
|
|
return *this;
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data
|
|
//-------------------------------------------------------------------
|
|
long WayPoint::GetDataType (void)
|
|
{
|
|
return HIE_C_ulEDT_Waypoint;
|
|
}
|
|
|
|
void* WayPoint::GetData (void)
|
|
{
|
|
return GetStruct();
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
// SAVE
|
|
//-------------------------------------------------------------------
|
|
void WayPoint::fn_vNotifySave (void)
|
|
{
|
|
if (!m_bSave) return;
|
|
|
|
if (!GetInterface()->fn_bExistWaypointSaveFile() && !ms_bNotifyHeader)
|
|
{
|
|
char szSectionName [SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
// header
|
|
SCR_fn_v_SvL1_RegisterNotify ( GetInterface()->fn_csGetWaypointSaveFileName().GetBuffer(256), WayPoint::fn_vCallbackHeader, NULL, SCR_EA_Ntfy_AddSection );
|
|
|
|
// Isolate section
|
|
SCR_fn_v_RdL0_ComputeSectionName
|
|
(
|
|
szSectionName,
|
|
GetInterface()->fn_csGetWaypointSaveFileName().GetBuffer(256),
|
|
C_SubSectionIsolateWayPointDescription,
|
|
" "
|
|
);
|
|
SCR_fn_v_SvL1_RegisterNotify ( szSectionName, WayPoint::fn_vCallbackEmptySectionWaypointIsolate, NULL, SCR_EA_Ntfy_AddSection );
|
|
|
|
// Inway section
|
|
SCR_fn_v_RdL0_ComputeSectionName
|
|
(
|
|
szSectionName,
|
|
GetInterface()->fn_csGetWaypointSaveFileName().GetBuffer(256),
|
|
C_SubSectionInWayWayPointDescription,
|
|
" "
|
|
);
|
|
SCR_fn_v_SvL1_RegisterNotify ( szSectionName, WayPoint::fn_vCallbackEmptySectionWaypointInWay, NULL, SCR_EA_Ntfy_AddSection );
|
|
|
|
ms_bNotifyHeader=TRUE;
|
|
}
|
|
|
|
fn_vNotifySection( SCR_EA_Ntfy_AddOrRebuildSection );
|
|
|
|
}
|
|
|
|
void WayPoint::fn_vNotifyUnSave (void)
|
|
{
|
|
if (m_bSave) CPA_SaveObject::fn_vNotifyUnSave ();
|
|
}
|
|
|
|
void WayPoint::fn_vNotifyRestore (void)
|
|
{
|
|
if (m_bSave) CPA_SaveObject::fn_vNotifyRestore ();
|
|
}
|
|
|
|
void WayPoint::fn_vNotifyRename (void)
|
|
{
|
|
if (m_bSave) CPA_SaveObject::fn_vNotifyRename ();
|
|
}
|
|
|
|
void WayPoint::fn_vUpdateReference (CPA_SaveObject *pReferencedObject)
|
|
{
|
|
if (m_bSave) fn_vUpdateReference (pReferencedObject);
|
|
}
|
|
|
|
void WayPoint::fn_vCallbackHeader ( SCR_tdst_File_Description *p_stFile, char *_p_szSectionName, void *_p_vData,SCR_tde_Ntfy_Action _eAction )
|
|
{
|
|
if (_eAction==SCR_EA_Ntfy_AddSection)
|
|
{
|
|
char szBuffer [256];
|
|
char szTime [256];
|
|
char szDate [256];
|
|
SCR_M_SvL0_SaveScriptFileHeader(p_stFile);
|
|
SCR_M_SvL0_SaveComment(p_stFile, "Generated by waypoint editor");
|
|
_strtime(szTime);
|
|
_strdate(szDate);
|
|
sprintf(szBuffer, "Created date : %s %s", szDate, szTime);
|
|
SCR_M_SvL0_SaveComment(p_stFile, szBuffer);
|
|
SCR_M_SvL0_SaveBlankLine(p_stFile);
|
|
}
|
|
}
|
|
|
|
|
|
// create empty section for isolate waypoint
|
|
void WayPoint::fn_vCallbackEmptySectionWaypointIsolate ( SCR_tdst_File_Description *p_stFile, char *p_szSectionName, void *_p_vData,SCR_tde_Ntfy_Action _eAction )
|
|
{
|
|
if (_eAction==SCR_EA_Ntfy_AddSection)
|
|
{
|
|
char szSectionName [SCR_CV_ui_Cfg_MaxLenName];
|
|
strcpy ( szSectionName, C_SubSectionIsolateWayPointDescription );
|
|
strcat ( szSectionName, ":" );
|
|
|
|
SCR_fn_v_SvL1_ToEndSection (p_stFile);
|
|
SCR_M_SvL0_SaveBlankLine (p_stFile);
|
|
SCR_M_SvL0_SaveBeginSection ( p_stFile, szSectionName, SCR_CC_C_Cfg_EOL );
|
|
SCR_M_SvL0_SaveEndSection ( p_stFile, SCR_CC_C_Cfg_EOL );
|
|
}
|
|
}
|
|
|
|
// create empty section for waypoint "in way"
|
|
void WayPoint::fn_vCallbackEmptySectionWaypointInWay ( SCR_tdst_File_Description *p_stFile, char *p_szSectionName, void *_p_vData,SCR_tde_Ntfy_Action _eAction )
|
|
{
|
|
if (_eAction==SCR_EA_Ntfy_AddSection)
|
|
{
|
|
char szSectionName [SCR_CV_ui_Cfg_MaxLenName];
|
|
strcpy ( szSectionName, C_SubSectionInWayWayPointDescription );
|
|
strcat ( szSectionName, ":" );
|
|
|
|
SCR_fn_v_SvL1_ToEndSection (p_stFile);
|
|
SCR_M_SvL0_SaveBlankLine (p_stFile);
|
|
SCR_M_SvL0_SaveBeginSection ( p_stFile, szSectionName, SCR_CC_C_Cfg_EOL );
|
|
SCR_M_SvL0_SaveEndSection ( p_stFile, SCR_CC_C_Cfg_EOL );
|
|
}
|
|
}
|
|
|
|
|
|
void WayPoint::fn_vCallbackSave ( SCR_tdst_File_Description *_p_stFile, char *_p_szSectionName, void *_p_vData,SCR_tde_Ntfy_Action _eAction )
|
|
{
|
|
WayPoint* poWayPoint = (WayPoint*)_p_vData;
|
|
|
|
switch (_eAction)
|
|
{
|
|
case SCR_EA_Ntfy_AddSection :
|
|
case SCR_EA_Ntfy_ModifySection :
|
|
case SCR_EA_Ntfy_RebuildSection :
|
|
{
|
|
// declaration
|
|
char szSectionName [SCR_CV_ui_Cfg_MaxLenName];
|
|
char szObjectName [SCR_CV_ui_Cfg_MaxLenName];
|
|
double a3_dVertex [3];
|
|
MTH3D_tdstVector stVertex;
|
|
double xRadius;
|
|
|
|
//init
|
|
strcpy ( szObjectName, poWayPoint->GetName() );
|
|
WP_fnv_WayPoint_GetVertex ( poWayPoint->GetStruct(), &stVertex );
|
|
xRadius = WP_fnx_WayPoint_GetRadius ( poWayPoint->GetStruct() );
|
|
|
|
MTH3D_M_vGetVectorElements ( &(a3_dVertex[0]), &(a3_dVertex[1]), &(a3_dVertex[2]), &stVertex );
|
|
|
|
SCR_fn_v_RdL0_ComputeSectionName
|
|
(
|
|
szSectionName,
|
|
NULL,
|
|
pszWaypointAction,
|
|
szObjectName
|
|
);
|
|
|
|
|
|
SCR_g_ui_SvL0_IndentationLevel=1;
|
|
SCR_M_SvL0_SaveBeginSection ( _p_stFile, szSectionName, SCR_CC_C_Cfg_EOL );
|
|
|
|
SCR_M_SvL0_SaveEntry( _p_stFile, "Vertex", SCR_CC_C_Cfg_NoChar );
|
|
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_ArrayDouble, 2, 3, a3_dVertex );
|
|
|
|
SCR_M_SvL0_SaveEntry( _p_stFile, "Radius", SCR_CC_C_Cfg_NoChar );
|
|
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_ArrayDouble, 2, 1, &xRadius );
|
|
|
|
|
|
if (WP_fnb_WayPoint_IsDynamic(poWayPoint->GetStruct()))
|
|
{
|
|
HIE_tdxHandleToSuperObject hSuperObject = WP_fnh_WayPoint_GetSuperObject (poWayPoint->GetStruct());
|
|
CPA_BaseObject* poBaseObject = poWayPoint->GetInterface()->GetMainWorld()->fn_p_oFindObjectWithEngine (hSuperObject);
|
|
|
|
strcpy ( szSectionName, ((CPA_SaveObject*)((CPA_SuperObject*)poBaseObject)->GetObject())->GetReferencedSectionName() );
|
|
|
|
SCR_M_SvL0_SaveEntry( _p_stFile, "Father", SCR_CC_C_Cfg_NoChar );
|
|
SCR_fn_v_SvL0_SaveParameters_MP ( _p_stFile, SCR_EF_SvL0_Normal, 1, szSectionName );
|
|
|
|
}
|
|
|
|
|
|
SCR_M_SvL0_SaveEndSection (_p_stFile, SCR_CC_C_Cfg_EOL);
|
|
SCR_g_ui_SvL0_IndentationLevel=0;
|
|
|
|
poWayPoint->fn_vSectionSaved ();
|
|
|
|
} break;
|
|
|
|
case SCR_EA_Ntfy_DeleteSection :
|
|
poWayPoint->fn_vSectionDeleted ();
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void WayPoint::fn_vSetRadius (GLI_tdxValue* pxR)
|
|
{
|
|
GetInterface()->GetInterface()->GetMultiDevice()->GetEditManager()->AskFor(new ModifWayPointRadius (this, pxR));
|
|
}
|
|
|
|
void WayPoint::fn_vChangeSystemCoordinate (void)
|
|
{
|
|
GetInterface()->GetInterface()->GetMultiDevice()->GetEditManager()->AskFor(new ModifWayPointCoordinate (this));
|
|
}
|
|
|
|
|
|
void WayPoint::fn_vSetCoordinate (BOOL bAbsolute)
|
|
{
|
|
m_bAbsoluteCoordinate = bAbsolute;
|
|
}
|
|
|
|
GLI_tdxValue WayPoint::fn_xGetRadius (void)
|
|
{
|
|
GLI_tdxValue stRadius;
|
|
stRadius = WP_fnx_WayPoint_GetRadius (GetStruct() );
|
|
return stRadius;
|
|
}
|
|
|
|
|
|
CPA_SuperObject* WayPoint::fn_pGetFather (void)
|
|
{
|
|
return m_poFather;
|
|
}
|
|
|
|
void WayPoint::fn_vSetFather (CPA_SuperObject* poFather)
|
|
{
|
|
m_poFather=poFather;
|
|
}
|
|
|
|
CPA_SuperObject* WayPoint::fn_pGetDynamicFather (void)
|
|
{
|
|
return m_poDynamicFather;
|
|
}
|
|
|
|
void WayPoint::fn_vSetDynamicFather (CPA_SuperObject* poDynamicFather)
|
|
{
|
|
m_poDynamicFather=poDynamicFather;
|
|
}
|
|
|
|
void WayPoint::fn_vComputeMotorStructure (void)
|
|
{
|
|
if (m_bAbsoluteCoordinate)
|
|
{
|
|
MTH3D_tdstVector stVertex;
|
|
// compute absolute matrix
|
|
GetInterface()->fn_vComputeAbsoluteMatrix (GetSuperObject());
|
|
GEO_tdxHandleToMatrix hAbsoluteMatrix = HIE_fn_hGetSuperObjectGlobalMatrix ( GetSuperObject()->GetStruct() );
|
|
POS_fn_vGetTranslationVector( hAbsoluteMatrix, &stVertex ) ;
|
|
WP_fnv_WayPoint_SetVertex (GetStruct(), &stVertex);
|
|
WP_fnv_WayPoint_SetSuperObject (GetStruct(), NULL);
|
|
}
|
|
else
|
|
{
|
|
MTH3D_tdstVector stVertex;
|
|
WP_fnv_WayPoint_SetSuperObject ( GetStruct(), fn_pGetFather()->GetStruct() );
|
|
GEO_tdxHandleToMatrix hRelativeMatrix;
|
|
hRelativeMatrix = HIE_fn_hGetSuperObjectMatrix (GetSuperObject()->GetStruct());
|
|
POS_fn_vGetTranslationVector( hRelativeMatrix, &stVertex ) ;
|
|
WP_fnv_WayPoint_SetVertex (GetStruct(), &stVertex);
|
|
}
|
|
}
|
|
|
|
|
|
// this function attach the appropriate graphic object to the WayPoint Object
|
|
// bSreen echo on the screen the new draw -> default TRUE
|
|
// bDestroy delete in the hiearchy the old graphic object -> default TRUE
|
|
void WayPoint::fn_vDraw (BOOL bScreen, BOOL bDestroy)
|
|
{
|
|
// Shaitan Correction {
|
|
CPA_SuperObject * pDelSuperObject;
|
|
CPA_SuperObject * pNewGraphicObject;
|
|
//End Shaitan Correction }
|
|
|
|
BOOL bMustChange = (fn_bIsGeneralRealDraw()!=m_bCurrentDraw);
|
|
|
|
|
|
// Shaitan Correction {
|
|
// we must change the draw
|
|
if (m_bCurrentDraw)
|
|
pDelSuperObject = m_pRealGraphic;
|
|
else
|
|
pDelSuperObject = m_pSymbolicalGraphic;
|
|
//End Shaitan Correction }
|
|
|
|
if (bMustChange)
|
|
{
|
|
m_bCurrentDraw = fn_bIsGeneralRealDraw();
|
|
|
|
// Shaitan Correction {
|
|
// we must change the draw
|
|
// POSITION xPos;
|
|
// CPA_SuperObjectBase* pDelSuperObject;
|
|
// pDelSuperObject = GetSuperObject()->GetHeadElement (xPos);
|
|
//End Shaitan Correction }
|
|
|
|
// Ruse de sioux
|
|
if (bDestroy)
|
|
{
|
|
GetInterface()->fn_vSetModifDeleteOk (TRUE);
|
|
GetInterface()->GetInterface()->fn_bDeleteObjectInHierarchy (pDelSuperObject,FALSE,FALSE,FALSE,FALSE);
|
|
GetInterface()->fn_vSetModifDeleteOk (FALSE);
|
|
}
|
|
else GetSuperObject()->RemoveAll();
|
|
}
|
|
|
|
|
|
// Shaitan Correction {
|
|
// we must change the draw
|
|
if (m_bCurrentDraw)
|
|
pNewGraphicObject = m_pRealGraphic;
|
|
else
|
|
pNewGraphicObject = m_pSymbolicalGraphic;
|
|
|
|
// pNewGraphicObject = m_bCurrentDraw ? ((Waypoint_Interface*)GetInterface())->fn_pGetNewSphericalGraphicObject() : ((Waypoint_Interface*)GetInterface())->fn_pGetNewSymbolicalGraphicObject ();
|
|
//End Shaitan Correction }
|
|
|
|
if (bMustChange)
|
|
{
|
|
GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy (pNewGraphicObject, GetSuperObject(),FALSE,FALSE,FALSE);
|
|
pNewGraphicObject->SetEditProtected (TRUE);
|
|
pNewGraphicObject->SetSuperObjectOwner (GetSuperObject());
|
|
}
|
|
|
|
// register the relative location;
|
|
GEO_tdxHandleToMatrix hRelativeMatrix = HIE_fn_hGetSuperObjectMatrix (pDelSuperObject->GetStruct());
|
|
|
|
// no scale
|
|
POS_fn_vResetScaleMatrix( hRelativeMatrix );
|
|
|
|
if (m_bCurrentDraw)
|
|
{
|
|
// compute the radius by changing the scale matrix
|
|
MTH3D_tdstVector stI, stJ, stK;
|
|
GLI_tdxValue xR;
|
|
xR = WP_fnx_WayPoint_GetRadius (GetStruct());
|
|
|
|
POS_fn_vGetScaleMatrix
|
|
(
|
|
hRelativeMatrix,
|
|
&stI,
|
|
&stJ,
|
|
&stK
|
|
);
|
|
|
|
MTH3D_M_vMulScalarVector(&stI, xR, &stI );
|
|
MTH3D_M_vMulScalarVector(&stJ, xR, &stJ );
|
|
MTH3D_M_vMulScalarVector(&stK, xR, &stK );
|
|
|
|
POS_fn_vSetScaleMatrix
|
|
(
|
|
hRelativeMatrix,
|
|
&stI ,
|
|
&stJ ,
|
|
&stK
|
|
);
|
|
|
|
// normalize
|
|
// POS_fn_vNormalizeMatrix( hRelativeMatrix );
|
|
}
|
|
|
|
// correct the scale with the father's one
|
|
CPA_SuperObject *pFather = fn_pGetFather();
|
|
|
|
POS_tdstCompletePosition stScaleMatrix, stInvertMatrix;
|
|
POS_fn_vSetIdentityMatrix(&stScaleMatrix);
|
|
POS_fn_vSetIdentityMatrix(&stInvertMatrix);
|
|
|
|
MTH3D_tdstVector stI, stJ, stK;
|
|
POS_fn_vGetScaleMatrix
|
|
(
|
|
HIE_fn_hGetSuperObjectGlobalMatrix(pFather->GetStruct()),
|
|
&stI,
|
|
&stJ,
|
|
&stK
|
|
);
|
|
POS_fn_vSetScaleMatrix
|
|
(
|
|
&stScaleMatrix,
|
|
&stI ,
|
|
&stJ ,
|
|
&stK
|
|
);
|
|
POS_fn_vInvertMatrix(&stInvertMatrix, &stScaleMatrix);
|
|
POS_fn_vMulMatrixMatrix(hRelativeMatrix, &stInvertMatrix, hRelativeMatrix);
|
|
|
|
// init the location
|
|
HIE_fn_vSetSuperObjectMatrix(pNewGraphicObject->GetStruct(), hRelativeMatrix);
|
|
|
|
|
|
// Redraw the world
|
|
if (bScreen) GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw); // provisoire JT
|
|
}
|
|
|
|
|
|
void WayPoint::fn_vDrawNewRadius (void)
|
|
{
|
|
if (!fn_bIsGeneralRealDraw()) return;
|
|
|
|
// compute the radius by changing the scale matrix
|
|
GEO_tdxHandleToMatrix hRelativeMatrix = HIE_fn_hGetSuperObjectMatrix (m_pRealGraphic->GetStruct());
|
|
MTH3D_tdstVector stI, stJ, stK;
|
|
GLI_tdxValue xR;
|
|
xR = WP_fnx_WayPoint_GetRadius (GetStruct());
|
|
|
|
POS_fn_vResetScaleMatrix( hRelativeMatrix ) ;
|
|
|
|
POS_fn_vGetScaleMatrix
|
|
(
|
|
hRelativeMatrix,
|
|
&stI,
|
|
&stJ,
|
|
&stK
|
|
);
|
|
|
|
MTH3D_M_vMulScalarVector(&stI, xR, &stI );
|
|
MTH3D_M_vMulScalarVector(&stJ, xR, &stJ );
|
|
MTH3D_M_vMulScalarVector(&stK, xR, &stK );
|
|
|
|
POS_fn_vSetScaleMatrix
|
|
(
|
|
hRelativeMatrix,
|
|
&stI,
|
|
&stJ,
|
|
&stK
|
|
);
|
|
|
|
// correct the scale with the father's one
|
|
CPA_SuperObject *pFather = fn_pGetFather();
|
|
|
|
POS_tdstCompletePosition stScaleMatrix, stInvertMatrix;
|
|
POS_fn_vSetIdentityMatrix(&stScaleMatrix);
|
|
POS_fn_vSetIdentityMatrix(&stInvertMatrix);
|
|
|
|
POS_fn_vGetScaleMatrix
|
|
(
|
|
HIE_fn_hGetSuperObjectGlobalMatrix(pFather->GetStruct()),
|
|
&stI,
|
|
&stJ,
|
|
&stK
|
|
);
|
|
POS_fn_vSetScaleMatrix
|
|
(
|
|
&stScaleMatrix,
|
|
&stI ,
|
|
&stJ ,
|
|
&stK
|
|
);
|
|
POS_fn_vInvertMatrix(&stInvertMatrix, &stScaleMatrix);
|
|
POS_fn_vMulMatrixMatrix(hRelativeMatrix, &stInvertMatrix, hRelativeMatrix);
|
|
// normalize
|
|
// POS_fn_vNormalizeMatrix( hRelativeMatrix );
|
|
GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
|
|
}
|
|
|
|
|
|
BOOL WayPoint::fn_bIsWaypointDrawable (void)
|
|
{
|
|
return ( (ms_bOnScreen && ( m_bAlone ? TRUE : !fn_bDrawJustIsolateWaypoint() )) || m_bOnScreen ) && fn_bIsValid();
|
|
}
|
|
|
|
|
|
BOOL WayPoint::fn_bCheckCoherence (void)
|
|
{
|
|
CList<CPA_BaseObject*,CPA_BaseObject*> oInvalidFatherList;
|
|
int iIncoherenceNb = g_oCoherenceManager.m_fn_iGetInvalidFatherList ( this, &oInvalidFatherList );
|
|
|
|
if (!iIncoherenceNb) return TRUE;
|
|
|
|
POSITION xPos;
|
|
CPA_BaseObject* poBaseObject;
|
|
|
|
for ( xPos=oInvalidFatherList.GetHeadPosition(); xPos; oInvalidFatherList.GetNext(xPos) )
|
|
{
|
|
poBaseObject = oInvalidFatherList.GetAt (xPos);
|
|
if (poBaseObject->GetType()==C_szIABehaviourTypeName) return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL WayPoint::fn_bIsReferencedInAI (void)
|
|
{
|
|
CList<CPA_BaseObject*,CPA_BaseObject*> oInvalidFatherList;
|
|
int iIncoherenceNb = g_oCoherenceManager.m_fn_iGetFatherList ( this, &oInvalidFatherList );
|
|
|
|
if (!iIncoherenceNb) return FALSE;
|
|
|
|
POSITION xPos;
|
|
CPA_BaseObject* poBaseObject;
|
|
|
|
for ( xPos=oInvalidFatherList.GetHeadPosition(); xPos; oInvalidFatherList.GetNext(xPos) )
|
|
{
|
|
poBaseObject = oInvalidFatherList.GetAt (xPos);
|
|
if (poBaseObject->GetType()==C_szIABehaviourTypeName) return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|