Add rayman2 source files

This commit is contained in:
2024-09-18 02:33:44 +08:00
parent bcc093f8ed
commit fb036c54fd
14339 changed files with 2596224 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,684 @@
/* (c) Ubi Studios 1996-97-98*/
/* See Vincent Greco for any comment or question*/
#include "ACP_base.h"
#include "cpa_std.h"
#include "GEO.h"
#include "GLI.h"
#include "PCS.h"
#include "PO.h"
#include "IPO.h"
#include "POS.h"
#include "SPO/HieConst.h"
#include "LST.h"
#include "SPO/HieSpObj.h"
#include "SPO/HieHand.h"
#include "SPO/HieDef.h"
#include "SPO/HieMacro.h"
#include "SPO/HieMtStk.h"
#include "SPO/HieExt.h"
#include "../HieDrw.h"
#include "PRF.h"
extern int g_iSPODisplayed;
extern ACP_tdxBool bViewingInMirror;
#include "MEC.h"
/*#include "ENV.h"*/
#ifdef USE_IPT_DX5
#include "IPT_DX5.h" /* InPuT (absolutely before GAM.h)*/
#else /* USE_IPT_WIN */
#include "IPT.h" /* InPuT (absolutely before GAM.h)*/
#endif /* USE_IPT_WIN */
#include "PCS.h" /* Physical Collide Set */
#include "RND.h" /* RaNDom*/
#include "VIG.h" /* Vignette*/
/*#include "SRF.h" // Surface*/
#include "SND.h" /* SND*/
#include "SCT.h" /* SeCTor*/
#include "FIL.h" /* SeCTor*/
#include "PRT.h" /* PaRTicules*/
#include "Gam.h"
/*ANNECY JMD 17/02/98 {*/
#include "ISI.h"
/*END ANNECY JMD }*/
#define HIE_M_MustBeDisplayed(_lDrawMask) \
(( (_lDrawMask&GLI_C_lIsNotVisibleInRealWorld) && (_lDrawMask&GLI_C_lIsNotDrawingInMirror) ) || \
( (_lDrawMask&GLI_C_lIsNotVisibleInSymetricWorld) && !(_lDrawMask&GLI_C_lIsNotDrawingInMirror) ))
#define HIE_C_InheritableFlags \
(GLI_C_lIsNotVisibleInRealWorld|\
GLI_C_lIsNotVisibleInSymetricWorld|\
GLI_C_lCameraIsUnderWater|\
GLI_C_lIsNotDrawingSuperObjectBoundingVolume|\
GLI_C_lIsNotDrawingInMirror|\
GLI_C_lNotInvertBackfaces|\
GLI_C_lNotHideWhatIsUnderWater|\
GLI_C_lIsNotWired)
/*
* Blend RLI
*/
unsigned char g_ucNbRLIUse = 0 ;
unsigned char g_ucIndex1 = 0 ;
unsigned char g_ucIndex2 = 0 ;
MTH_tdxReal g_xPercent ;
void HIE_vSetCharactereRLI ( unsigned char ucNbRLI, unsigned char ucIndex1, unsigned char ucIndex2, MTH_tdxReal xPercent)
{
if ( ucNbRLI <= 2 || ucNbRLI >= 0 )
{
g_ucNbRLIUse = ucNbRLI ;
g_ucIndex1 = ucIndex1 - 1;
g_ucIndex2 = ucIndex2 - 1;
g_xPercent = xPercent ;
}
}
/*///////////////////////////////////////////////////////////////////////////////////////////////////////////*/
/* New version*/
/*///////////////////////////////////////////////////////////////////////////////////////////////////////////*/
#if defined(USE_PROFILER) && !defined(PRESS_DEMO)
ACP_tdxBool fn_bSendOneSuperObjectToViewportReal
(
GLD_tdxHandleToViewportAttributes _hVpt ,
HIE_tdxHandleToSuperObject _hSprObj ,
long *_p_lDrawMask,
long _lCullingResult
)
#else
ACP_tdxBool fn_bSendOneSuperObjectToViewport
(
GLD_tdxHandleToViewportAttributes _hVpt ,
HIE_tdxHandleToSuperObject _hSprObj ,
long *_p_lDrawMask,
long _lCullingResult
)
#endif
{
long lType , lCullingResult;
unsigned long ulCurrentBits;
GEO_tdxHandleToBoundingSphere hBoundingSphere = NULL;
GEO_tdxHandleToParallelBox hParallelBox = NULL;
MTH3D_tdstVector stSphereCenter;
MTH_tdxReal xSphereRadius;
ACP_tdxHandleToRadiosity hRad;
float fGlobalAlphaTemp , fCullingTransparency;
ACP_tdxBool bBoxBoundingVolume;
MTH3D_tdstVector stMinPoint;
MTH3D_tdstVector stMaxPoint;
POS_tdstCompletePosition stIdentityMatrix;
if ( _lCullingResult != GEO_C_lCullingIn )
{
/* Get bounding Volume*/
bBoxBoundingVolume = (ACP_tdxBool) HIE_fn_SO_bHasABoxBoundingVolume(_hSprObj);
if(bBoxBoundingVolume)
{
hParallelBox = (GEO_tdxHandleToParallelBox)HIE_fn_hGetSuperObjectBoundingVolume(_hSprObj);
}
else
{
hBoundingSphere = (GEO_tdxHandleToBoundingSphere)HIE_fn_hGetSuperObjectBoundingVolume(_hSprObj);
}
if ((!bBoxBoundingVolume) && (hBoundingSphere))
{
MTH3D_M_vCopyVector(&stSphereCenter, GEO_fn_pGetCenterPointOfBoundingSphere(hBoundingSphere));
xSphereRadius = GEO_fn_xGetRadiusOfBoundingSphere(hBoundingSphere);
}
if ( (bBoxBoundingVolume) && (hParallelBox) )
{
MTH3D_tdstVector *p_stMinPoint;
MTH3D_tdstVector *p_stMaxPoint;
MTH3D_tdstVector stTranslation;
p_stMinPoint = GEO_fn_pGetMinPointOfParallelBox(hParallelBox);
p_stMaxPoint = GEO_fn_pGetMaxPointOfParallelBox(hParallelBox);
stTranslation = (HIE_fn_hGetSuperObjectGlobalMatrix(_hSprObj))->stTranslationVector;
MTH3D_M_vAddVector(&stMinPoint, p_stMinPoint , &stTranslation);
MTH3D_M_vAddVector(&stMaxPoint, p_stMaxPoint , &stTranslation);
POS_fn_vSetIdentityMatrix(&stIdentityMatrix);
}
}
lType = HIE_fn_ulGetSuperObjectType(_hSprObj);
if (lType == HIE_C_ulActor)
{
ulCurrentBits = fn_ulStandardGameGetCustomBits(M_GetMSHandle(_hSprObj,StandardGame));
lCullingResult = GEO_C_lCullingIn; /* to force recursive culling*/
if
(
(_lCullingResult != GEO_C_lCullingIn)
||
(
( (!hBoundingSphere) && (!hParallelBox) )
||
(
(!bBoxBoundingVolume)
&& ((lCullingResult = GEO_lCullingSphereNoMMM(_hVpt, &stSphereCenter, xSphereRadius, HIE_fn_hGetSuperObjectGlobalMatrix(_hSprObj), _lCullingResult)) != GEO_C_lCullingOut)/* volontary assignment*/
)
||
(
(bBoxBoundingVolume)
&& ((lCullingResult = GEO_lCullingBox(_hVpt, &stMinPoint, &stMaxPoint, _lCullingResult)) != GEO_C_lCullingOut) /* volontary assignment*/
)
)
)
{
*_p_lDrawMask |= ~HIE_C_InheritableFlags;
*_p_lDrawMask &= HIE_fn_lGetSuperObjectDrawMask(_hSprObj);
/* invisibility bit*/
if ( HIE_M_MustBeDisplayed(*_p_lDrawMask) && !HIE_fn_SO_bIsHidden( _hSprObj ) )
{
/* clear*/
ulCurrentBits &= ~GAM_C_CustBitOutOfVisibility;
}
#ifdef U64
/*unnecessary on PC, because it was set as default before anything is sent to the viewport (default value)*/
else
{
/* set*/
ulCurrentBits |= GAM_C_CustBitOutOfVisibility;
}
#endif /* U64 */
fn_vStandardGameSetCustomBits(M_GetMSHandle(_hSprObj,StandardGame), ulCurrentBits);
/* culling bit*/
if( lCullingResult == GEO_C_lCullingIn )
{
/* set*/
/* ANNECY MT - 12/10/98 {*/
fn_vStandardGameSetUselessCulling(M_GetMSHandle(_hSprObj,StandardGame), TRUE);
/* END ANNECY MT }*/
}
else
{
/* clear*/
/* ANNECY MT - 12/10/98 {*/
fn_vStandardGameSetUselessCulling(M_GetMSHandle(_hSprObj,StandardGame), FALSE);
/* END ANNECY MT }*/
}
return TRUE;
}
#ifdef U64
/*unnecessary on PC, because it was set as default before anything is sent to the viewport (default value)*/
else
{
ulCurrentBits |= GAM_C_CustBitOutOfVisibility;
fn_vStandardGameSetCustomBits(M_GetMSHandle(_hSprObj,StandardGame), ulCurrentBits);
}
#endif /* U64 */
}
else
{
if
(
(_lCullingResult != GEO_C_lCullingIn)
||
(
( (!hBoundingSphere) && (!hParallelBox) )
||
(
(!bBoxBoundingVolume)
&& (lCullingResult = GEO_lCullingSphereNoMMM(_hVpt, &stSphereCenter, xSphereRadius, HIE_fn_hGetSuperObjectGlobalMatrix(_hSprObj), _lCullingResult) != GEO_C_lCullingOut) /* volontary assignment*/
)
||
(
(bBoxBoundingVolume)
&& ((lCullingResult = GEO_lCullingBox(_hVpt, &stMinPoint, &stMaxPoint, _lCullingResult)) != GEO_C_lCullingOut)/* volontary assignment*/
)
)
)
{
*_p_lDrawMask &= HIE_fn_lGetSuperObjectDrawMask(_hSprObj);
/**/
if ( HIE_M_MustBeDisplayed(*_p_lDrawMask) && !HIE_fn_SO_bIsHidden( _hSprObj ) )
{
fGlobalAlphaTemp = GLI_vGetGlobalAlpha();
fCullingTransparency = MTH_M_xRealToFloat( GEO_xGetZFarTransparencyLevel() );
GLI_vSetGlobalAlpha( fCullingTransparency * HIE_fn_fGetSuperObjectTransparenceLevel(_hSprObj) );
if ( lType == HIE_C_ulPO )
{
GEO_tdxHandleToVisualSet hVisualSet ;
/*if the SuperObject is a leaf, its Bounding Volume is the same that*/
/*the one of its linked object : no need to test it (so I set hBoundingVolume to NULL).*/
/*unless the bounding volume of the SuperObject was NULL*/
if(bBoxBoundingVolume)
{
MTH3D_M_vMiddleVector(&stSphereCenter, &stMinPoint, &stMaxPoint);
MTH3D_M_vSubVector (& stSphereCenter , & stSphereCenter , & HIE_fn_hGetSuperObjectGlobalMatrix (_hSprObj) -> stTranslationVector);
}
else
{
if (!hBoundingSphere)
hBoundingSphere = PO_fn_hGetBoundingVolume((PO_tdxHandleToPhysicalObject)HIE_fn_hGetSuperObjectObject(_hSprObj));
MTH3D_M_vCopyVector(&stSphereCenter, GEO_fn_pGetCenterPointOfBoundingSphere(hBoundingSphere));
xSphereRadius = GEO_fn_xGetRadiusOfBoundingSphere(hBoundingSphere);
}
hVisualSet = PO_fn_hGetVisualSet((PO_tdxHandleToPhysicalObject)HIE_fn_hGetSuperObjectObject(_hSprObj)) ;
if ( g_ucNbRLIUse == 1 )
{
hRad = GLI_hGetRLI ( hVisualSet, g_ucIndex1 ) ;
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvComputed, 1 ); /* update number of computed objects*/
GLI_lSendVisualSetToViewportWithRLI2(_hVpt,hVisualSet ,&stSphereCenter,*_p_lDrawMask, hRad);
}
else if ( g_ucNbRLIUse == 2 )
{
/* xNumISILOD = 0 ???--------------------------------------------|*/
hRad = GLI_hComputeBlendRLI (hVisualSet, g_ucIndex1, g_ucIndex2, 0, g_xPercent) ;
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvComputed, 1 ); /* update number of computed objects*/
if ( hRad != NULL )
{
GLI_lSendVisualSetToViewportWithRLI2(_hVpt,hVisualSet,&stSphereCenter,*_p_lDrawMask, hRad);
ISI_fn_vFreeISI (hRad) ;
}
else
{
if(((hBoundingSphere) || (hParallelBox)))
{
GLI_lSendVisualSetToViewportBV2(_hVpt ,hVisualSet ,&stSphereCenter, xSphereRadius, *_p_lDrawMask);
}
else
{
GLI_lSendVisualSetToViewport2(_hVpt ,hVisualSet ,&stSphereCenter, *_p_lDrawMask);
}
}
}
else
{
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvComputed, 1 ); /* update number of computed objects*/
if(((hBoundingSphere) || (hParallelBox)))
{
GLI_lSendVisualSetToViewportBV2(_hVpt ,hVisualSet ,&stSphereCenter, xSphereRadius, *_p_lDrawMask);
}
else
{
GLI_lSendVisualSetToViewport2(_hVpt ,hVisualSet ,&stSphereCenter, *_p_lDrawMask);
}
}
}
/*the linked object is IPO*/
else if ( lType==HIE_C_ulIPO )
{
if ( bBoxBoundingVolume )
{
MTH3D_M_vMiddleVector(&stSphereCenter, &stMinPoint, &stMaxPoint);
MTH3D_M_vSubVector (& stSphereCenter , & stSphereCenter , & HIE_fn_hGetSuperObjectGlobalMatrix (_hSprObj) -> stTranslationVector);
}
else
{
if ( !hBoundingSphere )
{
hBoundingSphere = PO_fn_hGetBoundingVolume(IPO_fn_hGetPhysicalObject((IPO_tdxHandleToInstanciatedPhysicalObject)HIE_fn_hGetSuperObjectObject(_hSprObj)));
}
MTH3D_M_vCopyVector(&stSphereCenter, GEO_fn_pGetCenterPointOfBoundingSphere(hBoundingSphere));
xSphereRadius = GEO_fn_xGetRadiusOfBoundingSphere(hBoundingSphere);
}
hRad = IPO_fn_hGetRadiosity((IPO_tdxHandleToInstanciatedPhysicalObject) HIE_fn_hGetSuperObjectObject(_hSprObj));
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvComputed, 1 ); /* update number of computed objects*/
GLI_lSendVisualSetToViewportWithRLI2(_hVpt,PO_fn_hGetVisualSet(IPO_fn_hGetPhysicalObject((IPO_tdxHandleToInstanciatedPhysicalObject)HIE_fn_hGetSuperObjectObject(_hSprObj))),&stSphereCenter,*_p_lDrawMask, hRad);
}
/*the linked object is geometric*/
else if ( lType &( HIE_C_ulEDT_Geometric | HIE_C_ulSpecialEffect))
{
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvComputed, 1 ); /* update number of computed objects*/
GLI_xSendObjectToViewportWithLights(_hVpt, (ACP_tdxHandleOfObject)HIE_fn_hGetSuperObjectObject(_hSprObj), *_p_lDrawMask);
}
GLI_vSetGlobalAlpha( fGlobalAlphaTemp );
}
return TRUE;
}
}
return (ACP_tdxBool) HIE_fn_SO_bCheckChildren(_hSprObj);
}
/*///////////////////////////////////////////////////////////////////////////////////////////////////////////*/
/*///////////////////////////////////////////////////////////////////////////////////////////////////////////*/
/*///////////////////////////////////////////////////////////////////////////////////////////////////////////*/
extern void GLI_fn_vDrawMirror(BOOL);
#if defined(USE_PROFILER) && !defined(PRESS_DEMO)
void fn_vSendOneModuleToViewPortReal(GLD_tdxHandleToViewportAttributes _hVpt,
HIE_tdxHandleToSuperObject _hSprObj ,
long _lDrawMask)
#else
void fn_vSendOneModuleToViewPort(GLD_tdxHandleToViewportAttributes _hVpt,
HIE_tdxHandleToSuperObject _hSprObj ,
long _lDrawMask)
#endif
{
long lType;
GEO_tdxHandleToBoundingSphere hBoundingSphere = NULL;
GEO_tdxHandleToParallelBox hParallelBox = NULL;
MTH3D_tdstVector stSphereCenter;
MTH_tdxReal xSphereRadius;
ACP_tdxHandleToRadiosity hRad;
float fGlobalAlphaTemp , fCullingTransparency;
void GLI_vSetLensFlareRef ( void *p_vRef ) ;
GLI_vSetLensFlareRef ( (void *) _hSprObj ) ;
fGlobalAlphaTemp = GLI_vGetGlobalAlpha();
fCullingTransparency = MTH_M_xRealToFloat( GEO_xGetZFarTransparencyLevel() );
GLI_vSetGlobalAlpha( fCullingTransparency * HIE_fn_fGetSuperObjectTransparenceLevel(_hSprObj) );
lType = HIE_fn_ulGetSuperObjectType(_hSprObj);
if ( lType == HIE_C_ulPO )
{
GEO_tdxHandleToVisualSet hVisualSet ;
/*if the SuperObject is a leaf, its Bounding Volume is the same that*/
/*the one of its linked object : no need to test it (so I set hBoundingVolume to NULL).*/
/*unless the bounding volume of the SuperObject was NULL*/
hBoundingSphere = PO_fn_hGetBoundingVolume((PO_tdxHandleToPhysicalObject)HIE_fn_hGetSuperObjectObject(_hSprObj));
MTH3D_M_vCopyVector(&stSphereCenter, GEO_fn_pGetCenterPointOfBoundingSphere(hBoundingSphere));
xSphereRadius = GEO_fn_xGetRadiusOfBoundingSphere(hBoundingSphere);
hVisualSet = PO_fn_hGetVisualSet((PO_tdxHandleToPhysicalObject)HIE_fn_hGetSuperObjectObject(_hSprObj)) ;
/* VL modif pour prendre en compte les RLI si un perso n'a pas de MSLight */
if ( ( g_ucNbRLIUse == 0 ) && (GLI_lGetVisualSetNumbertOfLOD( hVisualSet ) == 1) )
{
hRad = GLI_hGetRLI ( hVisualSet, 0 ) ;
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvComputed, 1 ); /* update number of computed objects*/
GLI_lSendVisualSetToViewportWithRLI2(_hVpt,hVisualSet ,&stSphereCenter,_lDrawMask, hRad);
}
else
/* fun modif VL */
if ( g_ucNbRLIUse == 1 )
{
hRad = GLI_hGetRLI ( hVisualSet, g_ucIndex1 ) ;
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvComputed, 1 ); /* update number of computed objects*/
GLI_lSendVisualSetToViewportWithRLI2(_hVpt,hVisualSet ,&stSphereCenter,_lDrawMask, hRad);
}
else if ( g_ucNbRLIUse == 2 )
{
/* xNumISILOD = 0 ???--------------------------------------------|*/
hRad = GLI_hComputeBlendRLI (hVisualSet, g_ucIndex1, g_ucIndex2, 0, g_xPercent) ;
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvComputed, 1 ); /* update number of computed objects*/
if ( hRad != NULL )
{
GLI_lSendVisualSetToViewportWithRLI2(_hVpt,hVisualSet,&stSphereCenter,_lDrawMask, hRad);
ISI_fn_vFreeISI (hRad) ;
}
else
{
if(((hBoundingSphere) || (hParallelBox)))
GLI_lSendVisualSetToViewportBV2(_hVpt ,hVisualSet ,&stSphereCenter, xSphereRadius, _lDrawMask);
else
GLI_lSendVisualSetToViewport2(_hVpt ,hVisualSet ,&stSphereCenter, _lDrawMask);
}
}
else
{
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvComputed, 1 ); /* update number of computed objects*/
if(((hBoundingSphere) || (hParallelBox)))
GLI_lSendVisualSetToViewportBV2(_hVpt ,hVisualSet ,&stSphereCenter, xSphereRadius, _lDrawMask);
else
GLI_lSendVisualSetToViewport2(_hVpt ,hVisualSet ,&stSphereCenter, _lDrawMask);
}
}
/*the linked object is IPO*/
else if ( lType==HIE_C_ulIPO )
{
hBoundingSphere = PO_fn_hGetBoundingVolume(IPO_fn_hGetPhysicalObject((IPO_tdxHandleToInstanciatedPhysicalObject)HIE_fn_hGetSuperObjectObject(_hSprObj)));
MTH3D_M_vCopyVector(&stSphereCenter, GEO_fn_pGetCenterPointOfBoundingSphere(hBoundingSphere));
xSphereRadius = GEO_fn_xGetRadiusOfBoundingSphere(hBoundingSphere);
hRad = IPO_fn_hGetRadiosity((IPO_tdxHandleToInstanciatedPhysicalObject) HIE_fn_hGetSuperObjectObject(_hSprObj));
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvComputed, 1 ); /* update number of computed objects*/
GLI_lSendVisualSetToViewportWithRLI2(_hVpt,PO_fn_hGetVisualSet(IPO_fn_hGetPhysicalObject((IPO_tdxHandleToInstanciatedPhysicalObject)HIE_fn_hGetSuperObjectObject(_hSprObj))),&stSphereCenter,_lDrawMask, hRad);
}
/*the linked object is IPO_Mirror*/
else if ( lType==HIE_C_ulIPO_Mirror )
{
if (bViewingInMirror)
{
hBoundingSphere = PO_fn_hGetBoundingVolume(IPO_fn_hGetPhysicalObject((IPO_tdxHandleToInstanciatedPhysicalObject)HIE_fn_hGetSuperObjectObject(_hSprObj)));
MTH3D_M_vCopyVector(&stSphereCenter, GEO_fn_pGetCenterPointOfBoundingSphere(hBoundingSphere));
xSphereRadius = GEO_fn_xGetRadiusOfBoundingSphere(hBoundingSphere);
hRad = IPO_fn_hGetRadiosity((IPO_tdxHandleToInstanciatedPhysicalObject) HIE_fn_hGetSuperObjectObject(_hSprObj));
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvComputed, 1 ); /* update number of computed objects*/
GLI_fn_vDrawMirror( 1 );
GLI_lSendVisualSetToViewportWithRLI2(_hVpt,PO_fn_hGetVisualSet(IPO_fn_hGetPhysicalObject((IPO_tdxHandleToInstanciatedPhysicalObject)HIE_fn_hGetSuperObjectObject(_hSprObj))),&stSphereCenter,_lDrawMask, hRad);
GLI_fn_vDrawMirror( 0 );
}
}
/*the linked object is geometric*/
else if( lType & (HIE_C_ulEDT_Geometric | HIE_C_ulSpecialEffect))
{
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvComputed, 1 ); /* update number of computed objects*/
GLI_xSendObjectToViewportWithLights(_hVpt, (ACP_tdxHandleOfObject)HIE_fn_hGetSuperObjectObject(_hSprObj), _lDrawMask);
}
GLI_vSetGlobalAlpha( fGlobalAlphaTemp );
}
/*///////////////////////////////////////////////////////////////////////////////////////////////////////////*/
/*///////////////////////////////////////////////////////////////////////////////////////////////////////////*/
#if defined(USE_PROFILER) && !defined(PRESS_DEMO)
ACP_tdxBool fn_bSendOneSuperObjectToViewport
(
GLD_tdxHandleToViewportAttributes _hVpt,
HIE_tdxHandleToSuperObject _hSprObj,
long *_p_lDrawMask,
long _lCullingResult
)
{
ACP_tdxBool bResult,bStopChrono;
void *p_vData,*p_vData2;
p_vData2 = NULL;
PRF_fn_vSetIndependantVariable( PRF_C_ulIdpDisplayedElements, 0 ); /* init flag "faces displayed"*/
bStopChrono = (PRF_fn_iGetFunctionNumberOfStart( PRF_C_ulFctDisplay , &p_vData ) > 0 ? 1 : 0);
if( bStopChrono )
{
if( PRF_fn_iGetFunctionNumberOfStart( PRF_C_ulFctDisplayCommon , &p_vData2 ) > 0 )
PRF_fn_vStopChrono( PRF_C_ulFctDisplayCommon , p_vData2 );
else
p_vData2 = NULL;
PRF_fn_vStopChrono( PRF_C_ulFctDisplay, p_vData );
PRF_fn_vStartChrono( PRF_C_ulFctDisplaySpecific, PRF_C_pvMisc );
}
bResult = fn_bSendOneSuperObjectToViewportReal( _hVpt, _hSprObj, _p_lDrawMask, _lCullingResult);
if( bStopChrono )
{
PRF_fn_vStopChrono( PRF_C_ulFctDisplaySpecific, PRF_C_pvMisc );
PRF_fn_vStartChrono( PRF_C_ulFctDisplay, p_vData );
if( p_vData2 )
PRF_fn_vStartChrono( PRF_C_ulFctDisplayCommon, p_vData2 );
}
if( PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDisplayedElements ) ) /* at least one face has been displayed*/
{
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvDisplayed, 1 ); /* update number of displayed objects*/
PRF_fn_vSetIndependantVariable( PRF_C_ulIdpDisplayedObjects, 1 ); /* set flag "object displayed" for sector*/
}
return bResult;
}
void fn_vSendOneModuleToViewPort(GLD_tdxHandleToViewportAttributes _hVpt,
HIE_tdxHandleToSuperObject _hSprObj ,
long _lDrawMask)
{
ACP_tdxBool bStopChrono;
void *p_vData,*p_vData2;
p_vData2 = NULL;
PRF_fn_vSetIndependantVariable( PRF_C_ulIdpDisplayedElements, 0 ); /* init flag "faces displayed"*/
bStopChrono = (PRF_fn_iGetFunctionNumberOfStart( PRF_C_ulFctDisplay , &p_vData ) > 0 ? 1 : 0);
if( bStopChrono )
{
if( PRF_fn_iGetFunctionNumberOfStart( PRF_C_ulFctDisplayCommon , &p_vData2 ) > 0 )
PRF_fn_vStopChrono( PRF_C_ulFctDisplayCommon , p_vData2 );
else
p_vData2 = NULL;
PRF_fn_vStopChrono( PRF_C_ulFctDisplay, p_vData );
PRF_fn_vStartChrono( PRF_C_ulFctDisplaySpecific, PRF_C_pvMisc );
}
fn_vSendOneModuleToViewPortReal( _hVpt, _hSprObj, _lDrawMask );
if( bStopChrono )
{
PRF_fn_vStopChrono( PRF_C_ulFctDisplaySpecific, PRF_C_pvMisc );
PRF_fn_vStartChrono( PRF_C_ulFctDisplay, p_vData );
if( p_vData2 )
PRF_fn_vStartChrono( PRF_C_ulFctDisplayCommon, p_vData2 );
}
if( PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDisplayedElements ) ) /* at least one face has been displayed*/
{
PRF_fn_vIncreaseVariable( PRF_C_ulVarObjects + PRF_fn_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvDisplayed, 1 ); /* update number of displayed objects*/
PRF_fn_vSetIndependantVariable( PRF_C_ulIdpDisplayedObjects, 1 ); /* set flag "object displayed" for sector*/
}
}
void HIE_fn_vUpdateRasterForObject( GEO_tdstGeometricObject *p_stObject,
unsigned long _ulRasterObject,
unsigned long _ulRasterFace,
unsigned long _ulRasterElement )
{
/* take account Object*/
if( p_stObject )
{
ACP_tdxIndex xIndexElement, xNbElements;
/* update number of activated objects*/
PRF_fn_vIncreaseVariable( _ulRasterObject, PRF_C_pvVisible, 1 );
/* ANNECY MT - 27/05/98 {*/
/* update number of elements*/
xNbElements = GEO_xGetGeometricObjectNumberOfElements( p_stObject );
PRF_fn_vIncreaseVariable( _ulRasterElement, PRF_C_pvVisible, xNbElements );
/* update number of faces*/
/* END ANNECY MT }*/
for( xIndexElement = 0 ; xIndexElement < xNbElements ; xIndexElement++ )
{
switch( GEO_xGetElementType( p_stObject, xIndexElement ) )
{
case GEO_C_xElementIndexedTriangles:
PRF_fn_vIncreaseVariable( _ulRasterFace, PRF_C_pvVisible, GEO_lGetIndexedTriangleNbFaces( p_stObject, xIndexElement ) );
break;
case GEO_C_xElementFaceMapDescriptors:
PRF_fn_vIncreaseVariable( _ulRasterFace, PRF_C_pvVisible, ((GEO_tdstElementFaceMapDescriptors *)p_stObject -> d_stListOfElements[xIndexElement])->xNbFaces );
break;
case GEO_C_xElementSprites:
PRF_fn_vIncreaseVariable( _ulRasterFace, PRF_C_pvVisible, ((GEO_tdstElementSprite *)p_stObject -> d_stListOfElements[xIndexElement])->xNbSprites * 2 );
break;
case GEO_C_xElementTMeshes:
PRF_fn_vIncreaseVariable( _ulRasterFace, PRF_C_pvVisible, ((GEO_tdstElementTMeshes *) p_stObject -> d_stListOfElements[xIndexElement])->xNbFaces );
break;
case GEO_C_xElementPoints:
case GEO_C_xElementLines:
case GEO_C_xElementSpheres:
case GEO_C_xElementAlignedBoxes:
case GEO_C_xElementCones:
break;
#ifdef USE_ALTIMAPS
case GEO_C_xElementAltimap:
PRF_fn_vIncreaseVariable( _ulRasterFace, PRF_C_pvVisible, ((GEO_tdstElementAltimap *)p_stObject -> d_stListOfElements[xIndexElement])->xNbFaces );
break;
#endif
default:
break;
}
}
}
}
void HIE_fn_vUpdateRasterForSuperObject( HIE_tdxHandleToSuperObject _hSuperObject,
unsigned long _ulRasterObject,
unsigned long _ulRasterFace,
unsigned long _ulRasterElement )
{
GEO_tdstGeometricObject *p_stObject;
ACP_tdxIndex i;
HIE_tdxHandleToSuperObject hChild;
if(HIE_fn_lGetSuperObjectDrawMask(_hSuperObject) & GLI_C_lDrawNothing)
{
p_stObject = HIE_fn_p_stGetGeometricObjectFromSuperObject( _hSuperObject );
/* take account SuperObject*/
HIE_fn_vUpdateRasterForObject( p_stObject, _ulRasterObject, _ulRasterFace, _ulRasterElement );
/* take account children*/
HIE_M_ForEachChildOf(_hSuperObject, hChild, i)
{
/* ANNECY MT - 27/05/98 {*/
HIE_fn_vUpdateRasterForSuperObject( hChild, _ulRasterObject, _ulRasterFace, _ulRasterElement );
/* END ANNECY MT }*/
}
}
}
#endif /* USE_PROFILER && PRESS_DEMO */
/*
* Use for Lens Flare
*/
ACP_tdxBool HIE_fn_bIsSegmentIntersectedInCameraSector (POS_tdstCompletePosition *p_stCameraPos, POS_tdstCompletePosition *p_stSPOPos) {
MTH3D_tdstVector stOrg, stOrgVect, stVect, stNormal, stHit ;
HIE_tdxHandleToSuperObject hSprObjHit, hSector ;
POS_tdstCompletePosition hCameraPosInv ;
HIE_tdxHandleToSuperObject hMainCamera = CAM_fn_hGetActiveCamera(1); /* 1 ... aaargh !*/
ACP_tdxIndex xIndex;
SECT_tdxHandleOfSectorObject hSectorObject;
SECT_tdxHandleOfElementLstGraphicInteraction hGraphicInteractionChild;
/* coordonn<6E>es camera dans le repere du monde*/
POS_fn_vInvertIsoMatrix( &hCameraPosInv, p_stCameraPos );
POS_fn_vGetTranslationVector(&hCameraPosInv, &stOrg) ;
/* coordonn<6E>es du centre d'objet dans le repere du monde*/
POS_fn_vGetTranslationVector(p_stSPOPos, &stVect) ;
MTH3D_M_vSubVector(&stOrgVect, &stVect, &stOrg) ;
/* le secteur courant*/
hSector = fn_h_SectInfoGetCurrentSector(M_GetMSHandle(hMainCamera, SectInfo)) ;
/* distance dans stVect qui est reduit a chaque intersection*/
MTH3D_M_vCopyVector(&stVect, &stOrgVect) ;
if ( HIE_bIntersectSegmentWithFirstSuperObject (&stOrg, &stVect, hSector, &stHit, &stNormal, &hSprObjHit) ){
return (1) ;
}
/* For each sector in graphic interaction*/
hSectorObject=(SECT_tdxHandleOfSectorObject)HIE_fn_hGetSuperObjectObject(hSector);
LST2_M_StaticForEachElementOf( &(hSectorObject->stListOfSectorsInGraphicInteraction), hGraphicInteractionChild, xIndex) {
MTH3D_M_vCopyVector(&stVect, &stOrgVect) ;
if ( HIE_bIntersectSegmentWithFirstSuperObject( &stOrg, &stVect, hGraphicInteractionChild->hPointerOfSectorSO,
&stHit, &stNormal, &hSprObjHit) ){
return (1) ;
}
}
return (0) ;
}

