49 | function AmbientSoundManager:loadMapData(xmlFile, missionInfo) |
50 | AmbientSoundManager:superClass().loadMapData(self) |
51 | |
52 | local xmlFilename = Utils.getFilename(getXMLString(xmlFile, "map.sounds#filename"), g_currentMission.baseDirectory) |
53 | if xmlFile == nil then |
54 | return false |
55 | end |
56 | |
57 | local soundXmlFile = loadXMLFile("ambientSoundsXML", xmlFilename) |
58 | if soundXmlFile == nil or soundXmlFile == 0 then |
59 | g_logManager:xmlWarning(xmlFilename, "Warning: AmbientSounds could not load xmlFile!") |
60 | return false |
61 | end |
62 | |
63 | self.initialized = true |
64 | self.mapSoundGrid = MapDataGrid:new(g_currentMission.mapWidth, self.blocksPerRowColumn) |
65 | |
66 | -- initialize grid |
67 | for i=1, self.blocksPerRowColumn do |
68 | for j=1, self.blocksPerRowColumn do |
69 | self.mapSoundGrid:setValue(i, j, {}) |
70 | end |
71 | end |
72 | |
73 | self.ambientXmlFilename = xmlFilename |
74 | local filename = getXMLString(soundXmlFile, "sound.ambient3d#filename") |
75 | if filename ~= nil then |
76 | local ambient3DFilename = Utils.getFilename(filename, g_currentMission.baseDirectory) |
77 | self.ambient3DFilename = ambient3DFilename |
78 | end |
79 | |
80 | self:loadAmbientSounds() |
81 | |
82 | self.indoorVolumeFactor = getXMLFloat(soundXmlFile, "sound.ambient3d#indoorVolumeFactor") or 1 |
83 | self.indoorLowpassGainFactor = getXMLFloat(soundXmlFile, "sound.ambient3d#indoorLowpassGainFactor") or 1 |
84 | |
85 | -- log("---> ", #self.splines) |
86 | -- for _, spline in ipairs(self.splines) do |
87 | -- for i=0, getSplineLength(spline), 5 do |
88 | -- local t = i / getSplineLength(spline) |
89 | -- local x,y,z = getSplinePosition(spline, t) |
90 | -- log(x, y, z, t, getNumOfChildren(spline)) |
91 | |
92 | -- local value, rowIndex, colIndex = self.mapSoundGrid:getValueAtWorldPos(x, z) |
93 | -- if value == nil then |
94 | -- value = {} |
95 | -- self.mapSoundGrid:setValue(rowIndex, colIndex, value) |
96 | -- end |
97 | -- value[spline] = {spline=spline} |
98 | |
99 | -- for j=0, getNumOfChildren(spline)-1 do |
100 | -- log(getName(getChildAt(spline, j))) |
101 | -- local soundNode = self.nodeToSoundNode[getChildAt(spline, j)] |
102 | -- if soundNode ~= nil then |
103 | -- soundNode:setWorldPosition(x,y,z) |
104 | -- self:addSoundNodeToGrid(soundNode) |
105 | -- end |
106 | -- end |
107 | -- end |
108 | -- end |
109 | |
110 | if g_addCheatCommands then |
111 | addConsoleCommand("gsReloadAmbientSounds", "Reload ambient sound system", "consoleCommandReloadAmbientSound", self) |
112 | addConsoleCommand("gsToggleAmbientSoundsDebug", "Toggles ambient sound system debugging", "consoleCommandToggleAmbientSoundsDebug", self) |
113 | end |
114 | |
115 | delete(soundXmlFile) |
116 | |
117 | return true |
118 | end |