/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_SceneTraverser.cpp Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo and/or its licensed developers and are protected by national and international copyright laws. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. The content herein is highly confidential and should be handled accordingly. $Revision: 31311 $ *---------------------------------------------------------------------------*/ #include "precompiled.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace nw { namespace gfx { NW_UT_RUNTIME_TYPEINFO_DEFINITION(SceneTraverser, ISceneVisitor); //---------------------------------------- SceneTraverser* SceneTraverser::Builder::Create( os::IAllocator* allocator ) { NW_NULL_ASSERT(allocator); void* memory = allocator->Alloc(sizeof(SceneTraverser)); NW_NULL_ASSERT(memory); SceneTraverser* traverser = new(memory) SceneTraverser(allocator); return traverser; } //---------------------------------------- void SceneTraverser::Begin(SceneContext* sceneContext) { NW_NULL_ASSERT(sceneContext); this->m_SceneContext = sceneContext; // TODO: 現在はシーンノードの直列化の結果を初期化してますが、 // 必要時のみクリアするように検討中です。 this->m_SceneContext->Clear(); } //---------------------------------------- void SceneTraverser::End() { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext = NULL; } //---------------------------------------- void SceneTraverser::VisitSceneNode(SceneNode* node) { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(node); } //---------------------------------------- void SceneTraverser::VisitTransformNode(TransformNode* node) { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(node); } //---------------------------------------- void SceneTraverser::VisitUserRenderNode(UserRenderNode* node) { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(node); this->m_SceneContext->PushUserRenderNode(node); } //---------------------------------------- void SceneTraverser::VisitModel(Model* model) { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(model); this->m_SceneContext->PushModel(model); this->m_SceneContext->PushAnimatableNode(model); } //---------------------------------------- void SceneTraverser::VisitSkeletalModel(SkeletalModel* model) { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(model); this->m_SceneContext->PushModel(model); this->m_SceneContext->PushSkeletalModel(model); this->m_SceneContext->PushAnimatableNode(model); } //---------------------------------------- void SceneTraverser::VisitCamera(Camera* camera) { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(camera); this->m_SceneContext->PushCamera(camera); this->m_SceneContext->PushAnimatableNode(camera); } //---------------------------------------- void SceneTraverser::VisitFog(Fog* fog) { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(fog); this->m_SceneContext->PushFog(fog); this->m_SceneContext->PushAnimatableNode(fog); } //---------------------------------------- void SceneTraverser::VisitLight(Light* light) { NW_UNUSED_VARIABLE(light); this->m_SceneContext->PushSceneNode(light); this->m_SceneContext->PushLight(light); this->m_SceneContext->PushAnimatableNode(light); } //---------------------------------------- void SceneTraverser::VisitFragmentLight(FragmentLight* light) { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(light); this->m_SceneContext->PushLight(light); this->m_SceneContext->PushFragmentLight(light); this->m_SceneContext->PushAnimatableNode(light); } #if defined(NW_GFX_VERTEX_LIGHT_ENABLED) //---------------------------------------- void SceneTraverser::VisitVertexLight(VertexLight* light) { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(light); this->m_SceneContext->PushLight(light); this->m_SceneContext->PushVertexLight(light); this->m_SceneContext->PushAnimatableNode(light); } #endif //---------------------------------------- void SceneTraverser::VisitAmbientLight(AmbientLight* light) { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(light); this->m_SceneContext->PushLight(light); this->m_SceneContext->PushAmbientLight(light); this->m_SceneContext->PushAnimatableNode(light); } //---------------------------------------- void SceneTraverser::VisitHemiSphereLight(HemiSphereLight* light) { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(light); this->m_SceneContext->PushLight(light); this->m_SceneContext->PushHemiSphereLight(light); this->m_SceneContext->PushAnimatableNode(light); } //---------------------------------------- void SceneTraverser::VisitParticleSet(ParticleSet* particleSet) { particleSet->CopyTraversalResults(particleSet->GetParent()); NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(particleSet); this->m_SceneContext->PushParticleSet(particleSet); } //---------------------------------------- void SceneTraverser::VisitParticleEmitter(ParticleEmitter* particleEmitter) { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(particleEmitter); this->m_SceneContext->PushParticleEmitter(particleEmitter); } //---------------------------------------- void SceneTraverser::VisitParticleModel(ParticleModel* model) { NW_NULL_ASSERT(this->m_SceneContext); this->m_SceneContext->PushSceneNode(model); this->m_SceneContext->PushModel(model); this->m_SceneContext->PushParticleModel(model); this->m_SceneContext->PushAnimatableNode(model); } } // namespace gfx } // namespace nw