3D Game Programming All in One (Course Technology PTR Game Development Series)
A silent world is a dreary one. You can liven up your game world by inserting sounds to give a sense of the environment using AudioEmitters.
First, copy the file C:\3DGPAi1\RESOURCES\CH20\LOON.WAV over to C:\koob\control\data\sounds\.
Then open C:\koob\control\server\misc\sndprofiles.cs and add the following AudioProfile to the end of the file:
datablock AudioProfile(LoonSound) { filename = "~/data/sound/loon.wav"; description = AudioDefaultLooping3d; };
Run your game, and open the World Editor and then the World Editor Creator as before.
Next, in the Tree view, locate Mission Objects, environment, AudioEmitter as shown in Figure 20.8. Click AudioEmitter while facing a location where you would like to place the AudioEmitter.
In the dialog box presented (see Figure 20.9), click the Sound Profile button. From the list that opens, choose the LoonSound Profile.
Make sure the Use profile's desc?, Looping?, and Is 3D sound? check boxes are selected, and then click OK. Check Figure 20.9 to verify the settings.
An AudioEmitter marker will be placed in the game world at the center of your screen, on the ground, as shown in Figure 20.10.
Now exit the editor by toggling the F11 key, make sure you are in camera fly mode, and move up and away from where you placed the marker. Then go back in to the editor. You should see two concentric spheres, as shown in Figure 20.11. The inner sphere is very faintly defined with gray lines in the figure, while the outer sphere is defined with black lines. In the Torque editor, the inner sphere is made with red lines, and the outer sphere is made with blue lines.
The inner sphere represents the reference (or minimum) distance, and the outer sphere represents the maximum distance. The larger the outer sphere, the more gradual the drop-off in sound as you move away from the emitter. The larger the inner sphere, the farther the sound will carry.
Press F3 to switch to World Editor Inspector, and then click the hand cursor on the marker. At the bottom right, the editor frame contains the properties for the object, as show in Figure 20.12.
You can use this frame to adjust the settings for the emitter. Click the buttons in the Inspector frame to expand a selection of properties. After making changes, make sure to click the Apply button to have your changes applied to the selected object.
Категории