|
VR-Engage
2.3
|
The DtEngineAudioUpdater provides realistic audio simulation for vehicle engines. It dynamically modulates sound pitch and volume based on engine RPM or speed values, applies smoothing to prevent jitter, and positions sounds in 3D space based on the entity's location.
The component supports multiple engine sounds with different characteristics and can tie sound playback to an engine on/off state attribute.
#include <engineAudioUpdater.h>
Classes | |
| struct | EngineSound |
Public Member Functions | |
| DtEngineAudioUpdater () | |
| virtual | ~DtEngineAudioUpdater () override |
| virtual bool | initialize (DtPlayerStation *player, DtInitTable &config) override |
| virtual void | tick (double dt) override |
| virtual void | shutdown () override |
| virtual const char * | type () const override |
Public Member Functions inherited from makVre::DtPlayerComponent | |
| DtPlayerComponent () | |
| virtual | ~DtPlayerComponent () |
| virtual bool | postInitialize () |
| bool | componentReady () const |
| void | setComponentReady (bool ready) |
| virtual DtInitTickStatus | finalizeInitTick (double dt) |
| virtual void | setName (const std::string &name) |
| virtual const std::string & | name () |
| virtual DtPlayerStation & | player () |
| virtual DtAttributeHandle & | playerAttributeStore () |
| virtual const DtAttributeHandle & | playerAttributeStore () const |
| virtual const DtAttributeHandle & | ownshipState () const |
| virtual void | setExtendedData (const std::string &key, const std::string &value, DtEntityIdentifier entity=DtEntityIdentifier::nullId()) |
Protected Attributes | |
| DtAttributeHandleType< bool > | myEngineOnAttr |
| std::vector< EngineSound > | myEngineSounds |
| bool | myWarnedAboutMissingEngineStateVar |
Protected Attributes inherited from makVre::DtPlayerComponent | |
| bool | myComponentReady = true |
| std::string | myName |
| DtInitTable | myConfig |
| DtPlayerStation * | myPlayer |
| makVrv::DtDe * | myDe |
| DtEntityResolver * | myResolver |
| DtAttributeCallbackManager | myAttributeCallbacks |
| DtVreMessageHandlerGroup | myMessageHandlers |
Additional Inherited Members | |
Protected Member Functions inherited from makVre::DtPlayerComponent | |
| virtual void | initializeStateAttributes () |
| makVre::DtEngineAudioUpdater::DtEngineAudioUpdater | ( | ) |
Constructor for DtEngineAudioUpdater.
Initializes the component with the name "DtEngineAudioUpdater".
|
overridevirtual |
Virtual destructor for DtEngineAudioUpdater.
Ensures proper cleanup of audio resources when the component is destroyed.
|
overridevirtual |
Initializes the component with configuration from Lua.
Sets up audio sources based on the provided configuration. Each source is configured with its associated RPM attribute, maximum RPM value, pitch range, smoothing factor, gain, and decibel level.
| player | Pointer to the player station this component belongs to |
| config | Configuration table containing initialization parameters, especially the sources table |
Reimplemented from makVre::DtPlayerComponent.
References makVre::DtPlayerComponent::player().
|
overridevirtual |
Updates the audio playback based on RPM state attributes.
Called each frame to manage audio playback. For each configured sound:
| dt | Delta time in seconds since the last tick |
Implements makVre::DtPlayerComponent.
|
overridevirtual |
Shuts down the component.
Cleans up all audio resources by stopping and deleting sounds.
Reimplemented from makVre::DtPlayerComponent.
|
overridevirtual |
Returns the type identifier for this component.
Implements makVre::DtPlayerComponent.
|
protected |
Attribute handle indicating whether the engine is running. The attribute name is configurable via the engineOnAttribute config key. Defaults to "engine-on" if not specified.
| Attribute Store Key | engine-on |
|---|
|
protected |
Collection of engine sounds managed by this component.
|
protected |