ccdemos/realtime_dragon.cc
author Radek Brich <radek.brich@devl.cz>
Tue, 06 May 2008 09:39:58 +0200
branchpyrit
changeset 93 96d65f841791
parent 92 9af5c039b678
child 100 c005054bf4c1
permissions -rw-r--r--
more build script tuning make all float constants single precision solve many warnings from msvc and gcc with various -W... flags add common.cc file for dbgmsg() function witch apparently cannot be inlined fix python module building with msvc, add manifest file handling remove forgotten RenderrowData class add stanford models download script for windows (.bat)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#include "raytracer.h"
71
4fedf7290929 simplify kd-tree building, it's also much faster now
Radek Brich <radek.brich@devl.cz>
parents: 69
diff changeset
     2
#include "kdtree.h"
80
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
     3
#include "serialize.h"
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
39
7079dcc3bd74 ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents: 38
diff changeset
     5
#include "common_sdl.h"
7079dcc3bd74 ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents: 38
diff changeset
     6
#include "common_ply.h"
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
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)
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
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: 38
diff changeset
    10
	Raytracer rt;
71
4fedf7290929 simplify kd-tree building, it's also much faster now
Radek Brich <radek.brich@devl.cz>
parents: 69
diff changeset
    11
	KdTree top;
39
7079dcc3bd74 ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents: 38
diff changeset
    12
	Camera cam;
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
38
5d043eeb09d9 realtime_dragon demo: now fullsize model + octree
Radek Brich <radek.brich@devl.cz>
parents: 36
diff changeset
    14
	rt.setMaxDepth(0);
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
	rt.setTop(&top);
80
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    16
	rt.setCamera(&cam);
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
    17
	cam.setEye(Vector(0,0,10));
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
    19
	Light light1(Vector(-5.0, 2.0, 8.0), Colour(0.9, 0.3, 0.6));
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
	light1.castShadows(false);
72
7c3f38dff082 kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents: 71
diff changeset
    21
	rt.addLight(&light1);
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
    23
	//Light light2(Vector(-2.0, 10.0, 2.0), Colour(0.4, 0.6, 0.3));
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
	//light2.castShadows(false);
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    25
	//rt.addlight(&light2);
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    26
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    27
	Material mat(Colour(0.9, 0.9, 0.9));
69
303583d2fb97 move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents: 62
diff changeset
    28
	mat.setSmooth(true);
80
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    29
	LinearColourMap cmap(Colour(0.5, 0.0, 0.0), Colour(1.0, 1.0, 0.5));
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    30
	//LinearColourMap cmap(Colour(1.0, 0.2, 0.0), Colour(0.3, 0.9, 0.2));
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    31
	mat.setTexture(new CloudTexture(10, &cmap));
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    32
80
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    33
	ifstream fin("realtime_dragon.kdtreedump");
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    34
	if (!fin)
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    35
	{
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    36
		load_ply(rt, "../models/ply/dragon/dragon_vrip.ply",
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
    37
			&mat, Vector(-29,29,-29), Vector(0,-3.6,0));
80
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    38
		top.optimize();
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    39
	}
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    40
	else
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    41
		top.load(fin, &mat);
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    42
80
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    43
	for (int i = 1; i < argc; i++)
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    44
	{
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    45
		if (strcmp(argv[1], "-dump") == 0)
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    46
		{
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    47
			resetSerializer();
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    48
			ofstream fout("realtime_dragon.kdtreedump");
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    49
			fout << top << endl;
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    50
			fout.close();
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    51
		}
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    52
80
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    53
		if (strcmp(argv[1], "-buildonly") == 0)
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    54
			return 0;
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 72
diff changeset
    55
	}
71
4fedf7290929 simplify kd-tree building, it's also much faster now
Radek Brich <radek.brich@devl.cz>
parents: 69
diff changeset
    56
39
7079dcc3bd74 ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents: 38
diff changeset
    57
	loop_sdl(rt, cam);
92
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
    58
	
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
    59
	return 0;
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    60
}