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

SceneFilter.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/SceneFilter.h"
00027 #include "Core/Utility/StringTokenizer.h"
00028 #include "Core/InputOutput/TextReader.h"
00029 #include "Graphics/SceneFilter/SceneLogicCheckFilter/SceneLogicCheckFilter.h"
00030 #include "Graphics/SceneFilter/ChangePicturePathFilter/\
00031 ChangePicturePathFilter.h"
00032 #include "Graphics/SceneFilter/CalculateBoundingBoxFilter/\
00033 CalculateBoundingBoxFilter.h"
00034 #include "Graphics/SceneFilter/CalculateBoundingSphereFilter/\
00035 CalculateBoundingSphereFilter.h"
00036 #include "Graphics/SceneFilter/BuildIndexedTriangleFilter/\
00037 BuildIndexedTriangleFilter.h"
00038 
00039 namespace Lamp{
00040 
00041 //------------------------------------------------------------------------------
00042 // コンストラクタ
00043 SceneFilter::SceneFilter(Scene* scene) : scene_(scene){
00044 }
00045 //------------------------------------------------------------------------------
00046 // デストラクタ
00047 SceneFilter::~SceneFilter(){
00048 }
00049 //------------------------------------------------------------------------------
00050 // フィルタ
00051 bool SceneFilter::filter(const String& command){
00052     Assert(scene_ != NULL);
00053     StringTokenizer tokenizer_(command);
00054     // 空行読み飛ばし
00055     if(!tokenizer_.hasMoreTokens()){ return true; }
00056     String token = tokenizer_.getNextToken();
00057     // 行頭スラッシュコメントの読み飛ばし
00058     if(token.startsWith("//")){ return true; }
00059     // シーン論理チェック
00060     if(token == "SceneLogicCheck"){
00061         SceneLogicCheckFilter filter(scene_);
00062         return filter.filter(command);
00063     // ピクチャパス変更
00064     }else if(token == "ChangePicturePath"){
00065         ChangePicturePathFilter filter(scene_);
00066         return filter.filter(command);
00067     // バウンディングボックス算出
00068     }else if(token == "CalculateBoundingBox"){
00069         CalculateBoundingBoxFilter filter(scene_);
00070         return filter.filter(command);
00071     // バウンディングスフィア算出
00072     }else if(token == "CalculateBoundingSphere"){
00073         CalculateBoundingSphereFilter filter(scene_);
00074         return filter.filter(command);
00075     // インデックストライアングル構築
00076     }else if(token == "BuildIndexedTriangle"){
00077         BuildIndexedTriangleFilter filter(scene_);
00078         return filter.filter(command);
00079     }else{
00080         ErrorOut("SceneFilter::filter() Unknown scene filter %s",
00081             command.getBytes());
00082         return false;
00083     }
00084     return false;
00085 }
00086 //------------------------------------------------------------------------------
00087 // フィルタ
00088 bool SceneFilter::filter(TextReader* reader){
00089     while(true){
00090         if(reader->isEnd()){ return true; }
00091         if(!filter(reader->readLine())){ return false; }
00092     }
00093     return true;
00094 }
00095 //------------------------------------------------------------------------------
00096 } // End of namespace Lamp
00097 //------------------------------------------------------------------------------

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