Beispiel #1
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : flags - 
// Output : int
//-----------------------------------------------------------------------------
int CSprite::DrawModel( int flags, const RenderableInstance_t &instance )
{
	VPROF_BUDGET( "CSprite::DrawModel", VPROF_BUDGETGROUP_PARTICLE_RENDERING );
	//See if we should draw
	if ( !IsVisible() || ( m_bReadyToDraw == false ) )
		return 0;



	// Tracker 16432:  If rendering a savegame screenshot then don't draw sprites 
	//   who have viewmodels as their moveparent
	if ( g_bRenderingScreenshot || !r_drawviewmodel.GetBool() )
	{
		C_BaseViewModel *vm = ToBaseViewModel( GetMoveParent() );
		if ( vm )
		{
			return 0;
		}
	}

	//Must be a sprite
	if ( modelinfo->GetModelType( GetModel() ) != mod_sprite )
	{
		const char *modelName = modelinfo->GetModelName( GetModel() );
		char msg[256];
		V_snprintf( msg, 256, "Sprite %d has non-mod_sprite model %s (type %d)\n",
			entindex(), modelName, modelinfo->GetModelType( GetModel() ) );
		AssertMsgOnce( 0, msg );
		return 0;
	}

	float renderscale = GetRenderScale();
	if ( m_bWorldSpaceScale )
	{
		CEngineSprite *psprite = ( CEngineSprite * )modelinfo->GetModelExtraData( GetModel() );
		float flMinSize = MIN( psprite->GetWidth(), psprite->GetHeight() );
		renderscale /= flMinSize;
	}

	//Draw it
	int drawn = DrawSprite( 
		this,
		GetModel(), 
		GetAbsOrigin(), 
		GetAbsAngles(), 
		m_flFrame,				// sprite frame to render
		m_hAttachedToEntity,	// attach to
		m_nAttachment,			// attachment point
		GetRenderMode(),		// rendermode
		GetRenderFX(),
		(float)( GetRenderBrightness() * instance.m_nAlpha ) * ( 1.0f / 255.0f ) + 0.5f,	// alpha
		GetRenderColorR(),
		GetRenderColorG(),
		GetRenderColorB(),
		renderscale,			// sprite scale
		GetHDRColorScale()		// HDR Color Scale
		);

	return drawn;
}
void C_ASW_DynamicLight::ClientThink(void)
{
	Vector forward;
	AngleVectors( GetAbsAngles(), &forward );

	if ( (m_Flags & DLIGHT_NO_MODEL_ILLUMINATION) == 0 )
	{
		if (!m_pDynamicLight || m_pDynamicLight->key != ASW_LIGHT_INDEX_FIRES + index)
		{
			m_pDynamicLight = effects->CL_AllocDlight( ASW_LIGHT_INDEX_FIRES + index );	
		}
		m_pDynamicLight->color.b = GetRenderColorB();
		m_pDynamicLight->color.g = GetRenderColorG();
		m_pDynamicLight->color.r = GetRenderColorR();

		m_pDynamicLight->origin	= GetAbsOrigin();
		m_pDynamicLight->radius = m_Radius;
		m_pDynamicLight->color.exponent = m_Exponent;

		m_pDynamicLight->die		= gpGlobals->curtime + 30.0f;
	}
	else
	{
		// In this case, the m_Flags could have changed; which is how we turn the light off
		if (m_pDynamicLight)
		{
			m_pDynamicLight->die = gpGlobals->curtime;
			m_pDynamicLight = 0;
		}
	}

	SetNextClientThink(gpGlobals->curtime + 0.001);
}
Beispiel #3
0
void CASWEnvSpark::CreateSpark( void )
{
	CUtlReference<CNewParticleEffect> pEffect = CNewParticleEffect::CreateOrAggregate( NULL, "asw_env_sparks", GetAbsOrigin(), NULL );
	if ( pEffect )
	{
		pEffect->SetControlPoint( 0, GetAbsOrigin() );
		pEffect->SetControlPointOrientation( 0, Forward(), -Left(), Up() );
		pEffect->SetControlPoint( 2, Vector( GetRenderColorR(), GetRenderColorG(), GetRenderColorB() ) );
		float flMagnitude = m_flMagnitude/100;
		float flElecReduction = 1.0f;
		float flCollide = (m_flPercentCollide/100);
		float flAmtElectrical = 0;
		if ( m_bElectrical )
		{
			flAmtElectrical = flMagnitude;
			flElecReduction = 0.6;
		}

		pEffect->SetControlPoint( 3, Vector( ((1.0f-flCollide)* flMagnitude)*flElecReduction, (flCollide*flMagnitude)*flElecReduction, flMagnitude ) );
		pEffect->SetControlPoint( 4, Vector( flAmtElectrical, 0, 0 ) );
		//Msg( "Spark - Magnitude = %f\n", flMagnitude );
	}

	if ( m_bPlaySound )
	{
		EmitSound( "DoSpark" );
	}
}