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

Model.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 MODEL_H_
00026 #define MODEL_H_
00027 
00028 #include <Graphics/SceneNode/SceneLeaf.h>
00029 #include <Core/Container/ArrayList.h>
00030 
00031 namespace Lamp{
00032 
00033 class StandardModel;
00034 class CharacterModel;
00035 
00036 //------------------------------------------------------------------------------
00037 /**
00038  * モデル
00039  */
00040 class Model : public SceneLeaf{
00041 friend class SceneObjectManagerTemplate<Model>;
00042 friend class ModelManager;
00043 public:
00044     //--------------------------------------------------------------------------
00045     /**
00046      * モデルのコピー
00047      * @param copyMask コピーマスク
00048      * @return コピーされたモデル
00049      */
00050     virtual Model* copyModel(u_int copyMask = 0) const = 0;
00051 
00052     /**
00053      * 再帰的破棄
00054      * @param model 破棄するモデル
00055      * @return 破棄したオブジェクト数
00056      */
00057     static int recursiveDestroy(Model* model);
00058 
00059     //--------------------------------------------------------------------------
00060     // メッシュインターフェース
00061     //--------------------------------------------------------------------------
00062     /**
00063      * メッシュの追加
00064      * @param mesh 追加するメッシュ
00065      */
00066     virtual void addMesh(Mesh* mesh);
00067 
00068     /**
00069      * メッシュの削除
00070      * @param mesh 削除するメッシュ
00071      */
00072     virtual void removeMesh(Mesh* mesh);
00073 
00074     /**
00075      * メッシュ数の取得
00076      * @return メッシュ数
00077      */
00078     virtual int getMeshCount() const{ return meshes_.getCount(); }
00079 
00080     /**
00081      * メッシュの取得
00082      * @param index インデックス
00083      * @return メッシュ
00084      */
00085     virtual Mesh* getMesh(int index) const{
00086         Assert(index >= 0);
00087         Assert(index < getMeshCount());
00088         return meshes_.get(index);
00089     }
00090 
00091     //--------------------------------------------------------------------------
00092     // RTTI
00093     //--------------------------------------------------------------------------
00094     /**
00095      * モデルかどうか
00096      * @return モデルならtrue
00097      */
00098     virtual bool isModel() const{ return true; }
00099 
00100     //--------------------------------------------------------------------------
00101     /**
00102      * 標準モデルかどうか
00103      * @return 標準モデルならtrue
00104      */
00105     virtual bool isStandardModel() const{ return false; }
00106 
00107     /**
00108      * 標準モデルへのキャスト
00109      * @return 標準モデル。型が違えばNULLを返す。
00110      */
00111     virtual StandardModel* castStandardModel() const{
00112         if(isStandardModel()){ return (StandardModel*)this; }
00113         return NULL;
00114     }
00115 
00116     //--------------------------------------------------------------------------
00117     /**
00118      * キャラクタモデルかどうか
00119      * @return キャラクタモデルならtrue
00120      */
00121     virtual bool isCharacterModel() const{ return false; }
00122 
00123     /**
00124      * キャラクタモデルへのキャスト
00125      * @return キャラクタモデル。型が違えばNULLを返す。
00126      */
00127     virtual CharacterModel* castCharacterModel() const{
00128         if(isCharacterModel()){ return (CharacterModel*)this; }
00129         return NULL;
00130     }
00131 
00132     //--------------------------------------------------------------------------
00133 protected:
00134     /**
00135      * コンストラクタ
00136      * @param name 名前
00137      * @param scene シーン
00138      */
00139     Model(const String& name, Scene* scene);
00140 
00141     /**
00142      * デストラクタ
00143      */
00144     virtual ~Model();
00145 
00146     /**
00147      * モデルの値コピー
00148      * @param destination コピー先モデル
00149      * @param copyMask コピーマスク
00150      */
00151     virtual void copyModelValue(Model* destination, u_int copyMask) const;
00152 
00153     //--------------------------------------------------------------------------
00154     /**
00155      * 走査
00156      * @param parentMatrix 親行列
00157      * @param parentEnabled 親が有効か
00158      * @param parentScaled 親がスケールを使用しているか
00159      * @param parentChanged 親に変更があったか
00160      */
00161     virtual void traverse(const Matrix34& parentMatrix, bool parentEnabled,
00162         bool parentScaled, bool parentChanged);
00163 
00164     //--------------------------------------------------------------------------
00165 private:
00166     // メッシュ配列
00167     ArrayList<Mesh*> meshes_;
00168 
00169 };
00170 
00171 //------------------------------------------------------------------------------
00172 } // End of namespace Lamp
00173 #endif // End of MODEL_H_
00174 //------------------------------------------------------------------------------
00175 

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