Defining an Environmental Effect


In this section, we ll show how to add a new environmental reverb effect to the predefined list. This new effect will be for the environment inside of a submarine .

The Submarine Project

There are very few steps needed to add a new environment. The first is perhaps the most difficult, in that you must come up with a define that matches the DSFXI3DL2Reverb structure listed previously. In dsound .h, you will find a list of these defines for the preset environments, as shown in the following example.

 #define I3DL2_ENVIRONMENT_PRESET_SEWERPIPE -1000,-1000, 0.0f, 2.81f, 0.14f,           429, 0.014f, 648, 0.021f, 80.0f, 60.0f, 5000.0f 

Follow these steps to create a submarine environment:

  1. Create an I3DL2 definition for the environment. Chapter 5 and 7 will give you a lot of insight on these values, but for now, we will simply copy the sewer pipe environment and make it a submarine one. Add the following lines before the code for the envValues structure in  RumpusSFX.cpp .

     // Custom environment definitions.  #define I3DL2_ENVIRONMENT_SUBMARINE -1000,-1000, 0.0f, 2.81f, 0.14f,           429, 0.014f, 648, 0.021f, 80.0f, 60.0f, 5000.0f2. 
  2. At the end of the envValues structure, add the define name into the structure.

     I3DL2_ENVIRONMENT_PRESET_SMALLROOM,      I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM,      I3DL2_ENVIRONMENT_PRESET_LARGEROOM,      I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL,      I3DL2_ENVIRONMENT_PRESET_LARGEHALL,      I3DL2_ENVIRONMENT_PRESET_PLATE,      I3DL2_ENVIRONMENT_SUBMARINE 
  3. Change the value for max_environments in  RumpusSFX.h from 30 to 31.

  4. Add the submarine name to the end of the Enames structure in  RumpusEnvironment.cpp .

     "Small room (music)",      "Medium room (music)",      "Large room (music)",      "Medium hall (music)",      "Large hall (music)",      "Plate (music)",      "Submarine" 
  5. Compile and test the code. If there are any errors, double-check the previous steps.

You can add any number of new environments this way, since there is no limit.




Fundamentals of Audio and Video Programming for Games
Fundamentals of Audio and Video Programming for Games (Pro-Developer)
ISBN: 073561945X
EAN: 2147483647
Year: 2003
Pages: 120

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net