1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_SceneTraverser.h
4 
5   Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Revision: 23073 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NW_GFX_SCENETRAVERSER_H_
17 #define NW_GFX_SCENETRAVERSER_H_
18 
19 #include <nw/gfx/gfx_ISceneVisitor.h>
20 
21 namespace nw
22 {
23 namespace gfx
24 {
25 
26 class SceneContext;
27 
28 //---------------------------------------------------------------------------
29 //! @brief        シーン内を探索して更新と描画に必要な情報を収集します。
30 //---------------------------------------------------------------------------
31 class SceneTraverser  : public ISceneVisitor
32 {
33 private:
34     NW_DISALLOW_COPY_AND_ASSIGN(SceneTraverser);
35 
36 public:
37     NW_UT_RUNTIME_TYPEINFO;
38 
39     //! シーントラバーサを構築するためのクラスです。
40     class Builder
41     {
42     public:
43         //! @brief        シーントラバーサを生成します。
44         //!
45         //! @param[in]    allocator
46         //!
47         //! @return       生成したトラバーサを返します。
48         //!
49         SceneTraverser* Create(os::IAllocator* allocator);
50     };
51 
52     //! @brief        トラバース前処理を行います。
53     //!
54     //! 解析内容を管理するシーンコンテキストを設定します。
55     //!
56     //! @param[in] sceneContext   シーンコンテキストです。
57     //!
58     void Begin(SceneContext* sceneContext);
59 
60     //!  トラバース後処理を行います。
61     void End();
62 
63     //----------------------------------------
64     //! @name ビジターの実装
65     //@{
66 
67     virtual void VisitSceneNode(SceneNode* node);
68     virtual void VisitTransformNode(TransformNode* node);
69     virtual void VisitModel(Model* model);
70     virtual void VisitSkeletalModel(SkeletalModel* model);
71     virtual void VisitCamera(Camera* camera);
72     virtual void VisitFog(Fog* fog);
73     virtual void VisitLight(Light* light);
74     virtual void VisitFragmentLight(FragmentLight* light);
75 #if defined(NW_GFX_VERTEX_LIGHT_ENABLED)
76     virtual void VisitVertexLight(VertexLight* light);
77 #endif
78     virtual void VisitAmbientLight(AmbientLight* light);
79     virtual void VisitHemiSphereLight(HemiSphereLight* light);
80     virtual void VisitParticleSet(ParticleSet* particleSet);
81     virtual void VisitParticleEmitter(ParticleEmitter* particleEmitter);
82     virtual void VisitParticleModel(ParticleModel* particleModel);
83 
84     //@}
85 
86 private:
SceneTraverser(os::IAllocator * allocator)87     SceneTraverser(os::IAllocator* allocator)
88     : ISceneVisitor(allocator), m_SceneContext(NULL) {}
~SceneTraverser()89     virtual ~SceneTraverser() {}
90 
91     SceneContext* m_SceneContext;
92 };
93 
94 } // namespace gfx
95 } // namespace nw
96 
97 #endif // NW_GFX_SCENETRAVERSER_H_
98