VR-Engage  2.3
Loading...
Searching...
No Matches
makVre::DtEngineAudioUpdater Class Reference

Detailed Description

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>

Inheritance diagram for makVre::DtEngineAudioUpdater:
[legend]

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 ()
 

Constructor & Destructor Documentation

◆ DtEngineAudioUpdater()

makVre::DtEngineAudioUpdater::DtEngineAudioUpdater ( )

Constructor for DtEngineAudioUpdater.

Initializes the component with the name "DtEngineAudioUpdater".

◆ ~DtEngineAudioUpdater()

virtual makVre::DtEngineAudioUpdater::~DtEngineAudioUpdater ( )
overridevirtual

Virtual destructor for DtEngineAudioUpdater.

Ensures proper cleanup of audio resources when the component is destroyed.

Member Function Documentation

◆ initialize()

virtual bool makVre::DtEngineAudioUpdater::initialize ( DtPlayerStation * player,
DtInitTable & config )
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.

Parameters
playerPointer to the player station this component belongs to
configConfiguration table containing initialization parameters, especially the sources table
Returns
True if initialization succeeds, false otherwise

Reimplemented from makVre::DtPlayerComponent.

References makVre::DtPlayerComponent::player().

◆ tick()

virtual void makVre::DtEngineAudioUpdater::tick ( double dt)
overridevirtual

Updates the audio playback based on RPM state attributes.

Called each frame to manage audio playback. For each configured sound:

  • Reads the associated RPM attribute value
  • Normalizes the value based on the maximum RPM
  • Applies smoothing to reduce jitter
  • Calculates and sets pitch and gain values
  • Updates the sound position to match the entity's location
Parameters
dtDelta time in seconds since the last tick

Implements makVre::DtPlayerComponent.

◆ shutdown()

virtual void makVre::DtEngineAudioUpdater::shutdown ( )
overridevirtual

Shuts down the component.

Cleans up all audio resources by stopping and deleting sounds.

Reimplemented from makVre::DtPlayerComponent.

◆ type()

virtual const char * makVre::DtEngineAudioUpdater::type ( ) const
overridevirtual

Returns the type identifier for this component.

Returns
The type string for DtEngineAudioUpdater

Implements makVre::DtPlayerComponent.

Member Data Documentation

◆ myEngineOnAttr

DtAttributeHandleType<bool> makVre::DtEngineAudioUpdater::myEngineOnAttr
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 Keyengine-on

◆ myEngineSounds

std::vector<EngineSound> makVre::DtEngineAudioUpdater::myEngineSounds
protected

Collection of engine sounds managed by this component.

◆ myWarnedAboutMissingEngineStateVar

bool makVre::DtEngineAudioUpdater::myWarnedAboutMissingEngineStateVar
protected

The documentation for this class was generated from the following file: