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 LOD_SCENE_NODE_H_ 00026 #define LOD_SCENE_NODE_H_ 00027 00028 #include <Graphics/SceneNode/SceneNode.h> 00029 00030 namespace Lamp{ 00031 00032 //------------------------------------------------------------------------------ 00033 /** 00034 * レベルオブディティールシーンノード 00035 */ 00036 class LODSceneNode : public SceneNode{ 00037 friend class SceneObjectManagerTemplate<SceneNode>; 00038 friend class SceneNodeManager; 00039 public: 00040 //-------------------------------------------------------------------------- 00041 /** 00042 * コピー 00043 * @param copyMask コピーマスク 00044 * @return コピーされたシーンノード 00045 */ 00046 virtual SceneNode* copy(u_int copyMask = 0) const{ 00047 return copyLODSceneNode(copyMask); 00048 } 00049 00050 //-------------------------------------------------------------------------- 00051 /** 00052 * レベルオブディティールシーンノードコピー 00053 * @param copyMask コピーマスク 00054 * @return コピーされたレベルオブディティールシーンノード 00055 */ 00056 virtual LODSceneNode* copyLODSceneNode(u_int copyMask = 0) const; 00057 00058 //-------------------------------------------------------------------------- 00059 // LOD 00060 //-------------------------------------------------------------------------- 00061 /** 00062 * LOD分割数の設定 00063 * @param lodThresholdCount LOD分割数 00064 */ 00065 virtual void setLODThresholdCount(int lodThresholdCount){ 00066 Assert(lodThresholdCount >= 0); 00067 lodThresholdCount_ = lodThresholdCount; 00068 SafeArrayDelete(lodThreshold_); 00069 if(lodThresholdCount_ > 0){ 00070 lodThreshold_ = new float[lodThresholdCount_]; 00071 for(int i = 0; i < lodThresholdCount_; i++){ 00072 lodThreshold_[i] = 0.f; 00073 } 00074 } 00075 } 00076 00077 /** 00078 * LOD分割数の取得 00079 * @return LOD分割数 00080 */ 00081 virtual int getLODThresholdCount() const{ return lodThresholdCount_; } 00082 00083 //-------------------------------------------------------------------------- 00084 /** 00085 * LOD分割値の設定 00086 * @param index インデックス 00087 * @param lodThreshold LOD分割値 00088 */ 00089 virtual void setLODThreshold(int index, float lodThreshold){ 00090 Assert(index >= 0); 00091 Assert(index < lodThresholdCount_); 00092 lodThreshold_[index] = lodThreshold; 00093 } 00094 00095 /** 00096 * LOD分割値の取得 00097 * @param index インデックス 00098 * @return LOD分割値 00099 */ 00100 virtual float getLODThreshold(int index) const{ 00101 Assert(index >= 0); 00102 Assert(index < lodThresholdCount_); 00103 return lodThreshold_[index]; 00104 } 00105 00106 //-------------------------------------------------------------------------- 00107 // RTTI 00108 //-------------------------------------------------------------------------- 00109 /** 00110 * レベルオブディティールシーンノードかどうか 00111 * @return レベルオブディティールシーンノードならtrue 00112 */ 00113 virtual bool isLODSceneNode() const{ return true; } 00114 00115 protected: 00116 //-------------------------------------------------------------------------- 00117 /** 00118 * コンストラクタ 00119 * @param name 名前 00120 * @param scene シーン 00121 */ 00122 LODSceneNode(const String& name, Scene* scene); 00123 00124 /** 00125 * デストラクタ 00126 */ 00127 virtual ~LODSceneNode(); 00128 00129 //-------------------------------------------------------------------------- 00130 /** 00131 * 走査 00132 * @param parentMatrix 親行列 00133 * @param cameraPosition カメラ位置 00134 * @param parentEnabled 親が有効か 00135 * @param parentScaled 親がスケールを使用しているか 00136 * @param parentChanged 親に変更があったか 00137 */ 00138 virtual void traverse(const Matrix34& parentMatrix, 00139 const Vector3& cameraPosition, bool parentEnabled, bool parentScaled, 00140 bool parentChanged); 00141 00142 private: 00143 //-------------------------------------------------------------------------- 00144 // LOD分割数 00145 int lodThresholdCount_; 00146 // LOD分割値 00147 float* lodThreshold_; 00148 00149 }; 00150 00151 //------------------------------------------------------------------------------ 00152 } // End of namespace Lamp 00153 #endif // End of LOD_SCENE_NODE_H_ 00154 //------------------------------------------------------------------------------