 |
RigsofRods
Soft-body Physics Simulation
|
Go to the documentation of this file.
33 #include <OgreVector3.h>
34 #include <OgreString.h>
37 #include <OpenAL/al.h>
38 #include <OpenAL/alc.h>
39 #include <OpenAL/alext.h>
40 #include <OpenAL/efx-presets.h>
45 #include <AL/efx-presets.h>
87 void Update(
const float dt);
114 void SetListener(Ogre::Vector3 position, Ogre::Vector3 direction, Ogre::Vector3 up, Ogre::Vector3 velocity);
144 void SetSpeedOfSound(
const float speed_of_sound)
const { alSpeedOfSound(speed_of_sound); }
155 void SetDopplerFactor(
const float doppler_factor)
const { alDopplerFactor(doppler_factor); }
163 void SetDopplerFactor(
const ALuint hardware_source,
const float doppler_factor)
const;
195 const EFXEAXREVERBPROPERTIES*
GetEfxProperties(
const std::string& efx_preset_name)
const;
232 void recomputeSource(
int source_index,
int reason,
float vfl, Ogre::Vector3 *vvec);
246 void assign(
int source_index,
int hardware_index);
252 void retire(
int source_index);
254 bool loadWAVFile(Ogre::String filename, ALuint buffer, Ogre::String resource_group_name =
"");
316 ALuint
CreateAlEffect(
const EFXEAXREVERBPROPERTIES* efx_properties)
const;
386 bool UpdateOcclusionFilter(
const int hardware_index,
const ALuint effect_slot_id,
const EFXEAXREVERBPROPERTIES* reference_efx_reverb_properties)
const;
404 const Ogre::Vector3& cone_direction,
405 const float cone_inner_angle,
406 const float cone_outer_angle,
407 const float cone_outer_gain,
408 const float cone_outer_gain_hf
Game state manager and message-queue provider.
void pauseAllSounds()
Unlike the name suggests, this sets the listener's gain to 0, essentially muting all sounds.
int audio_buffers_in_use_count
static const unsigned int MAX_HARDWARE_SOURCES
void UpdateAlListener()
Updates the listener's position, orientation and velocity vectors in OpenAL.
LPALDELETEEFFECTS alDeleteEffects
LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots
LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf
bool loadWAVFile(Ogre::String filename, ALuint buffer, Ogre::String resource_group_name="")
Ogre::Vector3 GetListenerPosition() const
Returns the position vector of the listener.
const EFXEAXREVERBPROPERTIES * GetEfxProperties(const std::string &efx_preset_name) const
Returns a pointer to properties of an EFX preset stored in the EFX properties map.
float m_air_absorption_factor
float GetSpeedOfSound() const
void assign(int source_index, int hardware_index)
Adds an audio source to hardware source.
void setMasterVolume(float v)
Updates both CVar audio_master_volume and the listener's gain to the provided value.
void SetListener(Ogre::Vector3 position, Ogre::Vector3 direction, Ogre::Vector3 up, Ogre::Vector3 velocity)
Sets position and speed of the listener.
void UpdateListenerEffectSlot(const float dt)
Dynamically adjusts some parameters of the currently active reverb preset based on the current enviro...
void recomputeSource(int source_index, int reason, float vfl, Ogre::Vector3 *vvec)
Computes audibility of an audio source and retires it if it is inaudible.
ALuint getHardwareSource(int hardware_index)
Returns the AL handle for the hardware source with the provided index.
void SetSpeedOfSound(const float speed_of_sound) const
Updates the speed of sound in OpenAL with the provided value.
ALuint hardware_sources[MAX_HARDWARE_SOURCES]
void PrepopulateEfxPropertiesMap()
Helper function that fills the m_efx_properties_map with presets provided by OpenAL's efx-presets....
static const float REFERENCE_DISTANCE
ALuint CreateAlEffect(const EFXEAXREVERBPROPERTIES *efx_properties) const
Creates an OpenAL effect based on the parameters of an efx/eax reverb preset.
LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots
Ogre::Vector3 m_listener_velocity
static const unsigned int MAX_AUDIO_BUFFERS
LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot
void DeleteAlEffect(const ALuint efx_effect_id) const
Deletes an OpenAL effect.
Ogre::Vector3 m_listener_position
int hardware_sources_num
total number of allocated hardware sources (<= MAX_HARDWARE_SOURCES)
bool IsHardwareSourceObstructed(const int hardware_index) const
Performs various checks against the environment of the listener to determine whether the sound belong...
bool ListenerIsUnderwater() const
void UpdateObstructionFilter(const int hardware_index, const bool enable_obstruction_filter) const
Applies an obstruction filter to the provided hardware source.
void retire(int source_index)
Stops and the removes an audio source from hardware source.
float GetDopplerFactor() const
void SetAirAbsorptionFactor(const float air_absorption_factor)
Sets the air absorptions factor for the direct path of all sounds.
void UpdateSourceFilters(const int hardware_index) const
Helper function to call several other functions to update source filters.
ALuint m_efx_occlusion_wet_path_lowpass_filter_id
SoundPtr createSound(Ogre::String filename, Ogre::String resource_group_name="")
void UpdateDirectedSounds() const
Updates AL Cones for sources of directed sound emissions (exhausts, turboprops and turbojets).
const EFXEAXREVERBPROPERTIES * m_listener_efx_reverb_properties
void SmoothlyUpdateAlAuxiliaryEffectSlot(const float dt, const ALuint slot_id, const EFXEAXREVERBPROPERTIES *target_efx_properties)
This performs a smooth update of the efx properties of an OpenAL Auxiliary Effect slot using linear i...
SoundPtr audio_sources[MAX_AUDIO_BUFFERS]
void Update(const float dt)
Does the per-frame update of sounds and listener environment.
LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti
int getNumHardwareSources()
Returns the number of currently used hardware sources.
LPALDELETEFILTERS alDeleteFilters
void resumeAllSounds()
Unlike the name suggests, this sets the listener's gain to the value of the CVar audio_master_volume.
std::map< std::string, EFXEAXREVERBPROPERTIES > m_efx_properties_map
ALuint m_efx_occlusion_wet_path_send_id
int hardware_sources_map[MAX_HARDWARE_SOURCES]
maps from the index of a hardware source to the index of the audio source currently assigned to the c...
void UpdateListenerEnvironment()
Determines several properties of the environment of the listener and updates OpenAL to use them.
void CleanUp()
Cleans up various objects that should be reset when returning from a terrain to the main menu.
void UpdateGlobalDopplerFactor() const
Updates the global Doppler factor based on CVar settings and the state of the physics simulation.
Central state/object manager and communications hub.
void UpdateConeProperties(const ALuint source, const Ogre::Vector3 &cone_direction, const float cone_inner_angle, const float cone_outer_angle, const float cone_outer_gain, const float cone_outer_gain_hf) const
Updates the Cone properties for the hardware source.
int hardware_sources_in_use_count
void recomputeAllSources()
void UpdateEfxSpecificProperties(const float dt)
Updates properties of OpenAL facilities that are only available with EFX.
ALCcontext * sound_context
LPALGENFILTERS alGenFilters
bool m_listener_is_underwater
EfxReverbEngine m_efx_reverb_engine
static const float MAX_DISTANCE
LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv
const EFXEAXREVERBPROPERTIES * GetReverbPresetAt(Ogre::Vector3 position) const
Determines which reverb preset corresponds to the provided position and returns its properties.
ALuint m_efx_outdoor_obstruction_lowpass_filter_id
bool UpdateOcclusionFilter(const int hardware_index, const ALuint effect_slot_id, const EFXEAXREVERBPROPERTIES *reference_efx_reverb_properties) const
Applies an occlusion filter to the provided source if certain conditions apply.
ALuint audio_buffers[MAX_AUDIO_BUFFERS]
Ogre::Vector3 m_listener_direction
Ogre::String audio_buffer_file_name[MAX_AUDIO_BUFFERS]
int m_audio_sources_in_use_count
void SetDopplerFactor(const float doppler_factor) const
Updates the global Doppler factor in OpenAL with the provided value.
const std::map< std::string, EFXEAXREVERBPROPERTIES > & getEfxPropertiesMap() const
Returns currently registered EFX presets.
std::map< ALuint, ALuint > m_efx_effect_id_map
std::pair< int, float > audio_sources_most_audible[MAX_AUDIO_BUFFERS]
LPALGENEFFECTS alGenEffects
std::tuple< Ogre::Vector3, float, float > ComputeEarlyReflectionsProperties() const
Detects surfaces close to the listener and calculates a user-relative (as opposed to listener-relativ...
Ogre::Vector3 m_listener_up
static const float ROLLOFF_FACTOR
void UpdateSourceSpecificDopplerFactor(const int hardware_index) const
Identifies the actor to which the sound corresponding to a hardware source belongs and updates the Do...
float GetAirAbsorptionFactor() const