294 lines
9.7 KiB
C
294 lines
9.7 KiB
C
/*********************************************************/
|
|
/* Module used to display Waypoints in the Game engine*/
|
|
/* */
|
|
/* Author : Marc Fascia - Annecy*/
|
|
/* Date : 02 / 03 / 1998*/
|
|
/**/
|
|
/*********************************************************/
|
|
|
|
#define _WP_D_WAYPOINT_FRIEND_
|
|
|
|
#include "specif/AIOption.h"
|
|
#include "AIMacros.h"
|
|
#include "AIUseCPA.h"
|
|
#include "AI_Mmg.h"
|
|
#include "AI_Erm.h"
|
|
|
|
#include "AI_Proto.h"
|
|
|
|
#include "WPEngDsp.h"
|
|
#include "WPWayPt.h"
|
|
|
|
#include "WP_Handl.h"
|
|
|
|
#include "WP_Func.h"
|
|
|
|
#ifndef U64
|
|
static GEO_tdstGeometricObject * p_stGeoModel;
|
|
static GEO_tdstGeometricObject * p_stGeoCurr;
|
|
#endif
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"{
|
|
#endif
|
|
#if !defined(PRESS_DEMO)
|
|
extern void DisplayPolices (char * _szText , long _lX , long _lY);
|
|
#else
|
|
#define DisplayPolices(a,b,c)
|
|
#endif /* PRESS_DEMO */
|
|
extern void GLI_vEndOfGeometricLoad( void );
|
|
/*bart990209 : extern void GLI_vDownLoadTexture( void );*/
|
|
#ifndef U64
|
|
/*static*/ unsigned char ucIsInitDone = 0;
|
|
#endif
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#if !defined(U64) && !defined(RETAIL)
|
|
/***********************************************************************************************/
|
|
/* Name : WP_InitGeoModel*/
|
|
/* Description : Loads the Geo Obj used to display the WP from .mod file */
|
|
/* Author : Marc FASCIA*/
|
|
/* Date : 04/03/98*/
|
|
/***********************************************************************************************/
|
|
GEO_tdstGeometricObject * WP_InitGeoModel()
|
|
{
|
|
GEO_tdstGeometricObject * p_stLoaded;
|
|
|
|
p_stLoaded = (GEO_tdstGeometricObject *) SCR_M_ul_RdL0_ExtractLongValue(
|
|
SCR_fnp_st_RdL0_AnalyseSection( "GameData\\World\\Graphics\\Objects\\Banks\\Waypoints\\wp.mod^Geometric:Box01", SCR_CDF_uw_Anl_ForceAnalyse ),
|
|
0 );
|
|
|
|
return p_stLoaded;
|
|
}
|
|
/* LOL #endif*/
|
|
|
|
/***********************************************************************************************/
|
|
/* Name : WP_SendWaypointsToViewport*/
|
|
/* Description : Displays the Geo Objs for WP*/
|
|
/* Author : Marc FASCIA*/
|
|
/* Date : 04/03/98*/
|
|
/* Optimized ? : No*/
|
|
/***********************************************************************************************/
|
|
void WP_SendWaypointsToViewport( GLD_tdstViewportAttributes * p_stViewport, unsigned long ulDrawMask )
|
|
|
|
{
|
|
|
|
WP_tdstWayPoint * p_stWaypt;
|
|
ACP_tdxIndex xNbVertices;
|
|
unsigned int uiPos;
|
|
SCR_tdst_Link_Value * pLinkValue = NULL;
|
|
SCR_tdst_Link_Table * pLinkTable;
|
|
char szText[ 255 ];
|
|
|
|
/*--- First time we are here ??? ---*/
|
|
if( !ucIsInitDone )
|
|
{
|
|
/*--- Loading Goe Objs from file ---*/
|
|
p_stGeoModel = WP_InitGeoModel();
|
|
p_stGeoCurr = WP_InitGeoModel();
|
|
GLI_vEndofGeometricLoad();
|
|
|
|
ucIsInitDone = 1;
|
|
|
|
}
|
|
|
|
/*--- gettink back the Waypoints linktable*/
|
|
pLinkTable = WP_fnp_WayPoint_GetLinkTable();
|
|
|
|
/*--- First element*/
|
|
uiPos = 0;
|
|
SCR_M_DyAr_GetNextElement( SCR_tdst_Link_Value, uiPos, pLinkValue, SCR_M_st_Link_GetDynamicArray(pLinkTable) )
|
|
while (pLinkValue)
|
|
{
|
|
/*--- Getting the Waypoint handle*/
|
|
p_stWaypt = (WP_tdstWayPoint *) SCR_M_ul_Link_GetValue( pLinkValue );
|
|
|
|
for( xNbVertices = 0 ; xNbVertices < p_stGeoCurr->xNbPoints ; xNbVertices++ )
|
|
{
|
|
/*--- Translates the current object at the waypoint position*/
|
|
MTH3D_M_vAddVector( &(p_stGeoCurr->d_stListOfPoints[ xNbVertices ]),
|
|
&(p_stGeoModel->d_stListOfPoints[ xNbVertices ]),
|
|
&(p_stWaypt->m_stVertex) );
|
|
}
|
|
|
|
/*--- Translates the center of BV of object*/
|
|
MTH3D_M_vAddVector( &p_stGeoCurr->xBoudingSphereCenter, &p_stGeoModel->xBoudingSphereCenter, &p_stWaypt->m_stVertex );
|
|
|
|
/*--- Sends the object to the Display Routines*/
|
|
GLI_xSendObjectToViewportWithLights( p_stViewport, p_stGeoCurr, ulDrawMask );
|
|
|
|
/*--- Next Linked Value*/
|
|
uiPos++;
|
|
SCR_M_DyAr_GetNextElement( SCR_tdst_Link_Value, uiPos, pLinkValue, SCR_M_st_Link_GetDynamicArray(pLinkTable) )
|
|
}
|
|
sprintf( szText, "[P] Display Waypoints" );
|
|
DisplayPolices( (char *)szText, 450, 450 );
|
|
|
|
}
|
|
/* LOL */
|
|
#endif /* U64 */
|
|
|
|
/*--------------------------------------------------------------
|
|
-------------------- OLD VERSION -----------------------------
|
|
--------------------------------------------------------------
|
|
|
|
|
|
#include "SPO\HieSpObj.h"
|
|
|
|
|
|
static HIE_tdstSuperObject * p_stWaypointsSPO;
|
|
static unsigned char s_ucWPDisplayNotInitialized = 1;
|
|
|
|
|
|
//*********************************************************************************************
|
|
// Name : WP_InitWaypointSPO
|
|
// Description : Creates the SPO that will contain all the GEO Objs for the WP
|
|
// Author : Marc FASCIA
|
|
// Date : 04/03/98
|
|
// Optimized ? : No
|
|
//*********************************************************************************************
|
|
HIE_tdstSuperObject * WP_InitSPO()
|
|
{
|
|
MTH3D_tdstMatrix stIdMatrix;
|
|
MTH3D_tdstVector stZeroVector;
|
|
POS_stCompletePosition stCompletePos;
|
|
HIE_tdstSuperObject * p_stSPO;
|
|
|
|
//--- Creates the SPO in memory
|
|
p_stSPO = HIE_fn_hCreateSuperObject();
|
|
|
|
//--- Inits the Position ---
|
|
MTH3D_M_vNullVector( &stZeroVector );
|
|
MTH3D_M_vSetIdentityMatrix( &stIdMatrix );
|
|
POS_fn_vSetTransformMatrix( &stCompletePos, &stIdMatrix.stCol_0, &stIdMatrix.stCol_1, &stIdMatrix.stCol_2 );
|
|
POS_fn_vSetRotationMatrix( &stCompletePos, &stIdMatrix.stCol_0, &stIdMatrix.stCol_1, &stIdMatrix.stCol_2 );
|
|
POS_fn_vSetTranslationVector( &stCompletePos, &stZeroVector );
|
|
|
|
HIE_fn_vSetSuperObjectMatrix( p_stSPO, &stCompletePos );
|
|
|
|
return p_stSPO;
|
|
}
|
|
|
|
|
|
|
|
//*********************************************************************************************
|
|
// Name : WP_InitWPModel
|
|
// Description : Loads the GEO Obj primitive displayed for each WP
|
|
// Author : Marc FASCIA
|
|
// Date : 04/03/98
|
|
// Optimized ? : No
|
|
//*********************************************************************************************
|
|
GEO_tdstGeometricObject * WP_InitWPModel()
|
|
{
|
|
GEO_tdstGeometricObject * p_stLoaded;
|
|
|
|
p_stLoaded = (GEO_tdstGeometricObject *) SCR_M_ul_RdL0_ExtractLongValue(
|
|
SCR_fnp_st_RdL0_AnalyseSection( "GameData\\World\\Levels\\morbide\\morbide.mod^Geometric:Box01", SCR_CDF_uw_Anl_ForceAnalyse ),
|
|
0 );
|
|
return p_stLoaded;
|
|
}
|
|
|
|
|
|
//*********************************************************************************************
|
|
// Name : WP_FillWaypointsSPO
|
|
// Description : Links the Geo Objs with the WP SPO
|
|
// Author : Marc FASCIA
|
|
// Date : 04/03/98
|
|
// Optimized ? : No
|
|
//*********************************************************************************************
|
|
void WP_FillWaypointSPO()
|
|
|
|
{
|
|
WP_tdstWayPoint * p_stWaypt;
|
|
ACP_tdxIndex xNbVertices;
|
|
unsigned int uiPos;
|
|
SCR_tdst_Link_Value * pLinkValue;
|
|
SCR_tdst_Link_Table * pLinkTable;
|
|
GEO_tdstGeometricObject * p_stCurrGeoObj;
|
|
static HIE_tdstSuperObject * p_stCurrSPO;
|
|
|
|
//--- gettink back the Waypoints linktable
|
|
pLinkTable = WP_fnp_WayPoint_GetLinkTable();
|
|
|
|
//--- First element
|
|
uiPos = 0;
|
|
SCR_M_DyAr_GetNextElement( SCR_tdst_Link_Value, uiPos, pLinkValue, SCR_M_st_Link_GetDynamicArray(pLinkTable) )
|
|
while (pLinkValue)
|
|
{
|
|
//--- Getting the Waypoint handle
|
|
p_stWaypt = (WP_tdstWayPoint *) SCR_M_ul_Link_GetValue( pLinkValue );
|
|
|
|
//--- Creates the Geo Obj and the SPO
|
|
p_stCurrGeoObj = WP_InitWPModel();
|
|
p_stCurrSPO = WP_InitSPO();
|
|
|
|
//--- Links it to its own SPO ---
|
|
HIE_fn_vSetSuperObjectObjectAndType( p_stWaypointsSPO, p_stCurrGeoObj, C_ucPhysical );
|
|
|
|
//--- Creates SPO hierarchy ---
|
|
HIE_fn_vSuperObjectAddTail( p_stWaypointsSPO, p_stCurrSPO );
|
|
|
|
|
|
for( xNbVertices = 0 ; xNbVertices < p_stCurrGeoObj->xNbPoints ; xNbVertices++ )
|
|
{
|
|
//--- Translates the Model object at the waypoint position
|
|
MTH3D_M_vAddVector( &(p_stCurrGeoObj->d_stListOfPoints[ xNbVertices ]),
|
|
&(p_stCurrGeoObj->d_stListOfPoints[ xNbVertices ]),
|
|
&(p_stWaypt->m_stVertex) );
|
|
}
|
|
|
|
//--- Sends the object to the Display Routines
|
|
// GLI_xSendObjectToViewportWithLights( p_stViewport, p_stCurrGeoObj, ulDrawMask );
|
|
|
|
//--- Next Linked Value
|
|
uiPos++;
|
|
SCR_M_DyAr_GetNextElement( SCR_tdst_Link_Value, uiPos, pLinkValue, SCR_M_st_Link_GetDynamicArray(pLinkTable) )
|
|
}
|
|
}
|
|
|
|
|
|
//*********************************************************************************************
|
|
// Name : WP_WPAttachInHierarchy
|
|
// Description : Adds the WP SPO in the SPO hierarchy
|
|
// Author : Marc FASCIA
|
|
// Date : 04/03/98
|
|
// Optimized ? : No
|
|
//*********************************************************************************************
|
|
void WP_WPAttachInHierarchy( HIE_tdstSuperObject * p_stRootSPO )
|
|
{
|
|
//--- We need to load the Model the first time
|
|
if( s_ucWPDisplayNotInitialized )
|
|
{
|
|
//--- Init of the Waypoints root spo ---
|
|
p_stWaypointsSPO = WP_InitSPO();
|
|
HIE_fn_vSetSuperObjectObjectAndType( p_stWaypointsSPO, NULL, C_ucNoAction );
|
|
WP_FillWaypointSPO();
|
|
|
|
//--- Now the hierarchy has been built ---
|
|
s_ucWPDisplayNotInitialized = 0;
|
|
}
|
|
|
|
//--- Linking this branch to the static tree ---
|
|
HIE_fn_vSuperObjectAddTail( p_stRootSPO, p_stWaypointsSPO );
|
|
}
|
|
|
|
|
|
//*********************************************************************************************
|
|
// Name : WP_WPIsolateFromHierarchy
|
|
// Description : Removes the WP SPO in the SPO hierarchy
|
|
// Author : Marc FASCIA
|
|
// Date : 04/03/98
|
|
// Optimized ? : No
|
|
//*********************************************************************************************
|
|
void WP_WPIsolateFromHierarchy()
|
|
{
|
|
//--- Cutting the Waypoint branch from the static tree ---
|
|
HIE_fn_vIsolate( p_stWaypointsSPO );
|
|
}
|
|
|
|
|
|
*/
|