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 SURFACE_TEXTURE_H_ 00026 #define SURFACE_TEXTURE_H_ 00027 00028 #include <Graphics/Texture/Texture.h> 00029 00030 namespace Lamp{ 00031 00032 //------------------------------------------------------------------------------ 00033 /** 00034 * サーフェーステクスチャ 00035 */ 00036 class SurfaceTexture : public Texture{ 00037 friend class TextureManager; 00038 public: 00039 /** 00040 * サーフェーステクスチャかどうか 00041 * @return サーフェーステクスチャならtrue 00042 */ 00043 virtual bool isSurfaceTexture() const{ return true; } 00044 00045 //-------------------------------------------------------------------------- 00046 /** 00047 * コピー 00048 * @param copyMask コピーマスク 00049 * @return コピーされたテクスチャ 00050 */ 00051 virtual Texture* copy(u_int copyMask = 0) const{ 00052 return copySurfaceTexture(copyMask); 00053 } 00054 00055 /** 00056 * サーフェーステクスチャのコピー 00057 * @param copyMask コピーマスク 00058 * @return コピーされたサーフェーステクスチャ 00059 */ 00060 virtual SurfaceTexture* copySurfaceTexture(u_int copyMask = 0) const; 00061 00062 //-------------------------------------------------------------------------- 00063 // ピクチャインターフェース 00064 //-------------------------------------------------------------------------- 00065 /** 00066 * ピクチャの追加 00067 * @param picture 追加するピクチャ 00068 */ 00069 virtual void addPicture(Picture* picture){ 00070 Assert(picture_ == NULL); 00071 Assert(picture != NULL); 00072 picture_ = picture; 00073 addPictureReference(picture_); 00074 stateChanged(); 00075 } 00076 00077 /** 00078 * ピクチャの削除 00079 * @param picture 削除するピクチャ 00080 */ 00081 virtual void removePicture(Picture* picture){ 00082 Assert(picture_ == picture); 00083 removePictureReference(picture_); 00084 picture_ = NULL; 00085 stateChanged(); 00086 } 00087 00088 /** 00089 * ピクチャ数の取得 00090 * @return ピクチャ数 00091 */ 00092 virtual int getPictureCount() const{ 00093 if(picture_ == NULL){ return 0; } 00094 return 1; 00095 } 00096 00097 /** 00098 * ピクチャの取得 00099 * @param index インデックス 00100 * @return ピクチャ 00101 */ 00102 virtual Picture* getPicture(int index) const{ 00103 Assert(picture_ != NULL); 00104 Assert(index == 0); 00105 return picture_; 00106 } 00107 00108 //-------------------------------------------------------------------------- 00109 /** 00110 * アドレスモードUの設定 00111 * @param addressModeU アドレスモードU 00112 */ 00113 virtual void setAddressModeU(AddressMode addressModeU){ 00114 addressModeU_ = addressModeU; 00115 stateChanged(); 00116 } 00117 00118 /** 00119 * アドレスモードUの取得 00120 * @return アドレスモードU 00121 */ 00122 virtual AddressMode getAddressModeU() const{ return addressModeU_; } 00123 00124 //-------------------------------------------------------------------------- 00125 /** 00126 * アドレスモードVの設定 00127 * @param addressModeV アドレスモードV 00128 */ 00129 virtual void setAddressModeV(AddressMode addressModeV){ 00130 addressModeV_ = addressModeV; 00131 stateChanged(); 00132 } 00133 00134 /** 00135 * アドレスモードVの取得 00136 * @return アドレスモードV 00137 */ 00138 virtual AddressMode getAddressModeV() const{ return addressModeV_; } 00139 00140 //-------------------------------------------------------------------------- 00141 /** 00142 * リピートUVの設定 00143 * @param repeatUV リピートUV 00144 */ 00145 virtual void setRepeatUV(const TexCoord2& repeatUV){ 00146 repeatUV_ = repeatUV; 00147 stateChanged(); 00148 } 00149 00150 /** 00151 * リピートUVの取得 00152 * @return リピートUV 00153 */ 00154 virtual const TexCoord2& getRepeatUV() const{ return repeatUV_; } 00155 00156 //-------------------------------------------------------------------------- 00157 /** 00158 * オフセットUVの設定 00159 * @param offsetUV オフセットUV 00160 */ 00161 virtual void setOffsetUV(const TexCoord2& offsetUV){ 00162 offsetUV_ = offsetUV; 00163 stateChanged(); 00164 } 00165 00166 /** 00167 * オフセットUVの取得 00168 * @return オフセットUV 00169 */ 00170 virtual const TexCoord2& getOffsetUV() const{ return offsetUV_; } 00171 00172 //-------------------------------------------------------------------------- 00173 protected: 00174 /** 00175 * コンストラクタ 00176 * @param name 名前 00177 * @param scene シーン 00178 */ 00179 SurfaceTexture(const String& name, Scene* scene); 00180 00181 /** 00182 * デストラクタ 00183 */ 00184 virtual ~SurfaceTexture(); 00185 00186 /** 00187 * D3Dテクスチャの取得 00188 * @return D3Dテクスチャの取得 00189 */ 00190 virtual Direct3DTexture* getD3DTexture(); 00191 00192 //-------------------------------------------------------------------------- 00193 private: 00194 // ピクチャ 00195 Picture* picture_; 00196 // アドレスモードU 00197 AddressMode addressModeU_; 00198 // アドレスモードV 00199 AddressMode addressModeV_; 00200 // リピートUV 00201 TexCoord2 repeatUV_; 00202 // オフセットUV 00203 TexCoord2 offsetUV_; 00204 // ラップU 00205 bool wrapU_; 00206 // ラップV 00207 bool wrapV_; 00208 00209 }; 00210 00211 //------------------------------------------------------------------------------ 00212 } // End of namespace Lamp 00213 #endif // End of SURFACE_TEXTURE_H_ 00214 //------------------------------------------------------------------------------ 00215