/*========================================================================= * MSPrtSrc.cpp : MSPrtSrc's functions * * * * MSPrtSrc MUST BE REPLACE BY THE C FILENAME * * * Version 1.0 * Creation date 01/10/96 * Revision date * * That file needs to be compatible for all platforms. * * (c) Ubi Studios 1996 *=======================================================================*/ #ifndef D_THROW_PRT /*******************************************************/ /**** For the structures and variables declarations ****/ /*******************************************************/ #define D_MSPrtSrc_StructureDefine #define D_MSPrtSrc_VariableDefine #include "ToolsCPA.h" #include "Options/Options.h" #include "Macros.h" #include "Actions/AllActs.h" #include "Structur/MemGame.h" #include "Structur/ErrGame.h" #include "Structur/Objects.h" #include "Structur/GameScpt.h" #include "Structur/StdObjSt.h" #include "Structur/EngMode.h" #include "Basic.h" #include "ObjInit.h" #include "ZeMem.h" #include "MainChar.h" #include "Effect.h" /*-------------------------------------------------------------------- * Functions declarations *--------------------------------------------------------------------*/ ACP_tdxBool fn_bIsGeneratorActiveInThisEnvironment ( HIE_tdxHandleToSuperObject _hCharacterSource, tdstParticleGenerator * _p_stGenerator ); ACP_tdxBool fn_bIsGeneratorPointInCorrectEnvironment ( HIE_tdxHandleToSuperObject _hActiveSector, MTH3D_tdstVector * _p_stAbsolutePoint, long _lEnvironmentMask, MTH_tdxReal * _p_xDepthCorrection ); extern ACP_tdxBool fn_bIsInFix(struct tdstEngineObject_ *p_stObject); /* ======================================================================================= Script callback functions ======================================================================================= */ /*----------------------------------------------------------------------------- * Description : MSPrtSrc's object action script callback *----------------------------------------------------------------------------- * Input : Object pointer * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Olivier *---------------------------------------------------------------------------*/ #if defined(GAM_USE_SCRIPT) SCR_tde_Anl_ReturnValue fn_eMSPrtSrcScriptCallback(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action _eAction) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ MS_tdxHandleToMSPrtSrc h_MSPrtSrc; struct tdstEngineObject_ *p_stEngineObject; SCR_tdst_Cxt_Values * p_stValues; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* to avoid warning */ _p_stFile = _p_stFile; if (M_IsTitle) { SCR_M_RdL0_GetSectionLong(C_ParentSection,0,struct tdstEngineObject_ *, p_stEngineObject); MMG_fn_vBeginMemoryInfo (MMG_C_lTypeMiniStructure , MMG_C_lSubTypePrtSrc , p_stEngineObject); h_MSPrtSrc = fn_h_MSPrtSrcRealAlloc(); MMG_fn_vEndMemoryInfo (); p_stEngineObject->h_MSPrtSrc=h_MSPrtSrc; h_MSPrtSrc->ucGeneratorActivation = 1; SCR_M_RdL0_SetSectionLong(C_ThisSection,0,h_MSPrtSrc); } else if (M_IsEntry) { SCR_M_RdL0_GetSectionLong(C_ThisSection,0,MS_tdxHandleToMSPrtSrc,h_MSPrtSrc); if (M_ActionIs(C_EntryMSPrtSrcGeneratorActivation)) { M_CheckScriptParamNumber(1); h_MSPrtSrc->ucGeneratorActivation = (unsigned char) ((strcmp(_ap_szParams[0],"OFF") == 0) ? 0 : 1); } else if( M_ActionIs(C_EntryMSPrtSrcParticleGenerator) ) { M_CheckScriptParamNumber(1); p_stValues=SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal); h_MSPrtSrc->p_stParticleGenerator = (tdstParticleGenerator *)(p_stValues->a_ulValues[0]); } else if( M_ActionIs(C_EntryMSPrtSrcWaterStreakGenerator) ) { M_CheckScriptParamNumber(1); p_stValues=SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal); h_MSPrtSrc->hWaterStreakGenerator = (GAM_tdxHandleToWaterStreakEffect)(p_stValues->a_ulValues[0]); } else if( M_ActionIs(C_EntryMSPrtSrcFootPathGenerator) ) { M_CheckScriptParamNumber(1); p_stValues = SCR_fnp_st_RdL0_AnalyseSection( _ap_szParams[0], SCR_CDF_uw_Anl_Normal ); h_MSPrtSrc->hFootPath = (GAM_tdxHandleToFootPathEffect) ( p_stValues->a_ulValues[0] ); } } return( SCR_ERV_Anl_NormalReturn ); } /*----------------------------------------------------------------------------- * Description : Script callback function for FootPath effect description function *----------------------------------------------------------------------------- * Creation date : 25/11/97 Author : Tahiti Bob *---------------------------------------------------------------------------*/ SCR_tde_Anl_ReturnValue fn_eFootPathScriptCallBack(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action _eAction) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ tdstFootPath *p_stFootPath; ACP_tdxIndex xObj; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* section beginning : allocate and init FootPath effect structure */ if (M_IsTitle) { p_stFootPath = (tdstFootPath *) fn_h_FootPath_Alloc(); SCR_M_RdL0_SetSectionLong(C_ThisSection, 0, p_stFootPath); #if defined(ACTIVE_EDITOR) { char a255_cLinkKey[255]; SCR_M_RdL0_ComputeOpenSectionNameR(0, a255_cLinkKey); SCR_M_v_Link_SetAdditionalLong ( SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stPrtSrcLinkTable, a255_cLinkKey, (unsigned long) p_stFootPath), 1, strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)) ); } #endif /* ACTIVE_EDITOR */ } /* entry : foot path parameters */ else if (M_IsEntry) { /* retrieve allocated footpath description structure */ SCR_M_RdL0_GetSectionLong(C_ThisSection, 0, tdstFootPath *, p_stFootPath ); /* number of alpha levels */ if ( M_ActionIs( C_szEntryNumberOfAlphaLevels ) ) { M_CheckScriptParamNumber(1); p_stFootPath->xNumberOfAlphaLevels = (ACP_tdxIndex)atoi( _ap_szParams[0] ); if (p_stFootPath->xNumberOfAlphaLevels > 8) p_stFootPath->xNumberOfAlphaLevels = 8; if (p_stFootPath->xNumberOfAlphaLevels < 1) p_stFootPath->xNumberOfAlphaLevels = 1; } /* number of points for each alpha levels */ else if ( M_ActionIs( C_szEntryNumberOfPointsByAlpha ) ) { M_CheckScriptParamNumber( p_stFootPath->xNumberOfAlphaLevels ); for (xObj = 0; xObj < p_stFootPath->xNumberOfAlphaLevels; xObj++ ) { p_stFootPath->a8_xNumberOfPoints[ xObj ] = (ACP_tdxIndex) atoi( _ap_szParams[ xObj ] ); } } /* alpha color for each alpha level */ else if ( M_ActionIs( C_szEntryAlpha ) ) { M_CheckScriptParamNumber( p_stFootPath->xNumberOfAlphaLevels ); for (xObj = 0; xObj < p_stFootPath->xNumberOfAlphaLevels; xObj++ ) { p_stFootPath->a8_xAlphaColor[ xObj ] = (MTH_tdxReal) atof( _ap_szParams[ xObj ] ); } } /* offset for left and right foot print : this is two vectors */ else if ( M_ActionIs( C_szEntryFootPrintOffsets ) ) { M_CheckScriptParamNumber( 6 ); MTH3D_M_vSetVectorElements(&p_stFootPath->a2_stOffset[0], (MTH_tdxReal)atof(_ap_szParams[0]),(MTH_tdxReal)atof(_ap_szParams[1]),(MTH_tdxReal)atof(_ap_szParams[2])); MTH3D_M_vSetVectorElements(&p_stFootPath->a2_stOffset[1], (MTH_tdxReal)atof(_ap_szParams[3]),(MTH_tdxReal)atof(_ap_szParams[4]),(MTH_tdxReal)atof(_ap_szParams[5])); } /* dimension of footprint (real in meter) */ else if ( M_ActionIs( C_szEntryFootPrintDimension ) ) { M_CheckScriptParamNumber( 2 ); p_stFootPath->a2_xScale[0] = (MTH_tdxReal) ( atof(_ap_szParams[0]) / 2 ); p_stFootPath->a2_xScale[1] = (MTH_tdxReal) ( atof(_ap_szParams[1]) / 2 ); } /* texture use for footprint */ else if ( M_ActionIs( C_szEntryFootPrintGameMaterial ) ) { M_CheckScriptParamNumber( 1 ); p_stFootPath->hFootPrintMaterial = GMT_fn_hLoadGameMaterial( _ap_szParams[0] ); } /* material mask, used to know if material under foot accept foot print */ else if ( M_ActionIs( C_szEntryMaterialMask ) ) { M_CheckScriptParamNumber( 1 ); p_stFootPath->xConsiderMaterial = (GMT_tdxMask) atoi( _ap_szParams[ 0 ] ); } } else if (M_IsEnd) { /* retrieve allocated footpath description structure */ SCR_M_RdL0_GetSectionLong(C_ThisSection, 0, tdstFootPath *, p_stFootPath ); fn_v_FootPath_Create( p_stFootPath ); } return (SCR_ERV_Anl_NormalReturn); } /*ENDANNECY VL }*/ /*----------------------------------------------------------------------------- * Description : Particle Generator script callback *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Olivier *---------------------------------------------------------------------------*/ SCR_tde_Anl_ReturnValue fn_ePrtGeneratorScriptCallBack(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action _eAction) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ tdstParticleGenerator *p_stPrtGen; SCR_tdst_Cxt_Values *p_stValues; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ _p_stFile=_p_stFile; if (M_IsTitle) { p_stPrtGen = (tdstParticleGenerator *)fn_hParticleGeneratorAllocation(); p_stPrtGen->ucLinkedToEnvironment = 0; p_stPrtGen->lEnvironmentMask = C_lAllEnvironments; #if defined(ACTIVE_EDITOR) { char a255_cLinkKey[255]; SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey); SCR_M_v_Link_SetAdditionalLong ( SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stPrtGenLinkTable, a255_cLinkKey,(unsigned long)p_stPrtGen), 1, strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)) ); } #endif /* ACTIVE_EDITOR */ SCR_M_RdL0_SetSectionLong(C_ThisSection,0,p_stPrtGen); } else if (M_IsEntry) { SCR_M_RdL0_GetSectionLong(C_ThisSection,0,tdstParticleGenerator *,p_stPrtGen); if( M_ActionIs(C_EntryPrtGenLoadParticleSystem) ) { M_CheckScriptParamNumber(1); p_stValues=SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal); p_stPrtGen->p_stPrtSys = (PRT_tdstParticlesSystem *)(p_stValues->a_ulValues[0]); } else if( M_ActionIs(C_EntryPrtGenLoadParticleEnvironment) ) { M_CheckScriptParamNumber(1); p_stValues=SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal); p_stPrtGen->p_stPrtEnv = (PRT_tdstParticlesEnvironment *)(p_stValues->a_ulValues[0]); } else if( M_ActionIs(C_EntryPrtGenLoadParticleSource) ) { M_CheckScriptParamNumber(1); p_stValues=SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal); p_stPrtGen->p_stPrtSrc = (PRT_tdstParticlesSource *)(p_stValues->a_ulValues[0]); } else if( M_ActionIs(C_EntryPrtGenLinkedToEnvironment) ) { M_CheckScriptParamNumber(1); if( !strcmp(_ap_szParams[0],C_szLinkedToEnvironment) ) p_stPrtGen->ucLinkedToEnvironment = 1; } else if( M_ActionIs(C_EntryPrtGenEnvironmentMask) ) { M_CheckScriptParamNumber(1); p_stPrtGen->lEnvironmentMask = atoi(_ap_szParams[0]); } else if (M_ActionIs( C_EntryPrtGenLinkedPrtGenMask ) ) { M_CheckScriptParamNumber(1); p_stPrtGen->ulLinkedPrtGenMask = atoi(_ap_szParams[0]); } else if (M_ActionIs( C_EntryPrtGenLinkedPrtGen ) ) { M_CheckScriptParamNumber(1); p_stValues = SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal); p_stPrtGen->p_stLinkedPrtGen = (tdstParticleGenerator *)(p_stValues->a_ulValues[0]); } } return(SCR_ERV_Anl_NormalReturn); } /*----------------------------------------------------------------------------- * Description : Particle Source script callback *----------------------------------------------------------------------------- * Creation date : 06/11/97 Author : Olivier *---------------------------------------------------------------------------*/ SCR_tde_Anl_ReturnValue fn_ePrtSrcScriptCallBack(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action _eAction) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ PRT_tdstParticlesSource * p_stPrtSrc; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ _p_stFile=_p_stFile; if (M_IsTitle) { PRT_fn_vCreateParticlesSource(&p_stPrtSrc); #if defined(ACTIVE_EDITOR) { char a255_cLinkKey[255]; SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey); SCR_M_v_Link_SetAdditionalLong ( SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stPrtSrcLinkTable, a255_cLinkKey,(unsigned long)p_stPrtSrc), 1, strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)) ); } #endif /* ACTIVE_EDITOR */ SCR_M_RdL0_SetSectionLong(C_ThisSection,0,p_stPrtSrc); } else if (M_IsEntry) { SCR_M_RdL0_GetSectionLong(C_ThisSection,0,PRT_tdstParticlesSource *,p_stPrtSrc); if (M_ActionIs(C_EntryPrtSrcGenerationMode)) { M_CheckScriptParamNumber(1); if( !strcmp(_ap_szParams[0],C_szNoGeneration) ) PRT_M_vSetGenerationModeParticlesSource ( p_stPrtSrc, PRT_C_ucNoGeneration ); else if( !strcmp(_ap_szParams[0],C_szContinuousGeneration) ) PRT_M_vSetGenerationModeParticlesSource ( p_stPrtSrc, PRT_C_ucContinousGeneration ); else if( !strcmp(_ap_szParams[0],C_szProbabilistGeneration) ) PRT_M_vSetGenerationModeParticlesSource ( p_stPrtSrc, PRT_C_ucProbabilistGeneration ); else if( !strcmp(_ap_szParams[0],C_szCrenelGeneration) ) PRT_M_vSetGenerationModeParticlesSource ( p_stPrtSrc, PRT_C_ucCrenelGeneration ); } else if( M_ActionIs(C_EntryPrtSrcGenerationProbability) ) { M_CheckScriptParamNumber(1); PRT_M_vSetGenerationProbabilityParticlesSource ( p_stPrtSrc, (MTH_tdxReal)atof(_ap_szParams[0]) ); } else if( M_ActionIs(C_EntryPrtSrcCrenelGeneration) ) { M_CheckScriptParamNumber(2); PRT_M_vSetNbFramesCrenelParticlesSource ( p_stPrtSrc, (ACP_tdxIndex)atoi(_ap_szParams[0]), (ACP_tdxIndex)atoi(_ap_szParams[1]) ); } else if( M_ActionIs(C_EntryPrtSrcNbParticlesToGenerateMode) ) { M_CheckScriptParamNumber(1); if( !strcmp(_ap_szParams[0],C_szConstantNb) ) PRT_M_vSetNbParticlesToGenerateModeParticlesSource ( p_stPrtSrc, PRT_C_ucConstantNb ); else if( !strcmp(_ap_szParams[0],C_szProbabilistNb) ) PRT_M_vSetNbParticlesToGenerateModeParticlesSource ( p_stPrtSrc, PRT_C_ucProbabilistNb ); } else if( M_ActionIs(C_EntryPrtSrcNbParticlesToGenerate) ) { M_CheckScriptParamNumber(1); PRT_M_vSetNbParticlesToGenerateParticlesSource ( p_stPrtSrc, (unsigned char)atoi(_ap_szParams[0]) ); } else if( M_ActionIs(C_EntryPrtSrcNbMinMax) ) { M_CheckScriptParamNumber(2); PRT_M_vSetNbMinMaxParticlesSource ( p_stPrtSrc, (ACP_tdxIndex)atoi(_ap_szParams[0]), (ACP_tdxIndex)atoi(_ap_szParams[1]) ); } else if( M_ActionIs(C_EntryPrtSrcGeometryMode) ) { M_CheckScriptParamNumber(1); if( !strcmp(_ap_szParams[0],C_szPoint) ) PRT_M_vSetGeometryModeParticlesSource ( p_stPrtSrc, PRT_C_ucPoint ); else if( !strcmp(_ap_szParams[0],C_szQuad) ) PRT_M_vSetGeometryModeParticlesSource ( p_stPrtSrc, PRT_C_ucQuad ); } else if( M_ActionIs(C_EntryPrtSrcQuad) ) { MTH3D_tdstVector stVector1; MTH3D_tdstVector stVector2; MTH3D_tdstVector stVector3; M_CheckScriptParamNumber(9); MTH3D_M_vSetVectorElements(&stVector1,(MTH_tdxReal)atof(_ap_szParams[0]),(MTH_tdxReal)atof(_ap_szParams[1]),(MTH_tdxReal)atof(_ap_szParams[2])); MTH3D_M_vSetVectorElements(&stVector2,(MTH_tdxReal)atof(_ap_szParams[3]),(MTH_tdxReal)atof(_ap_szParams[4]),(MTH_tdxReal)atof(_ap_szParams[5])); MTH3D_M_vSetVectorElements(&stVector3,(MTH_tdxReal)atof(_ap_szParams[6]),(MTH_tdxReal)atof(_ap_szParams[7]),(MTH_tdxReal)atof(_ap_szParams[8])); PRT_fn_vSetQuadParticlesSource ( p_stPrtSrc, &stVector1, &stVector2, &stVector3 ); } else if( M_ActionIs(C_EntryPrtSrcPoint) ) { MTH3D_tdstVector stVector; M_CheckScriptParamNumber(3); MTH3D_M_vSetVectorElements(&stVector,(MTH_tdxReal)atof(_ap_szParams[0]),(MTH_tdxReal)atof(_ap_szParams[1]),(MTH_tdxReal)atof(_ap_szParams[2])); PRT_fn_vSetPointParticlesSource ( p_stPrtSrc, &stVector ); } else if( M_ActionIs(C_EntryPrtSrcSpeedAndRange) ) { M_CheckScriptParamNumber(2); PRT_M_vSetSpeedParticlesSource ( p_stPrtSrc, (MTH_tdxReal)atof(_ap_szParams[0]) ); PRT_M_vSetSpeedRangeParticlesSource ( p_stPrtSrc, (MTH_tdxReal)atof(_ap_szParams[1]) ); } else if( M_ActionIs(C_EntryPrtSrcLinkMode) ) { M_CheckScriptParamNumber(1); if( !strcmp(_ap_szParams[0],C_szRotationLink) ) PRT_M_vSetLinkModeParticlesSource(p_stPrtSrc,(unsigned char)0); else if( !strcmp(_ap_szParams[0],C_szTranslationLink) ) PRT_M_vSetLinkModeParticlesSource(p_stPrtSrc,(unsigned char)1); else /* C_szRotationAndTranslationLink */ PRT_M_vSetLinkModeParticlesSource(p_stPrtSrc,(unsigned char)2); } else if( M_ActionIs(C_EntryPrtSrcNoLifeTime) ) { M_CheckScriptParamNumber(0); PRT_M_vSetLifeModeParticlesSource(p_stPrtSrc,PRT_C_ucNoLifeTime); } else if( M_ActionIs(C_EntryPrtSrcConstantLifeTime) ) { M_CheckScriptParamNumber(1); PRT_M_vSetLifeModeParticlesSource( p_stPrtSrc,PRT_C_ucConstantLifeTime ); PRT_M_vSetLifeTimeParticlesSource( p_stPrtSrc,(MTH_tdxReal)atof(_ap_szParams[0]) ); } else if( M_ActionIs(C_EntryPrtSrcProbabilistLifeTime) ) { M_CheckScriptParamNumber(2); PRT_M_vSetLifeModeParticlesSource( p_stPrtSrc,PRT_C_ucProbabilistLifeTime ); PRT_M_vSetMinMaxLifeTimeParticlesSource( p_stPrtSrc,(MTH_tdxReal)atof(_ap_szParams[0]),(MTH_tdxReal)atof(_ap_szParams[1]) ); } } return(SCR_ERV_Anl_NormalReturn); } #endif /* U64 */ /*----------------------------------------------------------------------------- * Description : CallBack of Particle System loading *----------------------------------------------------------------------------- * Creation date : 11/09/97 Author : Olivier *---------------------------------------------------------------------------*/ #if !defined(U64) SCR_tde_Anl_ReturnValue fn_ePrtSysScriptCallback(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action _eAction) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ PRT_tdstParticlesSystem * p_stPrtSys; #if defined(ACTIVE_EDITOR) char a255_cLinkKey[255]; #endif /* ACTIVE_EDITOR */ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ _p_stFile=_p_stFile; if (M_IsTitle) { M_CheckScriptParamNumber(1); PRT_fn_vCreateParticlesSystem(&p_stPrtSys,(ACP_tdxIndex)atoi(_ap_szParams[0])); #if defined(ACTIVE_EDITOR) SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey); SCR_M_v_Link_SetAdditionalLong ( SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stPrtSysLinkTable, a255_cLinkKey,(unsigned long)p_stPrtSys), 1, strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)) ); #endif /* ACTIVE_EDITOR */ SCR_M_RdL0_SetSectionLong(C_ThisSection,0,p_stPrtSys); } else if (M_IsEntry) { SCR_M_RdL0_GetSectionLong(C_ThisSection,0,PRT_tdstParticlesSystem *,p_stPrtSys); if (M_ActionIs(C_EntryPrtSysCreatePoint)) { GMT_tdxHandleToGameMaterial hMaterial; SCR_tdst_Cxt_Values *p_stVal; M_CheckScriptParamNumber(1); p_stVal = SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal); hMaterial = (GMT_tdxHandleToGameMaterial)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0); assert(hMaterial != NULL); PRT_fn_vCreatePointParticles ( p_stPrtSys, hMaterial ); } else if (M_ActionIs(C_EntryPrtSysCreateSegment)) { GMT_tdxHandleToGameMaterial hMaterial; SCR_tdst_Cxt_Values *p_stVal; M_CheckScriptParamNumber(1); p_stVal = SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal); hMaterial = (GMT_tdxHandleToGameMaterial)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0); assert(hMaterial != NULL); PRT_fn_vCreateSegmentParticles ( p_stPrtSys, hMaterial ); } else if (M_ActionIs("MultipleSprites")) { M_CheckScriptParamNumber(1); PRT_fn_vCreateMultipleSpritesParticles( p_stPrtSys, (ACP_tdxIndex)atoi(_ap_szParams[0]) ); } else if (M_ActionIs(C_EntryPrtSysCreateSprite)) { ACP_tdxHandleOfSprite hSprite; SCR_tdst_Cxt_Values *p_stVal; M_CheckScriptParamNumber(1); p_stVal = SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal); hSprite = (ACP_tdxHandleOfSprite)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0); assert(hSprite != NULL); #if defined(ACTIVE_EDITOR) SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey); SCR_M_v_Link_SetAdditionalLong ( SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stPrtSysSpriteLinkTable, a255_cLinkKey,(unsigned long)hSprite), 1, strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)) ); #endif /* ACTIVE_EDITOR */ if ( PRT_fn_cSystemIsMultipleSprites( p_stPrtSys ) ) PRT_fn_vAddSprite( p_stPrtSys, hSprite ); else PRT_fn_vCreateSpriteParticles ( p_stPrtSys, hSprite ); } } else if (M_IsEnd) { SCR_M_RdL0_GetSectionLong(C_ThisSection,0,PRT_tdstParticlesSystem *,p_stPrtSys); if ( PRT_fn_cSystemIsMultipleSprites( p_stPrtSys ) ) PRT_fn_vEndCreateMultipleSpritesParticles( p_stPrtSys ); } return(SCR_ERV_Anl_NormalReturn); } /*----------------------------------------------------------------------------- * Description : CallBack of Particle Environment loading *----------------------------------------------------------------------------- * Creation date : 11/09/97 Author : Olivier *---------------------------------------------------------------------------*/ SCR_tde_Anl_ReturnValue fn_ePrtEnvScriptCallback(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action _eAction) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ PRT_tdstParticlesEnvironment * p_stPrtEnv; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ _p_stFile=_p_stFile; if (M_IsTitle) { PRT_fn_vCreateParticlesEnvironment(&p_stPrtEnv); #if defined(ACTIVE_EDITOR) { char a255_cLinkKey[255]; SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey); SCR_M_v_Link_SetAdditionalLong ( SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stPrtEnvLinkTable, a255_cLinkKey,(unsigned long)p_stPrtEnv), 1, strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)) ); } #endif /* ACTIVE_EDITOR */ SCR_M_RdL0_SetSectionLong(C_ThisSection,0,p_stPrtEnv); } else if (M_IsEntry) { SCR_M_RdL0_GetSectionLong(C_ThisSection,0,PRT_tdstParticlesEnvironment *,p_stPrtEnv); if (M_ActionIs(C_EntryPrtEnvType)) { M_CheckScriptParamNumber(1); if (!stricmp(_ap_szParams[0],C_szAlignedBox)) PRT_M_vSetTypeParticlesEnvironment ( p_stPrtEnv, PRT_C_ulAlignedBoxEnv ); else if (!stricmp(_ap_szParams[0],C_szSphere)) PRT_M_vSetTypeParticlesEnvironment ( p_stPrtEnv, PRT_C_ulSphereEnv ); } else if (M_ActionIs(C_EntryPrtEnvMinMaxPoint)) { MTH3D_tdstVector stVector1; MTH3D_tdstVector stVector2; M_CheckScriptParamNumber(6); MTH3D_M_vSetVectorElements(&stVector1,(MTH_tdxReal)atof(_ap_szParams[0]),(MTH_tdxReal)atof(_ap_szParams[1]),(MTH_tdxReal)atof(_ap_szParams[2])); MTH3D_M_vSetVectorElements(&stVector2,(MTH_tdxReal)atof(_ap_szParams[3]),(MTH_tdxReal)atof(_ap_szParams[4]),(MTH_tdxReal)atof(_ap_szParams[5])); PRT_M_vSetMinMaxPointParticlesEnvironment ( p_stPrtEnv, &stVector1, &stVector2 ); } else if (M_ActionIs(C_EntryPrtEnvSphere)) { MTH3D_tdstVector stVector; M_CheckScriptParamNumber(4); MTH3D_M_vSetVectorElements(&stVector,(MTH_tdxReal)atof(_ap_szParams[0]),(MTH_tdxReal)atof(_ap_szParams[1]),(MTH_tdxReal)atof(_ap_szParams[2])); PRT_M_vSetSphereParticlesEnvironment ( p_stPrtEnv, &stVector, (MTH_tdxReal)atof(_ap_szParams[3]) ); } else if (M_ActionIs(C_EntryPrtEnvAcceleration)) { MTH3D_tdstVector stVector; M_CheckScriptParamNumber(4); MTH3D_M_vSetVectorElements(&stVector,(MTH_tdxReal)atof(_ap_szParams[0]),(MTH_tdxReal)atof(_ap_szParams[1]),(MTH_tdxReal)atof(_ap_szParams[2])); PRT_M_vSetAccelerationParticlesEnvironment ( p_stPrtEnv, &stVector ); PRT_M_vSetAccelerationRangeParticlesEnvironment ( p_stPrtEnv, (MTH_tdxReal)atof(_ap_szParams[3]) ); } } return(SCR_ERV_Anl_NormalReturn); } /*----------------------------------------------------------------------------- * Description : register of particles callbacks *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Olivier *---------------------------------------------------------------------------*/ void fn_vRegisterAllGamParticlesCallBacks() { SCR_fn_v_RdL0_RegisterCallback(C_SectionPrtSysDescription,fn_ePrtSysScriptCallback,SCR_CRC_c_RdL0_ForSection); SCR_fn_v_RdL0_RegisterCallback(C_SectionPrtEnvDescription,fn_ePrtEnvScriptCallback,SCR_CRC_c_RdL0_ForSection); SCR_fn_v_RdL0_RegisterCallback(C_SectionParticleGenerator,fn_ePrtGeneratorScriptCallBack,SCR_CRC_c_RdL0_ForSection); SCR_fn_v_RdL0_RegisterCallback(C_SectionParticleSource,fn_ePrtSrcScriptCallBack,SCR_CRC_c_RdL0_ForSection); SCR_fn_v_RdL0_RegisterCallback(C_szSectionFootPathEffectDescription, fn_eFootPathScriptCallBack, SCR_CRC_c_RdL0_ForSection); } #endif /*GAM_USE_SCRIPT*/ /* ======================================================================================= Script save function ======================================================================================= */ /*----------------------------------------------------------------------------- * Description : MSPrtSrc's save structure *----------------------------------------------------------------------------- * Input : SCR_tdst_File_Description *, struct tdstEngineObject_ * * Output : Void *----------------------------------------------------------------------------- * Creation date : 28/02/97 Author : Francois *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ /* void fn_vMSPrtSrcSaveMiniStructure(SCR_tdst_File_Description *p_stFile,struct tdstEngineObject_ *p_stObject) { char szSection[SCR_CV_ui_Cfg_MaxLenName]; MS_tdxHandleToMSPrtSrc h_MSPrtSrc = p_stObject->h_MSPrtSrc; SCR_M_SvL0_SaveBlankLine(p_stFile); SCR_M_SvL0_SaveComment(p_stFile, "**** MSPrtSrc mini-structure definition ****"); sprintf(szSection,"%s:",C_SectionMSPrtSrcDescription); SCR_M_SvL0_SaveBeginSection(p_stFile,szSection,SCR_CC_C_Cfg_EOL); // ** Put here the saving script functions ** SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL) } */ /* ======================================================================================= MSPrtSrc mini-structure functions ======================================================================================= */ /*----------------------------------------------------------------------------- * Description : MSPrtSrc's mini-structure sizeof *----------------------------------------------------------------------------- * Input : None * Output : Size of *----------------------------------------------------------------------------- * Creation date : 14/10/96 Author : Francois *---------------------------------------------------------------------------*/ unsigned long fn_ulMSPrtSrcSizeOf() { return(sizeof(struct tdstMSPrtSrc_)); } /*----------------------------------------------------------------------------- * Description : MSPrtSrc's object action allocation *----------------------------------------------------------------------------- * Input : Object pointer * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Francois *---------------------------------------------------------------------------*/ void fn_vMSPrtSrcAlloc(struct tdstEngineObject_ *p_stObject) { if (p_stObject == NULL) M_GameFatalError(E_uwGameMiniStructObjectNull); if (p_stObject->h_MSPrtSrc != NULL) M_GameFatalError(E_uwGameMiniStructAllocAlreadyAlloc); MMG_fn_vBeginMemoryInfo (MMG_C_lTypeMiniStructure , MMG_C_lSubTypePrtSrc , p_stObject); p_stObject->h_MSPrtSrc = fn_h_MSPrtSrcRealAlloc(); MMG_fn_vEndMemoryInfo (); fn_vMSPrtSrcInitValueSAI(p_stObject->h_MSPrtSrc); } MS_tdxHandleToMSPrtSrc fn_h_MSPrtSrcRealAlloc() { MS_tdxHandleToMSPrtSrc h_MSPrtSrc; h_MSPrtSrc = (MS_tdxHandleToMSPrtSrc)M_p_GameMallocInHLM(fn_ulMSPrtSrcSizeOf()); return(h_MSPrtSrc); } /*----------------------------------------------------------------------------- * Description : MSPrtSrc's object action free *----------------------------------------------------------------------------- * Input : Object pointer * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Francois *---------------------------------------------------------------------------*/ void fn_vMSPrtSrcFree(struct tdstEngineObject_ *p_stObject) { if (p_stObject==NULL) M_GameFatalError(E_uwGameMiniStructObjectNull); if (p_stObject->h_MSPrtSrc==NULL) M_GameFatalError(E_uwGameMiniStructNull); fn_vMSPrtSrcFreeInitValueSAI(p_stObject->h_MSPrtSrc); MMG_fn_vAddMemoryInfo( MMG_C_lTypeMiniStructure , MMG_C_lSubTypePrtSrc , p_stObject ); M_GameFreeInHLM(p_stObject->h_MSPrtSrc); } /*----------------------------------------------------------------------------- * Description : MSPrtSrc's object action initialisation *----------------------------------------------------------------------------- * Input : When this function's called (see ObjInit.h) * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Francois *---------------------------------------------------------------------------*/ void fn_vMSPrtSrcInit(struct tdstEngineObject_ *p_stObject,enum tdeObjectTreeInit_ eObjectInit) { if (p_stObject==NULL) M_GameFatalError(E_uwGameMiniStructObjectNull); if (p_stObject->h_MSPrtSrc==NULL) M_GameFatalError(E_uwGameMiniStructNull); switch(eObjectInit) { case OTI_ReinitTheMap: { GAM_tdxHandleToFootPathEffect hFootPath; hFootPath = fn_hMSPrtSrcGetFootPath( p_stObject->h_MSPrtSrc ); if (hFootPath != NULL) fn_v_FootPath_ReInit( hFootPath ); } break; case OTI_LoadSavedGame: break; case OTI_MapLoaded: if( fn_bIsInFix(p_stObject) ) { p_stObject->h_MSPrtSrc->p_stParticleGenerator = NULL; p_stObject->h_MSPrtSrc->hWaterStreakGenerator = NULL; p_stObject->h_MSPrtSrc->ucGeneratorActivation = 0; p_stObject->h_MSPrtSrc->ucCanGenerate = 0; } else { fn_vMSPrtSrcInitMinMaxPoints(p_stObject->h_MSPrtSrc); fn_vMSPrtSrcInitValueSAI(p_stObject->h_MSPrtSrc); fn_vMSPrtSrcSavedValueSAI(p_stObject->h_MSPrtSrc); } break; case OTI_AlwaysCreated: case OTI_PlayerDead: break; default: break; } } /*----------------------------------------------------------------------------- * Description : MSPrtSrc's object action desinitialisation *----------------------------------------------------------------------------- * Input : When this function's called (see ObjInit.h) * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Francois *---------------------------------------------------------------------------*/ void fn_vMSPrtSrcDesinit(struct tdstEngineObject_ *p_stObject,enum tdeObjectTreeInit_ eObjectInit) { if (p_stObject==NULL) M_GameFatalError(E_uwGameMiniStructObjectNull); if (p_stObject->h_MSPrtSrc==NULL) M_GameFatalError(E_uwGameMiniStructNull); switch(eObjectInit) { case OTI_ReinitTheMap: break; case OTI_MapLoaded: break; case OTI_AlwaysCreated: case OTI_PlayerDead: break; default: break; } } /*----------------------------------------------------------------------------- * Description : MSPrtSrc's object copy clone action *----------------------------------------------------------------------------- * Input : Handle to destination, handle to source * Output : None *----------------------------------------------------------------------------- * Creation date : 30/06/97 Author : Olivier Jourdan *---------------------------------------------------------------------------*/ void fn_vMSPrtSrcCopyClone(struct tdstEngineObject_ * _p_stObjectDest,struct tdstEngineObject_ * _p_stObjectSrc) { /* If MSPrtSrc doesn't contains pointers to structure that may be*/ /* changed during the game, this function must only be a :*/ memcpy(_p_stObjectDest->h_MSPrtSrc,_p_stObjectSrc->h_MSPrtSrc,fn_ulMSPrtSrcSizeOf()); } /*----------------------------------------------------------------------------- * Description : MSPrtSrc SAI functions *----------------------------------------------------------------------------- * Input : MS_tdxHandleToMSPrtSrc + (value) * Output : (value or pointer) *----------------------------------------------------------------------------- * Creation date : 29/01/97 Author : Francois *---------------------------------------------------------------------------*/ #define C_PrtSrc_SAIInitFlags (SAI_eInitWhenPlayerDead|SAI_eInitWhenReinitTheMap|SAI_eInitWhenMapLoaded) void fn_vMSPrtSrcInitValueSAI(MS_tdxHandleToMSPrtSrc h_MSPrtSrc) { /**** Put here the functions :*/ if( h_MSPrtSrc->p_stParticleGenerator!=NULL ) SAI_fn_bInsertPointerInTable((void*)&h_MSPrtSrc->p_stParticleGenerator, C_PrtSrc_SAIInitFlags); SAI_fn_bInsertCharInTable((void *)&h_MSPrtSrc->ucGeneratorActivation, C_PrtSrc_SAIInitFlags); } void fn_vMSPrtSrcSavedValueSAI(MS_tdxHandleToMSPrtSrc h_MSPrtSrc) { /**** Put here the functions :*/ /* if( h_MSPrtSrc->p_stParticleGenerator!=NULL )*/ /* SAI_fn_bInsertPointerInTable((void*)&h_MSPrtSrc->p_stParticleGenerator,SAI_ePlayerSaveCurrentValue);*/ /* SAI_fn_bInsertCharInTable((void *)&h_MSPrtSrc->ucGeneratorActivation,SAI_ePlayerSaveCurrentValue);*/ } void fn_vMSPrtSrcFreeInitValueSAI(MS_tdxHandleToMSPrtSrc h_MSPrtSrc) { /**** Put here the functions :*/ SAI_fn_bRemoveValueFromTable((void*)&h_MSPrtSrc->p_stParticleGenerator, C_PrtSrc_SAIInitFlags); SAI_fn_bRemoveValueFromTable((void *)&h_MSPrtSrc->ucGeneratorActivation, C_PrtSrc_SAIInitFlags); } /* ======================================================================================= Access functions ======================================================================================= */ /* --------------------------------------------------------------------------------------- MSPrtSrc access functions --------------------------------------------------------------------------------------- */ /* * Access to Particle Generator */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ tdxHandleToParticleGenerator fn_p_stMSPrtSrcGetGenerator(MS_tdxHandleToMSPrtSrc h_MSPrtSrc) { return( (tdxHandleToParticleGenerator)h_MSPrtSrc->p_stParticleGenerator ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ void fn_p_stMSPrtSrcSetGenerator(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,tdxHandleToParticleGenerator _p_stPrtGenerator) { h_MSPrtSrc->p_stParticleGenerator = (tdstParticleGenerator *)_p_stPrtGenerator; } /* * particle generator activation */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ unsigned char fn_ucMSPrtSrcGetGeneratorActivation(MS_tdxHandleToMSPrtSrc h_MSPrtSrc) { return( h_MSPrtSrc->ucGeneratorActivation ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ void fn_vMSPrtSrcSetGeneratorActivation(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,unsigned char _ucGeneratorActivation) { h_MSPrtSrc->ucGeneratorActivation = _ucGeneratorActivation; } /* * Water streak access */ GAM_tdxHandleToWaterStreakEffect fn_hMSPrtSrcGetWaterStreakGenerator(MS_tdxHandleToMSPrtSrc h_MSPrtSrc) { return( h_MSPrtSrc->hWaterStreakGenerator ); } #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vMSPrtSrcSetWaterStreakGenerator(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,GAM_tdxHandleToWaterStreakEffect _hWaterStreakGenerator) { h_MSPrtSrc->hWaterStreakGenerator = _hWaterStreakGenerator; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* * foot path access */ GAM_tdxHandleToFootPathEffect fn_hMSPrtSrcGetFootPath(MS_tdxHandleToMSPrtSrc h_MSPrtSrc) { return ( h_MSPrtSrc->hFootPath ); } #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vMSPrtSrcSetFootPath(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,GAM_tdxHandleToFootPathEffect _hFootPath ) { h_MSPrtSrc->hFootPath = _hFootPath; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* --------------------------------------------------------------------------------------- Particle generator access functions --------------------------------------------------------------------------------------- */ /* * access to PrtSrc */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ PRT_tdstParticlesSource * fn_p_stPrtGenGetSrc(tdxHandleToParticleGenerator _p_stPrtGenerator) { return( ((tdstParticleGenerator *)_p_stPrtGenerator)->p_stPrtSrc ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vPrtGenSetSrc(tdxHandleToParticleGenerator _p_stPrtGenerator,PRT_tdstParticlesSource * _p_stSrc) { ((tdstParticleGenerator *)_p_stPrtGenerator)->p_stPrtSrc = _p_stSrc; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* * Access to PrtSys */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ PRT_tdstParticlesSystem * fn_p_stPrtGenGetPrtSys(tdxHandleToParticleGenerator _p_stPrtGenerator) { return( ((tdstParticleGenerator *)_p_stPrtGenerator)->p_stPrtSys ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vPrtGenSetPrtSys(tdxHandleToParticleGenerator _p_stPrtGenerator,PRT_tdstParticlesSystem * _p_stPrtSys) { ((tdstParticleGenerator *)_p_stPrtGenerator)->p_stPrtSys = _p_stPrtSys; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* * Access to PrtEnv */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ PRT_tdstParticlesEnvironment * fn_p_stPrtGenGetPrtEnv(tdxHandleToParticleGenerator _p_stPrtGenerator) { return( ((tdstParticleGenerator *)_p_stPrtGenerator)->p_stPrtEnv ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vPrtGenSetPrtEnv(tdxHandleToParticleGenerator _p_stPrtGenerator,PRT_tdstParticlesEnvironment * _p_stPrtEnv) { ((tdstParticleGenerator *)_p_stPrtGenerator)->p_stPrtEnv = _p_stPrtEnv; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* * Access to MinPoint */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ MTH3D_tdstVector * fn_p_stPrtGenGetMinPoint(tdxHandleToParticleGenerator _p_stPrtGenerator) { return( &((tdstParticleGenerator *)_p_stPrtGenerator)->stMinPoint ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vPrtGenSetMinPoint(tdxHandleToParticleGenerator _p_stPrtGenerator,MTH3D_tdstVector * _p_stMinPoint) { MTH3D_M_vCopyVector(&((tdstParticleGenerator *)_p_stPrtGenerator)->stMinPoint,_p_stMinPoint); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* * Access to MaxPoint */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ MTH3D_tdstVector * fn_p_stPrtGenGetMaxPoint(tdxHandleToParticleGenerator _p_stPrtGenerator) { return( &((tdstParticleGenerator *)_p_stPrtGenerator)->stMaxPoint ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vPrtGenSetMaxPoint(tdxHandleToParticleGenerator _p_stPrtGenerator,MTH3D_tdstVector * _p_stMaxPoint) { MTH3D_M_vCopyVector(&((tdstParticleGenerator *)_p_stPrtGenerator)->stMaxPoint,_p_stMaxPoint); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* * Access to LinkValue */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ unsigned char fn_ucPrtGenGetLinkValue(tdxHandleToParticleGenerator _p_stPrtGenerator) { return( ((tdstParticleGenerator *)_p_stPrtGenerator)->ucLinkedToEnvironment ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vPrtGenSetLinkValue(tdxHandleToParticleGenerator _p_stPrtGenerator,unsigned char _ucLinkValue) { ((tdstParticleGenerator *)_p_stPrtGenerator)->ucLinkedToEnvironment = _ucLinkValue; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* * Access to Environment mask */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ long fn_lPrtGenGetEnvironmentMask(tdxHandleToParticleGenerator _p_stPrtGenerator) { return( ((tdstParticleGenerator *)_p_stPrtGenerator)->lEnvironmentMask ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vPrtGenSetEnvironmentMask(tdxHandleToParticleGenerator _p_stPrtGenerator,long _lEnvironmentMask) { ((tdstParticleGenerator *)_p_stPrtGenerator)->lEnvironmentMask = _lEnvironmentMask; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /*ANNECY VL PRT 24/03/98{*/ /* * Access to Linked Generator mask */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ long fn_lPrtGenGetLinkedGenMask(tdxHandleToParticleGenerator _p_stPrtGenerator) { return( ((tdstParticleGenerator *) _p_stPrtGenerator)->ulLinkedPrtGenMask ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vPrtGenSetLinkedGenMask(tdxHandleToParticleGenerator _p_stPrtGenerator,long _lLinkedGenMask) { ((tdstParticleGenerator *)_p_stPrtGenerator)->ulLinkedPrtGenMask = _lLinkedGenMask; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* * access to Linked generator */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ tdxHandleToParticleGenerator fn_hPrtGenGetLinkedGen(tdxHandleToParticleGenerator _p_stPrtGenerator) { return( tdxHandleToParticleGenerator ) ((tdstParticleGenerator *)_p_stPrtGenerator)->p_stLinkedPrtGen; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vPrtGenSetLinkedGen(tdxHandleToParticleGenerator _p_stPrtGenerator, tdxHandleToParticleGenerator _p_stLinkedGen) { ((tdstParticleGenerator *)_p_stPrtGenerator)->p_stLinkedPrtGen = (tdstParticleGenerator *) _p_stLinkedGen; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /*ENDANNECY VL}*/ /* ======================================================================================= Particles functions ======================================================================================= */ /*----------------------------------------------------------------------------- * Description : Particle generator allocation *----------------------------------------------------------------------------- * Input : None * Output : Handle on the new generator *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ tdxHandleToParticleGenerator fn_hParticleGeneratorAllocation() { tdstParticleGenerator * p_stPrtGen; p_stPrtGen = (tdstParticleGenerator *)M_p_GameMallocInHLM(sizeof(tdstParticleGenerator)); return((tdxHandleToParticleGenerator)p_stPrtGen); } /*----------------------------------------------------------------------------- * Description : Particle generation for a single source *----------------------------------------------------------------------------- * Input : Owner of the source * Output : None *----------------------------------------------------------------------------- * Creation date : 11/09/97 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void fn_vMSPrtSrcSourceGenerateParticles( HIE_tdxHandleToSuperObject _hCharacter) { MS_tdxHandleToMSPrtSrc hMSPrtSrc; /*ANNECY VL PRT 18/03/98{*/ MTH_tdxReal xTime; /* in s */ /*ENDANNECY VL}*/ hMSPrtSrc = M_GetMSHandle(_hCharacter,MSPrtSrc); if( !hMSPrtSrc ) return; if( !hMSPrtSrc->p_stParticleGenerator ) return; fn_vMSPrtSrcUpdateLinkedEnvironment(_hCharacter,hMSPrtSrc); /* If particle generator is active*/ if( hMSPrtSrc->ucGeneratorActivation!=0 ) { if( hMSPrtSrc->ucCanGenerate ) { /*ANNECY VL PRT 18/03/98{*/ xTime = ((MTH_tdxReal)g_stEngineStructure.stEngineTimer.ulCurrentTimerCount) * MTH_M_xDoubleToReal(0.001); /*ENDANNECY VL}*/ PRT_fn_vSourceGenerateParticle ( hMSPrtSrc->p_stParticleGenerator->p_stPrtSys, hMSPrtSrc->p_stParticleGenerator->p_stPrtSrc, HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacter), xTime ); } } } /*----------------------------------------------------------------------------- * Description : Init points in case of environment linked to * the source *----------------------------------------------------------------------------- * Input : handle on the MSPrtSrc mini-structure * Output : None *----------------------------------------------------------------------------- * Creation date : 11/09/97 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void fn_vMSPrtSrcInitMinMaxPoints(MS_tdxHandleToMSPrtSrc h_MSPrtSrc) { tdstParticleGenerator * p_stPrtGen; p_stPrtGen = h_MSPrtSrc->p_stParticleGenerator; if( !p_stPrtGen ) return; if( !p_stPrtGen->ucLinkedToEnvironment ) return; if( !p_stPrtGen->p_stPrtEnv ) return; if( p_stPrtGen->p_stPrtEnv->ulEnvType == PRT_C_ulAlignedBoxEnv ) { /* Aligned box*/ MTH3D_M_vCopyVector( &p_stPrtGen->stMinPoint, &p_stPrtGen->p_stPrtEnv->stMinPoint); MTH3D_M_vCopyVector( &p_stPrtGen->stMaxPoint, &p_stPrtGen->p_stPrtEnv->stMaxPoint); } else { /* Sphere*/ MTH3D_M_vCopyVector( &p_stPrtGen->stMinPoint, &p_stPrtGen->p_stPrtEnv->stSphereCenter); } } /*----------------------------------------------------------------------------- * Description : Update position of a particle environment if * linked to source *----------------------------------------------------------------------------- * Notes : Update is taking in account DnmEnvironments, but only * for aligned boxes *----------------------------------------------------------------------------- * Input : Owner of the source * Output : None *----------------------------------------------------------------------------- * Creation date : 11/09/97 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void fn_vMSPrtSrcUpdateLinkedEnvironment(HIE_tdxHandleToSuperObject _hCharacter,MS_tdxHandleToMSPrtSrc h_MSPrtSrc) { MTH3D_tdstVector stMinPoint,stMaxPoint; tdstParticleGenerator * p_stPrtGen; MTH_tdxReal xDepth; p_stPrtGen = h_MSPrtSrc->p_stParticleGenerator; h_MSPrtSrc->ucCanGenerate = 1; while( p_stPrtGen ) { if( !p_stPrtGen->ucLinkedToEnvironment ) return; if( !p_stPrtGen->p_stPrtEnv ) return; if( !fn_bIsGeneratorActiveInThisEnvironment(_hCharacter,p_stPrtGen) ) { h_MSPrtSrc->ucCanGenerate = 0; /*return;*/ } else { if( p_stPrtGen->p_stPrtEnv->ulEnvType == PRT_C_ulAlignedBoxEnv ) { /* Aligned box*/ POS_fn_vGetTranslationVector( HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacter), &stMinPoint); MTH3D_M_vAddVector( &stMaxPoint,&stMinPoint, &p_stPrtGen->stMaxPoint); MTH3D_M_vAddVector( &stMinPoint,&stMinPoint, &p_stPrtGen->stMinPoint); if( !fn_bIsGeneratorPointInCorrectEnvironment(fn_h_SectInfoGetCurrentSector(M_GetMSHandle(_hCharacter,SectInfo)),&stMinPoint,p_stPrtGen->lEnvironmentMask,&xDepth) ) { stMinPoint.xZ += xDepth; } if( !fn_bIsGeneratorPointInCorrectEnvironment(fn_h_SectInfoGetCurrentSector(M_GetMSHandle(_hCharacter,SectInfo)),&stMaxPoint,p_stPrtGen->lEnvironmentMask,&xDepth) ) { h_MSPrtSrc->ucCanGenerate = 0; /*return;*/ } else { if( stMinPoint.xZ >= stMaxPoint.xZ ) { h_MSPrtSrc->ucCanGenerate = 0; /*return;*/ } else { /* No environment informations are necessary*/ PRT_M_vSetMinMaxPointParticlesEnvironment( p_stPrtGen->p_stPrtEnv,&stMinPoint,&stMaxPoint); } } } else { /* Sphere*/ POS_fn_vMulMatrixVertex( &p_stPrtGen->p_stPrtEnv->stSphereCenter, HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacter), &p_stPrtGen->stMinPoint); } } p_stPrtGen = p_stPrtGen->p_stLinkedPrtGen; } } /*----------------------------------------------------------------------------- * Description : Particles generation and mechanics for a single source *----------------------------------------------------------------------------- * Input : owner of the source * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void fn_vTreatParticleGeneratorForCharacter( HIE_tdxHandleToSuperObject _hCharacter) { /*ANNECY VL PRT 18/03/98{*/ MTH_tdxReal xTime; /* in s */ /*ENDANNECY VL}*/ MTH_tdxReal xDeltaT; /* in s */ tdstParticleGenerator *p_stPrtGen; if( !M_GetMSHandle(_hCharacter,MSPrtSrc) ) return; p_stPrtGen = M_GetMSHandle(_hCharacter,MSPrtSrc)->p_stParticleGenerator; if( !p_stPrtGen ) return; xDeltaT = ((MTH_tdxReal)g_stEngineStructure.stEngineTimer.ulUsefulDeltaTime) * MTH_M_xDoubleToReal(0.001); /*ANNECY VL PRT 18/03/98{*/ xTime = ((MTH_tdxReal)g_stEngineStructure.stEngineTimer.ulCurrentTimerCount) * MTH_M_xDoubleToReal(0.001); /*PRT_fn_vMecaParticlesSystem( p_stPrtGen->p_stPrtSys, p_stPrtGen->p_stPrtEnv, xTime, xDeltaT);*/ while (p_stPrtGen != NULL) { PRT_fn_vMecaParticlesSystem( p_stPrtGen, xTime, xDeltaT); p_stPrtGen = p_stPrtGen->p_stLinkedPrtGen; } /*ENDANNECY VL}*/ } /*----------------------------------------------------------------------------- * Description : Particles drawing for an unique source *----------------------------------------------------------------------------- * Input : owner of the source * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void fn_vPreDrawParticleGeneratorForCharacter( HIE_tdxHandleToSuperObject _hCharacter) { tdstParticleGenerator * p_stPrtGen; GAM_tdxHandleToWaterStreakEffect hWaterStreak; /*ANNECY VL 26/11/97{*/ GAM_tdxHandleToFootPathEffect hFootPath; /*ENDANNECY VL }*/ if( !M_GetMSHandle(_hCharacter,MSPrtSrc) ) return; p_stPrtGen = M_GetMSHandle(_hCharacter,MSPrtSrc)->p_stParticleGenerator; while( p_stPrtGen ) { PRT_fn_vPreDrawParticlesSystem(p_stPrtGen); HIE_fn_bLoadIdentity(); GLI_xSendObjectToViewportWithLights ( &g_stEngineStructure.stViewportAttr, p_stPrtGen->p_stPrtSys->hParticlesSystemObject, GLI_C_lAllIsEnable ); HIE_fn_bPopMatrix(); p_stPrtGen = p_stPrtGen->p_stLinkedPrtGen; } /* WaterStreak Generator*/ hWaterStreak = M_GetMSHandle(_hCharacter,MSPrtSrc)->hWaterStreakGenerator; if( hWaterStreak ) { fn_vDisplayWaterStreak ( &g_stEngineStructure.stViewportAttr, hWaterStreak, g_stEngineStructure.ulDisplayMode ); } /* foot path*/ hFootPath = M_GetMSHandle(_hCharacter,MSPrtSrc)->hFootPath; if (hFootPath) fn_v_FootPath_Display( hFootPath, &g_stEngineStructure.stViewportAttr, g_stEngineStructure.ulDisplayMode); } /*----------------------------------------------------------------------------- * Description : Particles generation and mechanics *----------------------------------------------------------------------------- * Input : Active sector * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void GAM_fn_vTreatAllParticlesGeneratorInActiveSector(HIE_tdxHandleToSuperObject _hSector) { long lI,lJ; SECT_tdxHandleOfElementLstCharacter hCharacterList; SECT_tdxHandleOfElementLstActivityInteraction hActivityList; /* Deal with characters actions*/ SECT_M_ForEachCharListInSector(_hSector,hCharacterList,lI) { fn_vTreatParticleGeneratorForCharacter(SECT_GetCharacterInList(hCharacterList)); } /* Treat all the associated sectors for activity.*/ SECT_M_ForEachActivityNodeInActivityInteractionList(_hSector,hActivityList,lJ) { SECT_M_ForEachCharListInSector(SECT_GetSectorInActivityList(hActivityList),hCharacterList,lI) { fn_vTreatParticleGeneratorForCharacter(SECT_GetCharacterInList(hCharacterList)); } } } /*----------------------------------------------------------------------------- * Description : Particles drawing *----------------------------------------------------------------------------- * Input : Active sector * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void GAM_fn_vPreDrawAllParticlesGeneratorInActiveSector(HIE_tdxHandleToSuperObject _hSector) { /*** This function deals with sectors ***/ SECT_tdxHandleOfElementLstCharacter hCharacterList; SECT_tdxHandleOfElementLstGraphicInteraction hGraphicList; unsigned long ulI,ulJ; SECT_M_ForEachCharListInSector(_hSector,hCharacterList,ulI) { fn_vPreDrawParticleGeneratorForCharacter(SECT_GetCharacterInList(hCharacterList)); } SECT_M_ForEachGraphicNodeInGraphicInteractionList(_hSector,hGraphicList,ulJ) { SECT_M_ForEachCharListInSector(SECT_GetSectorInGraphicList(hGraphicList),hCharacterList,ulI) { fn_vPreDrawParticleGeneratorForCharacter(SECT_GetCharacterInList(hCharacterList)); } } } /*----------------------------------------------------------------------------- * Description : Particles drawing *----------------------------------------------------------------------------- * Input : Active Sector, absolute position of point to be * tested, environment mask * Output : TRUE if point can generate is the computed * environment, FALSE otherwise *----------------------------------------------------------------------------- * Creation date : 16/10/97 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ ACP_tdxBool fn_bIsGeneratorPointInCorrectEnvironment ( HIE_tdxHandleToSuperObject _hActiveSector, MTH3D_tdstVector * _p_stAbsolutePoint, long _lEnvironmentMask, MTH_tdxReal * _p_xDepthCorrection ) { /* DNM_tdxHandleToMecEnvironment hEnvironment; DNM_tdeFluidEnvironment eTmp; if( _lEnvironmentMask == C_lAllEnvironments ) return TRUE; hEnvironment = SECT_hGetDNMEnvironmentAndDepth ( NULL, _p_stAbsolutePoint, _hActiveSector, _p_xDepthCorrection ); eTmp = DNM_M_eFluidEnvironmentGetVolumicEnvironment((struct DNM_stMecEnvironment *)hEnvironment); switch( eTmp ) { case DNM_Fluid_Water: if( !(_lEnvironmentMask&C_lEnvironmentWater) ) return FALSE; break; case DNM_Fluid_Air: if( !(_lEnvironmentMask&C_lEnvironmentAir) ) return FALSE; break; default: return TRUE; break; } return TRUE;*/ return FALSE; } /*----------------------------------------------------------------------------- * Description : Particles drawing *----------------------------------------------------------------------------- * Input : Active Sector, absolute position of point to be * tested, environment mask * Output : TRUE if point can generate is the computed * environment, FALSE otherwise *----------------------------------------------------------------------------- * Creation date : 16/10/97 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ ACP_tdxBool fn_bIsGeneratorActiveInThisEnvironment(HIE_tdxHandleToSuperObject _hCharacterSource, tdstParticleGenerator * _p_stGenerator) { POS_tdxHandleToPosition hSourceMatrix; HIE_tdxHandleToSuperObject hActiveSector; MTH3D_tdstVector stTmpPoint; MTH_tdxReal xDepth; if( !_p_stGenerator->ucLinkedToEnvironment ) return TRUE; hSourceMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacterSource); hActiveSector = fn_h_SectInfoGetCurrentSector(M_GetMSHandle(_hCharacterSource,SectInfo)); POS_fn_vMulMatrixVertex(&stTmpPoint,hSourceMatrix,&_p_stGenerator->p_stPrtSrc->stVertex1); if( !fn_bIsGeneratorPointInCorrectEnvironment(hActiveSector,&stTmpPoint,_p_stGenerator->lEnvironmentMask,&xDepth) ) return FALSE; POS_fn_vMulMatrixVertex(&stTmpPoint, hSourceMatrix, &_p_stGenerator->p_stPrtSrc->stVertex2); if( !fn_bIsGeneratorPointInCorrectEnvironment(hActiveSector,&stTmpPoint,_p_stGenerator->lEnvironmentMask,&xDepth) ) return FALSE; POS_fn_vMulMatrixVertex(&stTmpPoint, hSourceMatrix, &_p_stGenerator->p_stPrtSrc->stVertex3); if( !fn_bIsGeneratorPointInCorrectEnvironment(hActiveSector,&stTmpPoint,_p_stGenerator->lEnvironmentMask,&xDepth) ) return FALSE; return TRUE; } /* Keeping it for ascendant compatibility*/ void fn_vMSPrtSysTreatAllParticlesSystemsForCharacter(HIE_tdxHandleToSuperObject _hCharacter) { _hCharacter = _hCharacter; GAM_fn_vTreatAllParticlesGeneratorInActiveSector ( fn_h_SectInfoGetCurrentSector(M_GetMSHandle(MC_fn_hGetCharacterInMainCharacterNode( MC_fn_hGetFirstMainCharNode()),SectInfo)) ); } void fn_vMSPrtSysPreDrawAllParticlesSystemsForCharacter(HIE_tdxHandleToSuperObject _hCharacter) { _hCharacter = _hCharacter; GAM_fn_vPreDrawAllParticlesGeneratorInActiveSector ( fn_h_SectInfoGetCurrentSector(M_GetMSHandle(MC_fn_hGetCharacterInMainCharacterNode( MC_fn_hGetFirstMainCharNode()),SectInfo)) ); } /*----------------------------------------------------------------------------- * Description : Particle generator copy clone *----------------------------------------------------------------------------- * Input : the particle generator model * Output : the particle generator clone *----------------------------------------------------------------------------- * Creation date : 29/11/97 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ tdxHandleToParticleGenerator fn_hParticleGeneratorCopyClone(tdxHandleToParticleGenerator _hPrtGen) { tdstParticleGenerator * p_stClone; tdstParticleGenerator * p_stGenitor; p_stGenitor = (tdstParticleGenerator *)_hPrtGen; p_stClone = (tdstParticleGenerator *)fn_hParticleGeneratorAllocation(); p_stClone->lEnvironmentMask = p_stGenitor->lEnvironmentMask; MTH3D_M_vCopyVector(&p_stClone->stMinPoint,&p_stGenitor->stMinPoint); MTH3D_M_vCopyVector(&p_stClone->stMaxPoint,&p_stGenitor->stMaxPoint); p_stClone->ucLinkedToEnvironment = p_stGenitor->ucLinkedToEnvironment; return( (tdxHandleToParticleGenerator)p_stClone ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /************************************** ************************************** *** Functions for AI manipulations *** ************************************** **************************************/ /* * Set the center of an environment (Box or sphere type, linked to * generator or not) */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vMSPrtSrcSetMiddlePointOfEnvironment(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,MTH3D_tdstVector * _p_stMiddlePoint) { tdstParticleGenerator * p_stGen; PRT_tdstParticlesEnvironment * p_stPrtEnv; MTH_tdxReal xXMidSize,xYMidSize,xZMidSize; if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; p_stGen = h_MSPrtSrc->p_stParticleGenerator; p_stPrtEnv = p_stGen->p_stPrtEnv; /* Sphere or box? */ if( p_stPrtEnv->ulEnvType == PRT_C_ulAlignedBoxEnv ) { /* Box */ if( p_stGen->ucLinkedToEnvironment ) { /* Local coordinates */ xXMidSize = (p_stGen->stMaxPoint.xX - p_stGen->stMinPoint.xX)/2.0f; xYMidSize = (p_stGen->stMaxPoint.xY - p_stGen->stMinPoint.xY)/2.0f; xZMidSize = (p_stGen->stMaxPoint.xZ - p_stGen->stMinPoint.xZ)/2.0f; MTH3D_M_vSetVectorElements(&p_stGen->stMinPoint, _p_stMiddlePoint->xX - xXMidSize, _p_stMiddlePoint->xY - xYMidSize, _p_stMiddlePoint->xZ - xZMidSize); MTH3D_M_vSetVectorElements(&p_stGen->stMaxPoint, _p_stMiddlePoint->xX + xXMidSize, _p_stMiddlePoint->xY + xYMidSize, _p_stMiddlePoint->xZ + xZMidSize); } else { /* Global coordinates */ xXMidSize = (p_stPrtEnv->stMaxPoint.xX - p_stPrtEnv->stMinPoint.xX)/2.0f; xYMidSize = (p_stPrtEnv->stMaxPoint.xY - p_stPrtEnv->stMinPoint.xY)/2.0f; xZMidSize = (p_stPrtEnv->stMaxPoint.xZ - p_stPrtEnv->stMinPoint.xZ)/2.0f; MTH3D_M_vSetVectorElements(&p_stPrtEnv->stMinPoint, _p_stMiddlePoint->xX - xXMidSize, _p_stMiddlePoint->xY - xYMidSize, _p_stMiddlePoint->xZ - xZMidSize); MTH3D_M_vSetVectorElements(&p_stPrtEnv->stMaxPoint, _p_stMiddlePoint->xX + xXMidSize, _p_stMiddlePoint->xY + xYMidSize, _p_stMiddlePoint->xZ + xZMidSize); } } else { /* Sphere */ if( p_stGen->ucLinkedToEnvironment ) { MTH3D_M_vCopyVector ( &p_stGen->stMinPoint, _p_stMiddlePoint ); } else { MTH3D_M_vCopyVector ( &p_stPrtEnv->stSphereCenter, _p_stMiddlePoint ); } } } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* * Set the sphere radius of an environment (no check on the env type) */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vMSPrtSrcSetRadiusOfSphereEnvironment(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,MTH_tdxReal _xRadius) { if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; h_MSPrtSrc->p_stParticleGenerator->p_stPrtEnv->xRadius = _xRadius; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vMSPrtSrcSetDimensionsOfBoxEnvironment(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,MTH_tdxReal _xXSemiLength,MTH_tdxReal _xYSemiLength,MTH_tdxReal _xZSemiLength) { tdstParticleGenerator * p_stGen; PRT_tdstParticlesEnvironment * p_stPrtEnv; MTH3D_tdstVector stMidPoint; if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; p_stGen = h_MSPrtSrc->p_stParticleGenerator; p_stPrtEnv = p_stGen->p_stPrtEnv; /* Sphere or box? */ if( p_stPrtEnv->ulEnvType == PRT_C_ulAlignedBoxEnv ) { /* Box */ if( p_stGen->ucLinkedToEnvironment ) { /* Local coordinates */ MTH3D_M_vAddVector(&stMidPoint, &p_stGen->stMaxPoint, &p_stGen->stMinPoint); MTH3D_M_vMulScalarVector(&stMidPoint,0.5f,&stMidPoint); MTH3D_M_vSetVectorElements(&p_stGen->stMinPoint, stMidPoint.xX - _xXSemiLength, stMidPoint.xY - _xYSemiLength, stMidPoint.xZ - _xZSemiLength); MTH3D_M_vSetVectorElements(&p_stGen->stMaxPoint, stMidPoint.xX + _xXSemiLength, stMidPoint.xY + _xYSemiLength, stMidPoint.xZ + _xZSemiLength); } else { /* Global coordinates */ MTH3D_M_vAddVector(&stMidPoint, &p_stPrtEnv->stMaxPoint, &p_stPrtEnv->stMinPoint); MTH3D_M_vMulScalarVector(&stMidPoint,0.5f,&stMidPoint); MTH3D_M_vSetVectorElements(&p_stPrtEnv->stMinPoint, stMidPoint.xX - _xXSemiLength, stMidPoint.xY - _xYSemiLength, stMidPoint.xZ - _xZSemiLength); MTH3D_M_vSetVectorElements(&p_stPrtEnv->stMaxPoint, stMidPoint.xX + _xXSemiLength, stMidPoint.xY + _xYSemiLength, stMidPoint.xZ + _xZSemiLength); } } else { /* Was called by a jester... */ } } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* * Set the acceleration of the environment */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vMSPrtSrcSetAccelerationOfEnvironment(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,MTH3D_tdstVector * _p_stAcceleration,MTH_tdxReal _xAccelerationRange) { if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; MTH3D_M_vCopyVector ( &h_MSPrtSrc->p_stParticleGenerator->p_stPrtEnv->stAcceleration, _p_stAcceleration ); h_MSPrtSrc->p_stParticleGenerator->p_stPrtEnv->xAccelerationRange = _xAccelerationRange; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ void fn_vMSPrtSrcSetGenerationModeNone(MS_tdxHandleToMSPrtSrc h_MSPrtSrc) { if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; PRT_M_vSetGenerationModeParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, PRT_C_ucNoGeneration ); } void fn_vMSPrtSrcSetGenerationModeContinuous(MS_tdxHandleToMSPrtSrc h_MSPrtSrc) { if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; PRT_M_vSetGenerationModeParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, PRT_C_ucContinousGeneration ); } void fn_vMSPrtSrcSetGenerationModeCrenel(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,ACP_tdxIndex _xNb1,ACP_tdxIndex _xNb2) { if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; PRT_M_vSetGenerationModeParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, PRT_C_ucCrenelGeneration ); /* Warning due to PRT module*/ PRT_M_vSetNbFramesCrenelParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, _xNb1, _xNb2 ); } void fn_vMSPrtSrcSetGenerationModeProbability(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,MTH_tdxReal _xProbability) { if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; PRT_M_vSetGenerationModeParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, PRT_C_ucProbabilistGeneration ); PRT_M_vSetGenerationProbabilityParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, _xProbability ); } void fn_vMSPrtSrcSetGenerationNumberConstant(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,ACP_tdxIndex _xNumber) { if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; PRT_M_vSetNbParticlesToGenerateModeParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, PRT_C_ucConstantNb ); PRT_M_vSetNbParticlesToGenerateParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, (unsigned char)_xNumber ); } void fn_vMSPrtSrcSetGenerationNumberProbabilist(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,ACP_tdxIndex _xMin,ACP_tdxIndex _xMax) { if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; PRT_M_vSetNbParticlesToGenerateModeParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, PRT_C_ucProbabilistNb ); PRT_M_vSetNbMinMaxParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, _xMin,_xMax ); } #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vMSPrtSrcSetGenerationSpeedAndSpeedRange(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,MTH_tdxReal _xSpeed,MTH_tdxReal _xSpeedRange) { if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; PRT_M_vSetSpeedParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, _xSpeed ); PRT_M_vSetSpeedRangeParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, _xSpeedRange ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ void fn_vMSPrtSrcSetParticlesInfiniteLifeTime(MS_tdxHandleToMSPrtSrc h_MSPrtSrc) { if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; PRT_M_vSetLifeModeParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, PRT_C_ucNoLifeTime ); } void fn_vMSPrtSrcSetParticlesConstantLifeTime(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,MTH_tdxReal _xLifeTime) { if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; PRT_M_vSetLifeModeParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, PRT_C_ucConstantLifeTime ); PRT_M_vSetLifeTimeParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, _xLifeTime ); } void fn_vMSPrtSrcSetParticlesProbabilistLifeTime(MS_tdxHandleToMSPrtSrc h_MSPrtSrc,MTH_tdxReal _xMinTime,MTH_tdxReal _xMaxTime) { if( !h_MSPrtSrc ) return; if( !h_MSPrtSrc->p_stParticleGenerator ) return; PRT_M_vSetLifeModeParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, PRT_C_ucProbabilistLifeTime ); PRT_M_vSetMinMaxLifeTimeParticlesSource ( h_MSPrtSrc->p_stParticleGenerator->p_stPrtSrc, _xMinTime, _xMaxTime ); } /***************************************************** ***************************************************** *** Functions to adapt particles on all computers *** ***************************************************** *****************************************************/ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vSetFactorForParticlesGeneration(float _fFactor) { PRT_fn_vSetNbParticlesFactor( MTH_M_xFloatToReal(_fFactor) ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ #endif /* D_THROW_PRT */