1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     PartsysPattern.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  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   $Rev: 46365 $
14  *---------------------------------------------------------------------------*/
15 
16 /*
17  *------------------------------------------------------------
18  * Copyright(c) 2009-2010 by Digital Media Professionals Inc.
19  * All rights reserved.
20  *------------------------------------------------------------
21  * This source code is the confidential and proprietary
22  * of Digital Media Professionals Inc.
23  *------------------------------------------------------------
24  */
25 
26 enum PARTSYS_PATTERN
27 {
28     PARTSYS_DEFAULT = 0x0,
29     PARTSYS_EXPLOSION1,
30     PARTSYS_EXPLOSION2,
31     PARTSYS_SNOW,
32     PARTSYS_SPIN,
33     PARTSYS_LAST
34 };
35 
36 /**********************************************************************************************************/
37 /********************Basic particle pattern****************************************************************/
38 /**********************************************************************************************************/
LoadParticleSystem1(struct _particleSys * pp)39 static void LoadParticleSystem1(struct _particleSys *pp)
40 {
41     /*------------------------------------------------------------------------------------*/
42     /*--------Definition of the 4 control point positions---------------------------------*/
43     /*------------------------------------------------------------------------------------*/
44     /*-----------Control Point 1---------------------Control Point 2----------------------*/
45     pp->m_partsys_center.m[0][0] = 0.0f;      /*|*/   pp->m_partsys_center.m[1][0] = -10.0f;
46     pp->m_partsys_center.m[0][1] = -10.0f;    /*|*/   pp->m_partsys_center.m[1][1] = -5.0f;
47     pp->m_partsys_center.m[0][2] = 0.0f;      /*|*/   pp->m_partsys_center.m[1][2] = 0.0f;
48     pp->m_partsys_center.m[0][3] = 1.0f;      /*|*/   pp->m_partsys_center.m[1][3] = 1.0f;
49     /*-----------Control Point 3---------------------Control Point 4----------------------*/
50     pp->m_partsys_center.m[2][0] = 10.0f;     /*|*/   pp->m_partsys_center.m[3][0] = 0.0f;
51     pp->m_partsys_center.m[2][1] = 5.0f;      /*|*/   pp->m_partsys_center.m[3][1] = 10.0f;
52     pp->m_partsys_center.m[2][2] = 0.0f;      /*|*/   pp->m_partsys_center.m[3][2] = 0.0f;
53     pp->m_partsys_center.m[2][3] = 1.0f;      /*|*/   pp->m_partsys_center.m[3][3] = 1.0f;
54     /*------------------------------------------------------------------------------------*/
55     /*------------------------------------------------------------------------------------*/
56 
57     /*------------------------------------------------------------------------------------*/
58     /*--------Definition of the 4 control point colors------------------------------------*/
59     /*------------------------------------------------------------------------------------*/
60     /*-----------Control Point 1---------------------Control Point 2----------------------*/
61     pp->m_partsys_color.m[0][0] = 0.0f;       /*|*/   pp->m_partsys_color.m[1][0] = 1.0f;
62     pp->m_partsys_color.m[0][1] = 0.0f;       /*|*/   pp->m_partsys_color.m[1][1] = 0.0f;
63     pp->m_partsys_color.m[0][2] = 0.0f;       /*|*/   pp->m_partsys_color.m[1][2] = 0.0f;
64     pp->m_partsys_color.m[0][3] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][3] = 1.0f;
65     /*-----------Control Point 3---------------------Control Point 4----------------------*/
66     pp->m_partsys_color.m[2][0] = 0.0f;       /*|*/   pp->m_partsys_color.m[3][0] = 0.0f;
67     pp->m_partsys_color.m[2][1] = 1.0f;       /*|*/   pp->m_partsys_color.m[3][1] = 0.0f;
68     pp->m_partsys_color.m[2][2] = 0.0f;       /*|*/   pp->m_partsys_color.m[3][2] = 1.0f;
69     pp->m_partsys_color.m[2][3] = 0.5f;       /*|*/   pp->m_partsys_color.m[3][3] = 0.0f;
70     /*------------------------------------------------------------------------------------*/
71     /*------------------------------------------------------------------------------------*/
72 
73     /*------------------------------------------------------------------------------------*/
74     /*--------Definition of the 4 bounding boxes------------------------------------------*/
75     /*--------Radii in X, Y and Z direction. W not used ----------------------------------*/
76     /*------------------------------------------------------------------------------------*/
77     /*-----------Control Point 1---------------------Control Point 2----------------------*/
78     pp->m_partsys_radius.m[0][0] = 0.0f;      /*|*/   pp->m_partsys_radius.m[1][0] = 1.0f;
79     pp->m_partsys_radius.m[0][1] = 0.0f;      /*|*/   pp->m_partsys_radius.m[1][1] = 1.0f;
80     pp->m_partsys_radius.m[0][2] = 0.0f;      /*|*/   pp->m_partsys_radius.m[1][2] = 1.0f;
81     pp->m_partsys_radius.m[0][3] = 0.0f;      /*|*/   pp->m_partsys_radius.m[1][3] = 0.0f;
82     /*-----------Control Point 3---------------------Control Point 4----------------------*/
83     pp->m_partsys_radius.m[2][0] = 1.0f;      /*|*/   pp->m_partsys_radius.m[3][0] = 10.0f;
84     pp->m_partsys_radius.m[2][1] = 1.0f;      /*|*/   pp->m_partsys_radius.m[3][1] = 1.0f;
85     pp->m_partsys_radius.m[2][2] = 1.0f;      /*|*/   pp->m_partsys_radius.m[3][2] = 1.0f;
86     pp->m_partsys_radius.m[2][3] = 1.0f;      /*|*/   pp->m_partsys_radius.m[3][3] = 1.0f;
87     /*------------------------------------------------------------------------------------*/
88     /*------------------------------------------------------------------------------------*/
89 
90     /*------------------------------------------------------------------------------------*/
91     /*--------Definition of the particle aspect-------------------------------------------*/
92     /*--------Particle size, texture coordinates !!!??TBD   ------------------------------*/
93     /*------------------------------------------------------------------------------------*/
94     /*Rotation disabled: Size, unused,unused,unused/alpha                                 */
95     /*Rotation Enabled:  Size, Angle, Radius, unused/alpha                                */
96     /*-----------Control Point 1---------------------Control Point 2----------------------*/
97     pp->m_partsys_aspect.m[0][0] = 10.0f;     /*|*/   pp->m_partsys_aspect.m[1][0] = 30.0f;
98     pp->m_partsys_aspect.m[0][1] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[1][1] = 0.0f;
99     pp->m_partsys_aspect.m[0][2] = 0.9f;      /*|*/   pp->m_partsys_aspect.m[1][2] = 0.9f;
100     pp->m_partsys_aspect.m[0][3] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[1][3] = 1.0f;
101     /*-----------Control Point 3---------------------Control Point 4----------------------*/
102     pp->m_partsys_aspect.m[2][0] = 30.0f;     /*|*/   pp->m_partsys_aspect.m[3][0] = 10.0f;
103     pp->m_partsys_aspect.m[2][1] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[3][1] = 0.0f;
104     pp->m_partsys_aspect.m[2][2] = 0.9f;      /*|*/   pp->m_partsys_aspect.m[3][2] = 0.9f;
105     pp->m_partsys_aspect.m[2][3] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[3][3] = 0.0f;
106     /*------------------------------------------------------------------------------------*/
107     /*------------------------------------------------------------------------------------*/
108     pp->m_size_min_max[0] = 1.0f;
109     pp->m_size_min_max[1] = static_cast<f32>(nn::gx::DISPLAY0_HEIGHT) / 2.0f;
110 
111     pp->m_random_seed[0] = 45.0f;
112     pp->m_random_seed[1] = 82.564f + pp->m_random_seed[0];
113     pp->m_random_seed[2] = 18.15f + pp->m_random_seed[0];
114     pp->m_random_seed[3] = 819.9875f + pp->m_random_seed[0];
115 
116     /* Core value for random
117      Algorithm is based Pseudo-random number generators: X(n+1) = (a*Xn+b) mod m
118      Expected values for uniform are
119      [0] = a, [1] = b, [2] = m, [3] = 1/m
120     */
121     pp->m_prng[0] = 17.0f;                              /* a */
122     pp->m_prng[1] = 37.0f;                              /* b */
123     pp->m_prng[2] = 65535.0f;                           /* m */
124     pp->m_prng[3] = 1.0f / (pp->m_prng[2]);             /* 1/m */
125 
126     pp->m_speed = 1.0f;             /*  emitter->particle_speed  */
127     pp->m_particleCountMax = 20.0f; /*  particle number          */
128 
129     /* Application only */
130     pp->simulationTime = 2.0f;
131     pp->NFrame = 256;
132     pp->dTime = pp->simulationTime/pp->NFrame;
133 }
134 
135 /************************************************************************************************************/
136 /*********************Explosition like     ******************************************************************/
137 /************************************************************************************************************/
138 /* all the control are in (0,0,0)
139  Bounding boxes have different radii
140  this gives the effect of grow/shrink for the particles
141 */
LoadParticleSystemExplositon1(struct _particleSys * pp)142 static void LoadParticleSystemExplositon1(struct _particleSys *pp)
143 {
144     /*------------------------------------------------------------------------------------*/
145     /*--------Definition of the 4 control point positions---------------------------------*/
146     /*------------------------------------------------------------------------------------*/
147     /*-----------Control Point 1---------------------Control Point 2----------------------*/
148     pp->m_partsys_center.m[0][0] = 0.0f;  /*|*/   pp->m_partsys_center.m[1][0] = 0.0f;
149     pp->m_partsys_center.m[0][1] = 0.0f;  /*|*/   pp->m_partsys_center.m[1][1] = 0.0f;
150     pp->m_partsys_center.m[0][2] = 0.0f;  /*|*/   pp->m_partsys_center.m[1][2] = 0.0f;
151     pp->m_partsys_center.m[0][3] = 1.0f;  /*|*/   pp->m_partsys_center.m[1][3] = 1.0f;
152     /*-----------Control Point 3---------------------Control Point 4----------------------*/
153     pp->m_partsys_center.m[2][0] = 0.0f;  /*|*/   pp->m_partsys_center.m[3][0] = 0.0f;
154     pp->m_partsys_center.m[2][1] = 0.0f;  /*|*/   pp->m_partsys_center.m[3][1] = 0.0f;
155     pp->m_partsys_center.m[2][2] = 0.0f;  /*|*/   pp->m_partsys_center.m[3][2] = 0.0f;
156     pp->m_partsys_center.m[2][3] = 1.0f;  /*|*/   pp->m_partsys_center.m[3][3] = 1.0f;
157     /*------------------------------------------------------------------------------------*/
158     /*------------------------------------------------------------------------------------*/
159 
160     /*------------------------------------------------------------------------------------*/
161     /*--------Definition of the 4 control point colors------------------------------------*/
162     /*------------------------------------------------------------------------------------*/
163     /*-----------Control Point 1---------------------Control Point 2----------------------*/
164     pp->m_partsys_color.m[0][0] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][0] = 1.0f;
165     pp->m_partsys_color.m[0][1] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][1] = 0.0f;
166     pp->m_partsys_color.m[0][2] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][2] = 0.0f;
167     pp->m_partsys_color.m[0][3] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][3] = 1.0f;
168     /*-----------Control Point 3---------------------Control Point 4----------------------*/
169     pp->m_partsys_color.m[2][0] = 0.0f;       /*|*/   pp->m_partsys_color.m[3][0] = 0.0f;
170     pp->m_partsys_color.m[2][1] = 1.0f;       /*|*/   pp->m_partsys_color.m[3][1] = 0.0f;
171     pp->m_partsys_color.m[2][2] = 0.0f;       /*|*/   pp->m_partsys_color.m[3][2] = 1.0f;
172     pp->m_partsys_color.m[2][3] = 1.0f;       /*|*/   pp->m_partsys_color.m[3][3] = 0.0f;
173     /*------------------------------------------------------------------------------------*/
174     /*------------------------------------------------------------------------------------*/
175 
176     /*------------------------------------------------------------------------------------*/
177     /*--------Definition of the 4 bounding boxes------------------------------------------*/
178     /*--------Radii in X, Y and Z direction. W not used ----------------------------------*/
179     /*------------------------------------------------------------------------------------*/
180     /*-----------Control Point 1---------------------Control Point 2----------------------*/
181     pp->m_partsys_radius.m[0][0] = 1.0f;      /*|*/   pp->m_partsys_radius.m[1][0] = 10.0f;
182     pp->m_partsys_radius.m[0][1] = 1.0f;      /*|*/   pp->m_partsys_radius.m[1][1] = 10.0f;
183     pp->m_partsys_radius.m[0][2] = 1.0f;      /*|*/   pp->m_partsys_radius.m[1][2] = 10.0f;
184     pp->m_partsys_radius.m[0][3] = 1.0f;      /*|*/   pp->m_partsys_radius.m[1][3] = 1.0f;
185     /*-----------Control Point 3---------------------Control Point 4----------------------*/
186     pp->m_partsys_radius.m[2][0] = 20.0f;     /*|*/   pp->m_partsys_radius.m[3][0] = 50.0f;
187     pp->m_partsys_radius.m[2][1] = 20.0f;     /*|*/   pp->m_partsys_radius.m[3][1] = 50.0f;
188     pp->m_partsys_radius.m[2][2] = 20.0f;     /*|*/   pp->m_partsys_radius.m[3][2] = 50.0f;
189     pp->m_partsys_radius.m[2][3] = 1.0f;      /*|*/   pp->m_partsys_radius.m[3][3] = 1.0f;
190     /*------------------------------------------------------------------------------------*/
191     /*------------------------------------------------------------------------------------*/
192 
193     /*------------------------------------------------------------------------------------*/
194     /*--------Definition of the particle aspect-------------------------------------------*/
195     /*--------Particle size, texture coordinates !!!??TBD   ------------------------------*/
196     /*------------------------------------------------------------------------------------*/
197     /*Rotation disabled: Size, unused,unused,unused/alpha                                 */
198     /*Rotation Enabled:  Size, Angle, Radius, unused/alpha                                */
199     /*-----------Control Point 1---------------------Control Point 2----------------------*/
200     pp->m_partsys_aspect.m[0][0] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[1][0] = 2.0f;
201     pp->m_partsys_aspect.m[0][1] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[1][1] = 0.0f;
202     pp->m_partsys_aspect.m[0][2] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[1][2] = 1.0f;
203     pp->m_partsys_aspect.m[0][3] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[1][3] = 1.0f;
204     /*-----------Control Point 3---------------------Control Point 4----------------------*/
205     pp->m_partsys_aspect.m[2][0] = 30.0f;     /*|*/   pp->m_partsys_aspect.m[3][0] = 50.0f;
206     pp->m_partsys_aspect.m[2][1] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[3][1] = 0.0f;
207     pp->m_partsys_aspect.m[2][2] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[3][2] = 1.0f;
208     pp->m_partsys_aspect.m[2][3] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[3][3] = 0.0f;
209     /*------------------------------------------------------------------------------------*/
210     /*------------------------------------------------------------------------------------*/
211     pp->m_size_min_max[0] = 1.0f;
212     pp->m_size_min_max[1] = static_cast<f32>(nn::gx::DISPLAY0_HEIGHT) / 2.0f;
213 
214     pp->m_random_seed[0] = 15.8794f;
215     pp->m_random_seed[1] = 2.564f + pp->m_random_seed[0];
216     pp->m_random_seed[2] = 1.15f + pp->m_random_seed[0];
217     pp->m_random_seed[3] = 0.9875f + pp->m_random_seed[0];
218 
219     /* Core value for random
220      Algorithm is based Pseudo-random number generators: X(n+1) = (a*Xn+b) mod m
221      Expected values for uniform are
222      [0] = a, [1] = b, [2] = m, [3] = 1/m
223     */
224     pp->m_prng[0] = 147.0f;                     /* a */
225     pp->m_prng[1] = 17.0f;                      /* b */
226     pp->m_prng[2] = 256847.0f;                  /* m */
227     pp->m_prng[3] = 1.0f / (pp->m_prng[2]);     /* 1/m */
228 
229     pp->m_speed = 0.55f;                /*  emitter->particle_speed  */
230     pp->m_particleCountMax = 100.0f;    /*  particle number          */
231 
232     /* Application only */
233     pp->simulationTime = 10.0f;
234     pp->NFrame = 512;
235     pp->dTime = pp->simulationTime/pp->NFrame;
236 }
237 
238 /***********************************************************************************************************/
239 /********************Explosition like     ******************************************************************/
240 /***********************************************************************************************************/
241 /* all the control are in (0,0,0)
242  Bounding boxes have growing radii
243  this gives the expanding for the particles */
LoadParticleSystemExplositon2(struct _particleSys * pp)244 static void LoadParticleSystemExplositon2(struct _particleSys *pp)
245 {
246     /*------------------------------------------------------------------------------------*/
247     /*--------Definition of the 4 control point positions---------------------------------*/
248     /*------------------------------------------------------------------------------------*/
249     /*-----------Control Point 1---------------------Control Point 2----------------------*/
250     pp->m_partsys_center.m[0][0] = 0.0f;  /*|*/   pp->m_partsys_center.m[1][0] = 0.0f;
251     pp->m_partsys_center.m[0][1] = 0.0f;  /*|*/   pp->m_partsys_center.m[1][1] = 0.0f;
252     pp->m_partsys_center.m[0][2] = 0.0f;  /*|*/   pp->m_partsys_center.m[1][2] = 0.0f;
253     pp->m_partsys_center.m[0][3] = 1.0f;  /*|*/   pp->m_partsys_center.m[1][3] = 1.0f;
254     /*-----------Control Point 3---------------------Control Point 4----------------------*/
255     pp->m_partsys_center.m[2][0] = 0.0f;  /*|*/   pp->m_partsys_center.m[3][0] = 0.0f;
256     pp->m_partsys_center.m[2][1] = 0.0f;  /*|*/   pp->m_partsys_center.m[3][1] = 0.0f;
257     pp->m_partsys_center.m[2][2] = 0.0f;  /*|*/   pp->m_partsys_center.m[3][2] = 0.0f;
258     pp->m_partsys_center.m[2][3] = 1.0f;  /*|*/   pp->m_partsys_center.m[3][3] = 1.0f;
259     /*------------------------------------------------------------------------------------*/
260     /*------------------------------------------------------------------------------------*/
261 
262     /*------------------------------------------------------------------------------------*/
263     /*--------Definition of the 4 control point colors------------------------------------*/
264     /*------------------------------------------------------------------------------------*/
265     /*-----------Control Point 1---------------------Control Point 2----------------------*/
266     pp->m_partsys_color.m[0][0] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][0] = 1.0f;
267     pp->m_partsys_color.m[0][1] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][1] = 0.0f;
268     pp->m_partsys_color.m[0][2] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][2] = 0.0f;
269     pp->m_partsys_color.m[0][3] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][3] = 1.0f;
270     /*-----------Control Point 3---------------------Control Point 4----------------------*/
271     pp->m_partsys_color.m[2][0] = 0.0f;       /*|*/   pp->m_partsys_color.m[3][0] = 0.0f;
272     pp->m_partsys_color.m[2][1] = 1.0f;       /*|*/   pp->m_partsys_color.m[3][1] = 0.0f;
273     pp->m_partsys_color.m[2][2] = 0.0f;       /*|*/   pp->m_partsys_color.m[3][2] = 1.0f;
274     pp->m_partsys_color.m[2][3] = 1.0f;       /*|*/   pp->m_partsys_color.m[3][3] = 0.0f;
275     /*------------------------------------------------------------------------------------*/
276     /*------------------------------------------------------------------------------------*/
277 
278     /*------------------------------------------------------------------------------------*/
279     /*--------Definition of the 4 bounding boxes------------------------------------------*/
280     /*--------Radii in X, Y and Z direction. W not used ----------------------------------*/
281     /*------------------------------------------------------------------------------------*/
282     /*-----------Control Point 1---------------------Control Point 2----------------------*/
283     pp->m_partsys_radius.m[0][0] = 1.0f;      /*|*/   pp->m_partsys_radius.m[1][0] = 1.0f;
284     pp->m_partsys_radius.m[0][1] = 1.0f;      /*|*/   pp->m_partsys_radius.m[1][1] = 1.0f;
285     pp->m_partsys_radius.m[0][2] = 1.0f;      /*|*/   pp->m_partsys_radius.m[1][2] = 1.0f;
286     pp->m_partsys_radius.m[0][3] = 1.0f;      /*|*/   pp->m_partsys_radius.m[1][3] = 1.0f;
287     /*-----------Control Point 3---------------------Control Point 4----------------------*/
288     pp->m_partsys_radius.m[2][0] = 80.0f;     /*|*/   pp->m_partsys_radius.m[3][0] = 0.0f;
289     pp->m_partsys_radius.m[2][1] = 80.0f;     /*|*/   pp->m_partsys_radius.m[3][1] = 0.0f;
290     pp->m_partsys_radius.m[2][2] = 80.0f;     /*|*/   pp->m_partsys_radius.m[3][2] = 0.0f;
291     pp->m_partsys_radius.m[2][3] = 1.0f;      /*|*/   pp->m_partsys_radius.m[3][3] = 1.0f;
292     /*------------------------------------------------------------------------------------*/
293     /*------------------------------------------------------------------------------------*/
294 
295     /*------------------------------------------------------------------------------------*/
296     /*--------Definition of the particle aspect-------------------------------------------*/
297     /*--------Particle size, texture coordinates !!!??TBD   ------------------------------*/
298     /*------------------------------------------------------------------------------------*/
299     /*Rotation disabled: Size, unused,unused,unused/alpha                                 */
300     /*Rotation Enabled:  Size, Angle, Radius, unused/alpha                                */
301     /*-----------Control Point 1---------------------Control Point 2----------------------*/
302     pp->m_partsys_aspect.m[0][0] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[1][0] = 3.0f;
303     pp->m_partsys_aspect.m[0][1] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[1][1] = 3.0f;
304     pp->m_partsys_aspect.m[0][2] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[1][2] = 1.0f;
305     pp->m_partsys_aspect.m[0][3] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[1][3] = 1.0f;
306     /*-----------Control Point 3---------------------Control Point 4----------------------*/
307     pp->m_partsys_aspect.m[2][0] = 20.0f;     /*|*/   pp->m_partsys_aspect.m[3][0] = 0.0f;
308     pp->m_partsys_aspect.m[2][1] = -3.0f;     /*|*/   pp->m_partsys_aspect.m[3][1] = -6.0f;
309     pp->m_partsys_aspect.m[2][2] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[3][2] = 1.0f;
310     pp->m_partsys_aspect.m[2][3] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[3][3] = 0.0f;
311     /*------------------------------------------------------------------------------------*/
312     /*------------------------------------------------------------------------------------*/
313     pp->m_size_min_max[0] = 1.0f;
314     pp->m_size_min_max[1] = static_cast<f32>(nn::gx::DISPLAY0_HEIGHT) / 2.0f;
315 
316     pp->m_random_seed[0] = 735.0f;
317     pp->m_random_seed[1] = 2.564f + pp->m_random_seed[0];
318     pp->m_random_seed[2] = 1.15f + pp->m_random_seed[0];
319     pp->m_random_seed[3] = 0.9875f + pp->m_random_seed[0];
320 
321     /* Core value for random
322      Algorithm is based Pseudo-random number generators: X(n+1) = (a*Xn+b) mod m
323      Expected values for uniform are
324      [0] = a, [1] = b, [2] = m, [3] = 1/m
325     */
326     pp->m_prng[0] = 147.0f;                 /* a */
327     pp->m_prng[1] = 17.0f;                  /* b */
328     pp->m_prng[2] = 256847.0f;              /* m */
329     pp->m_prng[3] = 1.0f / (pp->m_prng[2]); /* 1/m */
330 
331     pp->m_speed = 0.55f;                /*  emitter->particle_speed  */
332     pp->m_particleCountMax = 100.0f;    /*  particle number          */
333 
334     /* Application only */
335     pp->simulationTime = 10.0f;
336     pp->NFrame = 512;
337     pp->dTime = pp->simulationTime/pp->NFrame;
338 }
339 /*********************************************************************************************************/
340 /********************Snow / Falling flocon ***************************************************************/
341 /*********************************************************************************************************/
342 /* all the control are in (0,0,0)
343  Falling particles */
LoadParticleSystemSnow(struct _particleSys * pp)344 static void LoadParticleSystemSnow(struct _particleSys *pp)
345 {
346     /*------------------------------------------------------------------------------------*/
347     /*--------Definition of the 4 control point positions---------------------------------*/
348     /*------------------------------------------------------------------------------------*/
349     /*-----------Control Point 1---------------------Control Point 2----------------------*/
350     pp->m_partsys_center.m[0][0] = 0.0f;  /*|*/   pp->m_partsys_center.m[1][0] = 0.0f;
351     pp->m_partsys_center.m[0][1] = 35.0f; /*|*/   pp->m_partsys_center.m[1][1] = 10.0f;
352     pp->m_partsys_center.m[0][2] = 0.0f;  /*|*/   pp->m_partsys_center.m[1][2] = 0.0f;
353     pp->m_partsys_center.m[0][3] = 1.0f;  /*|*/   pp->m_partsys_center.m[1][3] = 1.0f;
354     /*-----------Control Point 3---------------------Control Point 4----------------------*/
355     pp->m_partsys_center.m[2][0] = 0.0f;  /*|*/   pp->m_partsys_center.m[3][0] = 0.0f;
356     pp->m_partsys_center.m[2][1] = -5.0f; /*|*/   pp->m_partsys_center.m[3][1] = -60.0f;
357     pp->m_partsys_center.m[2][2] = 0.0f;  /*|*/   pp->m_partsys_center.m[3][2] = 0.0f;
358     pp->m_partsys_center.m[2][3] = 1.0f;  /*|*/   pp->m_partsys_center.m[3][3] = 1.0f;
359     /*------------------------------------------------------------------------------------*/
360     /*------------------------------------------------------------------------------------*/
361 
362     /*------------------------------------------------------------------------------------*/
363     /*--------Definition of the 4 control point colors------------------------------------*/
364     /*------------------------------------------------------------------------------------*/
365     /*-----------Control Point 1---------------------Control Point 2----------------------*/
366     pp->m_partsys_color.m[0][0] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][0] = 1.0f;
367     pp->m_partsys_color.m[0][1] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][1] = 1.0f;
368     pp->m_partsys_color.m[0][2] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][2] = 1.0f;
369     pp->m_partsys_color.m[0][3] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][3] = 1.0f;
370     /*-----------Control Point 3---------------------Control Point 4----------------------*/
371     pp->m_partsys_color.m[2][0] = 1.0f;       /*|*/   pp->m_partsys_color.m[3][0] = 1.0f;
372     pp->m_partsys_color.m[2][1] = 1.0f;       /*|*/   pp->m_partsys_color.m[3][1] = 1.0f;
373     pp->m_partsys_color.m[2][2] = 1.0f;       /*|*/   pp->m_partsys_color.m[3][2] = 1.0f;
374     pp->m_partsys_color.m[2][3] = 0.0f;       /*|*/   pp->m_partsys_color.m[3][3] = 0.0f;
375     /*------------------------------------------------------------------------------------*/
376     /*------------------------------------------------------------------------------------*/
377 
378     /*------------------------------------------------------------------------------------*/
379     /*--------Definition of the 4 bounding boxes------------------------------------------*/
380     /*--------Radii in X, Y and Z direction. W not used ----------------------------------*/
381     /*------------------------------------------------------------------------------------*/
382     /*-----------Control Point 1---------------------Control Point 2----------------------*/
383     pp->m_partsys_radius.m[0][0] = 100.0f;    /*|*/   pp->m_partsys_radius.m[1][0] = 100.0f;
384     pp->m_partsys_radius.m[0][1] = 1.0f;      /*|*/   pp->m_partsys_radius.m[1][1] = 10.0f;
385     pp->m_partsys_radius.m[0][2] = 1.0f;      /*|*/   pp->m_partsys_radius.m[1][2] = 10.0f;
386     pp->m_partsys_radius.m[0][3] = 1.0f;      /*|*/   pp->m_partsys_radius.m[1][3] = 1.0f;
387     /*-----------Control Point 3---------------------Control Point 4----------------------*/
388     pp->m_partsys_radius.m[2][0] = 100.0f;    /*|*/   pp->m_partsys_radius.m[3][0] = 100.0f;
389     pp->m_partsys_radius.m[2][1] = 10.0f;     /*|*/   pp->m_partsys_radius.m[3][1] = 10.0f;
390     pp->m_partsys_radius.m[2][2] = 20.0f;     /*|*/   pp->m_partsys_radius.m[3][2] = 50.0f;
391     pp->m_partsys_radius.m[2][3] = 1.0f;      /*|*/   pp->m_partsys_radius.m[3][3] = 1.0f;
392     /*------------------------------------------------------------------------------------*/
393     /*------------------------------------------------------------------------------------*/
394 
395     /*------------------------------------------------------------------------------------*/
396     /*--------Definition of the particle aspect-------------------------------------------*/
397     /*--------Particle size, texture coordinates !!!??TBD   ------------------------------*/
398     /*------------------------------------------------------------------------------------*/
399     /*Rotation disabled: Size, unused,unused,unused/alpha                                 */
400     /*Rotation Enabled:  Size, Angle, Radius, unused/alpha                                */
401     /*-----------Control Point 1---------------------Control Point 2----------------------*/
402     pp->m_partsys_aspect.m[0][0] = 10.0f;     /*|*/   pp->m_partsys_aspect.m[1][0] = 10.0f;
403     pp->m_partsys_aspect.m[0][1] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[1][1] = 1.0f;
404     pp->m_partsys_aspect.m[0][2] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[1][2] = 1.0f;
405     pp->m_partsys_aspect.m[0][3] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[1][3] = 1.0f;
406     /*-----------Control Point 3---------------------Control Point 4----------------------*/
407     pp->m_partsys_aspect.m[2][0] = 10.0f;     /*|*/   pp->m_partsys_aspect.m[3][0] = 10.0f;
408     pp->m_partsys_aspect.m[2][1] = 6.0f;      /*|*/   pp->m_partsys_aspect.m[3][1] = 0.0f;
409     pp->m_partsys_aspect.m[2][2] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[3][2] = 1.0f;
410     pp->m_partsys_aspect.m[2][3] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[3][3] = 0.0f;
411     /*------------------------------------------------------------------------------------*/
412     /*------------------------------------------------------------------------------------*/
413     pp->m_size_min_max[0] = 1.0f;
414     pp->m_size_min_max[1] = static_cast<f32>(nn::gx::DISPLAY0_HEIGHT) / 2.0f;
415 
416     pp->m_random_seed[0] = 735.0f;
417     pp->m_random_seed[1] = 2.564f + pp->m_random_seed[0];
418     pp->m_random_seed[2] = 1.15f + pp->m_random_seed[0];
419     pp->m_random_seed[3] = 0.9875f + pp->m_random_seed[0];
420 
421     /* Core value for random
422      Algorithm is based Pseudo-random number generators: X(n+1) = (a*Xn+b) mod m
423      Expected values for uniform are
424      [0] = a, [1] = b, [2] = m, [3] = 1/m
425     */
426     pp->m_prng[0] = 17.0f;                      /* a */
427     pp->m_prng[1] = 37.0f;                      /* b */
428     pp->m_prng[2] = 16777215.0f;                /* m */
429     pp->m_prng[3] = 1.0f / (pp->m_prng[2]);     /* 1/m */
430 
431     pp->m_speed = 0.15f;                /*  emitter->particle_speed  */
432     pp->m_particleCountMax = 100.0f;    /*  particle number          */
433 
434     /* Application only */
435     pp->simulationTime = 10.0f;
436     pp->NFrame = 512;
437     pp->dTime = pp->simulationTime/pp->NFrame;
438 }
439 
440 /*********************************************************************************************************/
441 /********************Spinning / Fake blurry effect********************************************************/
442 /*********************************************************************************************************/
443 /* all the control are in (0,0,0)
444  Falling particles */
LoadParticleSystemSpin(struct _particleSys * pp)445 static void LoadParticleSystemSpin(struct _particleSys *pp)
446 {
447     /*------------------------------------------------------------------------------------*/
448     /*--------Definition of the 4 control point positions---------------------------------*/
449     /*------------------------------------------------------------------------------------*/
450     /*-----------Control Point 1---------------------Control Point 2----------------------*/
451     pp->m_partsys_center.m[0][0] = 0.0f;  /*|*/   pp->m_partsys_center.m[1][0] = 0.0f;
452     pp->m_partsys_center.m[0][1] = 0.0f;  /*|*/   pp->m_partsys_center.m[1][1] = 0.0f;
453     pp->m_partsys_center.m[0][2] = 0.0f;  /*|*/   pp->m_partsys_center.m[1][2] = 0.0f;
454     pp->m_partsys_center.m[0][3] = 1.0f;  /*|*/   pp->m_partsys_center.m[1][3] = 1.0f;
455     /*-----------Control Point 3---------------------Control Point 4----------------------*/
456     pp->m_partsys_center.m[2][0] = 0.0f;  /*|*/   pp->m_partsys_center.m[3][0] = 0.0f;
457     pp->m_partsys_center.m[2][1] = 0.0f;  /*|*/   pp->m_partsys_center.m[3][1] = 0.0f;
458     pp->m_partsys_center.m[2][2] = 0.0f;  /*|*/   pp->m_partsys_center.m[3][2] = 0.0f;
459     pp->m_partsys_center.m[2][3] = 1.0f;  /*|*/   pp->m_partsys_center.m[3][3] = 1.0f;
460     /*------------------------------------------------------------------------------------*/
461     /*------------------------------------------------------------------------------------*/
462 
463     /*------------------------------------------------------------------------------------*/
464     /*--------Definition of the 4 control point colors------------------------------------*/
465     /*------------------------------------------------------------------------------------*/
466     /*-----------Control Point 1---------------------Control Point 2----------------------*/
467     pp->m_partsys_color.m[0][0] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][0] = 0.0f;
468     pp->m_partsys_color.m[0][1] = 0.0f;       /*|*/   pp->m_partsys_color.m[1][1] = 1.0f;
469     pp->m_partsys_color.m[0][2] = 0.0f;       /*|*/   pp->m_partsys_color.m[1][2] = 0.0f;
470     pp->m_partsys_color.m[0][3] = 1.0f;       /*|*/   pp->m_partsys_color.m[1][3] = 1.0f;
471     /*-----------Control Point 3---------------------Control Point 4----------------------*/
472     pp->m_partsys_color.m[2][0] = 0.0f;       /*|*/   pp->m_partsys_color.m[3][0] = 1.0f;
473     pp->m_partsys_color.m[2][1] = 1.0f;       /*|*/   pp->m_partsys_color.m[3][1] = 1.0f;
474     pp->m_partsys_color.m[2][2] = 1.0f;       /*|*/   pp->m_partsys_color.m[3][2] = 1.0f;
475     pp->m_partsys_color.m[2][3] = 0.0f;       /*|*/   pp->m_partsys_color.m[3][3] = 0.0f;
476     /*------------------------------------------------------------------------------------*/
477     /*------------------------------------------------------------------------------------*/
478 
479     /*------------------------------------------------------------------------------------*/
480     /*--------Definition of the 4 bounding boxes------------------------------------------*/
481     /*--------Radii in X, Y and Z direction. W not used ----------------------------------*/
482     /*------------------------------------------------------------------------------------*/
483     /*-----------Control Point 1---------------------Control Point 2----------------------*/
484     pp->m_partsys_radius.m[0][0] = 0.0f;      /*|*/   pp->m_partsys_radius.m[1][0] = 0.0f;
485     pp->m_partsys_radius.m[0][1] = 0.0f;      /*|*/   pp->m_partsys_radius.m[1][1] = 0.0f;
486     pp->m_partsys_radius.m[0][2] = 0.0f;      /*|*/   pp->m_partsys_radius.m[1][2] = 0.0f;
487     pp->m_partsys_radius.m[0][3] = 0.0f;      /*|*/   pp->m_partsys_radius.m[1][3] = 0.0f;
488     /*-----------Control Point 3---------------------Control Point 4----------------------*/
489     pp->m_partsys_radius.m[2][0] = 0.0f;      /*|*/   pp->m_partsys_radius.m[3][0] = 0.0f;
490     pp->m_partsys_radius.m[2][1] = 0.0f;      /*|*/   pp->m_partsys_radius.m[3][1] = 0.0f;
491     pp->m_partsys_radius.m[2][2] = 0.0f;      /*|*/   pp->m_partsys_radius.m[3][2] = 0.0f;
492     pp->m_partsys_radius.m[2][3] = 0.0f;      /*|*/   pp->m_partsys_radius.m[3][3] = 0.0f;
493     /*------------------------------------------------------------------------------------*/
494     /*------------------------------------------------------------------------------------*/
495 
496     /*------------------------------------------------------------------------------------*/
497     /*--------Definition of the particle aspect-------------------------------------------*/
498     /*--------Particle size, texture coordinates !!!??TBD   ------------------------------*/
499     /*------------------------------------------------------------------------------------*/
500     /*Rotation disabled: Size, unused,unused,unused/alpha                                 */
501     /*Rotation Enabled:  Size, Angle, Radius, unused/alpha                                */
502     /*-----------Control Point 1---------------------Control Point 2----------------------*/
503     pp->m_partsys_aspect.m[0][0] = 30.0f;     /*|*/   pp->m_partsys_aspect.m[1][0] = 30.0f;
504     pp->m_partsys_aspect.m[0][1] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[1][1] = -3.1415f / 0.15f;
505     pp->m_partsys_aspect.m[0][2] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[1][2] = 1.0f;
506     pp->m_partsys_aspect.m[0][3] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[1][3] = 1.0f;
507     /*-----------Control Point 3---------------------Control Point 4----------------------*/
508     pp->m_partsys_aspect.m[2][0] = 30.0f;     /*|*/   pp->m_partsys_aspect.m[3][0] = 30.0f;
509     pp->m_partsys_aspect.m[2][1] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[3][1] = 3.1415f / 0.15f;
510     pp->m_partsys_aspect.m[2][2] = 1.0f;      /*|*/   pp->m_partsys_aspect.m[3][2] = 1.0f;
511     pp->m_partsys_aspect.m[2][3] = 0.0f;      /*|*/   pp->m_partsys_aspect.m[3][3] = 0.0f;
512     /*------------------------------------------------------------------------------------*/
513     /*------------------------------------------------------------------------------------*/
514     pp->m_size_min_max[0] = 1.0f;
515     pp->m_size_min_max[1] = static_cast<f32>(nn::gx::DISPLAY0_HEIGHT) / 2.0f;
516 
517     pp->m_random_seed[0] = 735.0f;
518     pp->m_random_seed[1] = 2.564f + pp->m_random_seed[0];
519     pp->m_random_seed[2] = 1.15f + pp->m_random_seed[0];
520     pp->m_random_seed[3] = 0.9875f + pp->m_random_seed[0];
521 
522     /* Core value for random
523      Algorithm is based Pseudo-random number generators: X(n+1) = (a*Xn+b) mod m
524      Expected values for uniform are
525      [0] = a, [1] = b, [2] = m, [3] = 1/m
526     */
527     pp->m_prng[0] = 147.0f;                     /* a */
528     pp->m_prng[1] = 17.0f;                      /* b */
529     pp->m_prng[2] = 256847.0f;                  /* m */
530     pp->m_prng[3] = 1.0f / (pp->m_prng[2]);     /* 1/m */
531 
532     pp->m_speed = 0.15f;                /*  emitter->particle_speed  */
533     pp->m_particleCountMax = 5.0f;  /*  particle number          */
534 
535     /* Application only */
536     pp->simulationTime = 10.0f;
537     pp->NFrame = 512;
538     pp->dTime = pp->simulationTime/pp->NFrame;
539 }
540 
541 /**********************************************************************************************************/
542 /********************Particle Pattern selector*************************************************************/
543 /**********************************************************************************************************/
544 
LoadParticlePattern(struct _particleSys * pp,PARTSYS_PATTERN pt)545 void LoadParticlePattern(struct _particleSys *pp, PARTSYS_PATTERN pt)
546 {
547     switch(pt)
548     {
549         case PARTSYS_EXPLOSION1:    LoadParticleSystemExplositon1(pp);     break;
550         case PARTSYS_EXPLOSION2:    LoadParticleSystemExplositon2(pp);     break;
551         case PARTSYS_SNOW:          LoadParticleSystemSnow(pp);            break;
552         case PARTSYS_SPIN:          LoadParticleSystemSpin(pp);            break;
553         case PARTSYS_DEFAULT:
554         default:
555                                     LoadParticleSystem1(pp);               break;
556     }
557 }
558