mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
api to change cutoff
This commit is contained in:
parent
5856cda6de
commit
a34532500e
@ -10,24 +10,28 @@ class SfxPlayer:
|
||||
UseInverseSquare = 0
|
||||
|
||||
def __init__(self):
|
||||
# Distance at which sounds can no longer be heard
|
||||
# This was determined experimentally
|
||||
self.cutoffDistance = 120.0
|
||||
|
||||
# cutoff for inverse square attenuation
|
||||
if SfxPlayer.UseInverseSquare:
|
||||
self.cutoffDistance = 300.0
|
||||
# volume attenuates according to the inverse square of the
|
||||
# distance from the source. volume = 1/(distance^2)
|
||||
# this is the volume at which a sound is nearly inaudible
|
||||
self.cutoffVolume = .02
|
||||
|
||||
# cutoff for inverse square attenuation
|
||||
if SfxPlayer.UseInverseSquare:
|
||||
self.setCutoffDistance(300.0)
|
||||
else:
|
||||
# Distance at which sounds can no longer be heard
|
||||
# This was determined experimentally
|
||||
self.setCutoffDistance(120.0)
|
||||
|
||||
def setCutoffDistance(self, d):
|
||||
self.cutoffDistance = d
|
||||
# this is the 'raw' distance at which the volume of a sound will
|
||||
# be equal to the cutoff volume
|
||||
rawCutoffDistance = math.sqrt(1./self.cutoffVolume)
|
||||
# this is a scale factor to convert distances so that a sound
|
||||
# located at self.cutoffDistance will have a volume
|
||||
# of self.cutoffVolume
|
||||
self.distanceScale = rawCutoffDistance / self.cutoffDistance
|
||||
self.distanceScale = rawCutoffDistance / self.cutoffDistance
|
||||
|
||||
def getLocalizedVolume(self, node):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user