aboutsummaryrefslogtreecommitdiff
path: root/addons/visualization.vortex/resources/Presets/Sphere.tra
blob: ef0df6489d0b593a236b7398b79fcdc7847e78c5 (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
// Sphere.tra
// Author - MrC
// Based on FadeSphere.r4 by Gordon Williams

const int stripx = 32;
const int stripy = 16;

int x,y;
float dx,da,db,sa,sb,a,b,mytime;

void Init()
{   
}

void Render()
{
	mytime = mytime + (TIMEPASS * 0.25);
	FINISHED = (mytime>1);

	gfxSetTexture(TEXTURE_NEXTPRESET);
	gfxSetAspect(0);
	gfxTranslate(0,0,2.414);
	gfxColour(1, 1, 1, 1);
	gfxTexRect(-1, 1, 1, -1);
	gfxTranslate(0,0,-2.414);

	a = mytime*2;
	if (a>1.0) a=1.0;
	a = (1.0-Cos(a*3.14159))/2.0;

	gfxSetAspect(a);

	b = (mytime*2)-1.0;
	if (b<0.0) b=0.0;
	b = (1.0-Cos(b*3.14159))/2.0;

	gfxTranslate(b*6,0,2.414+(a*1.5));

	gfxRotate(mytime*720,1,1,1);   

	gfxSetTexture(TEXTURE_CURRPRESET);

	gfxColour(1,1,1,1);
	for (y=0;y<stripy;y=y+1)
	{
		da = (1.0*y)/stripy;
		db = (1.0*(y+1))/stripy;
		sa = Sin(da*3.14159);
		sb = Sin(db*3.14159);
		da = -Cos(da*3.14159);
		db = -Cos(db*3.14159);
		gfxBegin(PRIM_QUADSTRIP);
		for (x=0;x<=stripx;x=x+1)
		{
			dx = (1.0*x)/stripx;
			gfxTexCoord(dx,(da*-0.5)+0.5);
			gfxVertex(((dx*2.0)-1.0)*(1.0-a)+(Cos(3.14159*2.0*dx)*a*sa),da,(Sin(3.14159*2.0*dx)*a*sa));
			gfxTexCoord(dx,(db*-0.5)+0.5);
			gfxVertex(((dx*2.0)-1.0)*(1.0-a)+(Cos(3.14159*2.0*dx)*a*sb),db,(Sin(3.14159*2.0*dx)*a*sb));
		}
		gfxEnd();
	}

}