OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / frameworks / base / libs / rs / java / Fountain / res / raw / fountain.c
1 // Fountain test script
2 #pragma version(1)
3
4 int newPart = 0;
5
6 int main(int launchID) {
7     int ct;
8     int count = Control->count;
9     int rate = Control->rate;
10     float height = getHeight();
11     struct point_s * p = (struct point_s *)point;
12
13     if (rate) {
14         float rMax = ((float)rate) * 0.005f;
15         int x = Control->x;
16         int y = Control->y;
17         int color = ((int)(Control->r * 255.f)) |
18                     ((int)(Control->g * 255.f)) << 8 |
19                     ((int)(Control->b * 255.f)) << 16 |
20                     (0xf0 << 24);
21         struct point_s * np = &p[newPart];
22
23         while (rate--) {
24             vec2Rand((float *)&np->delta.x, rMax);
25             np->position.x = x;
26             np->position.y = y;
27             np->color = color;
28             newPart++;
29             np++;
30             if (newPart >= count) {
31                 newPart = 0;
32                 np = &p[newPart];
33             }
34         }
35     }
36
37     for (ct=0; ct < count; ct++) {
38         float dy = p->delta.y + 0.15f;
39         float posy = p->position.y + dy;
40         if ((posy > height) && (dy > 0)) {
41             dy *= -0.3f;
42         }
43         p->delta.y = dy;
44         p->position.x += p->delta.x;
45         p->position.y = posy;
46         p++;
47     }
48
49     uploadToBufferObject(NAMED_PartBuffer);
50     drawSimpleMesh(NAMED_PartMesh);
51     return 1;
52 }