示例#1
0
void VolumeFader::getVolumes(std::vector<float> & theVolumes) const {
    // Hack: In a real fade, we want to return the actual volume. In a fade that's
    // just there to prevent clicks, this returns the destination volume.
    if (_myCurrentFrame + DEFAULT_FADE_FRAMES < _myFadeEndFrame) {
        getVolumes(_myCurrentFrame, theVolumes);
    } else {
        theVolumes = _myEndVolumes;
    }
}
示例#2
0
void VolumeFader::setVolumes(std::vector<float> theTargetVolumes, unsigned theFadeDurationFrames) {
    getVolumes(_myBeginVolumes);
    if (theTargetVolumes.size() != _myCurrentVolumes.size()) {
        throw Exception("VolumeFader::setVolumes() - number of volumes doesn't match number of channels", PLUS_FILE_LINE);
    }
    _myEndVolumes = theTargetVolumes; 
    _myFadeBeginFrame = _myCurrentFrame;
    _myFadeEndFrame = _myCurrentFrame + theFadeDurationFrames;
}
void MissionLighting::loadMission()
{
   print( V_MEDIUM, "Loading mission ( %s )...", missionFile );
   
   Persistent::Base::Error err;
   Persistent::Base * base = Persistent::Base::fileLoad( missionFile.c_str(), &err );
   
#ifdef FEAR
   // check if should attempt to load as a script...
   if( !base || !( err == Persistent::Base::Ok ) )
   {
      CMDConsole * con = CMDConsole::getLocked();
      con->evaluate( "setInstantGroup(0);" );
      con->executef( 2, "exec", missionFile.c_str() );
   }

   // check that it loaded up
   mission = (SimGroup *)manager->findObject( "MissionGroup" );
   
   _assert( mission, "Invalid mission file: %s\n", missionFile );
#else // STARSIEGE

   _assert( base && ( err == Persistent::Base::Ok ), "Failed to open mission file: %s\n", 
   missionFile );
   
   mission = dynamic_cast<SimGroup *>( base );
   _assert( mission, "Invalid mission file: %s\n", missionFile );
      
   manager->addObject( mission, "MissionGroup" );
#endif

   print( V_MEDIUM, "done.\n" );
   
   // get all the interiors and lights
   print( V_MEDIUM, "Grabbing mission lights, interiors and volumes\n" );
   getInteriors( mission );
   getLights( mission );
   getVolumes( mission );
   getTerrains( mission );
   
   print( V_LOW, "Found %d interiors.\n", m_interiors.size() );
   print( V_LOW, "Found %d lights.\n", m_lights.size() );
   print( V_LOW, "Found %d volumes.\n", m_volumes.size() );
   print( V_LOW, "Found %d terrains.\n", m_terrains.size() );
}
void MissionLighting::getVolumes( SimSet * set )
{
   AssertFatal( set, "Invalid SimSet object!" );
   
   // walk it
   for( SimSet::iterator itr = set->begin(); itr != set->end(); itr++ )
   {
      SimSet * ss = dynamic_cast<SimSet * >( *itr );
      if( ss )
         getVolumes( ss );
         
      // check if a simvolume
      SimVolume * vol = dynamic_cast< SimVolume * >( *itr );
      if( vol )
      {
         m_volumes.push_back( vol );
         print( V_LOWEST, " - volume: %s\n", vol->getName() );
      }
   }
}
示例#5
0
float VolumeFader::getVolume(Unsigned64 theFrame) const {
    std::vector<float> myVolumes;
    getVolumes(theFrame, myVolumes);
    return accumulate(myVolumes.begin(), myVolumes.end(),0.0f) / myVolumes.size();
}
示例#6
0
float VolumeFader::getVolume() const {
    std::vector<float> myVolumes;
    getVolumes(myVolumes);
    return accumulate(myVolumes.begin(), myVolumes.end(), 0.0f) / myVolumes.size();
}