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

SceneLogicCheckFilter.cpp

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 #include "LampBasic.h"
00026 #include "Graphics/SceneFilter/SceneLogicCheckFilter/SceneLogicCheckFilter.h"
00027 #include "Core/Utility/StringTokenizer.h"
00028 #include "Graphics/SceneNode/SceneNodeManager.h"
00029 #include "Graphics/Model/ModelManager.h"
00030 #include "Graphics/Mesh/MeshManager.h"
00031 #include "Graphics/MeshData/MeshDataManager.h"
00032 #include "Graphics/Material/MaterialManager.h"
00033 #include "Graphics/Texture/TextureManager.h"
00034 #include "Graphics/Picture/PictureManager.h"
00035 
00036 namespace Lamp{
00037 
00038 //------------------------------------------------------------------------------
00039 // コンストラクタ
00040 SceneLogicCheckFilter::SceneLogicCheckFilter(Scene* scene) :
00041     SceneFilterInterface(scene){
00042 }
00043 //------------------------------------------------------------------------------
00044 // デストラクタ
00045 SceneLogicCheckFilter::~SceneLogicCheckFilter(){
00046 }
00047 //------------------------------------------------------------------------------
00048 // フィルタ
00049 bool SceneLogicCheckFilter::filter(const String& command){
00050     StringTokenizer tokenizer_(command);
00051     if(!tokenizer_.hasMoreTokens()){
00052         ErrorOut("SceneLogicCheckFilter::filter() Not found filter name");
00053         return false;
00054     }
00055     String filterName = tokenizer_.getNextToken();
00056     if(filterName != "SceneLogicCheck"){
00057         ErrorOut("SceneLogicCheckFilter::filter() Invalid filter name %s",
00058             filterName.getBytes());
00059         return false;
00060     }
00061     return filterScene();
00062 }
00063 //------------------------------------------------------------------------------
00064 // シーンのフィルタ
00065 bool SceneLogicCheckFilter::filterScene(){
00066     if(!filterSceneNode()){ return false; }
00067     if(!filterModel()){ return false; }
00068     if(!filterMesh()){ return false; }
00069     if(!filterMeshData()){ return false; }
00070     if(!filterMaterial()){ return false; }
00071     if(!filterTexture()){ return false; }
00072     if(!filterPicture()){ return false; }
00073     return true;
00074 }
00075 //------------------------------------------------------------------------------
00076 // シーンノードのフィルタ
00077 bool SceneLogicCheckFilter::filterSceneNode(){
00078     // ルートノードが存在するかどうか
00079     int count = sceneNodeManager_->getCount();
00080     if(count < 1){
00081         ErrorOut("SceneLogicCheckFilter::fiterSceneNode() "
00082             "ルートノードが存在しません %d", count);
00083         return false;
00084     }
00085     // ルートノード名の確認
00086     SceneNode* rootNode = sceneNodeManager_->get(0);
00087     if(rootNode->getName() != "RootNode"){
00088         ErrorOut("SceneLogicCheckFilter::fiterSceneNode() "
00089             "ルートノードの名前が違います %s", rootNode->getName().getBytes());
00090         return false;
00091     }
00092     // 各シーンノードのチェック
00093     for(int i = 1; i < count; i++){
00094         SceneNode* sceneNode = sceneNodeManager_->get(i);
00095         // 参照カウンタが1以上かどうか
00096         if(sceneNode->getReferenceCount() < 1){
00097             ErrorOut("SceneLogicCheckFilter::fiterSceneNode() "
00098                 "参照されていないシーンノードがあります %s %d",
00099                 sceneNode->getName().getBytes(),
00100                 sceneNode->getReferenceCount());
00101             return false;
00102         }
00103     }
00104     return true;
00105 }
00106 //------------------------------------------------------------------------------
00107 // モデルのフィルタ
00108 bool SceneLogicCheckFilter::filterModel(){
00109     int count = modelManager_->getCount();
00110     // 各モデルのチェック
00111     for(int i = 0; i < count; i++){
00112         Model* model = modelManager_->get(i);
00113         // 参照カウンタが1以上かどうか
00114         if(model->getReferenceCount() < 1){
00115             ErrorOut("SceneLogicCheckFilter::filterModel() "
00116                 "参照されていないモデルがあります %s %d",
00117                 model->getName().getBytes(), model->getReferenceCount());
00118             return false;
00119         }
00120         // メッシュが存在するかどうか
00121         if(model->getMeshCount() == 0){
00122             ErrorOut("SceneLogicCheckFilter::filterModel() "
00123                 "メッシュを持たないモデルがあります %s",
00124                 model->getName().getBytes());
00125             return false;
00126         }
00127     }
00128     return true;
00129 }
00130 //------------------------------------------------------------------------------
00131 // メッシュのフィルタ
00132 bool SceneLogicCheckFilter::filterMesh(){
00133     int count = meshManager_->getCount();
00134     // 各メッシュのチェック
00135     for(int i = 0; i < count; i++){
00136         Mesh* mesh = meshManager_->get(i);
00137         // 参照カウンタが1以上かどうか
00138         if(mesh->getReferenceCount() < 1){
00139             ErrorOut("SceneLogicCheckFilter::filterMesh() "
00140                 "参照されていないメッシュがあります %s %d",
00141                 mesh->getName().getBytes(), mesh->getReferenceCount());
00142             return false;
00143         }
00144         // メッシュデータが存在するかどうか
00145         if(mesh->getMeshData() == NULL){
00146             ErrorOut("SceneLogicCheckFilter::filterMesh() "
00147                 "メッシュデータを持っていないメッシュがあります %s",
00148                 mesh->getName().getBytes());
00149             return false;
00150         }
00151         // マテリアルが存在するかどうか
00152         if(mesh->getMaterial() == NULL){
00153             ErrorOut("SceneLogicCheckFilter::filterMesh() "
00154                 "マテリアルを持っていないメッシュがあります %s",
00155                 mesh->getName().getBytes());
00156             return false;
00157         }
00158     }
00159     return true;
00160 }
00161 //------------------------------------------------------------------------------
00162 // メッシュデータのフィルタ
00163 bool SceneLogicCheckFilter::filterMeshData(){
00164     int count = meshDataManager_->getCount();
00165     // 各メッシュデータのチェック
00166     for(int i = 0; i < count; i++){
00167         MeshData* meshData = meshDataManager_->get(i);
00168         // 参照カウンタが1以上かどうか
00169         if(meshData->getReferenceCount() < 1){
00170             ErrorOut("SceneLogicCheckFilter::filterMeshData() "
00171                 "参照されていないメッシュデータがあります %s %d",
00172                 meshData->getName().getBytes(), meshData->getReferenceCount());
00173             return false;
00174         }
00175     }
00176     return true;
00177 }
00178 //------------------------------------------------------------------------------
00179 // マテリアルのフィルタ
00180 bool SceneLogicCheckFilter::filterMaterial(){
00181     int count = materialManager_->getCount();
00182     // 各マテリアルのチェック
00183     for(int i = 0; i < count; i++){
00184         Material* material = materialManager_->get(i);
00185         // 参照カウンタが1以上かどうか
00186         if(material->getReferenceCount() < 1){
00187             ErrorOut("SceneLogicCheckFilter::filterMaterial() "
00188                 "参照されていないマテリアルがあります %s %d",
00189                 material->getName().getBytes(), material->getReferenceCount());
00190             return false;
00191         }
00192     }
00193 // 各テクスチャのUVIndexが存在するか
00194     return true;
00195 }
00196 //------------------------------------------------------------------------------
00197 // テクスチャのフィルタ
00198 bool SceneLogicCheckFilter::filterTexture(){
00199     int count = textureManager_->getCount();
00200     // 各テクスチャのチェック
00201     for(int i = 0; i < count; i++){
00202         Texture* texture = textureManager_->get(i);
00203         // 参照カウンタが1以上かどうか
00204         if(texture->getReferenceCount() < 1){
00205             ErrorOut("SceneLogicCheckFilter::filterTexture() "
00206                 "参照されていないテクスチャがあります %s %d",
00207                 texture->getName().getBytes(), texture->getReferenceCount());
00208             return false;
00209         }
00210         // ピクチャが存在するかどうか
00211         if(texture->getPictureCount() <= 0){
00212             ErrorOut("SceneLogicCheckFilter::filterTexture() "
00213                 "ピクチャを持っていないテクスチャがあります %s",
00214                 texture->getName().getBytes());
00215             return false;
00216         }
00217     }
00218     return true;
00219 }
00220 //------------------------------------------------------------------------------
00221 // ピクチャのフィルタ
00222 bool SceneLogicCheckFilter::filterPicture(){
00223     int count = pictureManager_->getCount();
00224     // 各ピクチャのチェック
00225     for(int i = 0; i < count; i++){
00226         Picture* picture = pictureManager_->get(i);
00227         // 参照カウンタが1以上かどうか
00228         if(picture->getReferenceCount() < 1){
00229             ErrorOut("SceneLogicCheckFilter::filterPicture() "
00230                 "参照されていないピクチャがあります %s %d",
00231                 picture->getName().getBytes(), picture->getReferenceCount());
00232             return false;
00233         }
00234         // 幅、高さが2の累乗かどうか
00235         DimensionI size = picture->getSize();
00236         if((!Math::checkPow2(size.width)) || (!Math::checkPow2(size.height))){
00237             ErrorOut("SceneLogicCheckFilter::filterPicture() "
00238                 "サイズが2の累乗でないピクチャがあります %s %s",
00239                 picture->getName().getBytes(), size.toString().getBytes());
00240             return false;
00241         }
00242     }
00243     return true;
00244 }
00245 //------------------------------------------------------------------------------
00246 } // End of namespace Lamp
00247 //------------------------------------------------------------------------------

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