Merge pull request #3819 from arnova/subtitles_for_stacks
[vuplus_xbmc] / addons / visualization.vortex / resources / Presets / CubeBlowOut.tra
1 // CubeBlowOut.tra
2 // Author - MrC
3 // Based on FadeCubeBlowOut.r4 by Gordon Williams
4
5 int x,y;
6 float c,tm,td,ftime,fric;
7 float[] c_tx(64),c_ty(64),c_x(64),c_y(64),c_z(64),c_vx(64),c_vy(64),c_vz(64),c_rx(64),c_ry(64);
8 const float dx = 0.125;
9 const float dy = 0.125;
10
11 void Init()
12 {
13         reset();
14 }
15
16 void makenew(int n)
17 {
18    c_tx[n]=(n%8)/8.0;
19    c_ty[n]=(n-(n%8))/64.0;
20    c_x[n] = (c_tx[n]-0.5)*2+dx;
21    c_y[n] = (c_ty[n]-0.5)*2+dy;
22    c_z[n] = 0;
23    c_vx[n] = (c_x[n]+Rand()-0.5);
24    c_vy[n] = (c_y[n]+Rand());
25    c_vz[n] = (1.0+Rand());   
26    c_rx[n] = (1.0+Rand())*160;
27    c_ry[n] = (1.0+Rand())*160;
28 }
29
30 void drawcube(int n)
31 {
32    gfxBegin(PRIM_QUADLIST);
33    // FRONT FACE
34    gfxTexCoord(c_tx[n],c_ty[n]);
35    gfxVertex(-1,-1,-1);
36    gfxTexCoord(c_tx[n]+dx,1-(c_ty[n]));
37    gfxVertex(1,-1,-1);
38    gfxTexCoord(c_tx[n]+dx,1-(c_ty[n]+dy));
39    gfxVertex(1,1,-1);
40    gfxTexCoord(c_tx[n],1-(c_ty[n]+dy));
41    gfxVertex(-1,1,-1);
42    // BACK
43    gfxTexCoord(c_tx[n],1-(c_ty[n]));
44    gfxVertex(-1,-1,1);
45    gfxTexCoord(c_tx[n]+dx,1-(c_ty[n]));
46    gfxVertex(1,-1,1);
47    gfxTexCoord(c_tx[n]+dx,1-(c_ty[n]+dy));
48    gfxVertex(1,1,1);
49    gfxTexCoord(c_tx[n],1-(c_ty[n]+dy));
50    gfxVertex(-1,1,1);
51    // LEFT
52    gfxTexCoord(c_tx[n],1-(c_ty[n]));
53    gfxVertex(-1,-1,-1);
54    gfxTexCoord(c_tx[n]+dx,1-(c_ty[n]));
55    gfxVertex(-1,-1,1);
56    gfxTexCoord(c_tx[n]+dx,1-(c_ty[n]+dy));
57    gfxVertex(-1,1,1);
58    gfxTexCoord(c_tx[n],1-(c_ty[n]+dy));
59    gfxVertex(-1,1,-1);
60    // RIGHT
61    gfxTexCoord(c_tx[n],1-(c_ty[n]));
62    gfxVertex(1,-1,-1);
63    gfxTexCoord(c_tx[n]+dx,1-(c_ty[n]));
64    gfxVertex(1,-1,1);
65    gfxTexCoord(c_tx[n]+dx,1-(c_ty[n]+dy));
66    gfxVertex(1,1,1);
67    gfxTexCoord(c_tx[n],1-(c_ty[n]+dy));
68    gfxVertex(1,1,-1);
69    // UP
70    gfxTexCoord(c_tx[n],1-(c_ty[n]));
71    gfxVertex(1,-1,-1);
72    gfxTexCoord(c_tx[n]+dx,1-(c_ty[n]));
73    gfxVertex(1,-1,1);
74    gfxTexCoord(c_tx[n]+dx,1-(c_ty[n]+dy));
75    gfxVertex(-1,-1,1);
76    gfxTexCoord(c_tx[n],1-(c_ty[n]+dy));
77    gfxVertex(-1,-1,-1);
78    // DOWN
79    gfxTexCoord(c_tx[n],1-(c_ty[n]));
80    gfxVertex(1,1,-1);
81    gfxTexCoord(c_tx[n]+dx,1-(c_ty[n]));
82    gfxVertex(1,1,1);
83    gfxTexCoord(c_tx[n]+dx,1-(c_ty[n]+dy));
84    gfxVertex(-1,1,1);
85    gfxTexCoord(c_tx[n],1-(c_ty[n]+dy));
86    gfxVertex(-1,1,-1);
87
88    gfxEnd();
89 }
90
91 void reset()
92 {
93    for (x=0;x<64;x=x+1)
94    {
95       makenew(x);
96    }
97    tm = 0;
98    ftime = 0;
99 }
100
101 void Render()
102 {
103         gfxPushMatrix();
104         gfxTranslate(0, 0, 2.414);
105         gfxSetAspect(0);
106         gfxSetTexture(TEXTURE_NEXTPRESET);
107         gfxColour(1, 1, 1, 1);
108         gfxTexRect(-1, 1, 1, -1);
109         gfxPopMatrix();
110         gfxSetAspect(1);
111         gfxSetTexture(TEXTURE_CURRPRESET);
112
113
114         if (ftime<0.1)
115         td = TIMEPASS*(ftime*10);
116         else
117         td = TIMEPASS;
118         tm = tm+td;
119
120         ftime = ftime + (TIMEPASS*0.225);
121         if (ftime>0.6)
122         {
123                 ftime=1;
124                 FINISHED = true;
125                 return;
126         }
127
128         gfxPushMatrix();
129
130         gfxSetAspect(0);
131         gfxScale(-1,1,1);
132         gfxTranslate(0,0,2.414);
133         gfxTranslate(0,0,-dx);
134         gfxRotate(180,0,1,0);
135
136         fric = Pow(0.75,td);
137
138         for (x=0;x<64;x=x+1)
139         {
140         c_vy[x] = c_vy[x] - (td*2);
141         c_x[x] = c_x[x] + (td*c_vx[x]);
142         c_y[x] = c_y[x] + (td*c_vy[x]);
143         c_z[x] = c_z[x] + (td*c_vz[x]);
144         c_vx[x] = c_vx[x]*fric;
145         c_vy[x] = c_vy[x]*fric;
146         c_vz[x] = c_vz[x]*fric;
147
148         gfxPushMatrix();
149         gfxTranslate(c_x[x],c_y[x],c_z[x]);
150         gfxRotate(c_rx[x]*tm,1,0,0);
151         gfxRotate(c_ry[x]*tm,0,1,0);
152         gfxScale(dx,dx,dx);
153         drawcube(x);
154
155         gfxPopMatrix();
156
157         }
158
159         gfxPopMatrix();
160 }