ccdemos/spheres_shadow.cc
branchpyrit
changeset 19 4e0955fca797
parent 16 20bceb605f48
child 20 f22952603f29
equal deleted inserted replaced
18:25b7c445cf61 19:4e0955fca797
     4 int main()
     4 int main()
     5 {
     5 {
     6 	Raytracer rt;
     6 	Raytracer rt;
     7 	rt.setThreads(1);
     7 	rt.setThreads(1);
     8 
     8 
     9 	Light light1(Vector3(0.0, 5.0, 5.0), Colour(0.7, 0.3, 0.6));
     9 	Light light1(Vector3(0.0, 5.0, -5.0), Colour(0.7, 0.3, 0.6));
    10 	rt.addlight(&light1);
    10 	rt.addlight(&light1);
    11 
    11 
    12 	Light light2(Vector3(-2.0, 10.0, 2.0), Colour(0.4, 0.6, 0.3));
    12 	Light light2(Vector3(-2.0, 10.0, -2.0), Colour(0.4, 0.6, 0.3));
    13 	rt.addlight(&light2);
    13 	rt.addlight(&light2);
    14 
    14 
    15 	Material mat0(Colour(0.7, 0.7, 0.7));
    15 	Material mat0(Colour(0.7, 0.7, 0.7));
    16 
    16 
    17 	Box box(Vector3(-20.0, -1.2, -20.0), Vector3(20.0, -1.0, 20.0), &mat0);
    17 	Box box(Vector3(-20.0, -1.2, -20.0), Vector3(20.0, -1.0, 20.0), &mat0);
    18 	rt.addshape(&box);
    18 	rt.addshape(&box);
    19 
    19 
    20 	Material mat1(Colour(1.0, 0.0, 0.0));
    20 	Material mat1(Colour(1.0, 0.0, 0.0));
    21 	Sphere bigsphere(Vector3(3.0, 2.0, 7.0), 3.0, &mat1);
    21 	Sphere bigsphere(Vector3(3.0, 2.0, -7.0), 3.0, &mat1);
    22 	rt.addshape(&bigsphere);
    22 	rt.addshape(&bigsphere);
    23 
    23 
    24 	Material mat2(Colour(0.0, 1.0, 0.0));
    24 	Material mat2(Colour(0.0, 1.0, 0.0));
    25 	Sphere smallsphere(Vector3(-5.5, 1.5, 8.0), 2.0, &mat2);
    25 	Sphere smallsphere(Vector3(-5.5, 1.5, -8.0), 2.0, &mat2);
    26 	rt.addshape(&smallsphere);
    26 	rt.addshape(&smallsphere);
    27 
    27 
    28 	Material mat3(Colour(0.0, 0.0, 1.0));
    28 	Material mat3(Colour(0.0, 0.0, 1.0));
    29 	Sphere tinysphere(Vector3(-1.2, 0.0, 2.0), 0.5, &mat3);
    29 	Sphere tinysphere(Vector3(-1.2, 0.0, -2.0), 0.5, &mat3);
    30 	rt.addshape(&tinysphere);
    30 	rt.addshape(&tinysphere);
       
    31 
       
    32 	Camera cam;
       
    33 	cam.setEye(Vector3(0,0,15));
       
    34 	rt.setCamera(&cam);
    31 
    35 
    32 	int w = 800;
    36 	int w = 800;
    33 	int h = 600;
    37 	int h = 600;
    34 	float *fdata = rt.render(w, h);
    38 	float *fdata = rt.render(w, h);
    35 
    39