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_OBJECT_H_ 00026 #define SCENE_OBJECT_H_ 00027 00028 #include <Graphics/Scene/SceneObjectManagerTemplate.h> 00029 00030 namespace Lamp{ 00031 00032 class Scene; 00033 class Camera; 00034 class SceneNode; 00035 class SceneLeaf; 00036 class Light; 00037 class Model; 00038 class Mesh; 00039 class MeshData; 00040 class Material; 00041 class Texture; 00042 class Picture; 00043 00044 //------------------------------------------------------------------------------ 00045 /** 00046 * シーンオブジェクト 00047 */ 00048 class SceneObject{ 00049 public: 00050 //-------------------------------------------------------------------------- 00051 /** 00052 * リファレンスカウントの取得 00053 * @return リファレンスカウント 00054 */ 00055 virtual int getReferenceCount() const = 0; 00056 00057 //-------------------------------------------------------------------------- 00058 /** 00059 * 名前の取得 00060 * @return 名前 00061 */ 00062 virtual const String& getName() const{ return name_; } 00063 00064 //-------------------------------------------------------------------------- 00065 /** 00066 * シーンの取得 00067 * @return シーン 00068 */ 00069 virtual Scene* getScene() const{ return scene_; } 00070 00071 //-------------------------------------------------------------------------- 00072 /// コピーマスク 00073 enum CopyMask{ 00074 /// メッシュデータをコピーする 00075 copyMeshData = 0x1 << 0, 00076 /// マテリアルをコピーする 00077 copyMaterial = 0x1 << 1, 00078 /// テクスチャをコピーする 00079 copyTexture = 0x1 << 2, 00080 /// ピクチャをコピーする 00081 copyPicture = 0x1 << 3, 00082 }; 00083 00084 //-------------------------------------------------------------------------- 00085 // RTTI 00086 //-------------------------------------------------------------------------- 00087 /** 00088 * カメラかどうか 00089 * @return カメラならtrue 00090 */ 00091 virtual bool isCamera() const{ return false; } 00092 00093 /** 00094 * カメラへのキャスト 00095 * @return カメラ。型が違えばNULLを返す。 00096 */ 00097 virtual Camera* castCamera() const{ 00098 if(isCamera()){ return (Camera*)this; } 00099 return NULL; 00100 } 00101 00102 //-------------------------------------------------------------------------- 00103 /** 00104 * シーンノードかどうか 00105 * @return シーンノードならtrue 00106 */ 00107 virtual bool isSceneNode() const{ return false; } 00108 00109 /** 00110 * シーンノードへのキャスト 00111 * @return シーンノード。型が違えばNULLを返す。 00112 */ 00113 virtual SceneNode* castSceneNode() const{ 00114 if(isSceneNode()){ return (SceneNode*)this; } 00115 return NULL; 00116 } 00117 00118 //-------------------------------------------------------------------------- 00119 /** 00120 * シーンリーフかどうか 00121 * @return シーンリーフならtrue 00122 */ 00123 virtual bool isSceneLeaf() const{ return false; } 00124 00125 /** 00126 * シーンリーフへのキャスト 00127 * @return シーンリーフ。型が違えばNULLを返す。 00128 */ 00129 virtual SceneLeaf* castSceneLeaf() const{ 00130 if(isSceneLeaf()){ return (SceneLeaf*)this; } 00131 return NULL; 00132 } 00133 00134 //-------------------------------------------------------------------------- 00135 /** 00136 * ライトかどうか 00137 * @return ライトならtrue 00138 */ 00139 virtual bool isLight() const{ return false; } 00140 00141 /** 00142 * ライトへのキャスト 00143 * @return ライト。型が違えばNULLを返す。 00144 */ 00145 virtual Light* castLight() const{ 00146 if(isLight()){ return (Light*)this; } 00147 return NULL; 00148 } 00149 00150 //-------------------------------------------------------------------------- 00151 /** 00152 * モデルかどうか 00153 * @return モデルならtrue 00154 */ 00155 virtual bool isModel() const{ return false; } 00156 00157 /** 00158 * モデルへのキャスト 00159 * @return モデル。型が違えばNULLを返す。 00160 */ 00161 virtual Model* castModel() const{ 00162 if(isModel()){ return (Model*)this; } 00163 return NULL; 00164 } 00165 00166 //-------------------------------------------------------------------------- 00167 /** 00168 * メッシュかどうか 00169 * @return メッシュならtrue 00170 */ 00171 virtual bool isMesh() const{ return false; } 00172 00173 /** 00174 * メッシュへのキャスト 00175 * @return メッシュ。型が違えばNULLを返す。 00176 */ 00177 virtual Mesh* castMesh() const{ 00178 if(isMesh()){ return (Mesh*)this; } 00179 return NULL; 00180 } 00181 00182 //-------------------------------------------------------------------------- 00183 /** 00184 * メッシュデータかどうか 00185 * @return メッシュデータならtrue 00186 */ 00187 virtual bool isMeshData() const{ return false; } 00188 00189 /** 00190 * メッシュデータへのキャスト 00191 * @return メッシュデータ。型が違えばNULLを返す。 00192 */ 00193 virtual MeshData* castMeshData() const{ 00194 if(isMeshData()){ return (MeshData*)this; } 00195 return NULL; 00196 } 00197 00198 //-------------------------------------------------------------------------- 00199 /** 00200 * マテリアルかどうか 00201 * @return マテリアルならtrue 00202 */ 00203 virtual bool isMaterial() const{ return false; } 00204 00205 /** 00206 * シェーダへのキャスト 00207 * @return シェーダ。型が違えばNULLを返す。 00208 */ 00209 virtual Material* castMaterial() const{ 00210 if(isMaterial()){ return (Material*)this; } 00211 return NULL; 00212 } 00213 00214 //-------------------------------------------------------------------------- 00215 /** 00216 * テクスチャかどうか 00217 * @return テクスチャならtrue 00218 */ 00219 virtual bool isTexture() const{ return false; } 00220 00221 /** 00222 * テクスチャへのキャスト 00223 * @return テクスチャ。型が違えばNULLを返す。 00224 */ 00225 virtual Texture* castTexture() const{ 00226 if(isTexture()){ return (Texture*)this; } 00227 return NULL; 00228 } 00229 00230 //-------------------------------------------------------------------------- 00231 /** 00232 * ピクチャかどうか 00233 * @return ピクチャならtrue 00234 */ 00235 virtual bool isPicture() const{ return false; } 00236 00237 /** 00238 * ピクチャへのキャスト 00239 * @return ピクチャ。型が違えばNULLを返す。 00240 */ 00241 virtual Picture* castPicture() const{ 00242 if(isPicture()){ return (Picture*)this; } 00243 return NULL; 00244 } 00245 00246 //-------------------------------------------------------------------------- 00247 protected: 00248 /** 00249 * コンストラクタ 00250 * @param name 名前 00251 * @param scene シーン 00252 */ 00253 SceneObject(const String& name, Scene* scene) : 00254 name_(name), scene_(scene){} 00255 00256 /** 00257 * デストラクタ 00258 */ 00259 virtual ~SceneObject(){} 00260 00261 /// 名前 00262 String name_; 00263 /// シーン 00264 Scene* scene_; 00265 00266 private: 00267 // コピーコンストラクタの隠蔽 00268 SceneObject(const SceneObject& copy); 00269 00270 // 代入コピーの隠蔽 00271 void operator =(const SceneObject& copy); 00272 00273 }; 00274 00275 //------------------------------------------------------------------------------ 00276 } // End of namespace Lamp 00277 #endif // End of SCENE_OBJECT_H_ 00278 //------------------------------------------------------------------------------ 00279