//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_FireSmoke::Update( void ) { //If we haven't already, find the clip plane for smoke effects if ( ( m_nFlags & bitsFIRESMOKE_SMOKE ) && ( m_bClipTested == false ) ) { FindClipPlane(); } //Update all our parts UpdateEffects(); UpdateScale(); UpdateAnimation(); UpdateFlames(); //See if we should emit smoke if ( m_nFlags & bitsFIRESMOKE_SMOKE ) { float tempDelta = Helper_GetFrameTime(); while( m_tParticleSpawn.NextEvent( tempDelta ) ) { SpawnSmoke(); } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_FireSmoke::UpdateAnimation( void ) { int numFrames; float frametime = Helper_GetFrameTime(); for ( int i = 0; i < NUM_CHILD_FLAMES; i++ ) { m_entFlames[i].m_flFrame += m_entFlames[i].m_flSpriteFramerate * frametime; numFrames = modelinfo->GetModelFrameCount( m_entFlames[i].GetModel() ); if ( m_entFlames[i].m_flFrame >= numFrames ) { m_entFlames[i].m_flFrame = m_entFlames[i].m_flFrame - (int)(m_entFlames[i].m_flFrame); } } if ( m_nFlags & bitsFIRESMOKE_VISIBLE_FROM_ABOVE ) { for ( int i = 0; i < NUM_CHILD_FLAMES; i++ ) { m_entFlamesFromAbove[i].m_flFrame += m_entFlamesFromAbove[i].m_flSpriteFramerate * frametime; numFrames = modelinfo->GetModelFrameCount( m_entFlamesFromAbove[i].GetModel() ); if ( m_entFlamesFromAbove[i].m_flFrame >= numFrames ) { m_entFlamesFromAbove[i].m_flFrame = m_entFlamesFromAbove[i].m_flFrame - (int)(m_entFlamesFromAbove[i].m_flFrame); } } } }
//----------------------------------------------------------------------------- // Purpose: // Input : fTimeDelta - //----------------------------------------------------------------------------- void C_SmokeStack::Update(float fTimeDelta) { if (!m_pParticleMgr) { assert(false); return; } // Don't spawn particles unless we're visible. if (m_bEmit && (m_ParticleEffect.WasDrawnPrevFrame() || m_ParticleEffect.GetAlwaysSimulate())) { // Add new particles. Vector forward, right, up; AngleVectors(GetAbsAngles(), &forward, &right, &up); float tempDelta = fTimeDelta; while (m_ParticleSpawn.NextEvent(tempDelta)) { int iRandomFrame = random->RandomInt(0, m_iMaxFrames); iRandomFrame = 0; // Make a new particle. if (SmokeStackParticle *pParticle = (SmokeStackParticle*) m_ParticleEffect.AddParticle(sizeof(SmokeStackParticle), m_MaterialHandle[iRandomFrame])) { float angle = FRand(0, 2.0f*M_PI_F); pParticle->m_Pos = GetAbsOrigin() + right * (cos(angle) * m_flBaseSpread) + forward * (sin(angle) * m_flBaseSpread); pParticle->m_Velocity = FRand(-m_SpreadSpeed, m_SpreadSpeed) * right + FRand(-m_SpreadSpeed, m_SpreadSpeed) * forward + m_Speed * up; pParticle->m_vAccel = m_vWind; pParticle->m_Lifetime = 0; pParticle->m_flAngle = 0.0f; pParticle->m_flRollDelta = random->RandomFloat(-m_flRollSpeed, m_flRollSpeed); pParticle->m_flSortPos = pParticle->m_Pos.z; } } } // Setup the twist matrix. float flTwist = (m_flTwist * (M_PI_F * 2.f) / 360.0f) * Helper_GetFrameTime(); if ((m_bTwist = !!flTwist)) { m_TwistMat[0][0] = cos(flTwist); m_TwistMat[0][1] = sin(flTwist); m_TwistMat[1][0] = -sin(flTwist); m_TwistMat[1][1] = cos(flTwist); } QueueLightParametersInRenderer(); }
//----------------------------------------------------------------------------- // Purpose: // Input : flags - //----------------------------------------------------------------------------- int C_ExtinguisherJet::DrawModel( int flags ) { if ( m_bEmit == false ) return 1; Update( Helper_GetFrameTime() ); return 1; }
int CParticleEffectBinding::DrawModel( int flags ) { VPROF_BUDGET( "CParticleEffectBinding::DrawModel", VPROF_BUDGETGROUP_PARTICLE_RENDERING ); #ifndef PARTICLEPROTOTYPE_APP if ( !r_DrawParticles.GetInt() ) return 0; #endif Assert( flags != 0 ); // If we're in commander mode and it's trying to draw the effect, // exit out. If the effect has FLAGS_ALWAYSSIMULATE set, then it'll come back // in here and simulate at the end of the frame. if( !g_pClientMode->ShouldDrawParticles() ) return 0; SetDrawn( true ); // Don't do anything if there are no particles. if( !m_nActiveParticles ) return 1; // Reset the transformation matrix to identity. VMatrix mTempModel, mTempView; RenderStart( mTempModel, mTempView ); // Setup to redo our bbox? bool bBucketSort = random->RandomInt( 0, BUCKET_SORT_EVERY_N ) == 0; // Set frametime to zero if we've already rendered this frame. float flFrameTime = 0; if ( m_FrameCode != m_pParticleMgr->m_FrameCode ) { m_FrameCode = m_pParticleMgr->m_FrameCode; flFrameTime = Helper_GetFrameTime(); } // For each material, render... // This does an incremental bubble sort. It only does one pass every frame, and it will shuffle // unsorted particles one step towards where they should be. bool bWireframe = false; FOR_EACH_LL( m_Materials, iMaterial ) { CEffectMaterial *pMaterial = m_Materials[iMaterial]; if ( pMaterial->m_pGroup->m_pPageMaterial && pMaterial->m_pGroup->m_pPageMaterial->NeedsPowerOfTwoFrameBufferTexture() ) { UpdateRefractTexture(); } DrawMaterialParticles( bBucketSort, pMaterial, flFrameTime, bWireframe ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_FireSmoke::UpdateAnimation( void ) { int numFrames; float frametime = Helper_GetFrameTime(); for ( int i = 0; i < NUM_CHILD_FLAMES; i++ ) { m_entFlames[i].m_flFrame += m_entFlames[i].m_flSpriteFramerate * frametime; numFrames = modelinfo->GetModelFrameCount( m_entFlames[i].GetModel() ); if ( m_entFlames[i].m_flFrame >= numFrames ) { m_entFlames[i].m_flFrame = m_entFlames[i].m_flFrame - (int)(m_entFlames[i].m_flFrame); } } }