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

# SceneLeaf.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/SceneLeaf.h"
    00027 #include "Graphics/SceneNode/SceneNode.h"
    00028 #include "Graphics/Light/Light.h"
    00029 #include "Graphics/Model/Model.h"
    00030
    00031 namespace Lamp{
    00032
    00033 //------------------------------------------------------------------------------
    00034 // コンストラクタ
    00035 SceneLeaf::SceneLeaf(const String& name, Scene* scene) :
    00036     SceneObject(name, scene), parent_(NULL), enabled_(true),
    00037     globalEnabled_(false){
    00038 }
    00039 //------------------------------------------------------------------------------
    00040 // デストラクタ
    00041 SceneLeaf::~SceneLeaf(){
    00042 }
    00043 //------------------------------------------------------------------------------
    00044 // シーンリーフの値コピー
    00045 void SceneLeaf::copySceneLeafValue(SceneLeaf* destination) const{
    00046     // メンバのコピー
    00047     destination->setEnabled(enabled_);
    00048 }
    00049 //------------------------------------------------------------------------------
    00050 // 再帰的破棄
    00051 int SceneLeaf::recursiveDestroy(SceneLeaf* leaf){
    00052     Assert(leaf != NULL);
    00053     int result = 0;
    00054     // 親から削除
    00055     SceneNode* parent = leaf->getParent();
    00056     if(parent != NULL){ parent->removeSceneLeaf(leaf); }
    00057     if(leaf->isLight()){
    00058         // ライトの破棄
    00059         result += Light::destroy(leaf->castLight());
    00060     }else if(leaf->isModel()){
    00061         // モデルの破棄
    00062         result += Model::recursiveDestroy(leaf->castModel());
    00063     }else{
    00064         ErrorOut("SceneLeaf::recursiveDestroy Unknown type");
    00065     }
    00066     return result;
    00067 }
    00068 //------------------------------------------------------------------------------
    00069 // 走査
    00070 void SceneLeaf::traverse(const Matrix34& parentMatrix,
    00071     bool parentEnabled, bool parentScaled, bool parentChanged){
    00072     globalEnabled_ = (parentEnabled && isEnabled());
    00073 }
    00074 //------------------------------------------------------------------------------
    00075 } // End of namespace Lamp
    00076 //------------------------------------------------------------------------------