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 SCENE_LEAF_H_ 00026 #define SCENE_LEAF_H_ 00027 00028 #include <Graphics/Scene/SceneObject.h> 00029 00030 namespace Lamp{ 00031 00032 //------------------------------------------------------------------------------ 00033 /** 00034 * シーンリーフ 00035 */ 00036 class SceneLeaf : public SceneObject{ 00037 friend class SceneNode; 00038 friend class LODSceneNode; 00039 public: 00040 //-------------------------------------------------------------------------- 00041 /** 00042 * 親の取得 00043 * @return 親 00044 */ 00045 virtual SceneNode* getParent() const{ return parent_; } 00046 00047 /** 00048 * リファレンスカウントの取得 00049 * @return リファレンスカウント 00050 */ 00051 virtual int getReferenceCount() const{ 00052 if(parent_ != NULL){ return 1; } 00053 return 0; 00054 } 00055 00056 //-------------------------------------------------------------------------- 00057 /** 00058 * コピー 00059 * @param copyMask コピーマスク 00060 * @return コピーされたシーンリーフ 00061 */ 00062 virtual SceneLeaf* copy(u_int copyMask = 0) const = 0; 00063 00064 /** 00065 * 再帰的破棄 00066 * @param leaf 破棄するシーンリーフ 00067 * @return 破棄したオブジェクト数 00068 */ 00069 static int recursiveDestroy(SceneLeaf* leaf); 00070 00071 //-------------------------------------------------------------------------- 00072 // 有効、無効 00073 //-------------------------------------------------------------------------- 00074 /** 00075 * 有効、無効の設定 00076 * @param enabled trueなら有効、falseなら無効 00077 */ 00078 virtual void setEnabled(bool enabled){ enabled_ = enabled; } 00079 00080 /** 00081 * 有効、無効の取得 00082 * @return trueなら有効、falseなら無効 00083 */ 00084 virtual bool isEnabled() const{ return enabled_; } 00085 00086 /** 00087 * グローバルでの有効、無効の取得 00088 * @return trueなら有効、falseなら無効 00089 */ 00090 virtual bool isGlobalEnabled() const{ return globalEnabled_; } 00091 00092 //-------------------------------------------------------------------------- 00093 // RTTI 00094 //-------------------------------------------------------------------------- 00095 /** 00096 * シーンリーフかどうか 00097 * @return シーンリーフならtrue 00098 */ 00099 virtual bool isSceneLeaf() const{ return true; } 00100 00101 protected: 00102 //-------------------------------------------------------------------------- 00103 /** 00104 * コンストラクタ 00105 * @param name 名前 00106 * @param scene シーン 00107 */ 00108 SceneLeaf(const String& name, Scene* scene); 00109 00110 /** 00111 * デストラクタ 00112 */ 00113 virtual ~SceneLeaf(); 00114 00115 //-------------------------------------------------------------------------- 00116 /** 00117 * 走査 00118 * @param parentMatrix 親行列 00119 * @param parentEnabled 親が有効か 00120 * @param parentScaled 親がスケールを使用しているか 00121 * @param parentChanged 親に変更があったか 00122 */ 00123 virtual void traverse(const Matrix34& parentMatrix, bool parentEnabled, 00124 bool parentScaled, bool parentChanged); 00125 00126 //-------------------------------------------------------------------------- 00127 /** 00128 * 親の設定 00129 * @param parent 設定する親 00130 */ 00131 virtual void setParent(SceneNode* parent){ 00132 Assert(parent != NULL); 00133 Assert(parent_ == NULL); 00134 parent_ = parent; 00135 globalEnabled_ = false; 00136 } 00137 00138 /** 00139 * 親の削除 00140 * @param parent 削除する親 00141 */ 00142 virtual void removeParent(SceneNode* parent){ 00143 Assert(parent_ != NULL); 00144 Assert(parent_ == parent); 00145 parent_ = NULL; 00146 globalEnabled_ = false; 00147 } 00148 00149 /** 00150 * シーンリーフの値コピー 00151 * @param destination コピー先シーンリーフ 00152 */ 00153 virtual void copySceneLeafValue(SceneLeaf* destination) const; 00154 00155 private: 00156 //-------------------------------------------------------------------------- 00157 // 親 00158 SceneNode* parent_; 00159 // 有効、無効フラグ 00160 bool enabled_; 00161 // グローバルでの有効無効フラグ 00162 bool globalEnabled_; 00163 00164 00165 }; 00166 00167 //------------------------------------------------------------------------------ 00168 } // End of namespace Lamp 00169 #endif // End of SCENE_LEAF_H_ 00170 //------------------------------------------------------------------------------