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

# SceneNodeManager.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/SceneNode/SceneNodeManager.h"
    00027
    00028 namespace Lamp{
    00029
    00030 //------------------------------------------------------------------------------
    00031 // コンストラクタ
    00032 SceneNodeManager::SceneNodeManager(Scene* scene) :
    00033     SceneObjectManagerTemplate<SceneNode>(scene){
    00034 }
    00035 //------------------------------------------------------------------------------
    00036 // シーンノードの作成
    00037 SceneNode* SceneNodeManager::createSceneNode(const String& sceneNodeName){
    00038     if(!checkName(sceneNodeName)){ return NULL; }
    00039     SceneNode* sceneNode = new SceneNode(sceneNodeName, getScene());
    00040     addDatabase(sceneNodeName, sceneNode);
    00041     return sceneNode;
    00042 }
    00043 //------------------------------------------------------------------------------
    00044 // レベルオブディティールシーンノードの作成
    00045 LODSceneNode* SceneNodeManager::createLODSceneNode(const String& sceneNodeName){
    00046     if(!checkName(sceneNodeName)){ return NULL; }
    00047     LODSceneNode* sceneNode = new LODSceneNode(sceneNodeName, getScene());
    00048     addDatabase(sceneNodeName, sceneNode);
    00049     return sceneNode;
    00050 }
    00051 //------------------------------------------------------------------------------
    00052 int SceneNodeManager::clear(){
    00053     int result = getCount();
    00054     // ルートノードは解放しない
    00055     SceneNode* rootNode = array_.get(0);
    00056     int sceneNodeCount = rootNode->getSceneNodeCount();
    00057     for(int i = sceneNodeCount - 1; i >= 0; i--){
    00058         rootNode->removeSceneNode(rootNode->getSceneNode(i));
    00059     }
    00060     int sceneLeafCount = rootNode->getSceneLeafCount();
    00061     for(int i = sceneLeafCount - 1; i >= 0; i--){
    00062         rootNode->removeSceneLeaf(rootNode->getSceneLeaf(i));
    00063     }
    00064     // 要素の削除
    00065     for(int i = 1; i < result; i++){ delete array_.get(i); }
    00066     array_.clear();
    00067     database_.clear();
    00068     addDatabase(rootNode->getName(), rootNode);
    00069     return result - 1;
    00070 }
    00071 //------------------------------------------------------------------------------
    00072 } // End of namespace Lamp
    00073 //------------------------------------------------------------------------------