ccdemos/realtime.cc
author Radek Brich <radek.brich@devl.cz>
Fri, 14 Dec 2007 16:51:22 +0100
branchpyrit
changeset 39 7079dcc3bd74
parent 37 5f954c0d34fc
child 40 929aad02c5f2
permissions -rw-r--r--
ccdemos: put the common code to header files, common_ply.h and common_sdl.h move all ccdemos on octree and make them all realtime (-i argument)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#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
     2
#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
     3
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 "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
     5
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
int main()
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
{
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
     8
	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
     9
	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
    10
	Camera cam;
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
22
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
    12
	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
    13
	rt.setTop(&top);
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
	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
    16
	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
    17
	rt.addlight(&light1);
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
	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
    20
	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
    21
	rt.addlight(&light2);
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
	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
    24
	for (int y=0; y<10; y++)
79b516a3803d naive color driven sub-sampling
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    25
		for (int x=0; x<10; x++)
22
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
    26
			rt.addshape(new Sphere(Vector3(x*2-10, (Float)random()/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
    27
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    28
	rt.setCamera(&cam);
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
	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
    30
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    31
	top.optimize();
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    32
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
    33
	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
    34
}