whats up with the sound entry in addMaterialMapping?
by deepscratch · in Torque 3D Professional · 07/10/2009 (6:00 am) · 7 replies
I see an entry in the addMaterialMapping for sound,
but in the source, there is only this:
no entry for sound.
it also throws a console error of wrong number of arguments.
is this planning ahead for beta4?
or was something missed?
I'd like to make use of the functionality it implies.
cheers.
addMaterialMapping( "grass1" , "sound: 0" , "color: 0.46 0.36 0.26 0.4 0.0" );
but in the source, there is only this:
ConsoleFunction( addMaterialMapping, void, 3, 3, "(string texName, string matName)n"
"Set up a material to texture mapping.")
{
MATMGR->mapMaterial(argv[1],argv[2]);
}no entry for sound.
it also throws a console error of wrong number of arguments.
is this planning ahead for beta4?
or was something missed?
I'd like to make use of the functionality it implies.
cheers.
About the author
email me at medan121@gmail.com
Recent Threads
#2
07/10/2009 (6:20 am)
mm, I see nothing about sound there...
#3
art/terrains/Test/materials.cs:
This specifies to play sound 0 when we step on this material (in this case dirt_grass). But what is sound 0?
from player.cs (DefaultPlayerData), we see the sounds defined:
But we need to look in player.h to see what is sound 0:
So in this case, sound 0 is FootSoft sound, which is defined as FootLightSoftSound in the datablock. And the definition for that is (in the same file):
So, whenever the player steps on dirt_grass, we should hear the footstep_soft sound.
07/10/2009 (6:54 am)
It's in the template project - from art/terrains/Test/materials.cs:
new Material( TerrainSoft )
{
FootstepSoundId = 0; // Soft footstep sound defined on player datablock.
ImpactSoundId = 0; // Soft impact sound.
ShowDust = false; // Don't show dust particles (footpuffs, hover trails, etc.)
ShowFootprints = true; // But show footprints.
};
new Material( TerrainDirtGrass : TerrainSoft )
{
MapTo = "dirt_grass";
};This specifies to play sound 0 when we step on this material (in this case dirt_grass). But what is sound 0?
from player.cs (DefaultPlayerData), we see the sounds defined:
FootSoftSound = FootLightSoftSound; FootHardSound = FootLightHardSound; FootMetalSound = FootLightMetalSound; FootSnowSound = FootLightSnowSound; FootShallowSound = FootLightShallowSplashSound; FootWadingSound = FootLightWadingSound; FootUnderwaterSound = FootLightUnderwaterSound;
But we need to look in player.h to see what is sound 0:
enum Sounds {
FootSoft,
FootHard,
FootMetal,
FootSnow,
FootShallowSplash,
FootWading,
FootUnderWater,
FootBubbles,
MoveBubbles,
WaterBreath,
ImpactSoft,
ImpactHard,
ImpactMetal,
ImpactSnow,
ImpactWaterEasy,
ImpactWaterMedium,
ImpactWaterHard,
ExitWater,
MaxSounds
};
SFXProfile* sound[MaxSounds];So in this case, sound 0 is FootSoft sound, which is defined as FootLightSoftSound in the datablock. And the definition for that is (in the same file):
datablock SFXProfile(FootLightSoftSound)
{
filename = "art/sound/footstep_soft";
description = AudioClosest3d;
preload = true;
};So, whenever the player steps on dirt_grass, we should hear the footstep_soft sound.
#4
So you will need to define the sounds themselves on the player datablock, and set this if the given material (which maps to the same texture as the diffuse of your terrain material) will trigger the player's different footstep or impact sounds, most notably:
Here comes the obscure part. Checking player.cpp:
and player.h:
What that points to is that FootSoftSound will have an id of 0, FootHardSound 1, FootMetalSound 2, and so on..
If you wanted to have a metal thread plate material, you could set it up like this:
I hope that clears stuff up a bit. ;)
07/10/2009 (6:56 am)
Edit: Jaimi beat me to it :)// This is an example of how to map terrain blend tiles to material
// instances within Torque. None of these materials will be used
// for rendering, but they will be used by the collision detection
// code and thus play their part in defining interaction behavior
// when coming into contact with these materials.
new Material( TerrainSoft )
{
FootstepSoundId = 0; // Soft footstep sound defined on player datablock.
ImpactSoundId = 0; // Soft impact sound.
ShowDust = false; // Don't show dust particles (footpuffs, hover trails, etc.)
ShowFootprints = true; // But show footprints.
};
new Material( TerrainHard )
{
FootstepSoundId = 1; // Hard footstep sound defined on player datablock.
ImpactSoundId = 1; // Hard impact sound.
ShowDust = true; // Show dust particles.
ShowFootprints = true; // And show footprints.
};
// If you want custom sound effects for footstep and impact sounds,
// use the 'customFootstepSound' and 'customImpactSound' material properties
// that allow referencing SFXProfiles and will override the Id-based definitions.
// ...
new Material( TerrainDirtGrass : TerrainSoft )
{
MapTo = "dirt_grass";
};
new Material( TerrainRocks : TerrainHard )
{
MapTo = "rocks1";
// Choose a grey-ish particle color for the dust emitters.
EffectColor[ 0 ] = "0.5 0.5 0.5 1.0";
EffectColor[ 1 ] = "1.0 1.0 1.0 0.0";
};So you will need to define the sounds themselves on the player datablock, and set this if the given material (which maps to the same texture as the diffuse of your terrain material) will trigger the player's different footstep or impact sounds, most notably:
FootSoftSound = FootLightSoftSound; FootHardSound = FootLightHardSound; FootMetalSound = FootLightMetalSound; FootSnowSound = FootLightSnowSound; FootShallowSound = FootLightShallowSplashSound; FootWadingSound = FootLightWadingSound; FootUnderwaterSound = FootLightUnderwaterSound; FootBubblesSound = FootLightBubblesSound; movingBubblesSound = ArmorMoveBubblesSound; waterBreathSound = WaterBreathMaleSound; impactSoftSound = ImpactLightSoftSound; impactHardSound = ImpactLightHardSound; impactMetalSound = ImpactLightMetalSound; impactSnowSound = ImpactLightSnowSound; impactWaterEasy = ImpactLightWaterEasySound; impactWaterMedium = ImpactLightWaterMediumSound; impactWaterHard = ImpactLightWaterHardSound;
Here comes the obscure part. Checking player.cpp:
addField("FootSoftSound", TypeSFXProfilePtr, Offset(sound[FootSoft], PlayerData));
addField("FootHardSound", TypeSFXProfilePtr, Offset(sound[FootHard], PlayerData));
addField("FootMetalSound", TypeSFXProfilePtr, Offset(sound[FootMetal], PlayerData));
addField("FootSnowSound", TypeSFXProfilePtr, Offset(sound[FootSnow], PlayerData));
addField("FootShallowSound", TypeSFXProfilePtr, Offset(sound[FootShallowSplash], PlayerData));
addField("FootWadingSound", TypeSFXProfilePtr, Offset(sound[FootWading], PlayerData));
addField("FootUnderwaterSound", TypeSFXProfilePtr, Offset(sound[FootUnderWater], PlayerData));
addField("FootBubblesSound", TypeSFXProfilePtr, Offset(sound[FootBubbles], PlayerData));
addField("movingBubblesSound", TypeSFXProfilePtr, Offset(sound[MoveBubbles], PlayerData));
addField("waterBreathSound", TypeSFXProfilePtr, Offset(sound[WaterBreath], PlayerData));and player.h:
/// Zounds!
enum Sounds {
FootSoft,
FootHard,
FootMetal,
FootSnow,
FootShallowSplash,
FootWading,
FootUnderWater,
FootBubbles,
MoveBubbles,
WaterBreath,
ImpactSoft,
ImpactHard,
ImpactMetal,
ImpactSnow,
ImpactWaterEasy,
ImpactWaterMedium,
ImpactWaterHard,
ExitWater,
MaxSounds
};What that points to is that FootSoftSound will have an id of 0, FootHardSound 1, FootMetalSound 2, and so on..
If you wanted to have a metal thread plate material, you could set it up like this:
FootstepSoundId = 2; // Footstep on metal sound ImpactSoundId = 12; // Impact on metal sound (yes, it doesn't start from 0, its in the same enum) ShowDust = false; // no puffs on a metal thread plate ShowFootprints = false; // nor footprints
I hope that clears stuff up a bit. ;)
#5
07/10/2009 (7:36 am)
lovely, thanks guys, that clears it up nicely.
#6
I'm almost certain that you wouldn't include the water sounds when you setup your materials, only the four (hard, soft, metal, snow (0, 1, 2, 3)) footstep sounds and/or the "impact" sounds. Water should be handling it's sounds separately -- unless that's changed too.
07/10/2009 (10:02 am)
Somehow that explanatory faux material file got put into the "art/terrains/envpack" directory in the FPS Kit.... hmm, I should have caught that before now ;DI'm almost certain that you wouldn't include the water sounds when you setup your materials, only the four (hard, soft, metal, snow (0, 1, 2, 3)) footstep sounds and/or the "impact" sounds. Water should be handling it's sounds separately -- unless that's changed too.
#7
BTW, you really don't need to fiddle with the number-based sound identification from Player if you don't want to. I just kept this because it was already in there and it made sense to support it.
However, there is also the "customFootstepSound" and "customImpactSound" properties on materials. These reference SFXProfiles directly and will take precedence over the ID-based versions.
On the other hand, after figuring out what number does what, it may be easier to just go with it.
Also, the initial confusion around addMaterialMapping was because this function name was simply reused in TGEA for something completely different. addMaterialMapping() in TGEA/T3D has nothing to do with addMaterialMapping() in TGE.
Water sound effects are also handled in the player code but are not based on materials since there isn't really a collision going on there. It's a bunch of tests for water coverage.
07/10/2009 (1:57 pm)
BTW, you really don't need to fiddle with the number-based sound identification from Player if you don't want to. I just kept this because it was already in there and it made sense to support it.
However, there is also the "customFootstepSound" and "customImpactSound" properties on materials. These reference SFXProfiles directly and will take precedence over the ID-based versions.
On the other hand, after figuring out what number does what, it may be easier to just go with it.
Also, the initial confusion around addMaterialMapping was because this function name was simply reused in TGEA for something completely different. addMaterialMapping() in TGEA/T3D has nothing to do with addMaterialMapping() in TGE.
Water sound effects are also handled in the player code but are not based on materials since there isn't really a collision going on there. It's a bunch of tests for water coverage.
Associate Konrad Kiss
Bitgap Games