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

Fog.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  * フォグヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef FOG_H_
00026 #define FOG_H_
00027 
00028 namespace Lamp{
00029 
00030 //------------------------------------------------------------------------------
00031 /**
00032  * フォグ
00033  */
00034 class Fog{
00035 friend class Scene;
00036 public:
00037     /// モード
00038     enum Mode{
00039         /// 線形フォグ
00040         modeLinear = 0,
00041         /// 指数フォグ
00042         modeExponent,
00043         /// 二乗の指数フォグ
00044         modeExponent2
00045     };
00046 
00047     //--------------------------------------------------------------------------
00048     /**
00049      * 限界値の取得
00050      * @return 限界値
00051      */
00052     virtual float getLimit();
00053 
00054     //--------------------------------------------------------------------------
00055     /**
00056      * 有効、無効の設定
00057      * @param enabled trueなら有効、falseなら無効
00058      */
00059     virtual void setEnabled(bool enabled){ enabled_ = enabled; }
00060 
00061     /**
00062      * 有効、無効の取得
00063      * @return trueなら有効、falseなら無効
00064      */
00065     virtual bool isEnabled() const{ return enabled_; }
00066 
00067     //--------------------------------------------------------------------------
00068     /**
00069      * 色の設定
00070      * @param color 色
00071      */
00072     virtual void setColor(const Color4c& color){
00073         Assert(color.a == 0);
00074         color_ = color;
00075     }
00076 
00077     /**
00078      * 色の取得
00079      * @return 色
00080      */
00081     virtual const Color4c& getColor() const{ return color_; }
00082 
00083     //--------------------------------------------------------------------------
00084     /**
00085      * モードの設定
00086      * @param mode モード
00087      */
00088     virtual void setMode(Mode mode){ mode_ = mode; }
00089 
00090     /**
00091      * モードの取得
00092      * @return モード
00093      */
00094     virtual Mode getMode() const{ return mode_; }
00095 
00096     /**
00097      * モード文字列の設定
00098      * @param mode モード文字列
00099      */
00100     virtual void setModeString(const String& mode){
00101         if(mode == "linear"){
00102             mode_ = modeLinear;
00103         }else if(mode == "exponent"){
00104             mode_ = modeExponent;
00105         }else if(mode == "exponent2"){
00106             mode_ = modeExponent2;
00107         }else{
00108             ErrorOut("Fog::setModeString() "
00109                 "Unknown fog mode " + mode);
00110         }
00111     }
00112 
00113     /**
00114      * モード文字列の取得
00115      * @return モード文字列
00116      */
00117     virtual String getModeString() const{
00118         if(mode_ == modeLinear){
00119             return "linear";
00120         }else if(mode_ == modeExponent){
00121             return "exponent";
00122         }else if(mode_ == modeExponent2){
00123             return "exponent2";
00124         }
00125         return "";
00126     }
00127 
00128     //--------------------------------------------------------------------------
00129     /**
00130      * 濃度の設定
00131      *
00132      * モードがmodeExponent、modeExponent2の時に使用されます
00133      * @param density 濃度
00134      */
00135     virtual void setDensity(float density){
00136         Assert(density >= 0.f);
00137         Assert(density <= 1.f);
00138         density_ = density;
00139     }
00140 
00141     /**
00142      * 濃度の取得
00143      *
00144      * モードがmodeExponent、modeExponent2の時に使用されます
00145      * @return 濃度
00146      */
00147     virtual float getDensity() const{ return density_; }
00148 
00149     //--------------------------------------------------------------------------
00150     /**
00151      * ニアの設定
00152      *
00153      * モードがmodeLifogNearの時に使用されます
00154      * @param fogNear ニア
00155      */
00156     virtual void setNear(float fogNear){
00157         Assert(fogNear >= 0.f);
00158         fogNear_ = fogNear;
00159     }
00160 
00161     /**
00162      * ニアの取得
00163      *
00164      * モードがmodeLifogNearの時に使用されます
00165      * @return ニア
00166      */
00167     virtual float getNear() const{ return fogNear_; }
00168 
00169     //--------------------------------------------------------------------------
00170     /**
00171      * ファーの設定
00172      *
00173      * モードがmodeLifogNearの時に使用されます
00174      * @param fogFar ファー
00175      */
00176     virtual void setFar(float fogFar){
00177         Assert(fogFar >= 0.f);
00178         fogFar_ = fogFar;
00179     }
00180 
00181     /**
00182      * ファーの取得
00183      *
00184      * モードがmodeLifogNearの時に使用されます
00185      * @return ファー
00186      */
00187     virtual float getFar() const{ return fogFar_; }
00188 
00189     //--------------------------------------------------------------------------
00190 protected:
00191     /**
00192      * コンストラクタ
00193      */
00194     Fog();
00195 
00196     /**
00197      * デストラクタ
00198      */
00199     virtual ~Fog();
00200 
00201     //--------------------------------------------------------------------------
00202 private:
00203     // コピーコンストラクタの隠蔽
00204     Fog(const Fog& copy);
00205 
00206     // 代入コピーの隠蔽
00207     void operator =(const Fog& copy);
00208 
00209     // 色
00210     Color4c color_;
00211     // モード
00212     Mode mode_;
00213     // 濃度
00214     float density_;
00215     // ニア
00216     float fogNear_;
00217     // ファー
00218     float fogFar_;
00219     // 有効、無効
00220     bool enabled_;
00221     // リミット値
00222     static const float limitValue;
00223     // 指数ドロップオフリミット係数
00224     static const float exponentLimit;
00225     // 二乗の指数ドロップオフリミット係数
00226     static const float exponent2Limit;
00227 
00228 };
00229 
00230 //------------------------------------------------------------------------------
00231 } // End of namespace Lamp
00232 #endif // End of FOG_H_
00233 //------------------------------------------------------------------------------

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