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

BasicMaterial.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 BASIC_MATERIAL_H_
00026 #define BASIC_MATERIAL_H_
00027 
00028 #include <Graphics/Material/Material.h>
00029 
00030 namespace Lamp{
00031 
00032 //------------------------------------------------------------------------------
00033 /**
00034  * 基本マテリアル
00035  */
00036 class BasicMaterial : public Material{
00037 friend class MaterialManager;
00038 public:
00039     /**
00040      * 基本マテリアルかどうか
00041      * @return 基本マテリアルならtrue
00042      */
00043     virtual bool isBasicMaterial() const{ return true; }
00044 
00045     //--------------------------------------------------------------------------
00046     /**
00047      * コピー
00048      * @param copyMask コピーマスク
00049      * @return コピーされたマテリアル
00050      */
00051     virtual Material* copy(u_int copyMask = 0) const{
00052         return copyBasicMaterial(copyMask);
00053     }
00054 
00055     /**
00056      * 基本マテリアルのコピー
00057      * @param copyMask コピーマスク
00058      * @return コピーされたマテリアル
00059      */
00060     virtual BasicMaterial* copyBasicMaterial(u_int copyMask = 0) const;
00061 
00062     //--------------------------------------------------------------------------
00063     // 描画
00064     //--------------------------------------------------------------------------
00065     /**
00066      * 描画
00067      * @param request 描画リクエスト
00068      */
00069     virtual void draw(DrawRequest* request);
00070 
00071     //--------------------------------------------------------------------------
00072     // ベーステクスチャインターフェース
00073     //--------------------------------------------------------------------------
00074     /**
00075      * ベーステクスチャの設定
00076      * @param baseTexture 設定するベーステクスチャ
00077      */
00078     virtual void setBaseTexture(Texture* baseTexture){
00079         baseTexture_ = setTextureReferense(baseTexture_, baseTexture);
00080     }
00081 
00082     /**
00083      * ベーステクスチャの取得
00084      * @return ベーステクスチャ
00085      */
00086     virtual Texture* getBaseTexture() const{ return baseTexture_; }
00087 
00088     /**
00089      * ベーステクスチャの削除
00090      */
00091     virtual void removeBaseTexture(){ setBaseTexture(NULL); }
00092 
00093     //--------------------------------------------------------------------------
00094     /**
00095      * ベースUVインデックスの設定
00096      * @param baseUVIndex ベースUVインデックス
00097      */
00098     virtual void setBaseUVIndex(int baseUVIndex){
00099         Assert((baseUVIndex >= 0) && (baseUVIndex < 8));
00100         baseUVIndex_ = baseUVIndex;
00101     }
00102 
00103     /**
00104      * ベースUVインデックスの取得
00105      * @return ベースUVインデックス
00106      */
00107     virtual int getBaseUVIndex() const{ return baseUVIndex_; }
00108 
00109     //--------------------------------------------------------------------------
00110     // 光沢テクスチャインターフェース
00111     //--------------------------------------------------------------------------
00112     /**
00113      * 光沢テクスチャの設定
00114      * @param glossTexture 設定する光沢テクスチャ
00115      */
00116     virtual void setGlossTexture(Texture* glossTexture){
00117         glossTexture_ = setTextureReferense(glossTexture_, glossTexture);
00118     }
00119 
00120     /**
00121      * 光沢テクスチャの取得
00122      * @return 光沢テクスチャ
00123      */
00124     virtual Texture* getGlossTexture() const{ return glossTexture_; }
00125 
00126     /**
00127      * 光沢テクスチャの削除
00128      */
00129     virtual void removeGlossTexture(){ setGlossTexture(NULL); }
00130 
00131     //--------------------------------------------------------------------------
00132     /**
00133      * 光沢UVインデックスの設定
00134      * @param glossUVIndex 光沢UVインデックス
00135      */
00136     virtual void setGlossUVIndex(int glossUVIndex){
00137         Assert((glossUVIndex >= 0) && (glossUVIndex < 8));
00138         glossUVIndex_ = glossUVIndex;
00139     }
00140 
00141     /**
00142      * 光沢UVインデックスの取得
00143      * @return 光沢UVインデックス
00144      */
00145     virtual int getGlossUVIndex() const{ return glossUVIndex_; }
00146 
00147     //--------------------------------------------------------------------------
00148     // ライトテクスチャインターフェース
00149     //--------------------------------------------------------------------------
00150     /**
00151      * ライトテクスチャの設定
00152      * @param lightTexture 設定するライトテクスチャ
00153      */
00154     virtual void setLightTexture(Texture* lightTexture){
00155         lightTexture_ = setTextureReferense(lightTexture_, lightTexture);
00156     }
00157 
00158     /**
00159      * ライトテクスチャの取得
00160      * @return ライトテクスチャ
00161      */
00162     virtual Texture* getLightTexture() const{ return lightTexture_; }
00163 
00164     /**
00165      * ライトテクスチャの削除
00166      */
00167     virtual void removeLightTexture(){ setLightTexture(NULL); }
00168 
00169     //--------------------------------------------------------------------------
00170     /**
00171      * ライトUVインデックスの設定
00172      * @param lightUVIndex ライトUVインデックス
00173      */
00174     virtual void setLightUVIndex(int lightUVIndex){
00175         Assert((lightUVIndex >= 0) && (lightUVIndex < 8));
00176         lightUVIndex_ = lightUVIndex;
00177     }
00178 
00179     /**
00180      * ライトUVインデックスの取得
00181      * @return ライトUVインデックス
00182      */
00183     virtual int getLightUVIndex() const{ return lightUVIndex_; }
00184 
00185     //--------------------------------------------------------------------------
00186     // 汚れテクスチャインターフェース
00187     //--------------------------------------------------------------------------
00188     /**
00189      * 汚れテクスチャの設定
00190      * @param stainTexture 設定する汚れテクスチャ
00191      */
00192     virtual void setStainTexture(Texture* stainTexture){
00193         stainTexture_ = setTextureReferense(stainTexture_, stainTexture);
00194     }
00195 
00196     /**
00197      * 汚れテクスチャの取得
00198      * @return 汚れテクスチャ
00199      */
00200     virtual Texture* getStainTexture() const{ return stainTexture_; }
00201 
00202     /**
00203      * 汚れテクスチャの削除
00204      */
00205     virtual void removeStainTexture(){ setStainTexture(NULL); }
00206 
00207     //--------------------------------------------------------------------------
00208     /**
00209      * 汚れUVインデックスの設定
00210      * @param stainUVIndex 汚れUVインデックス
00211      */
00212     virtual void setStainUVIndex(int stainUVIndex){
00213         Assert((stainUVIndex >= 0) && (stainUVIndex < 8));
00214         stainUVIndex_ = stainUVIndex;
00215     }
00216 
00217     /**
00218      * 汚れUVインデックスの取得
00219      * @return 汚れUVインデックス
00220      */
00221     virtual int getStainUVIndex() const{ return stainUVIndex_; }
00222 
00223     //--------------------------------------------------------------------------
00224     // ディフューズ
00225     //--------------------------------------------------------------------------
00226     /**
00227      * ディフューズカラーの設定
00228      * @param diffuseColor ディフューズカラー
00229      */
00230     virtual void setDiffuseColor(const Color3f& diffuseColor){
00231         diffuseColor_ = diffuseColor;
00232         stateChanged();
00233     }
00234 
00235     /**
00236      * ディフューズカラーの取得
00237      * @return ディフューズカラー
00238      */
00239     virtual const Color3f& getDiffuseColor() const{ return diffuseColor_; }
00240 
00241     //--------------------------------------------------------------------------
00242     // スペキュラ
00243     //--------------------------------------------------------------------------
00244     /**
00245      * スペキュラカラーの設定
00246      * @param specularColor スペキュラカラー
00247      */
00248     virtual void setSpecularColor(const Color3f& specularColor){
00249         specularColor_ = specularColor;
00250         stateChanged();
00251     }
00252 
00253     /**
00254      * スペキュラカラーの取得
00255      * @return スペキュラカラー
00256      */
00257     virtual const Color3f& getSpecularColor() const{ return specularColor_; }
00258 
00259     //--------------------------------------------------------------------------
00260     /**
00261      * スペキュラパワーの設定
00262      * @param specularPower スペキュラパワー
00263      */
00264     virtual void setSpecularPower(float specularPower){
00265         specularPower_ = specularPower;
00266         stateChanged();
00267     }
00268 
00269     /**
00270      * スペキュラパワーの取得
00271      * @return スペキュラパワー
00272      */
00273     virtual float getSpecularPower() const{ return specularPower_; }
00274 
00275     //--------------------------------------------------------------------------
00276     /**
00277      * スペキュラが有効か
00278      * @return スペキュラが有効ならtrue
00279      */
00280     virtual bool isSpecularEnabled() const{
00281         return (specularColor_ != Color3f::black);
00282     }
00283 
00284     //--------------------------------------------------------------------------
00285     // アンビエント
00286     //--------------------------------------------------------------------------
00287     /**
00288      * アンビエントカラーの設定
00289      * @param ambientColor アンビエントカラー
00290      */
00291     virtual void setAmbientColor(const Color3f& ambientColor){
00292         ambientColor_ = ambientColor;
00293         stateChanged();
00294     }
00295 
00296     /**
00297      * アンビエントカラーの取得
00298      * @return アンビエントカラー
00299      */
00300     virtual const Color3f& getAmbientColor() const{ return ambientColor_; }
00301 
00302     //--------------------------------------------------------------------------
00303     // エミッシブ
00304     //--------------------------------------------------------------------------
00305     /**
00306      * エミッシブカラーの設定
00307      * @param emissiveColor エミッシブカラー
00308      */
00309     virtual void setEmissiveColor(const Color3f& emissiveColor){
00310         emissiveColor_ = emissiveColor;
00311         stateChanged();
00312     }
00313 
00314     /**
00315      * エミッシブカラーの取得
00316      * @return エミッシブカラー
00317      */
00318     virtual const Color3f& getEmissiveColor() const{ return emissiveColor_; }
00319 
00320     //--------------------------------------------------------------------------
00321 protected:
00322     /**
00323      * コンストラクタ
00324      * @param name 名前
00325      * @param scene シーン
00326      */
00327     BasicMaterial(const String& name, Scene* scene);
00328 
00329     /**
00330      * デストラクタ
00331      */
00332     virtual ~BasicMaterial();
00333 
00334     //--------------------------------------------------------------------------
00335     /**
00336      * 子の破棄
00337      * @return 破棄したオブジェクト数
00338      */
00339     virtual int destroyChildren();
00340 
00341     //--------------------------------------------------------------------------
00342     // 描画
00343     //--------------------------------------------------------------------------
00344     /**
00345      * ステートブロックの構築
00346      * @param startBlock [out]開始ステートブロック
00347      * @param endBlock [out]終了ステートブロック
00348      */
00349     virtual void buildStateBlock(
00350         Direct3DStateBlock** startBlock, Direct3DStateBlock** endBlock);
00351 
00352     //--------------------------------------------------------------------------
00353 private:
00354     // ベーステクスチャ
00355     Texture* baseTexture_;
00356     // 光沢テクスチャ
00357     Texture* glossTexture_;
00358     // ライトテクスチャ
00359     Texture* lightTexture_;
00360     // 汚れテクスチャ
00361     Texture* stainTexture_;
00362     // ディフューズカラー
00363     Color3f diffuseColor_;
00364     // スペキュラカラー
00365     Color3f specularColor_;
00366     // アンビエントカラー
00367     Color3f ambientColor_;
00368     // エミッシブカラー
00369     Color3f emissiveColor_;
00370     // スペキュラパワー
00371     float specularPower_;
00372     // ベースUVインデックス
00373     int baseUVIndex_;
00374     // 光沢UVインデックス
00375     int glossUVIndex_;
00376     // ライトUVインデックス
00377     int lightUVIndex_;
00378     // 汚れUVインデックス
00379     int stainUVIndex_;
00380 
00381 };
00382 
00383 //------------------------------------------------------------------------------
00384 } // End of namespace Lamp
00385 #endif // End of BASIC_MATERIAL_H_
00386 //------------------------------------------------------------------------------

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