Example #1
0
bool CGodRaysEffect::SetMaterialParms( const Vector& vLightPos )
{
	int nSunX, nSunY;
	bool bOnScreen = GetVectorInHudSpace( vLightPos, nSunX, nSunY );

	if( bOnScreen )
	{
		// Set the material parameters.
		m_pGrDecayVar->SetFloatValue( gfx_gr_decay.GetFloat() );
		m_pGrDensityVar->SetFloatValue( gfx_gr_density.GetFloat() );
		m_pGrExposureVar->SetFloatValue( gfx_gr_exposure.GetFloat() );
		m_pGrWeightVar->SetFloatValue( gfx_gr_weight.GetFloat() );

		// Set the sun position.
		float flSunX = float( nSunX ) / float( ScreenWidth() );
		float flSunY = float( nSunY ) / float( ScreenHeight() );
		m_pGrSunPosVar->SetVecValue(flSunX, flSunY);
	}

	return bOnScreen;
#if 0
	// Convert from 3d to 2d.
	Vector vLightPos2d;
	int behind = ScreenTransform( vLightPos, vLightPos2d );

	if( behind == 0 )
	{
		m_pGrDecayVar->SetFloatValue( gfx_gr_decay.GetFloat() );
		m_pGrDensityVar->SetFloatValue( gfx_gr_density.GetFloat() );
		m_pGrExposureVar->SetFloatValue( gfx_gr_exposure.GetFloat() );
		m_pGrWeightVar->SetFloatValue( gfx_gr_weight.GetFloat() );
		
		int sunX, sunY;
		GetVectorInScreenSpace( vLightPos, sunX, sunY );
		m_pGrSunPosVar->SetVecValue( sunX / ScreenWidth(), sunY / ScreenHeight() );

		return true;
	}

	return false;
#endif
}
Example #2
0
//-----------------------------------------------------------------------------
// Purpose: Get the x & y positions of an entity in Vgui space
//			Returns true if it's onscreen
//-----------------------------------------------------------------------------
bool GetTargetInHudSpace( C_BaseEntity *pTargetEntity, int& iX, int& iY, Vector *vecOffset )
{
	return GetVectorInHudSpace( pTargetEntity->WorldSpaceCenter(), iX, iY, vecOffset );
}