mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 15:14:35 +00:00
More Implements
-Most Vehicles and FX classes -Vehicle classes may need more preloads for assets.
This commit is contained in:
parent
1ea693fea6
commit
704eb27600
14 changed files with 191 additions and 147 deletions
|
|
@ -166,7 +166,9 @@ VehicleData::VehicleData()
|
|||
powerSteering = false;
|
||||
|
||||
for (S32 i = 0; i < Body::MaxSounds; i++)
|
||||
body.sound[i] = 0;
|
||||
{
|
||||
INIT_SOUNDASSET_ARRAY(VehicleBodySounds, i);
|
||||
}
|
||||
|
||||
dustEmitter = NULL;
|
||||
dustID = 0;
|
||||
|
|
@ -189,7 +191,8 @@ VehicleData::VehicleData()
|
|||
medSplashSoundVel = 2.0;
|
||||
hardSplashSoundVel = 3.0;
|
||||
|
||||
dMemset(waterSound, 0, sizeof(waterSound));
|
||||
for (S32 i = 0; i < Sounds::MaxSounds; i++)
|
||||
INIT_SOUNDASSET_ARRAY(VehicleWaterSounds, i);
|
||||
|
||||
collDamageThresholdVel = 20;
|
||||
collDamageMultiplier = 0.05f;
|
||||
|
|
@ -215,8 +218,10 @@ bool VehicleData::preload(bool server, String &errorStr)
|
|||
// Resolve objects transmitted from server
|
||||
if (!server) {
|
||||
for (S32 i = 0; i < Body::MaxSounds; i++)
|
||||
if (body.sound[i])
|
||||
Sim::findObject(SimObjectId((uintptr_t)body.sound[i]),body.sound[i]);
|
||||
if (mVehicleBodySounds[i])
|
||||
{
|
||||
_setVehicleBodySounds(getVehicleBodySounds(i), i);
|
||||
}
|
||||
}
|
||||
|
||||
if( !dustEmitter && dustID != 0 )
|
||||
|
|
@ -264,10 +269,9 @@ void VehicleData::packData(BitStream* stream)
|
|||
stream->write(body.restitution);
|
||||
stream->write(body.friction);
|
||||
for (i = 0; i < Body::MaxSounds; i++)
|
||||
if (stream->writeFlag(body.sound[i]))
|
||||
stream->writeRangedU32(mPacked ? SimObjectId((uintptr_t)body.sound[i]):
|
||||
body.sound[i]->getId(),DataBlockObjectIdFirst,
|
||||
DataBlockObjectIdLast);
|
||||
{
|
||||
PACKDATA_SOUNDASSET_ARRAY(VehicleBodySounds, i);
|
||||
}
|
||||
|
||||
stream->write(minImpactSpeed);
|
||||
stream->write(softImpactSpeed);
|
||||
|
|
@ -308,9 +312,10 @@ void VehicleData::packData(BitStream* stream)
|
|||
stream->write(enablePhysicsRep);
|
||||
|
||||
// write the water sound profiles
|
||||
for(i = 0; i < MaxSounds; i++)
|
||||
if(stream->writeFlag(waterSound[i]))
|
||||
stream->writeRangedU32(waterSound[i]->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
||||
for (i = 0; i < MaxSounds; i++)
|
||||
{
|
||||
PACKDATA_SOUNDASSET_ARRAY(VehicleWaterSounds, i);
|
||||
}
|
||||
|
||||
if (stream->writeFlag( dustEmitter ))
|
||||
{
|
||||
|
|
@ -359,11 +364,9 @@ void VehicleData::unpackData(BitStream* stream)
|
|||
stream->read(&body.restitution);
|
||||
stream->read(&body.friction);
|
||||
S32 i;
|
||||
for (i = 0; i < Body::MaxSounds; i++) {
|
||||
body.sound[i] = NULL;
|
||||
if (stream->readFlag())
|
||||
body.sound[i] = (SFXProfile*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst,
|
||||
DataBlockObjectIdLast);
|
||||
for (i = 0; i < Body::MaxSounds; i++)
|
||||
{
|
||||
UNPACKDATA_SOUNDASSET_ARRAY(VehicleBodySounds, i);
|
||||
}
|
||||
|
||||
stream->read(&minImpactSpeed);
|
||||
|
|
@ -405,12 +408,10 @@ void VehicleData::unpackData(BitStream* stream)
|
|||
stream->read(&enablePhysicsRep);
|
||||
|
||||
// write the water sound profiles
|
||||
for(i = 0; i < MaxSounds; i++)
|
||||
if(stream->readFlag())
|
||||
{
|
||||
U32 id = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
||||
waterSound[i] = dynamic_cast<SFXProfile*>( Sim::findObject(id) );
|
||||
}
|
||||
for (i = 0; i < Sounds::MaxSounds; i++)
|
||||
{
|
||||
UNPACKDATA_SOUNDASSET_ARRAY(VehicleWaterSounds, i);
|
||||
}
|
||||
|
||||
if( stream->readFlag() )
|
||||
{
|
||||
|
|
@ -491,15 +492,8 @@ void VehicleData::initPersistFields()
|
|||
addField( "bodyFriction", TypeF32, Offset(body.friction, VehicleData),
|
||||
"Collision friction coefficient.\nHow well this object will slide against "
|
||||
"objects it collides with." );
|
||||
addField( "softImpactSound", TYPEID< SFXProfile >(), Offset(body.sound[Body::SoftImpactSound], VehicleData),
|
||||
"@brief Sound to play on a 'soft' impact.\n\n"
|
||||
"This sound is played if the impact speed is < hardImpactSpeed and >= "
|
||||
"softImpactSpeed.\n\n"
|
||||
"@see softImpactSpeed" );
|
||||
addField( "hardImpactSound", TYPEID< SFXProfile >(), Offset(body.sound[Body::HardImpactSound], VehicleData),
|
||||
"@brief Sound to play on a 'hard' impact.\n\n"
|
||||
"This sound is played if the impact speed >= hardImpactSpeed.\n\n"
|
||||
"@see hardImpactSpeed" );
|
||||
|
||||
INITPERSISTFIELD_SOUNDASSET_ARRAY(VehicleBodySounds, Body::Sounds::MaxSounds, VehicleData, "Sounds for vehicle body impacts.");
|
||||
|
||||
addField( "minImpactSpeed", TypeF32, Offset(minImpactSpeed, VehicleData),
|
||||
"Minimum collision speed for the onImpact callback to be invoked." );
|
||||
|
|
@ -596,18 +590,8 @@ void VehicleData::initPersistFields()
|
|||
addField( "hardSplashSoundVelocity", TypeF32, Offset(hardSplashSoundVel, VehicleData),
|
||||
"Minimum velocity when entering the water for the imapactWaterHard sound "
|
||||
"to play.\n\n@see impactWaterHard" );
|
||||
addField( "exitingWater", TYPEID< SFXProfile >(), Offset(waterSound[ExitWater], VehicleData),
|
||||
"Sound to play when exiting the water." );
|
||||
addField( "impactWaterEasy", TYPEID< SFXProfile >(), Offset(waterSound[ImpactSoft], VehicleData),
|
||||
"Sound to play when entering the water with speed >= softSplashSoundVelocity "
|
||||
"and < mediumSplashSoundVelocity." );
|
||||
addField( "impactWaterMedium", TYPEID< SFXProfile >(), Offset(waterSound[ImpactMedium], VehicleData),
|
||||
"Sound to play when entering the water with speed >= mediumSplashSoundVelocity "
|
||||
"and < hardSplashSoundVelocity." );
|
||||
addField( "impactWaterHard", TYPEID< SFXProfile >(), Offset(waterSound[ImpactHard], VehicleData),
|
||||
"Sound to play when entering the water with speed >= hardSplashSoundVelocity." );
|
||||
addField( "waterWakeSound", TYPEID< SFXProfile >(), Offset(waterSound[Wake], VehicleData),
|
||||
"Looping sound to play while moving through the water." );
|
||||
|
||||
INITPERSISTFIELD_SOUNDASSET_ARRAY(WaterSounds, Sounds::MaxSounds, VehicleData, "Sounds for interacting with water.");
|
||||
|
||||
addField( "collDamageThresholdVel", TypeF32, Offset(collDamageThresholdVel, VehicleData),
|
||||
"Minimum collision velocity to cause damage to this vehicle.\nCurrently unused." );
|
||||
|
|
@ -876,8 +860,8 @@ bool Vehicle::onNewDataBlock(GameBaseData* dptr,bool reload)
|
|||
// costs and makes the system easier to understand.
|
||||
SFX_DELETE( mWakeSound );
|
||||
|
||||
if ( mDataBlock->waterSound[VehicleData::Wake] )
|
||||
mWakeSound = SFX->createSource( mDataBlock->waterSound[VehicleData::Wake], &getTransform() );
|
||||
if ( mDataBlock->getVehicleWaterSounds(VehicleData::Wake) != NULL )
|
||||
mWakeSound = SFX->createSource( mDataBlock->getVehicleWaterSoundProfile(VehicleData::Wake), &getTransform() );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -1140,27 +1124,27 @@ void Vehicle::updatePos(F32 dt)
|
|||
if (collSpeed >= mDataBlock->softImpactSpeed)
|
||||
impactSound = VehicleData::Body::SoftImpactSound;
|
||||
|
||||
if (impactSound != -1 && mDataBlock->body.sound[impactSound] != NULL)
|
||||
SFX->playOnce( mDataBlock->body.sound[impactSound], &getTransform() );
|
||||
if (impactSound != -1 && mDataBlock->getVehicleBodySounds(impactSound) != NULL)
|
||||
SFX->playOnce( mDataBlock->getVehicleBodySoundProfile(impactSound), &getTransform() );
|
||||
}
|
||||
|
||||
// Water volume sounds
|
||||
F32 vSpeed = getVelocity().len();
|
||||
if (!inLiquid && mWaterCoverage >= 0.8f) {
|
||||
if (vSpeed >= mDataBlock->hardSplashSoundVel)
|
||||
SFX->playOnce( mDataBlock->waterSound[VehicleData::ImpactHard], &getTransform() );
|
||||
SFX->playOnce( mDataBlock->getVehicleWaterSoundProfile(VehicleData::ImpactHard), &getTransform() );
|
||||
else
|
||||
if (vSpeed >= mDataBlock->medSplashSoundVel)
|
||||
SFX->playOnce( mDataBlock->waterSound[VehicleData::ImpactMedium], &getTransform() );
|
||||
SFX->playOnce( mDataBlock->getVehicleWaterSoundProfile(VehicleData::ImpactMedium), &getTransform() );
|
||||
else
|
||||
if (vSpeed >= mDataBlock->softSplashSoundVel)
|
||||
SFX->playOnce( mDataBlock->waterSound[VehicleData::ImpactSoft], &getTransform() );
|
||||
SFX->playOnce( mDataBlock->getVehicleWaterSoundProfile(VehicleData::ImpactSoft), &getTransform() );
|
||||
inLiquid = true;
|
||||
}
|
||||
else
|
||||
if(inLiquid && mWaterCoverage < 0.8f) {
|
||||
if (vSpeed >= mDataBlock->exitSplashSoundVel)
|
||||
SFX->playOnce( mDataBlock->waterSound[VehicleData::ExitWater], &getTransform() );
|
||||
SFX->playOnce( mDataBlock->getVehicleWaterSoundProfile(VehicleData::ExitWater), &getTransform() );
|
||||
inLiquid = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue