aboutsummaryrefslogtreecommitdiff
path: root/addons/visualization.vortex/resources/Presets/CubeRain.vtx
blob: 5ddbae8e55c56026c824aa8c4c3b3cb07fa524cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// CubeRain.vtx
// Author - MrC
// Based on CubeRain.r4 By Gordon Williams
int x,y;
float c,tm,tn,td;
float[] c_x(256),c_y(256),c_z(256),c_vz(256),c_rx(256),c_ry(256),c_sx(256),c_sy(256),c_sz(256);

float counter;
Texture	envTexture;

void MakeNew(int n)
{
   c_x[n]=c_y[n]=0;
   while (Mag(c_x[n],c_y[n])<1)
   {
      c_x[n] = (Rand()*8.0)-4.0;
      c_y[n] = (Rand()*8.0)-4.0;
   }

   c_z[n] = 10;
   c_vz[n] = (1.0+Rand())*4;
   c_rx[n] = (1.0+Rand())*80;
   c_ry[n] = (1.0+Rand())*80;
   c_sx[n] = (0.5+Rand())*0.15;
   c_sy[n] = (0.5+Rand())*0.15;
   c_sz[n] = (0.5+Rand())*0.15;
}

void Init()
{
	envTexture.LoadTexture("env2.jpg");
	counter = 0;
	
	for (x=0;x<256;x=x+1)
	{
      MakeNew(x);
      c_z[x] = Rand()*10;
	}
	tm = tn = 0;
}

void Render()
{
	td = ((TREBLE+1.0f)*TIMEPASS);
	tm = tm + td;
	tn = tn + ((BASS+1.5)*TIMEPASS*2);

	gfxTranslate(Cos(tn * 1.23f) * 0.5f, Sin(tn) * 0.5f, 0.0f);
	gfxRotate(Cos(tn*0.6734f)*20.0f, 1.0f, 0.0f, 0.0f);
	gfxRotate(Sin(tn*0.2143f)*20.0f, 0.0f, 1.0f, 0.0f);

	gfxSetEnvTexture(envTexture);

	for (x=0;x<256;x=x+1)
	{
		c_z[x] = c_z[x] - (td*c_vz[x]);
		if (c_z[x]<0)
		{
			MakeNew(x);
		}
		c = Cos(c_z[x]*0.05*3.1416);
		gfxColour(c,c,c,1);
		gfxPushMatrix();
		gfxTranslate(c_x[x],c_y[x],c_z[x]);
		gfxRotate(c_rx[x]*tm, 1, 0, 0);
		gfxRotate(c_ry[x]*tm, 0, 1, 0);
		gfxCube(-c_sx[x],-c_sy[x],-c_sz[x],c_sx[x],c_sy[x],c_sz[x]);
		gfxPopMatrix();
	}
}