void VFmodAnimationEventSoundTrigger::OnAnimationEvent() { // Get the active event trigger info VFmodEventSoundTriggerInfo_t* info = (VFmodEventSoundTriggerInfo_t*) m_pActiveTriggerInfo; // Check if effect file is specified if (info == NULL || info->m_spSoundResource == NULL) return; // Get entity position VisBaseEntity_cl* pEntity = (VisBaseEntity_cl *)m_pOwner; hkvVec3 vPos = pEntity->GetPosition(); // Trigger sound effect VFmodSoundObject* pSound = info->m_spSoundResource->CreateInstance(vPos, VFMOD_FLAG_NONE); if(pSound) pSound->Play(); }
VFmodSoundObject *RPG_VisionEffectHelper::CreateSoundEffect(RPG_VisionEffectSoundParams const& params) { VASSERT(VFmodManager::GlobalManager().IsInitialized()); // ensure that the native Fmod system has been correctly initialized VFmodSoundResource *soundResource = static_cast<VFmodSoundResource *> (GetEffectResource("FmodSoundResource", params.m_soundFilename)); VASSERT_MSG(soundResource, params.m_soundFilename); if (soundResource) { VFmodSoundObject *soundObject = soundResource->CreateInstance(params.m_position, VFMOD_FLAG_NONE); VASSERT_MSG(soundObject->IsValid(), params.m_soundFilename); if (soundObject->IsValid()) { soundObject->Play(); } } return NULL; }
// -------------------------------------------------------------------------- // // Instances // -------------------------------------------------------------------------- // VFmodSoundObject* VFmodManager::CreateSoundInstance(const char *szFilename, int iResourceUsageFlags, int iInstanceFlags, int iPriority) { VFmodSoundResource *pRes = LoadSoundResource(szFilename, iResourceUsageFlags); if (!pRes) return NULL; // Note: Create all sound objects here as paused as we need to set AND update the // correct distance and attenuation first! Call Play() afterwards it set. VFmodSoundObject* pObj = pRes->CreateInstance(hkvVec3(0.0f,0.0f,0.0f), iInstanceFlags | VFMOD_FLAG_PAUSED, iPriority); if (pObj) { // Force sound source position update pObj->OnObject3DChanged(VisObject3D_cl::VIS_OBJECT3D_POSCHANGED); // Play if set if((iInstanceFlags & VFMOD_FLAG_PAUSED) == 0) pObj->Play(); } return pObj; }