ccdemos/realtime.cc
author Radek Brich <radek.brich@devl.cz>
Sun, 31 May 2009 23:06:03 +0200
branchpyrit
changeset 100 c005054bf4c1
parent 93 96d65f841791
permissions -rw-r--r--
new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()

#include <stdlib.h>

#include "common_sdl.h"
#include "kdtree.h"

int main(int argc, char **argv)
{
	Raytracer rt;
	KdTree top;
	Camera cam;

	rt.setMaxDepth(2);
	rt.setTop(&top);

	Light light1(Vector(2.0f, -5.0f, -5.0f), Colour(0.2f, 0.3f, 0.8f));
	light1.castShadows(false);
	rt.addLight(&light1);

	Light light2(Vector(-2.0f, 10.0f, 2.0f), Colour(0.5f, 0.6f, 0.3f));
	light2.castShadows(false);
	rt.addLight(&light2);

	Material mat_sph(Colour(1.0f, 1.0f, 1.0f));
	mat_sph.setPhong(0.2f, 0.9f, 0.0f, 1.0f);
	mat_sph.setReflectivity(0.3f);
	for (int y=0; y<10; y++)
		for (int x=0; x<10; x++)
			rt.addShape(new Sphere(Vector((Float)x*2-10, (Float)rand()/RAND_MAX*5.0f, (Float)y*2-10), 0.45f, &mat_sph));

	rt.setCamera(&cam);
	cam.setEye(Vector(0,0,10));

	top.optimize();

	loop_sdl(rt, cam);

	return 0;
}