marauder2k9 Posted October 12, 2018 Share Posted October 12, 2018 This resource will add the exponential falloff to torque3ds sound distance attenuation instead of the linear falloff that it uses as stock... ALOT OF CODE CHANGES INCOMING BACK UP YOUR SOURCE!!! :) These changes were tested on stock Torque3d 3.10.1 release.Our first change of many: in sfxCommon.h around line 152 you should see enum SFXDistanceModelafter SFXDistanceModelLogarithmic add:SFXDistanceModelExponent, then at line 189 after break; ad case SFXDistanceModelExponent: distance = getMax(distance, minDistance); distance = getMin(distance, maxDistance); gain = pow((distance / minDistance), (-rolloffFactor)); break; Then in sfxDSDevice.cpp at line 203 you will see SFXDevice::setDistanceModelin the switch below break at case SFXDistanceModelLogarithmic:add case SFXDistanceModelExponent: Con::errorf("SFXDSDevice::setDistanceModel - 'exponential' distance attenuation not supported by DirectSound"); break; I'm not sure whether directsound has an exponential attenuation feature but just in case it doesnt i thought it best to sort it out with an error here.Next in sfxALDevice.cpp find SFXALDevice::setDistanceModel under the case SFXDistanceModelLogarithmic break;add: case SFXDistanceModelExponent: mOpenAL.alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED); if (mUserRolloffFactor != mRolloffFactor) _setRolloffFactor(mUserRolloffFactor); break; You could just copy and paste the logarithmic case here and change the values to be exponent but that would just be lazy........... :? Next in sfxSystem.cppFind around line 94 { SFXDistanceModelLogarithmic, "Logarithmic", "Volume attenuates logarithmically starting from the reference distance and halving every reference distance step from there on. " "Attenuation stops at max distance but volume won't reach zero." },Below this add { SFXDistanceModelExponent, "Exponential", "Volume attenuates exponentially starting from the reference distance and attenuating every reference distance step by the rolloff factor. " "Attenuation stops at max distance but volume won't reach zero." }, Because we are using AL_EXPONENT_DISTANCE_CLAMPED the volume attenuation stops when the source reaches max distance.Then load up your level in the world editor choose thelevelinfo from the mission group and scroll down to sound, under that change soundDistanceModel to Exponential. Done now any sound profiles that you have you can create an exponential rolloff attenuation rather than a linear rolloff. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.