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