本文整理汇总了C++中CSmartPtr::SetCollisionDamped方法的典型用法代码示例。如果您正苦于以下问题:C++ CSmartPtr::SetCollisionDamped方法的具体用法?C++ CSmartPtr::SetCollisionDamped怎么用?C++ CSmartPtr::SetCollisionDamped使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSmartPtr
的用法示例。
在下文中一共展示了CSmartPtr::SetCollisionDamped方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FX_AirboatGunImpact
//-----------------------------------------------------------------------------
// Purpose:
// Input : &origin -
// &normal -
// scale -
//-----------------------------------------------------------------------------
void FX_AirboatGunImpact( const Vector &origin, const Vector &normal, float scale )
{
#ifdef _XBOX
Vector offset = origin + ( normal * 1.0f );
CSmartPtr<CTrailParticles> sparkEmitter = CTrailParticles::Create( "FX_MetalSpark 1" );
if ( sparkEmitter == NULL )
return;
//Setup our information
sparkEmitter->SetSortOrigin( offset );
sparkEmitter->SetFlag( bitsPARTICLE_TRAIL_VELOCITY_DAMPEN );
sparkEmitter->SetVelocityDampen( 8.0f );
sparkEmitter->SetGravity( 800.0f );
sparkEmitter->SetCollisionDamped( 0.25f );
sparkEmitter->GetBinding().SetBBox( offset - Vector( 32, 32, 32 ), offset + Vector( 32, 32, 32 ) );
int numSparks = random->RandomInt( 4, 8 );
TrailParticle *pParticle;
PMaterialHandle hMaterial = sparkEmitter->GetPMaterial( "effects/spark" );
Vector dir;
float length = 0.1f;
//Dump out sparks
for ( int i = 0; i < numSparks; i++ )
{
pParticle = (TrailParticle *) sparkEmitter->AddParticle( sizeof(TrailParticle), hMaterial, offset );
if ( pParticle == NULL )
return;
pParticle->m_flLifetime = 0.0f;
pParticle->m_flDieTime = random->RandomFloat( 0.05f, 0.1f );
float spreadOfs = random->RandomFloat( 0.0f, 2.0f );
dir[0] = normal[0] + random->RandomFloat( -(0.5f*spreadOfs), (0.5f*spreadOfs) );
dir[1] = normal[1] + random->RandomFloat( -(0.5f*spreadOfs), (0.5f*spreadOfs) );
dir[2] = normal[2] + random->RandomFloat( -(0.5f*spreadOfs), (0.5f*spreadOfs) );
VectorNormalize( dir );
pParticle->m_flWidth = random->RandomFloat( 1.0f, 4.0f );
pParticle->m_flLength = random->RandomFloat( length*0.25f, length );
pParticle->m_vecVelocity = dir * random->RandomFloat( (128.0f*(2.0f-spreadOfs)), (512.0f*(2.0f-spreadOfs)) );
Color32Init( pParticle->m_color, 255, 255, 255, 255 );
}
#else
// Normal metal spark
FX_MetalSpark( origin, normal, normal, (int) scale );
#endif // _XBOX
// Add a quad to highlite the hit point
FX_AddQuad( origin,
normal,
random->RandomFloat( 16, 32 ),
random->RandomFloat( 32, 48 ),
0.75f,
1.0f,
0.0f,
0.4f,
random->RandomInt( 0, 360 ),
0,
Vector( 1.0f, 1.0f, 1.0f ),
0.05f,
"effects/combinemuzzle2_nocull",
(FXQUAD_BIAS_SCALE|FXQUAD_BIAS_ALPHA) );
}
示例2: FX_MetalSpark
void FX_MetalSpark(const Vector &position, const Vector &direction, const Vector &surfaceNormal, int iScale)
{
VPROF_BUDGET("FX_MetalSpark", VPROF_BUDGETGROUP_PARTICLE_RENDERING);
if (!fx_drawmetalspark.GetBool())
return;
//
// Emitted particles
//
Vector offset = position + (surfaceNormal * 1.0f);
CSmartPtr<CTrailParticles> sparkEmitter = CTrailParticles::Create("FX_MetalSpark 1");
if (sparkEmitter == NULL)
return;
//Setup our information
sparkEmitter->SetSortOrigin(offset);
sparkEmitter->SetFlag(bitsPARTICLE_TRAIL_VELOCITY_DAMPEN);
sparkEmitter->SetVelocityDampen(8.0f);
sparkEmitter->SetGravity(METAL_SPARK_GRAVITY);
sparkEmitter->SetCollisionDamped(METAL_SPARK_DAMPEN);
sparkEmitter->GetBinding().SetBBox(offset - Vector(32, 32, 32), offset + Vector(32, 32, 32));
int numSparks = random->RandomInt(4, 8) * (iScale * 2);
numSparks = (int) (0.5f + (float) numSparks * g_pParticleSystemMgr->ParticleThrottleScaling());
if (g_Material_Spark == NULL)
{
g_Material_Spark = sparkEmitter->GetPMaterial("effects/spark");
}
TrailParticle *pParticle;
Vector dir;
float length = 0.1f;
//Dump out sparks
for (int i = 0; i < numSparks; i++)
{
pParticle = (TrailParticle *) sparkEmitter->AddParticle(sizeof(TrailParticle), g_Material_Spark, offset);
if (pParticle == NULL)
return;
pParticle->m_flLifetime = 0.0f;
if (iScale > 1 && i % 3 == 0)
{
// Every third spark goes flying far if we're having a big batch of sparks.
pParticle->m_flDieTime = random->RandomFloat(0.15f, 0.25f);
}
else
{
pParticle->m_flDieTime = random->RandomFloat(0.05f, 0.1f);
}
float spreadOfs = random->RandomFloat(0.0f, 2.0f);
dir[0] = direction[0] + random->RandomFloat(-(METAL_SPARK_SPREAD*spreadOfs), (METAL_SPARK_SPREAD*spreadOfs));
dir[1] = direction[1] + random->RandomFloat(-(METAL_SPARK_SPREAD*spreadOfs), (METAL_SPARK_SPREAD*spreadOfs));
dir[2] = direction[2] + random->RandomFloat(-(METAL_SPARK_SPREAD*spreadOfs), (METAL_SPARK_SPREAD*spreadOfs));
VectorNormalize(dir);
pParticle->m_flWidth = random->RandomFloat(1.0f, 4.0f);
pParticle->m_flLength = random->RandomFloat(length*0.25f, length);
pParticle->m_vecVelocity = dir * random->RandomFloat((METAL_SPARK_MINSPEED*(2.0f - spreadOfs)), (METAL_SPARK_MAXSPEED*(2.0f - spreadOfs)));
Color32Init(pParticle->m_color, 255, 255, 255, 255);
}
//
// Impact point glow
//
FXQuadData_t data;
data.SetMaterial("effects/yellowflare");
data.SetColor(1.0f, 1.0f, 1.0f);
data.SetOrigin(offset);
data.SetNormal(surfaceNormal);
data.SetAlpha(1.0f, 0.0f);
data.SetLifeTime(0.1f);
data.SetYaw(random->RandomInt(0, 360));
int scale = random->RandomInt(24, 28);
data.SetScale(scale, 0);
FX_AddQuad(data);
}