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

MayaTexture.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  * Mayaテクスチャヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef MAYA_TEXTURE_H_
00026 #define MAYA_TEXTURE_H_
00027 
00028 namespace LampForMaya{
00029 
00030 //------------------------------------------------------------------------------
00031 /**
00032  * Mayaテクスチャ
00033  */
00034 class MayaTexture{
00035 friend class MayaTextureManager;
00036 public:
00037     /**
00038      * テクスチャのロード
00039      * @return 成功すればtrue
00040      */
00041     virtual bool load();
00042 
00043     /**
00044      * テクスチャのバインド
00045      * @return 成功すればtrue
00046      */
00047     virtual bool bind();
00048 
00049     /**
00050      * 名前の取得
00051      * @return 名前
00052      */
00053     virtual const String& getName() const{ return name_; }
00054 
00055     /**
00056      * 幅の取得
00057      * @param level ミップマップレベル
00058      * @return 幅
00059      */
00060     virtual u_int getWidth(int level = 0) const{
00061         u_int width = width_ >> level;
00062         if(width > 0){ return width; }
00063         return 1;
00064     }
00065 
00066     /**
00067      * 高さの取得
00068      * @param level ミップマップレベル
00069      * @return 高さ
00070      */
00071     virtual u_int getHeight(int level = 0) const{
00072         u_int height = height_ >> level;
00073         if(height > 0){ return height; }
00074         return 1;
00075     }
00076 
00077 protected:
00078     /**
00079      * コンストラクタ
00080      * @param node ノード
00081      * @param name 名前
00082      */
00083     MayaTexture(const MObject& node, const String& name);
00084 
00085     /**
00086      * デストラクタ
00087      */
00088     virtual ~MayaTexture();
00089 
00090     /**
00091      * クリア
00092      */
00093     virtual void clear();
00094 
00095     /**
00096      * 最大の2の累乗を求める
00097      * @param number 対象となる数
00098      * @return 対象の数以下における最大の2の累乗
00099      */
00100     u_int highestPowerOf2(u_int number) const{
00101         int power = 0;
00102         while(number > 1){
00103             power++;
00104             number >>= 1;
00105         }
00106         return power;
00107     }
00108 
00109 private:
00110     // コピーコンストラクタの隠蔽
00111     MayaTexture(const MayaTexture& copy);
00112 
00113     // 代入コピーの隠蔽
00114     void operator =(const MayaTexture& copy);
00115 
00116     // ノード
00117     MObject node_;
00118     // 名前
00119     String name_;
00120     // テクスチャID
00121     u_int textureID_;
00122     // イメージ
00123     u_char** images_;
00124     // ミップマップレベル
00125     int mipmapLevel_;
00126     // 幅
00127     u_int width_;
00128     // 高さ
00129     u_int height_;
00130     // リネームコールバックID
00131     MCallbackId renameCallbackID_;
00132     // 変更コールバックID
00133     MCallbackId dirtyCallbackID_;
00134     // ロード済みフラグ
00135     bool loaded_;
00136 
00137     // ピクセルあたりバイト数
00138     static const int bytesPerPixel_ = 4;
00139 };
00140 
00141 //------------------------------------------------------------------------------
00142 } // End of namespace LampForMaya
00143 #endif // End of MAYA_TEXTURE_H_
00144 //------------------------------------------------------------------------------
00145 

Generated on Wed Mar 16 10:29:55 2005 for LampForMaya by doxygen 1.3.2