1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_ResParticleModel.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 
18 #ifndef NW_GFX_RESPARTICLEMODEL_H_
19 #define NW_GFX_RESPARTICLEMODEL_H_
20 
21 #include <nw/ut/ut_ResUtil.h>
22 #include <nw/ut/ut_ResDictionary.h>
23 #include <nw/gfx/res/gfx_ResSceneObject.h>
24 #include <nw/gfx/res/gfx_ResModel.h>
25 #include <nw/gfx/res/gfx_ResParticleSet.h>
26 #include <nw/gfx/res/gfx_ResRevision.h>
27 #include <nw/gfx/res/gfx_ResTypeInfo.h>
28 
29 namespace nw {
30 namespace gfx {
31 namespace res {
32 
33 //! @details :private
34 struct ResParticleModelData : public ResModelData
35 {
36     nw::ut::ResS32 m_ParticleSetsTableCount;
37     nw::ut::Offset toParticleSetsTable;
38 };
39 
40 
41 //--------------------------------------------------------------------------
42 //! @brief  パーティクルモデルを表すバイナリリソースクラスです。
43 //--------------------------------------------------------------------------
44 class ResParticleModel : public ResModel
45 {
46 public:
47     enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleModel) };
48     enum { SIGNATURE = NW_RES_SIGNATURE32('PMDL') };
49     enum { BINARY_REVISION = REVISION_RES_EMITTER };
50 
51     NW_RES_CTOR_INHERIT( ResParticleModel, ResModel )
52 
53     NW_RES_FIELD_CLASS_LIST_DECL( ResParticleSet, ParticleSets ) // GetParticleSets(int idx), GetParticleSetsCount()
54 
55     void    Setup();
56 
57     //---------------------------------------------------------------------------
58     //! @brief        ResParticleModel 内の全ての ResParticleSet を巡回して TFunction を適用します。
59     //!
60     //! @tparam       TFunction ResParticleSet を引数に取る関数(オブジェクト)の型です。
61     //! @param[in]    function 適応する関数(オブジェクト)です。
62     //---------------------------------------------------------------------------
63     template<typename TFunction>
ForeachParticleSet(TFunction function)64     void ForeachParticleSet(TFunction function)
65     {
66         if (this->IsValid())
67         {
68             for (s32 i = 0; i < this->GetParticleSetsCount(); ++i)
69             {
70                 ResParticleSet resParticleSet = this->GetParticleSets(i);
71                 function(resParticleSet);
72             }
73         }
74     }
75 };
76 
77 } // namespace res
78 } // namespace gfx
79 } // namespace nw
80 
81 #endif // NW_GFX_RESPARTICLEMODEL_H_
82