Yesterday I added static sound sources to the game. The first step was to add them to the editor. I originall had in mind
a fairly complex scheme where each sound was represented by an OOBB. Within the OOBB, a character would hear the sound at
full volume, but outside it, it would hear the sound falloff. Then I realized that this wouldn't give proper panning effects,
and was more complicated than it needed to be.
Rather, I should just allow the level designer to place sound sources as points in the editor. The nearer you are to the point, the louder it is. Large sources, like a river, would need multiple sound sources placed to sound right.
Here is a shot of the 4 sound sources that represent the water.
Once things were working right in the editor, I added the sound sources to the level export process, and added code to read them in to the game engine. The whole thing probably took 4-5 hours of coding & debugging to do, which seems like a lot, and it tempted me to try to make the process easier, but that would undoubtedly take more than 4 hours to change, and chances are I will only need to add one or two more editable objects to the editor and game, and it's not clear how much time another system would save, so it doesn't seem worth the tradeoff.
In the editor, you can scale a sphere that represents the sound range. In the game, however, this value isn't used yet. I'm using FMOD, and treating the sound sources as 3D sounds. This gives the sounds an implicit volume just based on distance. I'm not sure, but I may be able to use the Channel::SetVolume method on top of the default 3D attenuation to adjust it. Another option would be to adjust the position I pass to fmod each frame.
With 3D sounds, you pass in the player location and the sound locations. I update the sound locations every frame, in case they're moving. FMOD does the subtraction to figure out the proper attenuation relative to the listener. If I want to manually force the sound to be quieter, I can move the sound into 'listener space', then scale the position up, then go back into world space, then pass in this virtual sound position.
A while ago I experimented with putting an ambient light grid all through space. This stopped working when I changed my A* implementation, because I was using the 2d grid to store the ambient light info. So, I went back to the old scheme of raycasts, or at least I thought I did. I had a devil of a time getting the latest batch of md2 files into the game such that they weren't too dark. Turns out my ambient was going through the old calculation for the ambient grid and coming up with zero, since the grid was unpopulated. So, I fixed that and put back the old raycast method. Unfortunately, now the enemy characters look washed out.
Here is a shot of my new pillar models, and the washed-out characters :