[Solved : No Bug] SoundRange3D()
Posted: Sat Jan 10, 2015 12:44 pm
SoundRange3D() work fine ONLY if a sound is on a node located at 0,0,0.
Snippet code :
- The distance between the camera and the node is always the same.
- The variable n indicates the new coordinates (x = y = z = n) of the node.
- If you increase n, the volume decreases.I think the SoundRange is calculated from the point 0,0,0
Snippet code :
- The distance between the camera and the node is always the same.
- The variable n indicates the new coordinates (x = y = z = n) of the node.
- If you increase n, the volume decreases.
Code: Select all
Enumeration
#Mainform
EndEnumeration
InitEngine3D()
InitKeyboard()
InitSprite()
OpenWindow(#Mainform,0, 0, 800, 600, "", #PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(#Mainform), 0, 0, 800, 600, 0, 0, 0)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/", #PB_3DArchive_FileSystem)
Camera = CreateCamera(#PB_Any,0,0,100,100)
CameraBackColor(Camera, RGB(145, 182, 201))
;Test Sound (x=y=z = n)
n = 0 ;Test with a zero value then the value 400
;The distance between the camera and the node is always the same.
MoveCamera(Camera, n+500, n+500, n+500)
CameraLookAt(Camera, n, n, n)
;Load Sound
WaterFallSound = LoadSound3D(#PB_Any, "Siren.ogg")
If WaterFallSound
WaterFallNode = CreateNode(#PB_Any, n, n, n)
CreateEntity(#PB_Any, MeshID(CreateSphere(#PB_Any, 25)), #PB_Material_None, n, n, n) ;Node Landmark
AttachNodeObject(WaterFallNode, SoundID3D(WaterFallSound))
SoundVolume3D(WaterFallSound, 100)
SoundRange3D(WaterFallSound, 100, 800)
PlaySound3D(WaterFallSound, #PB_Sound3D_Loop)
EndIf
Repeat
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
If ExamineKeyboard()
If KeyboardPushed (#PB_Key_Escape)
Break
EndIf
EndIf
RenderWorld(80)
FlipBuffers()
ForEver