1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: SmParticle.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 SM_PARTICLE_H_ 18 #define SM_PARTICLE_H_ 19 20 #include <nw/gfx.h> 21 #include "../include/SmBase.h" 22 23 //------------------------------------------------------------------------------ 24 // NW4C �p�[�e�B�N���e�@�\�ւ̃A�N�Z�T�N���X 25 class SmParticle : public SmBase 26 { 27 friend class GfxCtrl; 28 29 #define ARRAY_COUNT (32) 30 31 //! �������ꂽParticleModel�C���X�^���X��ێ����邽�߂̔z��ł��B 32 typedef nw::ut::FixedSizeArray<nw::gfx::ParticleModel*, ARRAY_COUNT> ParticleModelInstanceArray; 33 34 //! �������ꂽParticleEmitter�C���X�^���X��ێ����邽�߂̔z��ł��B 35 typedef nw::ut::FixedSizeArray<nw::gfx::ParticleEmitter*, ARRAY_COUNT> ParticleEmitterInstanceArray; 36 37 //! 38 typedef nw::ut::FixedSizeArray<bool, ARRAY_COUNT> ParticleInstAttachedArray; 39 40 private: 41 // �R���X�g���N�^ 42 SmParticle( nw::gfx::SceneNode* parentNode ); 43 44 // �f�X�g���N�^ 45 ~SmParticle(); 46 47 public: 48 // �p�[�e�B�N�����f����lj� 49 void AddParticleModel( nw::gfx::ParticleModel* particleModel ); 50 51 // �p�[�e�B�N���G�~�b�^��lj� 52 void AddParticleEmitter( nw::gfx::ParticleEmitter* particleEmitter ); 53 54 // �A�j���[�V�����t���[����ݒ肷�� 55 void SetAnimationFrame( f32 setFrame ); 56 57 // �A�j���[�V�����t���[����i�߂� 58 bool AddAnimationFrame( f32 addFrame, bool loop = true ); 59 60 // ���Z�b�g���� 61 void Reset(); 62 63 // �\��/��\�� SetVisible(bool visible)64 void SetVisible( bool visible ) 65 { 66 /* 67 ����A�p�[�e�B�N�����f���E�G�~�b�^�������̏ꍇ�̂ݓ��삷��B 68 */ 69 if( m_ParticleModelInstArray.size() != m_ParticleEmitterInstArray.size() ) 70 { 71 return; 72 } 73 74 for ( int i=0; i<m_ParticleModelInstArray.size(); i++ ) 75 { 76 if ( visible ) 77 { 78 // �A�^�b�`�̏ꍇ�́A�t���O�����ĕ�������B 79 if( m_ParticleInstAttachedArray[i] ) 80 { 81 attach( i ); 82 } 83 } 84 else 85 { 86 // �f�^�b�`�̏ꍇ�́A�S�ăf�^�b�` 87 detach( i ); 88 } 89 } 90 } SwapVisible()91 void SwapVisible(){} IsVisible()92 bool IsVisible() 93 { 94 return true; 95 } 96 97 98 /* 99 ���C������ 100 */ SetLayerId(u8 id)101 void SetLayerId( u8 id ) 102 { 103 for ( int i=0; i<m_ParticleModelInstArray.size(); i++ ) 104 { 105 m_ParticleModelInstArray[i]->SetLayerId( id ); 106 } 107 } 108 109 110 /* 111 �G�~�b�^���� 112 */ 113 nw::gfx::ParticleEmitter* GetEmitter( uint idx = 0 ) 114 { 115 return m_ParticleEmitterInstArray[idx]; 116 } 117 118 void ResetEmitter( int idx = -1 ) 119 { 120 if ( idx == -1 ) 121 { 122 for ( int i=0; i<m_ParticleEmitterInstArray.size(); i++ ) 123 { 124 m_ParticleEmitterInstArray[i]->Reset(); 125 } 126 } 127 else 128 { 129 if ( idx < m_ParticleEmitterInstArray.size() ) 130 { 131 m_ParticleEmitterInstArray[idx]->Reset(); 132 } 133 } 134 } 135 136 // 137 void SetVisibleZone( f32 term ); 138 139 140 private: detach(int index)141 void detach( int index ) 142 { 143 if ( m_ParticleModelInstArray[index]->GetParent() ) 144 { 145 m_pParentNode->DetachChild( m_ParticleModelInstArray[index] ); 146 } 147 if ( m_ParticleEmitterInstArray[index]->GetParent() ) 148 { 149 m_pParentNode->DetachChild( m_ParticleEmitterInstArray[index] ); 150 } 151 } 152 attach(int index)153 void attach( int index ) 154 { 155 if ( !m_ParticleModelInstArray[index]->GetParent() ) 156 { 157 m_pParentNode->AttachChild( m_ParticleModelInstArray[index] ); 158 } 159 if ( !m_ParticleEmitterInstArray[index]->GetParent() ) 160 { 161 m_pParentNode->AttachChild( m_ParticleEmitterInstArray[index] ); 162 } 163 } 164 165 private: 166 nw::gfx::SceneNode* m_pParentNode; 167 ParticleModelInstanceArray m_ParticleModelInstArray; 168 ParticleEmitterInstanceArray m_ParticleEmitterInstArray; 169 170 bool m_ParticleInstAttachedArray[ARRAY_COUNT]; 171 172 f32 m_AnimationFrame; 173 }; 174 175 176 #endif // SM_PARTICLE_H_ 177