Exemple #1
0
void circle(float x, float y, float r, uint32_t color)
{
	olPushMatrix();
	olPushColor();
	olMultColor(color);
	olTranslate(x, y);
	olRotate((x+y)*123);
	/*olBegin(OL_BEZIERSTRIP);
	olVertex(0, r, color);
	int i;
	for (i=0; i<2; i++) {
		olVertex(CP*r, r, C_WHITE);
		olVertex(r, CP*r, C_WHITE);
		olVertex(r, 0, C_WHITE);
		olVertex(r, -CP*r, C_WHITE);
		olVertex(CP*r, -r, C_WHITE);
		olVertex(0, -r, C_WHITE);
		olVertex(-CP*r, -r, C_WHITE);
		olVertex(-r, -CP*r, C_WHITE);
		olVertex(-r, 0, C_WHITE);
		olVertex(-r, CP*r, C_WHITE);
		olVertex(-CP*r, r, C_WHITE);
		olVertex(0, r, C_WHITE);
	}*/
/*	olVertex(0, r, color);
	olVertex(0, r, color);
	olVertex(r*0.1, r, color);
	olVertex(r*0.1, r, color);*/

	float circum = 2 * M_PI * r;
	int segments = circum / (1/30.0);
	if (segments < 50)
		segments = 50;
	int i;
	olBegin(OL_POINTS);
	olVertex(r, 0);
	for (i=0; i<=(2*segments+10); i++) {
		float w = i * M_PI * 2.0 / segments;
		uint32_t c = C_WHITE;
		if (i > 2*segments)
			c = C_GREY((10-(i-segments)) * 28);
		else if (i < 3)
			c = C_GREY(i * 85);
		olVertex(r*cosf(w), r*sinf(w));
	}
	olEnd();
	olPopColor();
	olPopMatrix();
}
Exemple #2
0
void DoEuskal(void)
{
	IldaFile *ild;
	ild = olLoadIlda("euskal18.ild");

	params.off_speed = 2.0/20.0;
	params.start_wait = 8;
	params.end_wait = 1;
	params.render_flags |= RENDER_NOREORDER;
	olSetRenderParams(&params);

	include_dark_points = 0;
	int count = count_active_points(ild);
	float cur_draw = 0;

	olSetVertexShader(cutoff);

	while(1) {
		int obj;
		float w;

		points_left = cur_draw;
		olDrawIlda(ild);
		render();

		cur_draw += ftime * count / 5.0;

		if (cur_draw > count) {
			break;
		}
	}

	olSetVertexShader(NULL);

	float bright = 300.0f;

	while(1) {
		uint32_t col;
		if (bright > 255.0f)
			col = C_WHITE;
		else
			col = C_GREY((int)bright);
		olPushColor();
		olMultColor(col);
		olDrawIlda(ild);
		olPopColor();

		render();

		bright -= ftime * 40.0;
		if (bright < 0)
			break;
	}

}
Exemple #3
0
int draw(void)
{
	int i;
	int cnt = 0;
	for (i=0; i<NUM_BLIPS; i++) {
		struct blip *b = &blips[i];
		if (b->active) {
			float br = b->bright * b->phase * 255.0;
			br = br > 255 ? 255 : br;
			uint32_t col = C_GREY((int)br);
			circle(b->x, b->y, b->r, col);
			cnt++;
		}
	}
	return cnt;
}
Exemple #4
0
int trace(int *field, uint8_t *tmp, int thresh, int w, int h, int decimate)
{
	int x, y, cx, cy, px, py, i;
	int iters = 0;
	int objects = 0;

	int sx[OVERDRAW], sy[OVERDRAW];

	memset(tmp, 0, w*h);

	for (y=1; y<h-1; y++) {
		for (x=1; x<w-1;x++) {
			int idx = y*w+x;
			if (field[idx] > thresh && (!(field[idx-w] > thresh)
			                         || !(field[idx+w] > thresh)
			                         || !(field[idx-1] > thresh)
			                         || !(field[idx+1] > thresh))) {
				tmp[idx] = 1;
			}
		}
	}

	int total = h*w;
	int dir = 0;
	int minx = 0, miny = 0;
	int maxx = w-1, maxy = h-1;

	int div = 0;

	px = 0;
	py = 0;
	while (total--)
	{
		if (tmp[py*w+px]) {
			x = cx = px;
			y = cy = py;
			iters = 0;
			olBegin(OL_POINTS);
			while (1)
			{
				int idx = y*w+x;
				if(div==0) {
					if (iters < OVERDRAW) {
						sx[iters] = x;
						sy[iters] = y;
					}
					olVertex(x, y, C_WHITE);
					iters++;
				}
				div = (div+1)%decimate;
				tmp[idx] = 0;
				if (tmp[idx-1]) {
					x--;
				} else if (tmp[idx+1]) {
					x++;
				} else if (tmp[idx-w]) {
					y--;
				} else if (tmp[idx+w]) {
					y++;
				} else if (tmp[idx-w-1]) {
					y--; x--;
				} else if (tmp[idx-w+1]) {
					y--; x++;
				} else if (tmp[idx+w-1]) {
					y++; x--;
				} else if (tmp[idx+w+1]) {
					y++; x++;
				} else {
					break;
				}

			}
			if (iters) {
				objects++;
				if (ABS(cx-x) <= 1 && ABS(cy-y) <= 1) {
					if (iters > OVERDRAW)
						iters = OVERDRAW;
					for (i=0; i<iters; i++)
						olVertex(sx[i], sy[i], C_GREY((int)(255.0 * (OVERDRAW - 1 - i) / (float)OVERDRAW)));
				}
			}
			olEnd();
		}
		switch(dir) {
			case 0:
				px++;
				if (px > maxx) {
					px--; py++; maxx--; dir++;
				}
				break;
			case 1:
				py++;
				if (py > maxy) {
					py--; px--; maxy--; dir++;
				}
				break;
			case 2:
				px--;
				if (px < minx) {
					px++; py--; minx++; dir++;
				}
				break;
			case 3:
				py--;
				if (py < miny) {
					py++; px++; miny++; dir=0;
				}
				break;
		}
	}
	return objects;
}
Exemple #5
0
void DoTunnel(float limit)
{
	params.on_speed = 2.0/100.0;
	params.start_dwell = 2;
	params.curve_dwell = 0;
	params.corner_dwell = 2;
	params.curve_angle = cosf(30.0*(M_PI/180.0)); // 30 deg
	params.end_dwell = 2;
	params.snap = 1/100000.0;
	params.flatness = 0.000005;
	params.start_wait = 6;
	params.off_speed = 2.0/30.0;
	params.end_wait = 3;
	params.render_flags &= ~RENDER_NOREORDER;
	olSetRenderParams(&params);

	float ctime = 0;

	int i,j;

	olLoadIdentity();

	float z = 0.0f;
	float rz = 0.0f;

	float dz=1.2;

	int id=0;

	while (audiotime < limit) {
		float left = (limit-audiotime)/AB;
		olResetColor();
		if (ctime < 2.0)
			olMultColor(C_GREY((int)(255*ctime/2)));
		else if (left < 2.0)
			olMultColor(C_GREY((int)(255*left/2)));

		olLoadIdentity3();
		olPerspective(45, 1, 1, 100);

		while(z > dz) {
			z -= dz;
			id++;
		}

		olScale3(0.6, 0.6, 1.0);
		olTranslate3(0, 0, 1.5);
		olTranslate3(0, 0, -z);
		tunnel_revxform(rz);

		for(i=0;i<10;i++) {
			if ((id+i) > 5) {
				olPushMatrix3();

				olTranslate3(0,0,dz*i);

				tunnel_xform(rz+dz*(i+id));
				olBegin(OL_LINESTRIP);

				for(j=0;j<11;j++) {
					float theta = j/5.0*M_PI;
					uint32_t c = C_RED;
					if(i==9) {
						c = C_RED_I((int)(255 * z/dz));
					}
					olVertex3(sinf(theta), cosf(theta), 0, c);
					//olVertex3(j/11.0,0,0,C_WHITE);
				}
				olEnd();

				olPopMatrix3();
			}
		}

		for(j=0;j<10;j++) {
			float theta = j/5.0*M_PI;
			olBegin(OL_LINESTRIP);
			for(i=0;i<9;i++) {
				if ((id+i) > 5) {
					olPushMatrix3();
					olTranslate3(0,0,dz*i);
					tunnel_xform(rz+dz*(i+id));
					olVertex3(sinf(theta), cosf(theta), 0,
							  C_GREEN_I((int)(255 * i/8.0)) | C_BLUE_I((int)(255 * (1-(i/8.0)))));
					olPopMatrix3();
				}
			}
			olEnd();
		}


		ctime += render();
		z += ftime*3.2;
		rz += ftime*3.2;

	}
}
Exemple #6
0
void DoTitle(float limit)
{
	IldaFile *ild;
	ild = olLoadIlda("lase_title.ild");

	include_dark_points = 1;

	int count = count_active_points(ild);
	float cur_draw = 0;
	float ctime = 0;

	olSetVertexShader(cutoff);

	params.render_flags |= RENDER_NOREORDER;
	olSetRenderParams(&params);

	while(1) {
		int obj;
		float w;

		points_left = cur_draw;
		olDrawIlda(ild);
		ctime += render();

		cur_draw += ftime * count / 3.0;

		if (cur_draw > count) {
			break;
		}
	}

	olSetVertexShader(NULL);

	while(AB*ctime < 8) {
		olDrawIlda(ild);
		ctime += render();
	}

	wipe_center = -1.0;
	wipe_w = 0.4;
	wipe_inv = 1;

	const char *s="A realtime laser demo";

	float s_x = -olGetStringWidth(font, 0.2, s) / 2;
	float s_y = -0.5;
	float s_h = 0.2;

	while(1) {
		olDrawIlda(ild);
		olSetPixelShader(hwipe);
		olDrawString(font, s_x, s_y, s_h, C_WHITE, s);
		olSetPixelShader(NULL);
		ctime += render();
		wipe_center += 1.7*ftime;

		if(wipe_center > 1.0f)
			break;
	}

	float bright = 300.0f;
	while(audiotime < limit) {
		uint32_t col;
		if (bright > 255.0f)
			col = C_WHITE;
		else
			col = C_GREY((int)bright);
		olPushColor();
		olMultColor(col);
		olDrawIlda(ild);
		olDrawString(font, s_x, s_y, s_h, C_WHITE, s);
		olPopColor();
		render();

		bright -= ftime * 130.0;
		if (bright < 0)
			bright = 0;
	}

}
Exemple #7
0
void render_cubes(float time)
{
	int i;

	OLRenderParams mpar;

	memcpy(&mpar, &params, sizeof(OLRenderParams));

	if (time > 32) {
		time += 1.0;
		mpar.on_speed = 0.022 + (1-usin(time, 2.0)) * 0.02;
		mpar.corner_dwell = 8*usin(time, 2.0);
		mpar.start_dwell = 2+3*usin(time, 2.0);
		mpar.start_wait = 3+5*usin(time, 2.0);
		mpar.end_dwell = 2+3*usin(time, 2.0);
		mpar.end_wait = 2*usin(time, 2.0);
		olSetRenderParams(&mpar);
		time -= 1.0;
	}
	printf("%f %d %d %d %d %d\n", mpar.on_speed, mpar.corner_dwell, mpar.start_dwell, mpar.start_wait, mpar.end_dwell, mpar.end_wait);

	olLoadIdentity3();
	olPerspective(60, 1, 1, 100);
	olTranslate3(0, 0, -2.1);

	for(i=0; i<3; i++) {
		if (i>0)
			olPushMatrix3();
		olScale3(0.6, 0.6, 0.6);
		if (i>0) {
			float tx = sinf(time + (i-1)*M_PI);
			float ty = cosf(time + (i-1)*M_PI);
			float tz = sinf(time + (i-1)*M_PI);
			float s = sinf(0.6*time);
			olTranslate3(tx*s,ty*s,tz*s);
			//olScale3(s,s,s);
			olScale3(0.3,0.3,0.3);
		}

		float mult;
		if (i==0)
			mult = 1;
		else if (i==1)
			mult = 1.5;
		else if (i==2)
			mult = -1.5;

		if (i==0)
			olMultColor(C_GREY(120));
		else
			olResetColor();



		olRotate3Z(mult*time * M_PI * 0.1 / 3.0);
		olRotate3Y(mult*time * M_PI * 0.8 / 3.0);
		olRotate3X(mult*time * M_PI * 0.73 / 3.0);

		olBegin(OL_LINESTRIP);
		olVertex3(-1, -1, -1, C_RED);
		olVertex3( 1, -1, -1, C_RED);
		olVertex3( 1,  1, -1, C_RED);
		olVertex3(-1,  1, -1, C_RED);
		olVertex3(-1, -1, -1, C_RED);
		olVertex3(-1, -1,  1, C_RED);
		olEnd();

		olBegin(OL_LINESTRIP);
		olVertex3( 1,  1,  1, C_GREEN);
		olVertex3(-1,  1,  1, C_GREEN);
		olVertex3(-1, -1,  1, C_GREEN);
		olVertex3( 1, -1,  1, C_GREEN);
		olVertex3( 1,  1,  1, C_GREEN);
		olVertex3( 1,  1, -1, C_GREEN);
		olEnd();

		olBegin(OL_LINESTRIP);
		olVertex3( 1, -1, -1, C_RED);
		olVertex3( 1, -1,  1, C_RED);
		olEnd();

		olBegin(OL_LINESTRIP);
		olVertex3(-1,  1,  1, C_GREEN);
		olVertex3(-1,  1, -1, C_GREEN);
		olEnd();

		/*olBegin(OL_BEZIERSTRIP);
		olVertex3(-1, 1, 0, C_WHITE);
		olVertex3(0, -1, 0, C_WHITE);
		olVertex3(0, -1, 0, C_WHITE);
		olVertex3(1, 1, 0, C_WHITE);
		olVertex3(-1, 0, 0, C_WHITE);
		olVertex3(-1, 0, 0, C_WHITE);
		olVertex3(1, -1, 0, C_WHITE);
		olVertex3(0, 1, 0, C_WHITE);
		olVertex3(0, 1, 0, C_WHITE);
		olVertex3(-1, -1, 0, C_WHITE);
		olVertex3(1, 0, 0, C_WHITE);
		olVertex3(1, 0, 0, C_WHITE);
		olVertex3(-1, 1, 0, C_WHITE);
		olEnd();*/
		if (i>0)
			olPopMatrix3();
	}
	olLoadIdentity3();
	olLoadIdentity();
	olSetRenderParams(&params);
	olResetColor();
}