ccdemos/realtime.cc
author Radek Brich <radek.brich@devl.cz>
Tue, 29 Apr 2008 23:31:08 +0200
branchpyrit
changeset 90 f6a72eb99631
parent 74 09aedbf5f95f
child 91 9d66d323c354
permissions -rw-r--r--
rename Python module from 'raytracer' to 'pyrit' improve Python binding: - new objects: Container, Octree, KdTree, Shape, Pixmap, Sampler, DefaultSampler - all shapes are now subclasses of Shape - clean, remove redundant Getattr's - Raytracer render method now just wraps C++ method without doing any additional work adjust all demos for changes in Python binding, remove PIL dependency add demo_PIL.py as a example of pyrit + PIL usage render_nff.py now either loads file given as a argument or reads input from stdin otherwise fix bug in pixmap float to char conversion

#include <stdlib.h>

#include "raytracer.h"
#include "kdtree.h"

#include "common_sdl.h"

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

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

	Light light1(Vector3(2.0, -5.0, -5.0), Colour(0.7, 0.3, 0.6));
	light1.castShadows(false);
	rt.addLight(&light1);

	Light light2(Vector3(-2.0, 10.0, 2.0), Colour(0.4, 0.6, 0.3));
	light2.castShadows(false);
	rt.addLight(&light2);

	Material mat_sph(Colour(1.0, 1.0, 1.0));
	for (int y=0; y<10; y++)
		for (int x=0; x<10; x++)
			rt.addShape(new Sphere(Vector3(x*2-10, (Float)rand()/RAND_MAX*5.0, y*2-10), 0.45, &mat_sph));

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

	top.optimize();

	loop_sdl(rt, cam);
}