VisParticleEffectFile_cl* VisParticleGroupManager_cl::LoadFromFile(const char *szFilename, bool bForceUnique) { VisParticleEffectFile_cl *pFile; g_sLastError.Reset(); if (!bForceUnique) { // already in resource list? Then return that one pFile = (VisParticleEffectFile_cl *)VResourceManager::GetResourceByName(szFilename); if(pFile) { if(!pFile->IsLoaded()) pFile->EnsureLoaded(); return pFile; } } // create a new one and try to load it from file pFile = new VisParticleEffectFile_cl(this); if (!pFile->LoadFromFile(szFilename)) { pFile->Purge(); return NULL; } return pFile; }
VisParticleGroupDescriptor_cl *VisParticleGroupManager_cl::DoArchiveExchange(VArchive &ar, VisParticleGroupDescriptor_cl *pSource) { if (ar.IsLoading()) { VString fxname,descname; ar >> fxname; ar >> descname; VisParticleEffectFile_cl* pFX = LoadFromFile(fxname); if (!pFX) return NULL; return pFX->FindDescriptor(descname); } else
VisParticleGroupDescriptor_cl *VisParticleGroupManager_cl::FindDescriptor(const char *szName) const { const int iCount = GetResourceCount(); for (int i=0;i<iCount;i++) { VisParticleEffectFile_cl *pFX = (VisParticleEffectFile_cl *)VisResourceManager_cl::GetResourceByIndex(i); if (!pFX) continue; VisParticleGroupDescriptor_cl *pDesc = pFX->FindDescriptor(szName); if (pDesc) return pDesc; } return NULL; }
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; }