I use the “y-up” coordinate system in my panda3d project, as this is what I am used to. This works great for all of the graphics features, but it seems to have no effect on the positional audio. I am using Panda3D 1.5.4 and the default openAL sound library (tried FMOD, it has the same problem).
I thought it might be something specific to my project, but I modified the 3d sound demo from the “Panda3D Audio for the Absolute Beginner” tutorial and I get the same behaviour. In the unmodified example I hold S to bring the cube behind the camera; the audio is now playing on the rear left speaker. In the modified example below, the audio is playing on both the rear left and front left speakers (I believe the audio system still thinks Z-axis is up and down).
Is there another setting to change the coordinate system of the audio, or is this a genuine bug?
I’ve included the modified tutorial code below (5-MovingSound.py):
#################################################
# Panda3D Audio for the Absolute Beginner #
# Created by: Joe Kelly #
# Lesson 5 - Moving 3D audio #
#################################################
from pandac.PandaModules import loadPrcFileData
loadPrcFileData('', 'coordinate-system yup')
import direct.directbase.DirectStart
#Import our class outline
from direct.showbase.DirectObject import DirectObject
#Import general program functions
import sys
#Import the Task library
from direct.task.Task import Task
from direct.showbase.Audio3DManager import Audio3DManager
#Create the Class
class World(DirectObject):
#Initialize World and Controls
def __init__(self):
#Start All Keys as "up"
self.keyMap = {"left":0, "right":0, "up":0, "down":0}
#List Keys for Use
self.accept("escape", sys.exit)
self.accept("a", self.setKey, ["left",1])
self.accept("d", self.setKey, ["right",1])
self.accept("w", self.setKey, ["up",1])
self.accept("s", self.setKey, ["down",1])
self.accept("a-up", self.setKey, ["left",0])
self.accept("d-up", self.setKey, ["right",0])
self.accept("w-up", self.setKey, ["up",0])
self.accept("s-up", self.setKey, ["down",0])
#Do not allow mouse control of camera
base.disableMouse()
#Load Models
self.boxDude = loader.loadModel("models/box")
self.boxDude.reparentTo(render)
self.boxDude.setPos(-8,0,-50)
self.sphereDude = loader.loadModel("models/sphere")
self.sphereDude.reparentTo(render)
self.sphereDude.setPos(8,0,-50)
#Add movement to Task list
taskMgr.add(self.move,"moveFunc")
#Play sound
self.audio3d = Audio3DManager(base.sfxManagerList[0], camera)
self.rainSound = self.audio3d.loadSfx('audio/shortrain.wav')
self.audio3d.attachSoundToObject(self.rainSound, self.boxDude)
self.rainSound.setLoop(True)
self.rainSound.play()
self.audio3d.setDropOffFactor(0.1)
#Set keystate variables taken from the "accept" lines
def setKey(self, key, value):
self.keyMap[key] = value
#Move objects based on keystates
def move(self, task):
if (self.keyMap["left"]!=0):
self.boxDude.setPos(self.boxDude.getX() - 0.2, 0, self.boxDude.getZ())
if (self.keyMap["right"]!=0):
self.boxDude.setPos(self.boxDude.getX() + 0.2, 0, self.boxDude.getZ())
if (self.keyMap["up"]!=0):
self.boxDude.setPos(self.boxDude.getX(), 0, self.boxDude.getZ() - 0.2)
if (self.keyMap["down"]!=0):
self.boxDude.setPos(self.boxDude.getX(), 0, self.boxDude.getZ() + 0.2)
return Task.cont
#Initialize the class
w = World()
run()