/*
   frames.c - Copyright but freely distributable as part of the ISL package
   (c) 1994 by Grizzly Bear Labs.  This is a small example of how to generate
   an ISL stage using a c program - look at it and learn, but don't bother
   generating the frames because they are boring!  :-)
*/

#include <stdio.h>

#define INC 16
#define MAX ((INC*INC*2)-1)
#define RATIO (169.0 / (MAX * MAX))

main()
{
	int frames = 1, t, cnt = -1, toggle = 0;
	float pos;

	printf("STAGE\nMAXFRAMES %d LOOP 0\n\n", MAX + 1);

	printf("CAMERA \"CAMERA\" LAYER 0\n");
	printf("POSITION FRAMES 1 1 XYZ 0. -600. -100. VELOCITY 1. 1. SPLINE\n");
	printf("ALIGN FRAMES 1 1 XYZ 0. 0. 0. VELOCITY 1. 1.\n");
	printf("SIZE FRAMES 1 1 XYZ 320. 640. 233.333333 VELOCITY 1. 1.\n\n");

	printf("GLOBALS \"GLOBALS\" LAYER 0\n");
	printf("ACTOR FRAMES 1 1 BRUSH \"\" 0 BACKDROP \"\" 0 ");
	printf("AMBIENT RGB 0. 0. 0. HORIZON RGB 0. 255. 255. ");
	printf("+ZENITH RGB 255. 0. 255. -ZENITH RGB 255. 0. 255. ");
	printf("FOG BTL 0. 0. 0. FOG RGB 0. 0. 0. ");
	printf("STARFIELD 0. TRANSITION 0\n\n");

	printf("LIGHT \"LIGHTSOURCE\" LAYER 0\n");
	printf("ACTOR FRAMES 1 %d POINT SHADOW ", MAX + 1);
	printf("RGB 512. 512. 512. TRANSITION 0\n");
	printf("POSITION FRAMES 1 1 XYZ 102. -158.000473 102.666656 VELOCITY 1. 1. SPLINE\n");
	printf("ALIGN FRAMES 1 1 XYZ 0. 0. 0. VELOCITY 1. 1.\n");
	printf("SIZE FRAMES 1 1 XYZ 32. 32. 32. VELOCITY 1. 1.\n\n");

	printf("OBJECT \"GROUND\" LAYER 0\n");
	printf("ACTOR FRAMES 1 %d NAME \"Bounce.imp/objects/ground\" ", MAX + 1);
	printf("STATE \"\" CYCLE 0. 0. VELOCITY 1. 0.\n");
	printf("POSITION FRAMES 1 1 XYZ 0. 0. -201.000320 VELOCITY 1. 1. SPLINE\n");
	printf("ALIGN FRAMES 1 1 XYZ 0. 0. 0. VELOCITY 1. 1.\n");
	printf("SIZE FRAMES 1 1 XYZ 320. 200. 1. VELOCITY 1. 1.\n\n");

	printf("OBJECT \"BALL\" LAYER 0\n");
	printf("ACTOR FRAMES 1 %d NAME \"Bounce.imp/objects/ball\" ", MAX + 1);
	printf("STATE \"\" CYCLE 0. 0. VELOCITY 1. 0.\n");
	for (t = 1; t < MAX; t++) {
		cnt++;
		if (cnt == INC) {
			toggle = toggle ? 0 : 1;
			cnt = 0;
		}
		if (toggle)
			continue;
		pos = ((float) (t * t)) * RATIO;
		printf("POSITION FRAMES %d %d XYZ 0. 0. -%.6f VELOCITY 1. 1. SPLINE\n",
			frames, frames, pos);
		frames++;
	}

	for (t = MAX; t > 0; t--) {
		cnt++;
		if (cnt == INC) {
			toggle = toggle ? 0 : 1;
			cnt = 0;
		}
		if (toggle)
			continue;
		pos = ((float) (t * t)) * RATIO;
		printf("POSITION FRAMES %d %d XYZ 0. 0. -%.6f VELOCITY 1. 1. SPLINE\n",
			frames, frames, pos);
		frames++;
	}
	printf("ALIGN FRAMES 1 1 XYZ 0. 0. 0. VELOCITY 1. 1.\n");
	printf("SIZE FRAMES 1 1 XYZ 32. 32. 32. VELOCITY 1. 1.\n\n");

}

