ccdemos/realtime.cc
author Radek Brich <radek.brich@devl.cz>
Fri, 04 Apr 2008 13:54:47 +0200
branchpyrit
changeset 59 64e456ab823d
parent 40 929aad02c5f2
child 72 7c3f38dff082
permissions -rw-r--r--
add color support to lwo reader python binding for Camera
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40
929aad02c5f2 Makefile: added help and distclean target, plus small fixes
Radek Brich <radek.brich@devl.cz>
parents: 39
diff changeset
     1
#include <stdlib.h>
929aad02c5f2 Makefile: added help and distclean target, plus small fixes
Radek Brich <radek.brich@devl.cz>
parents: 39
diff changeset
     2
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
#include "raytracer.h"
39
7079dcc3bd74 ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
     4
#include "octree.h"
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
39
7079dcc3bd74 ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
     6
#include "common_sdl.h"
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
40
929aad02c5f2 Makefile: added help and distclean target, plus small fixes
Radek Brich <radek.brich@devl.cz>
parents: 39
diff changeset
     8
int main(int argc, char **argv)
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
{
39
7079dcc3bd74 ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    10
	Raytracer rt;
7079dcc3bd74 ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    11
	Octree top;
7079dcc3bd74 ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    12
	Camera cam;
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
22
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
    14
	rt.setMaxDepth(3);
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
	rt.setTop(&top);
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
	Light light1(Vector3(2.0, -5.0, -5.0), Colour(0.7, 0.3, 0.6));
21
79b516a3803d naive color driven sub-sampling
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    18
	light1.castShadows(false);
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
	rt.addlight(&light1);
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
	Light light2(Vector3(-2.0, 10.0, 2.0), Colour(0.4, 0.6, 0.3));
21
79b516a3803d naive color driven sub-sampling
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    22
	light2.castShadows(false);
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
	rt.addlight(&light2);
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    25
	Material mat_sph(Colour(1.0, 1.0, 1.0));
21
79b516a3803d naive color driven sub-sampling
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    26
	for (int y=0; y<10; y++)
79b516a3803d naive color driven sub-sampling
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    27
		for (int x=0; x<10; x++)
40
929aad02c5f2 Makefile: added help and distclean target, plus small fixes
Radek Brich <radek.brich@devl.cz>
parents: 39
diff changeset
    28
			rt.addshape(new Sphere(Vector3(x*2-10, (Float)rand()/RAND_MAX*5.0, y*2-10), 0.45, &mat_sph));
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    30
	rt.setCamera(&cam);
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    31
	cam.setEye(Vector3(0,0,10));
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    32
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    33
	top.optimize();
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    34
39
7079dcc3bd74 ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    35
	loop_sdl(rt, cam);
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    36
}