/* 0 1 2 3 4 5 6 7 01234567890123456789012345678901234567890123456789012345678901234567890123456789 -------------------------------------------------------------------------------- -- Description : Particles system -------------------------------------------------------------------------------- -- Creation date : 12 jun 1997 Author : FPI -------------------------------------------------------------------------------- */ #ifndef D_THROW_PRT #include "acp_base.h" #include "MTH.h" #include "RND.h" #include "MEC.h" #include "GMT.h" #include "GEO.h" #include "GLI.h" #include "COL.h" #include "PRT/PrtSrc.h" /* -------------------------------------------------------------------------------- -- Description : Global variables -------------------------------------------------------------------------------- */ MTH_tdxReal PRT_g_xNbParticlesFactor = MTH_C_ONE; /* -------------------------------------------------------------------------------- -- Description : Particles source creation -------------------------------------------------------------------------------- -- Creation date : 15 jun 1997 Author : FPI -------------------------------------------------------------------------------- */ void PRT_fn_vCreateParticlesSource ( PRT_tdstParticlesSource **_p_pstParticlesSource ) { GEO_M_CPAMalloc ( *_p_pstParticlesSource, PRT_tdstParticlesSource *, sizeof ( PRT_tdstParticlesSource ), E_uwGEONotEnoughtMemory ); (*_p_pstParticlesSource)->ucLifeMode = PRT_C_ucNoLifeTime; } /* -------------------------------------------------------------------------------- -- Description : Particles source destruction -------------------------------------------------------------------------------- -- Creation date : 15 jun 1997 Author : FPI -------------------------------------------------------------------------------- */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void PRT_fn_vDestructParticlesSource ( PRT_tdstParticlesSource *_p_stParticlesSource ) { GEO_M_CPAFree ( _p_stParticlesSource ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* -------------------------------------------------------------------------------- -- Description : -------------------------------------------------------------------------------- -- Creation date : 12 jun 1997 Author : FPI -------------------------------------------------------------------------------- */ void PRT_fn_vSetQuadParticlesSource ( PRT_tdstParticlesSource *_p_stParticlesSource, MTH3D_tdstVector *_p_stVertex1, MTH3D_tdstVector *_p_stVertex2, MTH3D_tdstVector *_p_stVertex3 ) { MTH3D_tdstVector stEdge12; MTH3D_tdstVector stEdge13; MTH3D_M_vCopyVector ( &(_p_stParticlesSource->stVertex1), _p_stVertex1 ); MTH3D_M_vCopyVector ( &(_p_stParticlesSource->stVertex2), _p_stVertex2 ); MTH3D_M_vCopyVector ( &(_p_stParticlesSource->stVertex3), _p_stVertex3 ); MTH3D_M_vSubVector ( &stEdge12, _p_stVertex2, _p_stVertex1 ); MTH3D_M_vSubVector ( &stEdge13, _p_stVertex3, _p_stVertex1 ); MTH3D_M_vCrossProductVectorWithoutBuffer ( &(_p_stParticlesSource->stNormal) , &stEdge12 , &stEdge13 ); MTH3D_M_vNormalizeVector ( &(_p_stParticlesSource->stNormal), &(_p_stParticlesSource->stNormal) ); } /* -------------------------------------------------------------------------------- -- Description : -------------------------------------------------------------------------------- -- Creation date : 12 jun 1997 Author : FPI -------------------------------------------------------------------------------- */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void PRT_fn_vSetPointParticlesSource( PRT_tdstParticlesSource *_p_stParticlesSource,MTH3D_tdstVector *_p_stVertex ) { MTH3D_M_vCopyVector( &(_p_stParticlesSource->stVertex1), _p_stVertex ); MTH3D_M_vNullVector( &(_p_stParticlesSource->stNormal) ); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* -------------------------------------------------------------------------------- -- Description : -------------------------------------------------------------------------------- -- Creation date : 12 jun 1997 Author : FPI -------------------------------------------------------------------------------- */ ACP_tdxBool PRT_fn_bComputeParticlesGeneration ( PRT_tdstParticlesSource *_p_stParticlesSource ) { /* continuous generation */ if ( _p_stParticlesSource->ucGenerationMode == PRT_C_ucContinousGeneration ) return TRUE; /* probabilist generattion */ if ( _p_stParticlesSource->ucGenerationMode == PRT_C_ucProbabilistGeneration ) { if ( _p_stParticlesSource->xGenerationProbability > RND_fn_xGetRealRandomValue ( 0, MTH_C_ZERO, MTH_C_ONE ) ) return TRUE; return FALSE; } /* Crenel generation */ if ( _p_stParticlesSource->ucGenerationMode == PRT_C_ucCrenelGeneration ) { if ( _p_stParticlesSource->xFramesCounter < _p_stParticlesSource->xNbFramesNoGeneration ) { _p_stParticlesSource->xFramesCounter ++; return FALSE; } _p_stParticlesSource->xFramesCounter = (_p_stParticlesSource->xFramesCounter+1)%_p_stParticlesSource->xNbFramesTotal; return TRUE; } /* bad generation code or no generation */ return FALSE; } /* -------------------------------------------------------------------------------- -- Description : -------------------------------------------------------------------------------- -- Creation date : 12 jun 1997 Author : FPI -------------------------------------------------------------------------------- */ ACP_tdxIndex PRT_fn_xComputeNbParticlesToInject ( PRT_tdstParticlesSource *_p_stParticlesSource ) { if ( _p_stParticlesSource->ucNbParticlesToGenerateMode == PRT_C_ucConstantNb ) return _p_stParticlesSource->xNbParticlesToGenerate; if ( _p_stParticlesSource->ucNbParticlesToGenerateMode == PRT_C_ucProbabilistNb ) return (ACP_tdxIndex) RND_fn_ulGetUnsignedLongRandomValue ( 0, _p_stParticlesSource->xNbMin, _p_stParticlesSource->xNbMax ); return 0; } /* -------------------------------------------------------------------------------- -- Description : -------------------------------------------------------------------------------- -- Creation date : 12 jun 1997 Author : FPI -------------------------------------------------------------------------------- */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void PRT_fn_vSetNbParticlesFactor ( MTH_tdxReal _xNbParticlesFactor ) { PRT_g_xNbParticlesFactor = _xNbParticlesFactor; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ #endif /* D_THROW_PRT */