Пример #1
0
void Vehicle::CacheEffects()
{
	VisParticleEffectFile_cl* fxDustTrail = VisParticleGroupManager_cl::GlobalManager().LoadFromFile("Particles\\Car_DustTrail_Sand_SingleTire.xml");
	VASSERT(fxDustTrail);
	VisParticleEffectFile_cl* fxTyreMark = VisParticleGroupManager_cl::GlobalManager().LoadFromFile("Particles\\Car_Tyremark_Sand.xml");
	VASSERT(fxTyreMark);

	for (int wi = 0; wi < 4; wi ++)
	{
		m_wheelFX[wi] = fxDustTrail->CreateParticleEffectInstance(hkvVec3(0.f, 0.f, 0.f), hkvVec3(0.f, 0.f, 0.f), 1.0f);
		m_tyremarkFX[wi] = fxTyreMark->CreateParticleEffectInstance(hkvVec3(0.f, 0.f, 0.f), hkvVec3(0.f, 0.f, 0.f), 1.0f);

		// Tweak the particle color
		m_wheelFX[wi]->SetAmbientColor(VColorRef(75, 75, 75, 255));
		m_tyremarkFX[wi]->SetAmbientColor(VColorRef(75, 75, 75, 255));
	}
}
VisParticleEffect_cl* RPG_VisionEffectHelper::CreateParticleEffect(VString const& particleFilename, hkvVec3 const& position /*= hkvVec3(0.f, 0.f, 0.f)*/, hkvVec3 const& orientation /*= hkvVec3(0.f, 0.f, 0.f)*/)
{
    VASSERT(!particleFilename.IsEmpty());

    VisParticleEffectFile_cl *effectResource = static_cast<VisParticleEffectFile_cl *> (GetEffectResource("Particles", particleFilename.AsChar()));
    if (effectResource)
    {
        VisParticleEffect_cl* effect = effectResource->CreateParticleEffectInstance(position, orientation);

        if(effect)
        {
            for (int index = 0; index < effect->GetParticleGroupCount(); ++index)
            {
                effect->GetParticleGroup(index)->SetUpdateLifetimeIfInvisible(true);
            }
        }

        return effect;
    }

    return NULL;
}