aboutsummaryrefslogtreecommitdiff
path: root/addons/visualization.vortex/resources/Presets/CubeGridStrobe.vtx
blob: 5180032c1789a5684c234dd51b966a091738b061 (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
71
72
73
74
// CubeGridStrobe.vtx
// Author - Pike
// Based on CubeGrid.r4 by Gordon Williams

int x,y,z;
float t,c;
float bt,bs;
float time;

const int XMAX = 3;
const int YMAX = 3;
const int ZMAX = 5;

Texture envTexture;
Texture envTexture1;

void Init()
{
   t = 0;
   bt = 0;
   bs = 0;
   time = 0;
   envTexture.LoadTexture("env2.jpg");
   envTexture1.LoadTexture("env3_darker.png");
}

void Render()
{
	bt = bt + (TIMEPASS*(MIDDLE+0.5f));
	bs = bs + (TIMEPASS*(TREBLE+0.5f));
	t = t + (TIMEPASS*2.5);
	while (t>1.0)
	{
		t=t-1.0;
	}

	time = time + TIMEPASS;

	gfxRotate(time*60.0f, 0.0f, 0.0f, 1.0f);
	gfxRotate(bt*53.0f, 1.0f, 0.0f, 1.0f);
	gfxRotate(bs*62.0f, 0.0f, 1.0f, 0.0f);

	if (TREBLE > 0.5)
		gfxSetEnvTexture(envTexture);
	else
		gfxSetEnvTexture(envTexture1);

	gfxTranslate(-XMAX*0.5f, -YMAX*0.5f, -3.0f+t);
	for (z=0;z<=ZMAX;z=z+1)
	{    
		c=1;
		if (z==0)
			c = t;
		if (z==ZMAX)
			c = 1.0f - t;
		gfxColour(c,c,c,1);
		for (y=0;y<=YMAX;y=y+1) 
		{
			for (x=0;x<=XMAX;x=x+1)
			{
				gfxCube(x-0.15f, y-0.15f, z-0.15f, x+0.15f, y+0.15f, z+0.15f);
				if (x<XMAX)
				{
					gfxCube(x+0.15f, y-0.05f, z-0.05f, x+0.85f, y+0.05f, z+0.05f);
				}
				if (y<YMAX)
				{
					gfxCube(x-0.05f, y+0.15f, z-0.05f, x+0.05f, y+0.85f, z+0.05f);
				}
				gfxCube(x-0.05f, y-0.05f, z+0.15f, x+0.05f, y+0.05f, z+0.85f);
			}
		}
	}
}