View File

@@ -0,0 +1,358 @@
#define HIE_FRIEND
#include "ACP_base.h"
#include "GMT.h"
#include "GEO.h"
#include "GLI.h"
#include "DPT.h"
#include "VIG.h"
#include "MEC.h"
#include "PCS.h"
#include "PO.h"
#include "IPO.h"
#include "LST.h"
#include "SND.h"
#include "SCT.h"
#include "SPO/HieMtStk.h"
#include "SPO/HieConst.h"
#include "SPO/HieExt.h"
#include "SPO/Specif/HieLoad.h"
#include "SPO/Specif/HieSpObj.h"
#include "GAM/Structur/3DOSLkTb.h" /* any other way ? perhaps...*/
/*ROMTEAM PLG Files Ionut Grozea 01-05-1998*/
#ifdef ACTIVE_EDITOR
struct ISI_tdstObjectColorStruct_ m_ObjectColorStruct;
#endif
/*ENDROMTEAM PLG Files Ionut Grozea 01-05-1998*/
#include "ldt.h"
#define lTagAddChild 'CddA'
#define lTagPutMatrix 'MtuP'
#define lTagLinkedObject 'kniL'
#define lTagFlags 'galF'
#define lTagTransparency 'narT'
#define lTagMatrixTranslation 'narT'
#define lTagMatrixScale 'lacS'
#define lTagMatrixRotation 'atoR'
HREF g_hRefSPO;
#ifdef ACTIVE_EDITOR
extern void PLG_InitPLGLoad();
void LGT_fn_xLoadPlgObject();
#endif
/*****************************************************************
Function name : fn_iCreateSuperObject
Description :
Author : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM
Creation Date : 14-Oct-98
Modified :
Return type : int
Argument : LDT_tdst_Link *pLink
*****************************************************************/
int fn_iCreateSuperObject( LDT_tdst_Link *pLink )
{
VIG_fn_vAddToProgressBar(1);
/* new SuperObject for that section*/
pLink->pObject = (void*)HIE_fn_hCreateSuperObject();
return 0;
}
/*****************************************************************
Function name : fn_iLoadSuperObject
Description :
Author : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM
Creation Date : 14-Oct-98
Modified :
Return type : int
Argument : LDT_tdst_Link *pLink
*****************************************************************/
int fn_iLoadSuperObject( LDT_tdst_Link *pLink )
{
LDT_tdeParseResult result=ParseResult_BeginSection;
HIE_tdxHandleToSuperObject hSuperObject = (HIE_tdxHandleToSuperObject)pLink->pObject;
POS_tdstCompletePosition *p_stMatrix;
HIE_tdxHandleToVoid hLinkedObj;
char a255_cLongName[255];
HIE_tdxHandleToSuperObject hNewSuperObject;
int nLen;
static int iCount;
nLen = LDT_ComputeSectionName(pLink, a255_cLongName);
SCR_M_v_Link_SetAdditionalLong(SCR_fnp_st_Link_SetValue(HIE_fn_p_stGetSuperObjectLinkTable(), a255_cLongName, (unsigned long)hSuperObject), 1, nLen);
while( result!=ParseResult_EndSection )
{
result=LDT_GetNextEntry();
switch( result )
{
case ParseResult_Entry: /* an entry */
{
char *szEntry=LDT_szGetEntryName();
switch (*(long*)szEntry)
{
case lTagAddChild : /* */
{
hNewSuperObject = (HIE_tdxHandleToSuperObject)LDT_LoadSection(LDT_szGetParam(1));
HIE_fn_vSuperObjectAddTail(hSuperObject, hNewSuperObject);
}
break;
case lTagPutMatrix : /* */
{
p_stMatrix = (POS_tdstCompletePosition *)LDT_LoadSection(LDT_szGetParam(1));
HIE_fn_vSetSuperObjectMatrix(hSuperObject, p_stMatrix);
}
break;
case lTagLinkedObject : /* */
{
char szFile[SCR_CV_ui_Cfg_MaxLenName], szParent[SCR_CV_ui_Cfg_MaxLenName], szSection[SCR_CV_ui_Cfg_MaxLenName], szId[SCR_CV_ui_Cfg_MaxLenName];
char* szParams = LDT_szGetParam(1);
long lType;
LDT_SplitSectionName( szParams, szFile, szParent, szSection, szId );
if (strcmpi(szSection,"Geometric")==0)
{
hLinkedObj =(HIE_tdxHandleToVoid)GLI_pLoadGeometricInFile(szParams);
lType=HIE_C_ulEDT_Geometric;
}
else if (strcmpi(szSection,"Sector")==0)
{
hLinkedObj =(HIE_tdxHandleToVoid)LDT_LoadSection(szParams);
lType=HIE_C_ulSector;
}
else if (strcmpi(szSection,"SpecialEffect")==0)
{
hLinkedObj =(HIE_tdxHandleToVoid)LDT_LoadSection(szParams);
lType=HIE_C_ulSpecialEffect;
}
else if (strcmpi(szSection,"PHY")==0)
{
hLinkedObj = (HIE_tdxHandleToVoid)LDT_LoadSection(szParams);
lType=HIE_C_ulPO;
}
else if (strcmpi(szSection,"IPO")==0)
{
hLinkedObj = (HIE_tdxHandleToVoid)LDT_LoadSection(szParams);
lType=HIE_C_ulIPO;
}
else if (strcmpi(szSection,"Mirror")==0)
{
hLinkedObj =(HIE_tdxHandleToVoid)LDT_LoadSection(szParams);
lType=HIE_C_ulMirror;
}
else if (strcmpi(szSection,"Ipo_Mirror")==0)
{
hLinkedObj =(HIE_tdxHandleToVoid)LDT_LoadSection(szParams);
lType=HIE_C_ulIPO_Mirror;
}
else if (strcmpi(szSection,"PhyMirror")==0)
{
hLinkedObj =(HIE_tdxHandleToVoid)LDT_LoadSection(szParams);
lType=HIE_C_ulPO_Mirror;
}
/* Link the SuperObject with its Object*/
HIE_fn_vSetSuperObjectObjectAndType( hSuperObject,hLinkedObj,lType);
}
break;
case lTagFlags : /* */
{
HIE_fn_SO_vSetFlags( hSuperObject, atoi( LDT_szGetParam(1) ) );
}
break;
case lTagTransparency : /* */
{
HIE_fn_vSetSuperObjectTransparenceLevel( hSuperObject, (float)atof( LDT_szGetParam(1) ) );
}
break;
}
}
}
}
LDT_AddToRefsTable( g_hRefSPO, pLink, 0, 0);
/* By default, a loaded super object has the "box instead of sphere bounding volume" flag*/
HIE_fn_SO_vSetFlags (hSuperObject, HIE_fn_SO_ulGetFlags (hSuperObject) | HIE_C_Flag_ulTypeOfBoundingVolume);
/*ROMTEAM PLG Files Ionut Grozea 01-05-1998*/
#ifdef ACTIVE_EDITOR
if (!iCount)
{
PLG_InitPLGLoad();
LGT_fn_xLoadPlgObject();
iCount = 1;
}
#endif
/*ENDROMTEAM PLG Files Ionut Grozea 01-05-1998*/
return 0;
}
/*****************************************************************
Function name : fn_vSPOPostProcessLDT
Description :
Author : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM
Creation Date : 14-Oct-98
Modified :
Return type : void
Argument : HREF hRef
*****************************************************************/
void fn_vSPOPostProcessLDT( HREF hRef )
{
LDT_tdst_Link *pLink;
LDT_tdst_Link *pGetFrom;
int iType;
short xCount;
long *pVal;
MTH3D_tdstMatrix stIdentityMatrix;
MTH3D_tdstMatrix * p_stTransformationMatrix;
while( LDT_GetRefFromTable( hRef, &pLink, &pGetFrom, &iType, &xCount, &pVal )==0 )
{
HIE_tdxHandleToSuperObject hSuperObject = (HIE_tdxHandleToSuperObject)pLink->pObject;
/* If the matrix is the identity, we set the 'no transformation matrix' flag*/
MTH3D_M_vSetIdentityMatrix (& stIdentityMatrix);
p_stTransformationMatrix = & HIE_fn_hGetSuperObjectMatrix (hSuperObject) -> stTransformMatrix;
if (MTH3D_M_bEqualMatrix (p_stTransformationMatrix, & stIdentityMatrix))
{
HIE_fn_SO_vSetFlags (hSuperObject, HIE_fn_SO_ulGetFlags (hSuperObject) | HIE_C_Flag_ulNoTransformationMatrix);
}
}
}
/*****************************************************************
Function name : fn_iCreateOneMatrix
Description :
Author : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM
Creation Date : 14-Oct-98
Modified :
Return type : int
Argument : LDT_tdst_Link *pLink
*****************************************************************/
int fn_iCreateOneMatrix( LDT_tdst_Link *pLink )
{
POS_tdstCompletePosition *p_stMatrix;
p_stMatrix=GEO_fn_hCreateMatrix();
POS_fn_vSetIdentityMatrix(p_stMatrix);
pLink->pObject = (void*)p_stMatrix;
return 0;
}
/*****************************************************************
Function name : fn_iLoadOneMatrix
Description :
Author : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM
Creation Date : 14-Oct-98
Modified :
Return type : int
Argument : LDT_tdst_Link *pLink
*****************************************************************/
int fn_iLoadOneMatrix( LDT_tdst_Link *pLink )
{
LDT_tdeParseResult result=ParseResult_BeginSection;
POS_tdstCompletePosition *p_stMatrix = (POS_tdstCompletePosition *)pLink->pObject;
long i;
GLI_tdxValue a_xVertex[9];
MTH3D_tdstVector stI,stJ,stK;
while( result!=ParseResult_EndSection )
{
result=LDT_GetNextEntry();
switch( result )
{
case ParseResult_Entry: /* an entry */
{
char *szEntry=LDT_szGetEntryName();
switch (*(long*)(szEntry+6))
{
case lTagMatrixTranslation : /* */
{
char szFileName[_MAX_PATH], *szP;
LDT_ComputeSectionName(pLink, szFileName);
szP = strchr(szFileName, '^');
*szP = 0;
for (i=1;i<4;i++)
a_xVertex[i-1]=(GLI_tdxValue)GLI_M_FloatToValue(atof(LDT_szGetParam(i) ) * GLI_dGetUnitInMeterInFile(szFileName));
MTH3D_M_vSetVectorElements(&stI,a_xVertex[0],a_xVertex[1],a_xVertex[2]);
POS_fn_vSetTranslationVector(p_stMatrix,&stI);
}
break;
case lTagMatrixScale : /* */
{
for (i=1;i<10;i++)
a_xVertex[i-1]=(GLI_tdxValue)GLI_M_FloatToValue(atof(LDT_szGetParam(i) ));
if( !( (a_xVertex[0] == 1.0)
&& (a_xVertex[1] == 0.0)
&& (a_xVertex[2] == 0.0)
&& (a_xVertex[3] == 0.0)
&& (a_xVertex[4] == 1.0)
&& (a_xVertex[5] == 0.0)
&& (a_xVertex[6] == 0.0)
&& (a_xVertex[7] == 0.0)
&& (a_xVertex[8] == 1.0))
)
{
MTH3D_M_vSetVectorElements(&stI,a_xVertex[0],a_xVertex[1],a_xVertex[2]);
MTH3D_M_vSetVectorElements(&stJ,a_xVertex[3],a_xVertex[4],a_xVertex[5]);
MTH3D_M_vSetVectorElements(&stK,a_xVertex[6],a_xVertex[7],a_xVertex[8]);
POS_fn_vSetScaleMatrix(p_stMatrix,&stI,&stJ,&stK);
}
}
break;
case lTagMatrixRotation : /* */
{
for (i=1;i<10;i++)
a_xVertex[i-1]=(GLI_tdxValue)GLI_M_FloatToValue(atof(LDT_szGetParam(i)));
MTH3D_M_vSetVectorElements(&stI,a_xVertex[0],a_xVertex[1],a_xVertex[2]);
MTH3D_M_vSetVectorElements(&stJ,a_xVertex[3],a_xVertex[4],a_xVertex[5]);
MTH3D_M_vSetVectorElements(&stK,a_xVertex[6],a_xVertex[7],a_xVertex[8]);
POS_fn_vSetRotationMatrix(p_stMatrix,&stI,&stJ,&stK);
}
break;
}
}
}
}
/* Recalcul automatique du type*/
POS_fn_vUpdateMatrixType(p_stMatrix);
return 0;
}