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

Texture.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 TEXTURE_H_
00026 #define TEXTURE_H_
00027 
00028 #include <Graphics/Scene/SceneObject.h>
00029 #include <Core/Container/ArrayList.h>
00030 
00031 namespace Lamp{
00032 
00033 class Picture;
00034 class SurfaceTexture;
00035 
00036 //------------------------------------------------------------------------------
00037 /**
00038  * テクスチャ
00039  */
00040 class Texture : public SceneObject{
00041 friend class SceneObjectManagerTemplate<Texture>;
00042 friend class TextureManager;
00043 friend class Material;
00044 friend class RenderingDevice;
00045 public:
00046     /**
00047      * リファレンスカウントの取得
00048      * @return リファレンスカウント
00049      */
00050     virtual int getReferenceCount() const{ return parents_.getCount(); }
00051 
00052     //--------------------------------------------------------------------------
00053     /**
00054      * コピー
00055      * @param copyMask コピーマスク
00056      * @return コピーされたテクスチャ
00057      */
00058     virtual Texture* copy(u_int copyMask = 0) const = 0;
00059 
00060     /**
00061      * 再帰的破棄
00062      * @param texture 破棄するテクスチャ
00063      * @return 破棄したオブジェクト数
00064      */
00065     static int recursiveDestroy(Texture* texture);
00066 
00067     //--------------------------------------------------------------------------
00068     /**
00069      * ステート変更フラグを立てる
00070      */
00071     virtual void stateChanged();
00072 
00073     //--------------------------------------------------------------------------
00074     /**
00075      * 親のサイズ取得
00076      * @return 親のサイズ
00077      */
00078     virtual int getParentCount() const{ return parents_.getCount(); }
00079 
00080     /**
00081      * 親の取得
00082      * @param index 親のインデックス
00083      * @return 親
00084      */
00085     virtual Material* getParent(int index) const{
00086         Assert(index >= 0);
00087         Assert(index < getParentCount());
00088         return parents_.get(index);
00089     }
00090 
00091     //--------------------------------------------------------------------------
00092     // アドレスモード
00093     //--------------------------------------------------------------------------
00094     /// アドレスモード
00095     enum AddressMode{
00096         addressModeWrap = 0,
00097         addressModeClamp,
00098         addressModeMirror,
00099         addressModeMax,
00100     };
00101 
00102     /**
00103      * アドレスモードから文字列への変換
00104      * @param addressMode アドレスモード
00105      * @return アドレスモード文字列
00106      */
00107     static const String& addressModeToString(AddressMode addressMode);
00108 
00109     /**
00110      * 文字列からアドレスモードへの変換
00111      * @param addressModeString アドレスモード文字列
00112      * @return アドレスモード
00113      */
00114     static AddressMode addressModeFromString(const String& addressModeString);
00115 
00116     //--------------------------------------------------------------------------
00117     // ピクチャインターフェース
00118     //--------------------------------------------------------------------------
00119     /**
00120      * ピクチャの追加
00121      * @param picture 追加するピクチャ
00122      */
00123     virtual void addPicture(Picture* picture) = 0;
00124 
00125     /**
00126      * ピクチャの削除
00127      * @param picture 削除するピクチャ
00128      */
00129     virtual void removePicture(Picture* picture) = 0;
00130 
00131     /**
00132      * ピクチャ数の取得
00133      * @return ピクチャ数
00134      */
00135     virtual int getPictureCount() const = 0;
00136 
00137     /**
00138      * ピクチャの取得
00139      * @param index インデックス
00140      * @return ピクチャ
00141      */
00142     virtual Picture* getPicture(int index) const = 0;
00143 
00144     //--------------------------------------------------------------------------
00145     // RTTI
00146     //--------------------------------------------------------------------------
00147     /**
00148      * テクスチャかどうか
00149      * @return テクスチャならtrue
00150      */
00151     virtual bool isTexture() const{ return true; }
00152 
00153     //--------------------------------------------------------------------------
00154     /**
00155      * サーフェーステクスチャかどうか
00156      * @return サーフェーステクスチャならtrue
00157      */
00158     virtual bool isSurfaceTexture() const{ return false; }
00159 
00160     /**
00161      * サーフェーステクスチャへのキャスト
00162      * @return サーフェーステクスチャ。型が違えばNULLを返す。
00163      */
00164     virtual SurfaceTexture* castSurfaceTexture() const{
00165         if(isSurfaceTexture()){ return (SurfaceTexture*)this; }
00166         return NULL;
00167     }
00168 
00169     //--------------------------------------------------------------------------
00170 protected:
00171     /**
00172      * コンストラクタ
00173      * @param name 名前
00174      * @param scene シーン
00175      */
00176     Texture(const String& name, Scene* scene);
00177 
00178     /**
00179      * デストラクタ
00180      */
00181     virtual ~Texture();
00182 
00183     /**
00184      * テクスチャの値コピー
00185      * @param destination コピー先テクスチャ
00186      * @param copyMask コピーマスク
00187      */
00188     virtual void copyTextureValue(Texture* destination, u_int copyMask) const;
00189 
00190     /**
00191      * 参照の追加
00192      * @param parent 親
00193      * @return 参照カウント
00194      */
00195     virtual int addReference(Material* parent){
00196         parents_.add(parent);
00197         return getParentCount();
00198     }
00199 
00200     /**
00201      * 参照の削除
00202      * @param parent 親
00203      * @return 参照カウント
00204      */
00205     virtual int removeReference(Material* parent){
00206         parents_.removeByValue(parent);
00207         return getParentCount();
00208     }
00209 
00210     /**
00211      * ピクチャリファレンスの追加
00212      * @param picture リファレンスを追加するピクチャ
00213      */
00214     virtual void addPictureReference(Picture* picture);
00215 
00216     /**
00217      * ピクチャリファレンスの削除
00218      * @param picture リファレンスを削除するピクチャ
00219      */
00220     virtual void removePictureReference(Picture* picture);
00221 
00222     /**
00223      * D3Dテクスチャの取得
00224      * @return D3Dテクスチャの取得
00225      */
00226     virtual Direct3DTexture* getD3DTexture() = 0;
00227 
00228     //--------------------------------------------------------------------------
00229 private:
00230     // 親配列
00231     ArrayList<Material*> parents_;
00232 
00233     // アドレスモード文字列テーブル
00234     static const String addressModeStringTable[];
00235 
00236 };
00237 
00238 //------------------------------------------------------------------------------
00239 } // End of namespace Lamp
00240 #endif // End of TEXTURE_H_
00241 //------------------------------------------------------------------------------
00242 

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