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

CharacterModel.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 CHARACTER_MODEL_H_
00026 #define CHARACTER_MODEL_H_
00027 
00028 #include <Graphics/Model/Model.h>
00029 #include <Graphics/Model/Bone.h>
00030 
00031 namespace Lamp{
00032 
00033 //------------------------------------------------------------------------------
00034 /**
00035  * キャラクタモデル
00036  */
00037 class CharacterModel : public Model{
00038 friend class ModelManager;
00039 public:
00040     //--------------------------------------------------------------------------
00041     /// 最大ボーン数
00042     static const int maxBoneCount = 64;
00043 
00044     //--------------------------------------------------------------------------
00045     /**
00046      * キャラクタモデルかどうか
00047      * @return キャラクタモデルならtrue
00048      */
00049     virtual bool isCharacterModel() const{ return true; }
00050 
00051     //--------------------------------------------------------------------------
00052     /**
00053      * コピー
00054      * @param copyMask コピーマスク
00055      * @return コピーされたシーンリーフ
00056      */
00057     virtual SceneLeaf* copy(u_int copyMask = 0) const{
00058         return copyCharacterModel(copyMask);
00059     }
00060 
00061     /**
00062      * モデルのコピー
00063      * @param copyMask コピーマスク
00064      * @return コピーされたモデル
00065      */
00066     virtual Model* copyModel(u_int copyMask = 0) const{
00067         return copyCharacterModel(copyMask);
00068     }
00069 
00070     /**
00071      * キャラクタモデルのコピー
00072      * @param copyMask コピーマスク
00073      * @return コピーされたモデル
00074      */
00075     virtual CharacterModel* copyCharacterModel(u_int copyMask = 0) const;
00076 
00077     //--------------------------------------------------------------------------
00078     /**
00079      * ボーン行列の構築
00080      * @param forceCalculation 強制的に再計算する
00081      */
00082     virtual void buildBoneMatrix(bool forceCalculation = false);
00083 
00084     /**
00085      * ボーンにスケールが含まれるか
00086      * @return ボーンにスケールが含まれるならtrue
00087      */
00088     virtual bool isBoneScaled() const{ return boneScaled_; }
00089 
00090     //--------------------------------------------------------------------------
00091     /**
00092      * 位置変形行列配列の取得
00093      * @param forceCalculation 強制的に再計算する
00094      * @return 位置変形行列配列
00095      */
00096     virtual const Matrix34* getPositionDeformMatrixArray(
00097         bool forceCalculation = false);
00098 
00099     /**
00100      * 法線変形行列配列の取得
00101      * @param forceCalculation 強制的に再計算する
00102      * @return 法線変形行列配列
00103      */
00104     virtual const Matrix33* getNormalDeformMatrixArray(
00105         bool forceCalculation = false);
00106 
00107     //--------------------------------------------------------------------------
00108     // ボーンインターフェース
00109     //--------------------------------------------------------------------------
00110     /**
00111      * ボーンの作成
00112      *
00113      * ボーンを作成し、ボーンリストの最後尾に追加します。
00114      * すでに同じ名前のボーンが存在するとエラーになります。
00115      * 空文字列を名前に指定するとエラーになります。
00116      * @param boneName ボーン名
00117      * @return 作成されたボーン
00118      */
00119     virtual Bone* createBone(const String& boneName);
00120 
00121     /**
00122      * ボーンの破棄
00123      * @param bone 破棄するボーン
00124      */
00125     virtual void destroyBone(Bone* bone);
00126 
00127     /**
00128      * ボーンのクリア
00129      * @return 削除したボーン数
00130      */
00131     virtual int clearBone();
00132 
00133     /**
00134      * ボーン数の取得
00135      * @return ボーン数
00136      */
00137     virtual int getBoneCount() const{ return boneArray_.getCount(); }
00138 
00139     /**
00140      * ボーンの取得
00141      * @param index ボーンのインデクス
00142      * @return ボーン
00143      */
00144     virtual Bone* getBone(int index) const{
00145         Assert(index >= 0);
00146         Assert(index < boneArray_.getCount());
00147         return boneArray_.get(index);
00148     }
00149 
00150     /**
00151      * ボーンインデックスの取得
00152      * @param bone ボーン
00153      * @return ボーンインデックス。見つからなければ-1
00154      */
00155     virtual int getBoneIndex(Bone* bone) const{
00156         int boneCount = getBoneCount();
00157         for(int i = 0; i < boneCount; i++){
00158             if(getBone(i) == bone){ return i; }
00159         }
00160         return -1;
00161     }
00162 
00163     /**
00164      * ボーンの検索
00165      * @param boneName 検索するボーン名
00166      * @return ボーン
00167      */
00168     virtual Bone* searchBone(const String& boneName) const{
00169         return boneHash_.get(boneName);
00170     }
00171 
00172     //--------------------------------------------------------------------------
00173     /**
00174      * メッシュの追加
00175      * @param mesh 追加するメッシュ
00176      */
00177     virtual void addMesh(Mesh* mesh);
00178 
00179     //--------------------------------------------------------------------------
00180 protected:
00181     /**
00182      * コンストラクタ
00183      * @param name 名前
00184      * @param scene シーン
00185      */
00186     CharacterModel(const String& name, Scene* scene);
00187 
00188     /**
00189      * デストラクタ
00190      */
00191     virtual ~CharacterModel();
00192 
00193     /**
00194      * 変形行列配列の構築
00195      */
00196     virtual void buildDeformMatrixArray();
00197 
00198     /// ボーンハッシュ
00199     HashMap<String, Bone*> boneHash_;
00200     /// ボーン配列
00201     ArrayList<Bone*> boneArray_;
00202     /// 位置変形行列配列
00203     Matrix34* positionDeformMatrixArray_;
00204     /// 法線変形行列配列
00205     Matrix33* normalDeformMatrixArray_;
00206     /// 変形行列配列サイズ
00207     int deformMatrixArraySize_;
00208     /// ボーン行列の構築チック
00209     int buildBoneMatrixTick_;
00210     /// 変形行列配列チック
00211     int deformMatrixArrayTick_;
00212     /// ボーンにスケールが含まれるか
00213     bool boneScaled_;
00214 
00215     //--------------------------------------------------------------------------
00216 private:
00217 
00218 };
00219 
00220 //------------------------------------------------------------------------------
00221 } // End of namespace Lamp
00222 #endif // End of CHARACTER_MODEL_H_
00223 //------------------------------------------------------------------------------
00224 

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