mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Converts precipitationData to use sound asset macros
Adds handling for soundProfile fields and lookups of sound assets by SFXProfile name in project importer
This commit is contained in:
parent
328319b853
commit
17d1253ba2
4 changed files with 58 additions and 28 deletions
|
|
@ -127,7 +127,7 @@ ConsoleDocClass( PrecipitationData,
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
PrecipitationData::PrecipitationData()
|
PrecipitationData::PrecipitationData()
|
||||||
{
|
{
|
||||||
soundProfile = NULL;
|
INIT_SOUNDASSET(Sound);
|
||||||
|
|
||||||
INIT_IMAGEASSET(Drop);
|
INIT_IMAGEASSET(Drop);
|
||||||
|
|
||||||
|
|
@ -143,8 +143,7 @@ PrecipitationData::PrecipitationData()
|
||||||
|
|
||||||
void PrecipitationData::initPersistFields()
|
void PrecipitationData::initPersistFields()
|
||||||
{
|
{
|
||||||
addField( "soundProfile", TYPEID< SFXTrack >(), Offset(soundProfile, PrecipitationData),
|
INITPERSISTFIELD_SOUNDASSET(Sound, PrecipitationData, "Looping SFXProfile effect to play while Precipitation is active.");
|
||||||
"Looping SFXProfile effect to play while Precipitation is active." );
|
|
||||||
|
|
||||||
addProtectedField( "dropTexture", TypeFilename, Offset(mDropName, PrecipitationData), &_setDropData, &defaultProtectedGetFn,
|
addProtectedField( "dropTexture", TypeFilename, Offset(mDropName, PrecipitationData), &_setDropData, &defaultProtectedGetFn,
|
||||||
"@brief Texture filename for drop particles.\n\n"
|
"@brief Texture filename for drop particles.\n\n"
|
||||||
|
|
@ -190,7 +189,7 @@ bool PrecipitationData::preload( bool server, String &errorStr )
|
||||||
if( Parent::preload( server, errorStr) == false)
|
if( Parent::preload( server, errorStr) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( !server && !sfxResolve( &soundProfile, errorStr ) )
|
if (!server && (mSoundAsset.isNull() || !mSoundAsset->getSfxProfile()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -200,7 +199,8 @@ void PrecipitationData::packData(BitStream* stream)
|
||||||
{
|
{
|
||||||
Parent::packData(stream);
|
Parent::packData(stream);
|
||||||
|
|
||||||
sfxWrite( stream, soundProfile );
|
PACKDATA_SOUNDASSET(Sound);
|
||||||
|
//sfxWrite( stream, soundProfile );
|
||||||
|
|
||||||
PACKDATA_IMAGEASSET(Drop);
|
PACKDATA_IMAGEASSET(Drop);
|
||||||
|
|
||||||
|
|
@ -217,7 +217,8 @@ void PrecipitationData::unpackData(BitStream* stream)
|
||||||
{
|
{
|
||||||
Parent::unpackData(stream);
|
Parent::unpackData(stream);
|
||||||
|
|
||||||
sfxRead( stream, &soundProfile );
|
UNPACKDATA_SOUNDASSET(Sound);
|
||||||
|
//sfxRead( stream, &soundProfile );
|
||||||
|
|
||||||
UNPACKDATA_IMAGEASSET(Drop);
|
UNPACKDATA_IMAGEASSET(Drop);
|
||||||
|
|
||||||
|
|
@ -598,9 +599,9 @@ bool Precipitation::onNewDataBlock( GameBaseData *dptr, bool reload )
|
||||||
{
|
{
|
||||||
SFX_DELETE( mAmbientSound );
|
SFX_DELETE( mAmbientSound );
|
||||||
|
|
||||||
if ( mDataBlock->soundProfile )
|
if ( mDataBlock->mSoundAsset && mDataBlock->mSoundAsset->getSfxProfile() )
|
||||||
{
|
{
|
||||||
mAmbientSound = SFX->createSource( mDataBlock->soundProfile, &getTransform() );
|
mAmbientSound = SFX->createSource(mDataBlock->mSoundAsset->getSfxProfile(), &getTransform() );
|
||||||
if ( mAmbientSound )
|
if ( mAmbientSound )
|
||||||
mAmbientSound->play();
|
mAmbientSound->play();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "T3D/assets/ImageAsset.h"
|
#include "T3D/assets/ImageAsset.h"
|
||||||
|
#include "T3D/assets/SoundAsset.h"
|
||||||
|
|
||||||
class SFXTrack;
|
//class SFXTrack;
|
||||||
class SFXSource;
|
class SFXSource;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
@ -45,30 +46,32 @@ class PrecipitationData : public GameBaseData
|
||||||
typedef GameBaseData Parent;
|
typedef GameBaseData Parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SFXTrack* soundProfile;
|
//SFXTrack* soundProfile;
|
||||||
|
DECLARE_SOUNDASSET(PrecipitationData, Sound);
|
||||||
|
DECLARE_SOUNDASSET_SETGET(PrecipitationData, Sound);
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(PrecipitationData, Drop, onDropChanged, GFXStaticTextureSRGBProfile); ///< Texture for drop particles
|
DECLARE_IMAGEASSET(PrecipitationData, Drop, onDropChanged, GFXStaticTextureSRGBProfile); ///< Texture for drop particles
|
||||||
DECLARE_IMAGEASSET_SETGET(PrecipitationData, Drop);
|
DECLARE_IMAGEASSET_SETGET(PrecipitationData, Drop);
|
||||||
|
|
||||||
StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops
|
StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(PrecipitationData, Splash, onSplashChanged, GFXStaticTextureSRGBProfile); ///< Texture for splash particles
|
DECLARE_IMAGEASSET(PrecipitationData, Splash, onSplashChanged, GFXStaticTextureSRGBProfile); ///< Texture for splash particles
|
||||||
DECLARE_IMAGEASSET_SETGET(PrecipitationData, Splash);
|
DECLARE_IMAGEASSET_SETGET(PrecipitationData, Splash);
|
||||||
|
|
||||||
StringTableEntry mSplashShaderName; ///< The name of the shader used for raindrops
|
StringTableEntry mSplashShaderName; ///< The name of the shader used for raindrops
|
||||||
|
|
||||||
S32 mDropsPerSide; ///< How many drops are on a side of the raindrop texture.
|
S32 mDropsPerSide; ///< How many drops are on a side of the raindrop texture.
|
||||||
S32 mSplashesPerSide; ///< How many splash are on a side of the splash texture.
|
S32 mSplashesPerSide; ///< How many splash are on a side of the splash texture.
|
||||||
|
|
||||||
PrecipitationData();
|
PrecipitationData();
|
||||||
DECLARE_CONOBJECT(PrecipitationData);
|
DECLARE_CONOBJECT(PrecipitationData);
|
||||||
bool preload( bool server, String& errorStr );
|
bool preload( bool server, String& errorStr );
|
||||||
static void initPersistFields();
|
static void initPersistFields();
|
||||||
virtual void packData(BitStream* stream);
|
virtual void packData(BitStream* stream);
|
||||||
virtual void unpackData(BitStream* stream);
|
virtual void unpackData(BitStream* stream);
|
||||||
|
|
||||||
void onDropChanged() {}
|
void onDropChanged() {}
|
||||||
void onSplashChanged() {}
|
void onSplashChanged() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Raindrop
|
struct Raindrop
|
||||||
|
|
|
||||||
|
|
@ -919,7 +919,7 @@ T3Dpre4ProjectImporter::genProcessor("DebrisData", "shape shapeAsset shapeFile s
|
||||||
T3Dpre4ProjectImporter::genProcessor("DecalData", "material materialAsset");
|
T3Dpre4ProjectImporter::genProcessor("DecalData", "material materialAsset");
|
||||||
T3Dpre4ProjectImporter::genProcessor("ExplosionData", "explosionShape explosionShapeAsset");
|
T3Dpre4ProjectImporter::genProcessor("ExplosionData", "explosionShape explosionShapeAsset");
|
||||||
T3Dpre4ProjectImporter::genProcessor("ParticleData", "texture textureAsset textureName textureAsset textureExt textureExtAsset textureExtName textureExtAsset");
|
T3Dpre4ProjectImporter::genProcessor("ParticleData", "texture textureAsset textureName textureAsset textureExt textureExtAsset textureExtName textureExtAsset");
|
||||||
T3Dpre4ProjectImporter::genProcessor("PrecipitationData", "drop dropAsset dropTexture dropAsset splash splashAsset splashTexture splashAsset");
|
T3Dpre4ProjectImporter::genProcessor("PrecipitationData", "drop dropAsset dropTexture dropAsset splash splashAsset splashTexture splashAsset soundProfile soundAsset");
|
||||||
T3Dpre4ProjectImporter::genProcessor("SplashData", "texture textureAsset");
|
T3Dpre4ProjectImporter::genProcessor("SplashData", "texture textureAsset");
|
||||||
T3Dpre4ProjectImporter::genProcessor("LightFlareData", "flareTexture flareTextureAsset");
|
T3Dpre4ProjectImporter::genProcessor("LightFlareData", "flareTexture flareTextureAsset");
|
||||||
T3Dpre4ProjectImporter::genProcessor("PhysicsDebrisData", "shape shapeAsset shapeFile shapeAsset");
|
T3Dpre4ProjectImporter::genProcessor("PhysicsDebrisData", "shape shapeAsset shapeFile shapeAsset");
|
||||||
|
|
|
||||||
|
|
@ -556,23 +556,49 @@ function processLegacyField(%line, %originalFieldName, %newFieldName)
|
||||||
%targetFilename = sanitizeFilename(%value);
|
%targetFilename = sanitizeFilename(%value);
|
||||||
|
|
||||||
if(isObject(%targetFilename))
|
if(isObject(%targetFilename))
|
||||||
|
{
|
||||||
|
if(%originalFieldName $= "soundProfile")
|
||||||
|
{
|
||||||
|
$ProjectImporter::assetQuery.clear();
|
||||||
|
%foundAssets = AssetDatabase.findAssetName($ProjectImporter::assetQuery, %targetFilename);
|
||||||
|
if(%foundAssets != 0)
|
||||||
|
{
|
||||||
|
%assetId = $ProjectImporter::assetQuery.getAsset(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
//likely a material name, so handle it that way
|
//likely a material name, so handle it that way
|
||||||
%assetId = MaterialAsset::getAssetIdByMaterialName(%targetFilename);
|
%assetId = MaterialAsset::getAssetIdByMaterialName(%targetFilename);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!isFile(%targetFilename))
|
if(!isFile(%targetFilename))
|
||||||
{
|
{
|
||||||
|
if(%originalFieldName $= "soundProfile")
|
||||||
|
{
|
||||||
|
$ProjectImporter::assetQuery.clear();
|
||||||
|
%foundAssets = AssetDatabase.findAssetName($ProjectImporter::assetQuery, %targetFilename);
|
||||||
|
if(%foundAssets != 0)
|
||||||
|
{
|
||||||
|
%assetId = $ProjectImporter::assetQuery.getAsset(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
error("Legacy Project Importer - file described in line could not be found/is not valid");
|
error("Legacy Project Importer - file described in line could not be found/is not valid");
|
||||||
return %line;
|
return %line;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$ProjectImporter::assetQuery.clear();
|
$ProjectImporter::assetQuery.clear();
|
||||||
%foundAssets = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %targetFilename);
|
%foundAssets = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %targetFilename);
|
||||||
if(%foundAssets != 0)
|
if(%foundAssets != 0)
|
||||||
{
|
{
|
||||||
%assetId = $ProjectImporter::assetQuery.getAsset(0);
|
%assetId = $ProjectImporter::assetQuery.getAsset(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue