ccdemos/realtime.cc
author Radek Brich <radek.brich@devl.cz>
Tue, 26 Jul 2016 17:41:36 +0200
branchpyrit
changeset 103 3b3257a410fe
parent 100 c005054bf4c1
permissions -rw-r--r--
Updated to compile: - KdTree+Octree: max_depth changed to static const (this should be configured at compile time) - wget tool replaced by curl, which is now more widespread - added CMakeLists (to eventually replace SCons) - various fixes

#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;
}