sound asset conversions - ambience

This commit is contained in:
AzaezelX 2021-10-14 22:31:00 -05:00
parent f0d919e859
commit 9ab5f61c39
4 changed files with 20 additions and 13 deletions

View file

@ -85,10 +85,10 @@ SFXAmbience::ChangeSignal SFXAmbience::smChangeSignal;
SFXAmbience::SFXAmbience()
: mDopplerFactor( 0.5f ),
mRolloffFactor( 1.f ),
mSoundTrack( NULL ),
mEnvironment( NULL )
{
dMemset( mState, 0, sizeof( mState ) );
INIT_ASSET(SoundTrack);
}
//-----------------------------------------------------------------------------
@ -100,7 +100,7 @@ void SFXAmbience::initPersistFields()
addField( "environment", TypeSFXEnvironmentName, Offset( mEnvironment, SFXAmbience ),
"Reverb environment active in the ambience zone.\n"
"@ref SFX_reverb" );
addField( "soundTrack", TypeSFXTrackName, Offset( mSoundTrack, SFXAmbience ),
INITPERSISTFIELD_SOUNDASSET(SoundTrack, SFXAmbience,
"Sound track to play in the ambience zone." );
addField( "rolloffFactor", TypeF32, Offset( mRolloffFactor, SFXAmbience ),
"The rolloff factor to apply to distance-based volume attenuation in this space.\n"
@ -131,7 +131,8 @@ bool SFXAmbience::onAdd()
return false;
Sim::getSFXAmbienceSet()->addObject( this );
_setSoundTrack(getSoundTrack());
return true;
}
@ -150,9 +151,13 @@ bool SFXAmbience::preload( bool server, String& errorStr )
{
if( !sfxResolve( &mEnvironment, errorStr ) )
return false;
if( !sfxResolve( &mSoundTrack, errorStr ) )
_setSoundTrack(getSoundTrack());
if (!getSoundTrackProfile())
{
Con::errorf("SFXAmbience::Preload() - unable to find sfxProfile for asset %s", mSoundTrackAssetId);
return false;
}
for( U32 i = 0; i < MaxStates; ++ i )
if( !sfxResolve( &mState[ i ], errorStr ) )
@ -169,7 +174,7 @@ void SFXAmbience::packData( BitStream* stream )
Parent::packData( stream );
sfxWrite( stream, mEnvironment );
sfxWrite( stream, mSoundTrack );
PACKDATA_ASSET(SoundTrack);
stream->write( mRolloffFactor );
stream->write( mDopplerFactor );
@ -185,7 +190,7 @@ void SFXAmbience::unpackData( BitStream* stream )
Parent::unpackData( stream );
sfxRead( stream, &mEnvironment );
sfxRead( stream, &mSoundTrack );
UNPACKDATA_ASSET(SoundTrack);
stream->read( &mRolloffFactor );
stream->read( &mDopplerFactor );

View file

@ -33,6 +33,9 @@
#include "core/util/tSignal.h"
#endif
#ifndef SOUND_ASSET_H
#include "T3D/assets/SoundAsset.h"
#endif
class SFXEnvironment;
class SFXTrack;
@ -63,7 +66,8 @@ class SFXAmbience : public SimDataBlock
F32 mRolloffFactor;
/// Sound track to play when inside the ambient space.
SFXTrack* mSoundTrack;
DECLARE_SOUNDASSET(SFXAmbience, SoundTrack);
DECLARE_ASSET_SETGET(SFXAmbience, SoundTrack);
/// Reverb environment to apply when inside the ambient space.
SFXEnvironment* mEnvironment;
@ -89,10 +93,7 @@ class SFXAmbience : public SimDataBlock
/// Return the reverb environment of the ambient space.
SFXEnvironment* getEnvironment() const { return mEnvironment; }
/// Return the ambient soundtrack of this ambient space.
SFXTrack* getSoundTrack() const { return mSoundTrack; }
/// Return the given state bound to this ambient space.
SFXState* getState( U32 i ) const
{

View file

@ -150,7 +150,7 @@ void SFXSoundscapeManager::update()
if( !soundscape->_isOverridden() )
{
SFXTrack* track = ambience->getSoundTrack();
SFXTrack* track = ambience->getSoundTrackProfile();
if( !soundscape->mSource || soundscape->mSource->getTrack() != track )
{
if( soundscape->mSource != NULL )

View file

@ -1079,6 +1079,7 @@ T3Dpre4ProjectImporter::genProcessor("PostEffect", "texture textureAsset");
// Using existing SFXProfiles allows us to also injest the descriptions, giving us
// our meta-properties on the sound asset itself.
//==============================================================================
T3Dpre4ProjectImporter::genProcessor("SFXAmbience", "soundTrack soundTrackAsset");
function T3Dpre4ProjectImporter::processSFXProfileLine(%this, %line)
{
return %line;