void FGSensor::ProcessSensorSignal(void) { Output = Input; // perfect sensor // Degrade signal as specified if (fail_stuck) { Output = PreviousOutput; } else if (fcs->GetTrimStatus()) { if (lag != 0.0) {PreviousOutput = Output; PreviousInput = Input;} if (drift_rate != 0.0) drift = 0; if (gain != 0.0) Gain(); // models a finite gain if (bias != 0.0) Bias(); // models a finite bias if (delay != 0) for (int i=0; i<delay; i++) output_array[i] = Output; Clip(); } else { if (lag != 0.0) Lag(); // models sensor lag and filter if (noise_variance != 0.0) Noise(); // models noise if (drift_rate != 0.0) Drift(); // models drift over time if (gain != 0.0) Gain(); // models a finite gain if (bias != 0.0) Bias(); // models a finite bias if (delay != 0) Delay(); // models system signal transport latencies if (fail_low) Output = -HUGE_VAL; if (fail_high) Output = HUGE_VAL; if (bits != 0) Quantize(); // models quantization degradation Clip(); } if (IsOutput) SetOutput(); }
float Gain( float x, float biasAmt ) { // WARNING: not thread safe if( x < 0.5f ) return 0.5f * Bias(2*x, 1-biasAmt); else return 1 - 0.5f * Bias(2 - 2*x, 1-biasAmt); }
void FGSensor::ProcessSensorSignal(void) { Output = Input; // perfect sensor // Degrade signal as specified if (fail_stuck) { Output = PreviousOutput; } else { if (lag != 0.0) Lag(); // models sensor lag and filter if (noise_variance != 0.0) Noise(); // models noise if (drift_rate != 0.0) Drift(); // models drift over time if (gain != 0.0) Gain(); // models a finite gain if (bias != 0.0) Bias(); // models a finite bias if (delay != 0) Delay(); // models system signal transport latencies if (fail_low) Output = -HUGE_VAL; if (fail_high) Output = HUGE_VAL; if (bits != 0) Quantize(); // models quantization degradation Clip(); } }
bool FGSensor::Run(void ) { Input = InputNodes[0]->getDoubleValue() * InputSigns[0]; Output = Input; // perfect sensor // Degrade signal as specified if (fail_stuck) { Output = PreviousOutput; return true; } if (lag != 0.0) Lag(); // models sensor lag and filter if (noise_variance != 0.0) Noise(); // models noise if (drift_rate != 0.0) Drift(); // models drift over time if (bias != 0.0) Bias(); // models a finite bias if (delay != 0.0) Delay(); // models system signal transport latencies if (fail_low) Output = -HUGE_VAL; if (fail_high) Output = HUGE_VAL; if (bits != 0) Quantize(); // models quantization degradation Clip(); // Is it right to clip a sensor? return true; }
//Alpha virtual float UpdateAlpha( const SimpleParticle *pParticle ) { float tLifetime = pParticle->m_flLifetime / pParticle->m_flDieTime; float ramp = 1.0f - tLifetime; return Bias( ramp, 0.25f ); }
//----------------------------------------------------------------------------- // Updates the wind sound //----------------------------------------------------------------------------- void CEnvWindShared::UpdateWindSound( float flTotalWindSpeed ) { if (!g_pEffects->IsServer()) { float flDuration = random->RandomFloat( 1.0f, 2.0f ); CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController(); // FIXME: Tweak with these numbers float flNormalizedWindSpeed = flTotalWindSpeed / 150.0f; if (flNormalizedWindSpeed > 1.0f) flNormalizedWindSpeed = 1.0f; float flPitch = 120 * Bias( flNormalizedWindSpeed, 0.3f ) + 100; float flVolume = 0.3f * Bias( flNormalizedWindSpeed, 0.3f ) + 0.7f; controller.SoundChangePitch( m_pWindSound, flPitch, flDuration ); controller.SoundChangeVolume( m_pWindSound, flVolume, flDuration ); } }
Neuron::Neuron(int Number_Of_Connections, int Seed) { // Random Number Generation. - Seed defined in Neuron Class (Private Variable) std::mt19937_64 Generate(Seed); std::uniform_real_distribution<double> Weight(-0.5, 0.5); std::uniform_real_distribution<double> Bias(0, 1); // Resize the weight matrix for the number of connection, plus one additional weight that acts as the bias Neuron::Weights.resize((Number_Of_Connections + 1), 1); // Randomize input weights. for (int a = 0; a < Number_Of_Connections; a++) { Neuron::Weights(a) = Weight(Generate); } Neuron::Weights((Number_Of_Connections)) = Bias(Generate); // Randomize neuron bias. Neuron::Weight_Update_Old = Eigen::MatrixXd::Constant(Neuron::Weights.cols(), Neuron::Weights.rows(), 0); }
//Color virtual Vector UpdateColor( const SimpleParticle *pParticle ) { Vector color; float tLifetime = pParticle->m_flLifetime / pParticle->m_flDieTime; float ramp = Bias( 1.0f - tLifetime, 0.25f ); color[0] = ( (float) pParticle->m_uchColor[0] * ramp ) / 255.0f; color[1] = ( (float) pParticle->m_uchColor[1] * ramp ) / 255.0f; color[2] = ( (float) pParticle->m_uchColor[2] * ramp ) / 255.0f; return color; }
float vParticleImpulseGen::GetImpulse( vParticle *parent ) { Assert( parent != NULL ); float val = 0; switch ( mode ) { case PARTICLEIMPULSEGENERATOR_FRAMETIME: val = CFrameTimeHelper::GetFrameTime() * impulse_multiplier; break; case PARTICLEIMPULSEGENERATOR_LIFETIME_LINEAR: val = NORMALIZE( ( CFrameTimeHelper::GetCurrentTime() - parent->GetCreationTime() ) / parent->GetLifeDuration() ) * impulse_multiplier; break; case PARTICLEIMPULSEGENERATOR_LIFETIME_SINE: val = NORMALIZE( ( CFrameTimeHelper::GetCurrentTime() - parent->GetCreationTime() ) / parent->GetLifeDuration() ); val = NORMALIZE( abs( sin( M_PI_F * val * impulse_multiplier ) ) ); break; case PARTICLEIMPULSEGENERATOR_VELOCITY_LINEAR: val = parent->vecVelocity.Length() * impulse_multiplier; break; case PARTICLEIMPULSEGENERATOR_ANGULAR_VELOCITY_LINEAR: val = abs( parent->flAngularVelocity ) * impulse_multiplier; break; case PARTICLEIMPULSEGENERATOR_CURTIME_SINE: val = NORMALIZE( abs( sin( M_PI_F * CFrameTimeHelper::GetCurrentTime() * impulse_multiplier ) ) ); break; case PARTICLEIMPULSEGENERATOR_CURTIME_SINE_SIGNED: val = ( ( sin( M_PI_F * CFrameTimeHelper::GetCurrentTime() * impulse_multiplier ) ) ); break; default: Assert(0); break; } Assert( IsFinite(val) ); float sign = Sign( val ); val = sign * Bias( abs(val), impulse_bias ); val = RemapVal( val, 0.0f, 1.0f, reference_min, reference_max ); return val; }
bool FGActuator::Run(void ) { Input = InputNodes[0]->getDoubleValue() * InputSigns[0]; if( fcs->GetTrimStatus() ) initialized = 0; if (fail_zero) Input = 0; if (fail_hardover) Input = clipmax*sign(Input); Output = Input; // Perfect actuator. At this point, if no failures are present // and no subsequent lag, limiting, etc. is done, the output // is simply the input. If any further processing is done // (below) such as lag, rate limiting, hysteresis, etc., then // the Input will be further processed and the eventual Output // will be overwritten from this perfect value. if (fail_stuck) { Output = PreviousOutput; } else { if (lag != 0.0) Lag(); // models actuator lag if (rate_limit_incr != 0 || rate_limit_decr != 0) RateLimit(); // limit the actuator rate if (deadband_width != 0.0) Deadband(); if (hysteresis_width != 0.0) Hysteresis(); if (bias != 0.0) Bias(); // models a finite bias if (delay != 0) Delay(); // Model transport latency } PreviousOutput = Output; // previous value needed for "stuck" malfunction initialized = 1; Clip(); if (clip) { saturated = false; if (Output >= clipmax && clipmax != 0) saturated = true; else if (Output <= clipmin && clipmin != 0) saturated = true; } if (IsOutput) SetOutput(); return true; }
//----------------------------------------------------------------------------- // Purpose: Find what size of nugget to spawn //----------------------------------------------------------------------------- int CAntlionGrub::GetNuggetDenomination( void ) { // Find the desired health perc we want to be at float flDesiredHealthPerc = DynamicResupply_GetDesiredHealthPercentage(); CBasePlayer *pPlayer = AI_GetSinglePlayer(); if ( pPlayer == NULL ) return -1; // Get the player's current health percentage float flPlayerHealthPerc = (float) pPlayer->GetHealth() / (float) pPlayer->GetMaxHealth(); // If we're already maxed out, return the small nugget if ( flPlayerHealthPerc >= flDesiredHealthPerc ) { return NUGGET_SMALL; } // Find where we fall in the desired health's range float flPercDelta = flPlayerHealthPerc / flDesiredHealthPerc; // The larger to discrepancy, the higher the chance to move quickly to close it float flSeed = random->RandomFloat( 0.0f, 1.0f ); float flRandomPerc = Bias( flSeed, (1.0f-flPercDelta) ); int nDenomination; if ( flRandomPerc < 0.25f ) { nDenomination = NUGGET_SMALL; } else if ( flRandomPerc < 0.625f ) { nDenomination = NUGGET_MEDIUM; } else { nDenomination = NUGGET_LARGE; } // Msg("Player: %.02f, Desired: %.02f, Seed: %.02f, Perc: %.02f, Result: %d\n", flPlayerHealthPerc, flDesiredHealthPerc, flSeed, flRandomPerc, nDenomination ); return nDenomination; }
void Ati::nano17Init(char *filename) { float Total[6]; unsigned short index = 1; // index of calibration in file (second parameter; default = 1) cal=createCalibration(filename,index); // Taking Average samples for bias for(int j=0;j<AVERAGE_NUM;j++) { setVoltage(); for(int k=0;k<6;k++) Total[k]=Total[k]+voltages[k]; } for(int k=0;k<6;k++) Total[k]=Total[k]/AVERAGE_NUM; Bias(cal,Total); }
int main(int argc, char **argv){ double z,dlm,m,sdndm, Mmin, Mmax; int i,N; double temp, bias, R, sigmaM; if(argc!=5) { printf("\nCalculates the analytical halo bias for a given redshift and mass interval.\n"); printf("usage: abias work_dir z Mmin Mmax\n"); printf("Mmin and Mmax in Msun units.\n\n"); exit(1); } get_Simfast21_params(argv[1]); z=atof(argv[2]); Mmin=atof(argv[3]); Mmax=atof(argv[4]); dlm=0.01; N=log10(Mmax/Mmin)/dlm; sdndm=0.; bias=0.0; for(i=0;i<N;i++) { m=Mmin*pow(10,i*dlm+dlm/2.0); R=pow(m*3.0/4.0/PI/global_rho_m,1./3); sigmaM=(double)sigma(R); temp=mass_function_ST(z,m)*m; /* mass_function_ST in 1/Msun/(Mpc/h)^3 - comoving volume */ sdndm+=temp; bias=bias+temp*Bias(z,sigmaM); } sdndm*=dlm; bias=bias*dlm/sdndm; printf("halo number density over mass range: %E (h/Mpc)^3\n",sdndm); printf("bias over mass range: %f\n",bias); }
//----------------------------------------------------------------------------- // Purpose: // Input : flPerc - //----------------------------------------------------------------------------- void C_MortarShell::AddRisingParticles( float flPerc ) { SimpleParticle *sParticle; Vector offset; float radius = m_flRadius * 0.25f * flPerc; float val = RemapValClamped( gpGlobals->curtime, m_flStarttime, m_flStarttime + m_flLifespan, 0.0f, 1.0f ); float flCur = gpGlobals->frametime; // Anime ground effects while ( m_ParticleEvent.NextEvent( flCur ) ) { offset.x = random->RandomFloat( -radius, radius ); offset.y = random->RandomFloat( -radius, radius ); offset.z = random->RandomFloat( -8.0f, 8.0f ); offset += GetAbsOrigin(); sParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_pEmitter->GetPMaterial( "effects/spark" ), offset ); if ( sParticle == NULL ) return; sParticle->m_vecVelocity = Vector( Helper_RandomFloat( -4.0f, 4.0f ), Helper_RandomFloat( -4.0f, 4.0f ), Helper_RandomFloat( 32.0f, 256.0f ) * Bias( val, 0.25f ) ); sParticle->m_uchStartSize = random->RandomFloat( 4, 8 ) * flPerc; sParticle->m_flDieTime = random->RandomFloat( 0.5f, 1.0f ); sParticle->m_flLifetime = 0.0f; sParticle->m_flRoll = Helper_RandomInt( 0, 360 ); float alpha = 255 * flPerc; sParticle->m_flRollDelta = Helper_RandomFloat( -8.0f * flPerc, 8.0f * flPerc ); sParticle->m_uchColor[0] = alpha; sParticle->m_uchColor[1] = alpha; sParticle->m_uchColor[2] = alpha; sParticle->m_uchStartAlpha = alpha; sParticle->m_uchEndAlpha = 0; sParticle->m_uchEndSize = 0; } }
void AddCoolLine( const Vector &v1, const Vector &v2, unsigned long iExtraFadeOffset, bool bNegateMovementDir ) { float flLineSectionLength = 3; // How many inches each line travels. Each line is a solid color and alpha. int nLineSectionsToFade = 2; // How many lines to fade from translucent to opaque. int baseColor[3] = { 216, 183, 67 }; // gold float flTimeBetweenUpdates = 0.2f; unsigned long iLineFadeOffset = iExtraFadeOffset + (int)(gpGlobals->curtime / flTimeBetweenUpdates); if ( bNegateMovementDir ) iLineFadeOffset = 0xFFFFFFFF - iLineFadeOffset; Vector vDelta = v2 - v1; float flLineLen = vDelta.Length(); vDelta /= flLineLen; int nMaxLines = (int)(flLineLen / flLineSectionLength) + 1; static IMaterial *pWireframeMaterial = NULL; if ( !pWireframeMaterial ) pWireframeMaterial = materials->FindMaterial( "debug/debugwireframevertexcolor", TEXTURE_GROUP_OTHER ); static IMaterial *pBeamMaterial = NULL; if ( !pBeamMaterial ) pBeamMaterial = materials->FindMaterial( "effects/laser1", TEXTURE_GROUP_OTHER ); CMatRenderContextPtr pRenderContext( materials ); // Draw the solid underlying lines. IMesh* pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, pWireframeMaterial ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_LINES, 1 ); meshBuilder.Position3fv( v1.Base() ); meshBuilder.Color4ub( baseColor[0], baseColor[1], baseColor[2], 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3fv( v2.Base() ); meshBuilder.Color4ub( baseColor[0], baseColor[1], baseColor[2], 255 ); meshBuilder.AdvanceVertex(); meshBuilder.End( false, true ); // Draw the additive beams. float flCurDist = 0; Vector vStartPos = v1; for ( int i=0; i < nMaxLines; i++ ) { float flEndDist = MIN( flCurDist + flLineSectionLength, flLineLen ); Vector vEndPos = v1 + vDelta * flEndDist; int alpha; int iFadeAmt = (iLineFadeOffset+i) % (nLineSectionsToFade * 2); if ( iFadeAmt < nLineSectionsToFade ) alpha = (iFadeAmt * 255) / nLineSectionsToFade; else alpha = (255 * (nLineSectionsToFade - (iFadeAmt - nLineSectionsToFade))) / nLineSectionsToFade; float flAlpha = Bias( alpha / 255.0f, 0.6 ); CBeamSegDraw beamDraw; beamDraw.Start( pRenderContext, 2, pBeamMaterial ); BeamSeg_t beamSeg; beamSeg.SetColor( baseColor[0] * flAlpha / 255.0f, baseColor[1] * flAlpha / 255.0f, baseColor[2] * flAlpha / 255.0f, 1.0f ); beamSeg.m_flTexCoord = 0; beamSeg.m_flWidth = 6; beamSeg.m_vPos = vStartPos; beamDraw.NextSeg( &beamSeg ); beamSeg.m_vPos = vEndPos; beamDraw.NextSeg( &beamSeg ); beamDraw.End(); flCurDist = flEndDist; vStartPos = vEndPos; } }
void CBPGameMovement::FlyMove( void ) { int i; Vector wishvel; //float fmove, smove; Vector wishdir; float wishspeed; Vector forward, right, up; AngleVectors (mv->m_vecViewAngles, &forward, &right, &up); // Determine movement angles // Zero out z components of movement vectors //float flSpeed = 50; /*wishvel = forward * flSpeed*/; wishvel.Init(); //bool bOnGround = player->GetGroundEntity() != NULL; #if 1 // LEFT WING { // Launch up m_flLFlapAmount -= (bp_mv_flapdecay.GetFloat() * gpGlobals->frametime); m_flLFlapAmount = max( 0, max ( m_flLFlapAmount, ( (mv->m_nButtons & IN_JUMP) ? 1 : m_flLTriggerDiff ) ) ); // Grav float flGravity = RemapValClamped( m_flLTriggerAvg, 0, 1, bp_mv_gravity.GetFloat(), bp_mv_gravity_soar.GetFloat() ); //flGravity *= RemapValClamped( flGravity, 0, 100, 0.1, 1 ); // Smooth out the gravity, use the average over the last 2 sec. m_flLInterpGravity.AddToTail( float_time( flGravity, gpGlobals->curtime ) ); float flGravityAvg = 0; for ( int i = 0; i < m_flLInterpGravity.Count(); i++ ) flGravityAvg += m_flLInterpGravity[i].m_flValue; flGravityAvg /= m_flLInterpGravity.Count(); int iCount = m_flLInterpGravity.Count(); for ( int i = iCount-1; i >= 0; i-- ) { if ( m_flLInterpGravity[i].m_flTime < gpGlobals->curtime-BIRD_GRAV_SAMPLETIME ) m_flLInterpGravity.Remove(i); } // Combine the two m_flLUpForce = max( m_flLUpForce, m_flLFlapAmount * bp_mv_flapforce.GetFloat() ); m_flLUpForce -= flGravityAvg; } // RIGHT WING { // Launch up m_flRFlapAmount -= (bp_mv_flapdecay.GetFloat() * gpGlobals->frametime); m_flRFlapAmount = max( 0, max ( m_flRFlapAmount, ( (mv->m_nButtons & IN_JUMP) ? 1 : m_flRTriggerDiff ) ) ); // Grav float flGravity = RemapValClamped( m_flRTriggerAvg, 0, 1, bp_mv_gravity.GetFloat(), bp_mv_gravity_soar.GetFloat() ); //flGravity *= RemapValClamped( flGravity, 0, 100, 0.1, 1 ); // Smooth out the gravity, use the average over the last 2 sec. m_flRInterpGravity.AddToTail( float_time( flGravity, gpGlobals->curtime ) ); float flGravityAvg = 0; for ( int i = 0; i < m_flRInterpGravity.Count(); i++ ) flGravityAvg += m_flRInterpGravity[i].m_flValue; flGravityAvg /= m_flRInterpGravity.Count(); int iCount = m_flRInterpGravity.Count(); for ( int i = iCount-1; i >= 0; i-- ) { if ( m_flRInterpGravity[i].m_flTime < gpGlobals->curtime-BIRD_GRAV_SAMPLETIME ) m_flRInterpGravity.Remove(i); } // Combine the two m_flRUpForce = max( m_flRUpForce, m_flRFlapAmount * bp_mv_flapforce.GetFloat() ); m_flRUpForce -= flGravityAvg; } // Forward movement float flSoarAmt = ( m_flRTriggerAvg * 0.5 ) + ( m_flLTriggerAvg * 0.5 ); flSoarAmt = Bias( flSoarAmt, 0.75 ); m_flForwardForce -= RemapValClamped( flSoarAmt, 0, 1, bp_mv_flightdecay.GetFloat(), bp_mv_flightdecay_soar.GetFloat() ) * gpGlobals->frametime; m_flForwardForce = max( 0.25, max( m_flForwardForce, max( m_flLTriggerDiff, m_flRTriggerDiff ) ) ); wishvel = forward * ( m_flForwardForce * bp_mv_flightspeed.GetFloat() ); wishvel.z = (m_flRUpForce+m_flLUpForce)/2; // Calc turn rate from diff between wing avgs. /*GetBPPlayer()->m_flTurnRate = ( RemapValClamped( m_flRUpForce, 0, bp_mv_flapforce.GetFloat(), 0, 1 ) - RemapValClamped( m_flLUpForce, 0, bp_mv_flapforce.GetFloat(), 0, 1 ) ); GetBPPlayer()->m_flTurnRate *= abs(GetBPPlayer()->m_flTurnRate);*/ GetBPPlayer()->m_flTurnRate = bpmv->m_flRTrigger - bpmv->m_flLTrigger; GetBPPlayer()->m_flTurnRate *= abs(GetBPPlayer()->m_flTurnRate); GetBPPlayer()->m_flTurnRate *= abs(GetBPPlayer()->m_flTurnRate); GetBPPlayer()->m_flTurnRate *= bp_mv_turnrate.GetFloat(); #else if ( mv->m_nButtons & IN_FORWARD ) m_flLastForward = gpGlobals->curtime; float m_flTimeSinceFlap = gpGlobals->curtime - m_flLastForward; wishvel = forward * ( Bias( RemapValClamped( m_flTimeSinceFlap, 0, 5, 1, 0 ), 0.1 ) * bp_mv_flapforce.GetFloat() ); //m_flLastATime #endif VectorCopy (wishvel, wishdir); // Determine maginitude of speed of move wishspeed = VectorNormalize(wishdir); //engine->Con_NPrintf( 2, "Flap Force: %.2f %.2f", m_flLFlapAmount, m_flRFlapAmount ); //engine->Con_NPrintf( 3, "Gravity: %.2f %.2f", flGravity ); //engine->Con_NPrintf( 4, "Vertical Force: %.2f %.2f", m_flLUpForce, m_flRUpForce ); //engine->Con_NPrintf( 5, "Forward Force: %.2f", m_flForwardForce ); // // clamp to server defined max speed // /*if ( wishspeed != 0 && (wishspeed > mv->m_flMaxSpeed)) { VectorScale (wishvel, mv->m_flMaxSpeed/wishspeed, wishvel); wishspeed = mv->m_flMaxSpeed; }*/ //engine->Con_NPrintf( 6, "Speed: %.2f", wishspeed ); //AirAccelerate( wishdir, wishspeed, sv_airaccelerate.GetFloat() ); for (i=0 ; i<3 ; i++) { mv->m_vecVelocity[i] = wishspeed * wishdir[i]; mv->m_outWishVel[i] = wishspeed * wishdir[i]; } // Add in any base velocity to the current velocity. VectorAdd(mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity ); TryPlayerMove(); // Now pull the base velocity back out. Base velocity is set if you are on a moving object, like a conveyor (or maybe another monster?) VectorSubtract( mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity ); }
//----------------------------------------------------------------------------- // Purpose: // Input : frametime - //----------------------------------------------------------------------------- void CFXQuad::Draw( double frametime ) { VPROF_BUDGET( "FX_Quad::Draw", VPROF_BUDGETGROUP_PARTICLE_RENDERING ); // Update the effect Update( frametime ); float scaleTimePerc, alphaTimePerc; //Determine the scale if ( m_FXData.m_uiFlags & FXQUAD_BIAS_SCALE ) { scaleTimePerc = Bias( ( m_FXData.m_flLifeTime / m_FXData.m_flDieTime ), m_FXData.m_flScaleBias ); } else { scaleTimePerc = ( m_FXData.m_flLifeTime / m_FXData.m_flDieTime ); } float scale = m_FXData.m_flStartScale + ( ( m_FXData.m_flEndScale - m_FXData.m_flStartScale ) * scaleTimePerc ); //Determine the alpha if ( m_FXData.m_uiFlags & FXQUAD_BIAS_ALPHA ) { alphaTimePerc = Bias( ( m_FXData.m_flLifeTime / m_FXData.m_flDieTime ), m_FXData.m_flAlphaBias ); } else { alphaTimePerc = ( m_FXData.m_flLifeTime / m_FXData.m_flDieTime ); } float alpha = m_FXData.m_flStartAlpha + ( ( m_FXData.m_flEndAlpha - m_FXData.m_flStartAlpha ) * alphaTimePerc ); alpha = clamp( alpha, 0.0f, 1.0f ); CMatRenderContextPtr pRenderContext( materials ); //Bind the material IMesh* pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, m_FXData.m_pMaterial ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); //Update our roll m_FXData.m_flYaw = anglemod( m_FXData.m_flYaw + ( m_FXData.m_flDeltaYaw * frametime ) ); Vector pos; Vector vRight, vUp; float color[4]; color[0] = m_FXData.m_Color[0]; color[1] = m_FXData.m_Color[1]; color[2] = m_FXData.m_Color[2]; if ( m_FXData.m_uiFlags & FXQUAD_COLOR_FADE ) { color[0] *= alpha; color[1] *= alpha; color[2] *= alpha; } color[3] = alpha; VectorVectors( m_FXData.m_vecNormal, vRight, vUp ); Vector rRight, rUp; rRight = ( vRight * cos( DEG2RAD( m_FXData.m_flYaw ) ) ) - ( vUp * sin( DEG2RAD( m_FXData.m_flYaw ) ) ); rUp = ( vRight * cos( DEG2RAD( m_FXData.m_flYaw+90.0f ) ) ) - ( vUp * sin( DEG2RAD( m_FXData.m_flYaw+90.0f ) ) ); vRight = rRight * ( scale * 0.5f ); vUp = rUp * ( scale * 0.5f ); pos = m_FXData.m_vecOrigin + vRight - vUp; meshBuilder.Position3fv( pos.Base() ); meshBuilder.Normal3fv( m_FXData.m_vecNormal.Base() ); meshBuilder.TexCoord2f( 0, 1.0f, 1.0f ); meshBuilder.Color4fv( color ); meshBuilder.AdvanceVertex(); pos = m_FXData.m_vecOrigin - vRight - vUp; meshBuilder.Position3fv( pos.Base() ); meshBuilder.Normal3fv( m_FXData.m_vecNormal.Base() ); meshBuilder.TexCoord2f( 0, 0.0f, 1.0f ); meshBuilder.Color4fv( color ); meshBuilder.AdvanceVertex(); pos = m_FXData.m_vecOrigin - vRight + vUp; meshBuilder.Position3fv( pos.Base() ); meshBuilder.Normal3fv( m_FXData.m_vecNormal.Base() ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.Color4fv( color ); meshBuilder.AdvanceVertex(); pos = m_FXData.m_vecOrigin + vRight + vUp; meshBuilder.Position3fv( pos.Base() ); meshBuilder.Normal3fv( m_FXData.m_vecNormal.Base() ); meshBuilder.TexCoord2f( 0, 1.0f, 0.0f ); meshBuilder.Color4fv( color ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }