void SSParticles::SpawnBlock() { //find non active block for (int i = 0; i < MAX_PARTICLE_BLOCKS; i++) { if (!m_ParticleBlocks[i].IsActive) { m_ParticleBlocks[i].IsActive = true; m_ParticleBlocks[i].Particles = AllocateParticles(); m_ParticleBlocks[i].TTL = MIN_BLOCK_TTL + GetRandomNumber() * MIN_BLOCK_TTL; for (int k = 0; k < PARTICLE_BLOCK_COUNT; k++) { m_ParticleBlocks[i].Particles[k].Pos = glm::vec4(GetRandomNumber() * 2.0f - 1.0f, GetRandomNumber() * 2.0f - 1.0f, GetRandomNumber(), 1); m_ParticleBlocks[i].Particles[k].VelocityTTL = glm::vec4(GetRandomNumber() * 2.0f - 1.0f, GetRandomNumber() * 2.0f - 1.0f, GetRandomNumber() * 2.0f - 1.0f, 1); } break; //end outer for } } }
ParticleSystem::ParticleSystem( int iEntIndex, char *szFilename ) { int iParticles = 100; // default m_iEntIndex = iEntIndex; m_pNextSystem = NULL; m_pFirstType = NULL; if ( !c_bCosTableInit ) { for ( int i = 0; i < 360 + 90; i++ ) { c_fCosTable[i] = cos( i * M_PI / 180.0 ); } c_bCosTableInit = true; } const char *memFile; const char *szFile = (char *)LOAD_FILE( szFilename, NULL ); char *szToken; if( !szFile ) { ALERT( at_error, "particle %s not found.\n", szFilename ); return; } else { memFile = szFile; szToken = COM_ParseToken( &szFile ); while ( szToken ) { if ( !stricmp( szToken, "particles" ) ) { szToken = COM_ParseToken( &szFile ); iParticles = atof(szToken); } else if ( !stricmp( szToken, "maintype" ) ) { szToken = COM_ParseToken( &szFile ); m_pMainType = AddPlaceholderType(szToken); } else if ( !stricmp( szToken, "attachment" ) ) { szToken = COM_ParseToken( &szFile ); m_iEntAttachment = atof(szToken); } else if ( !stricmp( szToken, "killcondition" ) ) { szToken = COM_ParseToken( &szFile ); if ( !stricmp( szToken, "empty" ) ) { m_iKillCondition = CONTENTS_EMPTY; } else if ( !stricmp( szToken, "water" ) ) { m_iKillCondition = CONTENTS_WATER; } else if ( !stricmp( szToken, "solid" ) ) { m_iKillCondition = CONTENTS_SOLID; } } else if ( !stricmp( szToken, "{" ) ) { // parse new type this->ParseType( &szFile ); // parses the type, moves the file pointer } szToken = COM_ParseToken( &szFile ); } } FREE_FILE( (void *)memFile ); AllocateParticles( iParticles ); }
ParticleSystem::ParticleSystem( int iEntIndex, char *szFilename ) { int iParticles = 100; // default m_iEntIndex = iEntIndex; m_iEntAttachment = 0; m_pNextSystem = NULL; m_pFirstType = NULL; if (!c_bCosTableInit) { for (int i = 0; i < 360+90; i++) { c_fCosTable[i] = cos(i*M_PI/180.0); } c_bCosTableInit = true; } // gEngfuncs.Con_Printf("ParticleSystem: idx %d\n", m_iEntIndex ); char *szFile = (char *)gEngfuncs.COM_LoadFile( szFilename, 5, NULL); char szToken[1024]; if (!szFile) { gEngfuncs.Con_Printf("Particle %s not found.\n", szFilename ); return; } else { szFile = gEngfuncs.COM_ParseFile(szFile, szToken); while (szFile) { if ( !stricmp( szToken, "particles" ) ) { szFile = gEngfuncs.COM_ParseFile(szFile,szToken); iParticles = atof(szToken); } else if ( !stricmp( szToken, "maintype" ) ) { szFile = gEngfuncs.COM_ParseFile(szFile,szToken); m_pMainType = AddPlaceholderType(szToken); } else if ( !stricmp( szToken, "attachment" ) ) { szFile = gEngfuncs.COM_ParseFile(szFile,szToken); m_iEntAttachment = atoi(szToken); // gEngfuncs.Con_Printf("m_iEntAttachment %d\n", m_iEntAttachment ); } else if ( !stricmp( szToken, "killcondition" ) ) { szFile = gEngfuncs.COM_ParseFile(szFile,szToken); if ( !stricmp( szToken, "empty" ) ) { m_iKillCondition = CONTENTS_EMPTY; } else if ( !stricmp( szToken, "water" ) ) { m_iKillCondition = CONTENTS_WATER; } else if ( !stricmp( szToken, "solid" ) ) { m_iKillCondition = CONTENTS_SOLID; } } else if ( !stricmp( szToken, "{" ) ) { // parse new type this->ParseType( szFile ); // parses the type, moves the file pointer } szFile = gEngfuncs.COM_ParseFile(szFile, szToken); } } gEngfuncs.COM_FreeFile( szFile ); AllocateParticles(iParticles); }
//============================================ CParticleSystem :: CParticleSystem( cl_entity_t *ent, const char *szFilename, int attachment, float lifetime ) { int iParticles = 100; // default m_iKillCondition = CONTENTS_NONE; m_iEntAttachment = attachment; m_pActiveParticle = NULL; m_pMainParticle = NULL; m_fLifeTime = lifetime; m_pNextSystem = NULL; m_iLightingModel = 0; m_pFirstType = NULL; m_pEntity = ent; enable = true; entityMatrix.Identity(); if( !c_bCosTableInit ) { for( int i = 0; i < 360 + 90; i++ ) c_fCosTable[i] = cos( i * M_PI / 180.0f ); c_bCosTableInit = true; } char *afile = (char *)gEngfuncs.COM_LoadFile( (char *)szFilename, 5, NULL ); char szToken[1024]; char *pfile = afile; if( !pfile ) { ALERT( at_error, "couldn't load %s.\n", szFilename ); return; } else { pfile = COM_ParseFile( pfile, szToken ); while( pfile ) { if( !Q_stricmp( szToken, "particles" )) { pfile = COM_ParseFile( pfile, szToken ); iParticles = Q_atoi( szToken ); } else if( !Q_stricmp( szToken, "maintype" )) { pfile = COM_ParseFile( pfile, szToken ); m_pMainType = AddPlaceholderType( szToken ); } else if( !Q_stricmp( szToken, "attachment" )) { pfile = COM_ParseFile( pfile, szToken ); m_iEntAttachment = Q_atoi( szToken ); } else if( !Q_stricmp( szToken, "lightmodel" )) { pfile = COM_ParseFile( pfile, szToken ); m_iLightingModel = Q_atoi( szToken ); } else if( !Q_stricmp( szToken, "killcondition" )) { pfile = COM_ParseFile( pfile, szToken ); if( !Q_stricmp( szToken, "empty" )) { m_iKillCondition = CONTENTS_EMPTY; } else if( !Q_stricmp( szToken, "water" )) { m_iKillCondition = CONTENTS_WATER; } else if( !Q_stricmp( szToken, "solid" )) { m_iKillCondition = CONTENTS_SOLID; } } else if( !Q_stricmp( szToken, "{" )) { // parse new type this->ParseType( pfile ); } pfile = COM_ParseFile( pfile, szToken ); } } gEngfuncs.COM_FreeFile( afile ); AllocateParticles( iParticles ); }