mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
api to change cutoff
This commit is contained in:
parent
5856cda6de
commit
a34532500e
@ -10,24 +10,28 @@ class SfxPlayer:
|
|||||||
UseInverseSquare = 0
|
UseInverseSquare = 0
|
||||||
|
|
||||||
def __init__(self):
|
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
|
# volume attenuates according to the inverse square of the
|
||||||
# distance from the source. volume = 1/(distance^2)
|
# distance from the source. volume = 1/(distance^2)
|
||||||
# this is the volume at which a sound is nearly inaudible
|
# this is the volume at which a sound is nearly inaudible
|
||||||
self.cutoffVolume = .02
|
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
|
# this is the 'raw' distance at which the volume of a sound will
|
||||||
# be equal to the cutoff volume
|
# be equal to the cutoff volume
|
||||||
rawCutoffDistance = math.sqrt(1./self.cutoffVolume)
|
rawCutoffDistance = math.sqrt(1./self.cutoffVolume)
|
||||||
# this is a scale factor to convert distances so that a sound
|
# this is a scale factor to convert distances so that a sound
|
||||||
# located at self.cutoffDistance will have a volume
|
# located at self.cutoffDistance will have a volume
|
||||||
# of self.cutoffVolume
|
# of self.cutoffVolume
|
||||||
self.distanceScale = rawCutoffDistance / self.cutoffDistance
|
self.distanceScale = rawCutoffDistance / self.cutoffDistance
|
||||||
|
|
||||||
def getLocalizedVolume(self, node):
|
def getLocalizedVolume(self, node):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user