1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     GfxCtrl.h
4 
5   Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain proprietary
8   information of Nintendo and/or its licensed developers and are protected by
9   national and international copyright laws. They may not be disclosed to third
10   parties or copied or duplicated in any form, in whole or in part, without the
11   prior written consent of Nintendo.
12 
13   The content herein is highly confidential and should be handled accordingly.
14 
15   $Revision: $
16  *---------------------------------------------------------------------------*/
17 #ifndef GFX_CTRL_H_
18 #define GFX_CTRL_H_
19 
20 
21 #include <nw/gfx.h>
22 #include "../include/SmBase.h"
23 #include "../include/SmModel.h"
24 #include "../include/SmCamera.h"
25 #include "../include/SmSceneCtrl.h"
26 #include "../include/SmParticle.h"
27 
28 
29 //------------------------------------------------------------------------------
30 //! Gfx���\�[�X�Ɋւ���N���X�������E�j������N���X�ł��B
31 class GfxCtrl : public SmBase
32 {
33 public:
34     //! ���\�[�X��z�u����VRAM�^�C�v�ł��B
35     enum
36     {
37         GFX_CTRL_VRAM_A = NN_GX_MEM_VRAMA,
38         GFX_CTRL_VRAM_B = NN_GX_MEM_VRAMB,
39         GFX_CTRL_VRAM_NONE
40     };
41     typedef u32 GfxVramType;
42 
43     //! ���[�h���ꂽ���\�[�X���Ǘ����邽�߂̍\���̂ł��B
44     struct GfxResourceSet
45     {
46         nw::ut::MoveArray<u8>       buffer;
47         nw::gfx::ResGraphicsFile    resource;
48     };
49     #define GFX_RES_ARRAY_COUNT (32)
50 
51     //! ���[�h���ꂽ���\�[�X��ێ����邽�߂̔z��ł��B
52     typedef nw::ut::FixedSizeArray<GfxResourceSet, GFX_RES_ARRAY_COUNT>         GfxResourceArray;
53 
54     //! �������ꂽSmModel�C���X�^���X��ێ����邽�߂̔z��ł��B
55     typedef nw::ut::FixedSizeArray<SmModel*, GFX_RES_ARRAY_COUNT>               SmModelInstanceArray;
56 
57     //! �������ꂽ�A�j���[�V������ێ����邽�߂̔z��ł��B
58     typedef nw::ut::FixedSizeArray<nw::gfx::AnimObject*, GFX_RES_ARRAY_COUNT>   GfxAnimObjectArray;
59 
60 public:
61     //! �R���X�g���N�^�ł��B
62     GfxCtrl( SmSceneCtrl* sceneCtrl );
63 
64     //! �f�X�g���N�^�ł��B
65     ~GfxCtrl();
66 
67     //! SmModel�N���X�̃C���X�^���X�������܂��B
68     SmModel* CreateModel( SmModel* parentModel, const wchar_t* resourcePath, GfxVramType vramType );
69 
70     //! �p�[�e�B�N���������܂��B
71     SmParticle* CreateParticle( const wchar_t* resourcePath, GfxVramType vramType );
72 
73     //! ���C�g/�t�H�O/�V�[���‹���ݒ肵�܂��B
74     void CreateSceneEnvironment( const wchar_t* resourcePath );
75 
76     //! �J�����������܂��B
77     void CreateCamera( const wchar_t* resourcePath );
78 
79     //! �V�[���̏��������s���܂��B
80     void InitializeScene();
81 
82     //! �V�[���̃g���o�[�X���s���܂��B
83     void TraverseScene();
84 
85     //! �V�[���̍X�V���s���܂��B
86     void Update();
87 
88 
89     //! ���[�g�m�[�h���擾���܂��B
GetSceneRoot()90     nw::gfx::SceneNode* GetSceneRoot() { return m_SceneRoot; }
91 
92     //! �V�[���‹��ݒ���擾���܂��B
GetSceneEnvSetting()93     nw::gfx::SceneEnvironmentSetting* GetSceneEnvSetting() { return m_SceneEnvSetting; }
94 
95     //! nw::gfx::Camera�̃C���X�^���X���擾���܂��B
GetCamera()96     nw::gfx::Camera* GetCamera()
97     {
98         return m_SmCamera->GetGxCamera();
99     }
100 
101     //! SmCamera�̃C���X�^���X���擾���܂��B
GetSmCamera()102     SmCamera* GetSmCamera()
103     {
104         return m_SmCamera;
105     }
106 
107     //! �V�[����SmModel��lj����܂��B
108     bool AddModel( SmModel* model );
109 
110     //! ���C�g�̃A�j���[�V�������擾���܂��B
GetLightAnimEvaluator()111     nw::gfx::AnimEvaluator* GetLightAnimEvaluator()
112     {
113         return m_LightAnimation;
114     }
115 
116     // SceneCtrl�̃��O�o��
OutputLog()117     void OutputLog()
118     {
119         m_GfxSceneCtrl->OutputLog();
120     }
121 
122 private:
123     SmSceneCtrl*                        m_GfxSceneCtrl;
124 
125     nw::gfx::SceneNode*                 m_SceneRoot;
126     nw::gfx::Camera*                    m_Camera;
127     nw::gfx::Camera*                    m_ResCamera;
128     SmCamera*                           m_SmCamera;
129     SmParticle*                         m_SmParticle;
130 
131     nw::gfx::ParticleContext*           m_ParticleContext;
132     nw::gfx::ParticleSceneUpdater*      m_ParticleSceneUpdater;
133 
134     GfxResourceArray                    m_ResourcesArray;
135     GfxAnimObjectArray                  m_AnimationArray;
136     SmModelInstanceArray                m_SmModelInstArray;
137 
138     nw::gfx::SceneEnvironmentSetting*   m_SceneEnvSetting;
139 
140     nw::gfx::AnimEvaluator*             m_LightAnimation;
141 };
142 
143 
144 #endif  // GFX_CTRL_H_
145