00001 //------------------------------------------------------------------------------ 00002 // Lamp : Open source game middleware 00003 // Copyright (C) 2004 Junpei Ohtani ( Email : junpee@users.sourceforge.jp ) 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 //------------------------------------------------------------------------------ 00019 00020 /** @file 00021 * サウンドリスナヘッダ 00022 * @author Junpee 00023 */ 00024 00025 #ifndef SOUND_LISTENER_H_ 00026 #define SOUND_LISTENER_H_ 00027 00028 namespace Lamp{ 00029 00030 //------------------------------------------------------------------------------ 00031 /** 00032 * サウンドリスナ 00033 */ 00034 class SoundListener{ 00035 friend class LampSound; 00036 public: 00037 //-------------------------------------------------------------------------- 00038 /** 00039 * 位置の設定 00040 * @param position 位置 00041 */ 00042 virtual void setPosition(const Vector3& position); 00043 00044 /** 00045 * 位置の取得 00046 * @return 位置 00047 */ 00048 virtual const Vector3& getPosition() const{ return position_; } 00049 00050 //-------------------------------------------------------------------------- 00051 /** 00052 * 速度の設定 00053 * @param velocity 速度 00054 */ 00055 virtual void setVelocity(const Vector3& velocity); 00056 00057 /** 00058 * 速度の取得 00059 * @return 速度 00060 */ 00061 virtual const Vector3& getVelocity() const{ return velocity_; } 00062 00063 //-------------------------------------------------------------------------- 00064 /** 00065 * 位置と速度の設定 00066 * @param position 位置 00067 * @param millisecond 前回からの時間をミリ秒で設定 00068 */ 00069 virtual void setPositionAndVelocity( 00070 const Vector3& position, float millisecond); 00071 00072 //-------------------------------------------------------------------------- 00073 /** 00074 * 方向の設定 00075 * @param frontDirection 前方向 00076 * @param upDirection 上方向 00077 */ 00078 virtual void setDirection( 00079 const Vector3& frontDirection, const Vector3& upDirection); 00080 00081 /** 00082 * 前方向の取得 00083 * @return 前方向 00084 */ 00085 virtual const Vector3& getFrontDirection() const{ return frontDirection_; } 00086 00087 /** 00088 * 上方向の取得 00089 * @return 上方向 00090 */ 00091 virtual const Vector3& getUpDirection() const{ return upDirection_; } 00092 00093 //-------------------------------------------------------------------------- 00094 /** 00095 * 距離係数の設定 00096 * 00097 * デフォルト値はSoundDefinitionで定義されています。 00098 * @param distanceFactor 距離係数 00099 */ 00100 virtual void setDistanceFactor(float distanceFactor); 00101 00102 /** 00103 * 距離係数の取得 00104 * 00105 * デフォルト値はSoundDefinitionで定義されています。 00106 * @return 距離係数 00107 */ 00108 virtual float getDistanceFactor() const{ return distanceFactor_; } 00109 00110 //-------------------------------------------------------------------------- 00111 /** 00112 * ロールオフ係数の設定 00113 * @param rolloffFactor ロールオフ係数 00114 */ 00115 virtual void setRolloffFactor(float rolloffFactor); 00116 00117 /** 00118 * ロールオフ係数の取得 00119 * @return ロールオフ係数 00120 */ 00121 virtual float getRolloffFactor() const{ return rolloffFactor_; } 00122 00123 //-------------------------------------------------------------------------- 00124 /** 00125 * ドップラー係数の設定 00126 * @param dopplerFactor ドップラー係数 00127 */ 00128 virtual void setDopplerFactor(float dopplerFactor); 00129 00130 /** 00131 * ドップラー係数の取得 00132 * @return ドップラー係数 00133 */ 00134 virtual float getDopplerFactor() const{ return dopplerFactor_; } 00135 00136 //-------------------------------------------------------------------------- 00137 /** 00138 * 文字列への変換 00139 * @return 文字列 00140 */ 00141 virtual String toString() const; 00142 00143 //-------------------------------------------------------------------------- 00144 /** 00145 * 3D設定の適用 00146 * 00147 * 通常はLampSound::presentation()から呼ばれます。 00148 */ 00149 virtual void apply3DSettings(); 00150 00151 private: 00152 //-------------------------------------------------------------------------- 00153 /** 00154 * コンストラクタ 00155 * @param primaryBuffer プライマリバッファ 00156 */ 00157 SoundListener(DirectSoundPrimaryBuffer* primaryBuffer); 00158 00159 /** 00160 * デストラクタ 00161 */ 00162 virtual ~SoundListener(); 00163 00164 //-------------------------------------------------------------------------- 00165 // コピーコンストラクタの隠蔽 00166 SoundListener(const SoundListener& copy); 00167 00168 // 代入コピーの隠蔽 00169 void operator =(const SoundListener& copy); 00170 00171 // リスナ 00172 DirectSound3DListener* listener_; 00173 // 位置 00174 Vector3 position_; 00175 // 速度 00176 Vector3 velocity_; 00177 // 前方向 00178 Vector3 frontDirection_; 00179 // 上方向 00180 Vector3 upDirection_; 00181 // 距離係数 00182 float distanceFactor_; 00183 // ロールオフ係数 00184 float rolloffFactor_; 00185 // ドップラー係数 00186 float dopplerFactor_; 00187 00188 }; 00189 00190 //------------------------------------------------------------------------------ 00191 } // End of namespace Lamp 00192 #endif // End of SOUND_LISTENER_H_ 00193 //------------------------------------------------------------------------------