Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

Sound3D.h

Go to the documentation of this file.
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  * 3Dサウンドヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef SOUND_3D_H_
00026 #define SOUND_3D_H_
00027 
00028 #include <Sound/System/SoundBuffer.h>
00029 
00030 namespace Lamp{
00031 
00032 //------------------------------------------------------------------------------
00033 /**
00034  * 3Dサウンド
00035  */
00036 class Sound3D : public SoundBuffer{
00037 public:
00038     //--------------------------------------------------------------------------
00039     // 再生
00040     //--------------------------------------------------------------------------
00041     /**
00042      * 再生
00043      * @return 正常に再生されればtrue
00044      */
00045     virtual bool play(){
00046         apply3DSettings();
00047         return SoundBuffer::play();
00048     }
00049 
00050     //--------------------------------------------------------------------------
00051     // 3Dパラメータ
00052     //--------------------------------------------------------------------------
00053     /**
00054      * 位置の設定
00055      * @param position 位置
00056      */
00057     virtual void setPosition(const Vector3& position);
00058 
00059     /**
00060      * 位置の取得
00061      * @return 位置
00062      */
00063     virtual const Vector3& getPosition() const{ return position_; }
00064 
00065     /**
00066      * 速度の設定
00067      * @param velocity 速度
00068      */
00069     virtual void setVelocity(const Vector3& velocity);
00070 
00071     /**
00072      * 速度の取得
00073      * @return 速度
00074      */
00075     virtual const Vector3& getVelocity() const{ return velocity_; }
00076 
00077     /**
00078      * 位置と速度の設定
00079      * @param position 位置
00080      * @param millisecond 前回からの時間をミリ秒で設定
00081      */
00082     virtual void setPositionAndVelocity(
00083         const Vector3& position, float millisecond);
00084 
00085     //--------------------------------------------------------------------------
00086     /**
00087      * 最小距離の設定
00088      * @param minimumDistance 最小距離
00089      */
00090     virtual void setMinimumDistance(float minimumDistance);
00091 
00092     /**
00093      * 最小距離の取得
00094      * @return 最小距離
00095      */
00096     virtual float getMinimumDistance() const{ return minimumDistance_; }
00097 
00098     /**
00099      * 最大距離の設定
00100      * @param maximumDistance 最大距離
00101      */
00102     virtual void setMaximumDistance(float maximumDistance);
00103 
00104     /**
00105      * 最大距離の取得
00106      * @return 最大距離
00107      */
00108     virtual float getMaximumDistance() const{ return maximumDistance_; }
00109 
00110     /**
00111      * 距離の設定
00112      * @param minimumDistance 最小距離
00113      * @param maximumDistance 最大距離
00114      */
00115     virtual void setDistance(float minimumDistance, float maximumDistance){
00116         Assert(minimumDistance <= maximumDistance);
00117         setMinimumDistance(minimumDistance);
00118         setMaximumDistance(maximumDistance);
00119     }
00120 
00121     //--------------------------------------------------------------------------
00122     /**
00123      * コーンの向きの設定
00124      * @param coneDirection コーンの向き
00125      */
00126     virtual void setConeDirection(const Vector3& coneDirection);
00127 
00128     /**
00129      * コーンの向きの取得
00130      * @return コーンの向き
00131      */
00132     virtual const Vector3& getConeDirection() const{ return coneDirection_; }
00133 
00134     //--------------------------------------------------------------------------
00135     /**
00136      * コーン角度の設定
00137      * @param insideConeAngle 内側コーン角度をラジアンで指定
00138      * @param outsideConeAngle 外側コーン角度をラジアンで指定
00139      */
00140     virtual void setConeAngle(float insideConeAngle, float outsideConeAngle);
00141 
00142     /**
00143      * 内側コーン角度の取得
00144      * @return ラジアンによる内側コーン角度
00145      */
00146     virtual float getInsideConeAngle() const{ return insideConeAngle_; }
00147 
00148     /**
00149      * 外側コーン角度の取得
00150      * @return ラジアンによる外側コーン角度
00151      */
00152     virtual float getOutsideConeAngle() const{ return outsideConeAngle_; }
00153 
00154     //--------------------------------------------------------------------------
00155     /**
00156      * コーン外側ボリュームの設定
00157      * @param coneOutsideVolume コーン外側ボリュームを0.fから1.fの間で指定
00158      */
00159     virtual void setConeOutsideVolume(float coneOutsideVolume);
00160 
00161     /**
00162      * コーン外側ボリュームの取得
00163      * @return コーン外側ボリューム
00164      */
00165     virtual float getConeOutsideVolume() const{ return coneOutsideVolume_; }
00166 
00167     //--------------------------------------------------------------------------
00168     /**
00169      * 3Dの有効、無効設定
00170      * @param enabled 3Dが有効ならtrue
00171      */
00172     virtual void set3DEnabled(bool enabled);
00173 
00174     /**
00175      * 3Dが有効か
00176      * @return 3Dが有効ならtrue
00177      */
00178     virtual bool is3DEnabled() const{ return is3DEnabled_; }
00179 
00180     //--------------------------------------------------------------------------
00181     /**
00182      * 3D設定の適用
00183      *
00184      * 通常はLampSound::presentation()から呼ばれます。
00185      */
00186     virtual void apply3DSettings();
00187 
00188     //--------------------------------------------------------------------------
00189     // その他
00190     //--------------------------------------------------------------------------
00191     /**
00192      * リセット
00193      * @param flags リセットフラグ
00194      */
00195     virtual void reset(Reset flags);
00196 
00197     //--------------------------------------------------------------------------
00198     /**
00199      * 文字列への変換
00200      * @return 文字列
00201      */
00202     virtual String toString() const;
00203 
00204     //--------------------------------------------------------------------------
00205     // RTTI
00206     //--------------------------------------------------------------------------
00207     /**
00208      * 3Dサウンドかどうか
00209      * @return 3Dサウンドならtrue
00210      */
00211     virtual bool isSound3D() const{ return true; }
00212 
00213 protected:
00214     //--------------------------------------------------------------------------
00215     /**
00216      * コンストラクタ
00217      * @param soundBuffer サウンドバッファ
00218      */
00219     Sound3D(DirectSoundBuffer* soundBuffer);
00220 
00221     /**
00222      * デストラクタ
00223      */
00224     virtual ~Sound3D();
00225 
00226     /**
00227      * 3Dサウンドデータのコピー
00228      * @param destination コピー先3Dサウンド
00229      */
00230     virtual void copySound3DData(Sound3D* destination);
00231 
00232 private:
00233     //--------------------------------------------------------------------------
00234     // 3Dバッファ
00235     DirectSound3DBuffer* sound3DBuffer_;
00236     // 位置
00237     Vector3 position_;
00238     // 速度
00239     Vector3 velocity_;
00240     // コーンの向き
00241     Vector3 coneDirection_;
00242     // 最小距離
00243     float minimumDistance_;
00244     // 最大距離
00245     float maximumDistance_;
00246     // 内側コーン角度
00247     float insideConeAngle_;
00248     // 外側コーン角度
00249     float outsideConeAngle_;
00250     // コーン外側ボリューム
00251     float coneOutsideVolume_;
00252     // 3Dが有効か
00253     bool is3DEnabled_;
00254 
00255 };
00256 
00257 //------------------------------------------------------------------------------
00258 } // End of namespace Lamp
00259 #endif // End of SOUND_3D_H_
00260 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:35 2005 for Lamp by doxygen 1.3.2