VFmodEvent* RPG_VisionEffectHelper::PlayFmodSoundEvent(VString const& eventGroupName, VString const& eventName, hkvVec3 const& position /*= hkvVec3(0.0f,0.0f,0.0f)*/, int flags/*=VFMOD_FLAG_NONE*/)
{
    VASSERT(!eventGroupName.IsEmpty());   // Name of the event group, relative to the event project
    VASSERT(!eventName.IsEmpty());        // name of the event, relative to the parent event-group

    VString const& eventProjectPath = RPG_GameManager::s_instance.GetFmodEventProject();
    VASSERT_MSG(!eventProjectPath.IsEmpty(), "Please ensure that GameManager::FMOD_EVENT_PROJECT points to a valid FMOD project file.");

#if (defined _DEBUG) && !(RPG_FMOD_SUPPRESS_NONNULL_ASSERTS)
    // @for testing only: validate the project filename
    FMOD::EventProject* pEventProject = VFmodManager::GlobalManager().LoadEventProject(eventProjectPath.AsChar());
    VASSERT_MSG(pEventProject, eventProjectPath.AsChar());
#endif

    // load event group
    VFmodEventGroup *pEventGroup = VFmodManager::GlobalManager().LoadEventGroup(eventProjectPath.AsChar(), eventGroupName.AsChar());
#if !(RPG_FMOD_SUPPRESS_NONNULL_ASSERTS)
    VASSERT_MSG(pEventGroup && pEventGroup->IsValid(), eventGroupName.AsChar());
#endif

    if (pEventGroup && pEventGroup->IsValid())
    {
        // create event instance
        VFmodEvent *pEvent = pEventGroup->CreateEvent(eventName.AsChar(), position, flags);
        VASSERT_MSG(pEvent && pEvent->IsValid(), eventName.AsChar());
        return pEvent;
    }
    return NULL;
}
bool RPG_VisionEffectHelper::LoadFmodEventGroup(VString const& eventGroupName)
{
    VString const& eventProjectPath = RPG_GameManager::s_instance.GetFmodEventProject();
    VASSERT_MSG(!eventProjectPath.IsEmpty(), "Please ensure that GameManager::FMOD_EVENT_PROJECT points to a valid FMOD project file.");

    VFmodEventGroup *pEventGroup = VFmodManager::GlobalManager().LoadEventGroup(eventProjectPath.AsChar(), eventGroupName.AsChar());
    VASSERT_MSG(pEventGroup && pEventGroup->IsValid(), eventGroupName.AsChar());

    return pEventGroup->IsValid();
}
Exemplo n.º 3
0
VFmodEvent* VFmodManager::CreateEvent(const char *szEventProjectPath, const char *szEventName, int iFlags)
{
  VASSERT(szEventProjectPath!=NULL && szEventName!=NULL); 
  char szEventGroupName[FS_MAX_PATH];
  VFileHelper::GetFileDir(szEventName, szEventGroupName);
  const char *szEventRelativeName = VFileHelper::GetFilename(szEventName);

  VFmodEventGroup *pEventGroup = LoadEventGroup(szEventProjectPath, szEventGroupName);
  if (!pEventGroup)
    return NULL;

  VFmodEvent* pEvent = pEventGroup->CreateEvent(szEventRelativeName, hkvVec3(0.0f,0.0f,0.0f), iFlags | VFMOD_FLAG_PAUSED);
  if (pEvent)
  {
    // Force event position update
    pEvent->OnObject3DChanged(VisObject3D_cl::VIS_OBJECT3D_POSCHANGED);

    // Play if set
    if((iFlags & VFMOD_FLAG_PAUSED) == 0)
      pEvent->Start();
  }

  return pEvent;
}
Exemplo n.º 4
0
VFmodEventGroup* VFmodManager::LoadEventGroup(const char *szEventProjectPath, const char *szEventGroupName)
{
  VASSERT(szEventProjectPath!=NULL && szEventGroupName!=NULL);

  VFmodEventGroup *pEventGroup = NULL;

  // make absolute filenames comparable
  if (szEventProjectPath[0]=='\\' || szEventProjectPath[0]=='/') szEventProjectPath++; 
  if (szEventGroupName[0]=='\\' || szEventGroupName[0]=='/') szEventGroupName++; 

  // concatenate project-path and group-name into one string separated by '|', in order to be able 
  // to implement VFmodEventGroupManager::CreateResource()
  VStaticString<2*FS_MAX_PATH> sResourceName(szEventProjectPath);
  VFileHelper::GetFilenameNoExt(sResourceName, szEventProjectPath); // ensure, that project-path has no .fdp extension
  sResourceName += "|";
  sResourceName += szEventGroupName;

  int iCount = m_pEventGroupManager->GetResourceCount();
  const unsigned int iResourceNameHash = VPathHelper::GetHash(sResourceName);
  for (int i=0;i<iCount;i++) 
  {
    pEventGroup = (VFmodEventGroup*)m_pEventGroupManager->GetResourceByIndex(i);
    if (!pEventGroup || !pEventGroup->GetFilename() || !pEventGroup->GetFilename()[0])
      continue;
    if (!pEventGroup->CompareFileName(sResourceName, iResourceNameHash)) 
      continue;
    return pEventGroup;
  }
 
  // create a new event group
  pEventGroup = new VFmodEventGroup(m_pEventGroupManager);
  pEventGroup->SetFilename(sResourceName);
  pEventGroup->EnsureLoaded();

  return pEventGroup;
}