ccdemos/spheres_shadow.cc
branchpyrit
changeset 72 7c3f38dff082
parent 60 a23b5089b9c3
child 81 9dbb9c8c115b
equal deleted inserted replaced
71:4fedf7290929 72:7c3f38dff082
    16 	if (ly != 0.0)
    16 	if (ly != 0.0)
    17 		light.pos.y += ly;
    17 		light.pos.y += ly;
    18 	if (lz != 0.0)
    18 	if (lz != 0.0)
    19 		light.pos.z += lz;
    19 		light.pos.z += lz;
    20 	if (cf != 0.0)
    20 	if (cf != 0.0)
    21 		cam.f += cf;
    21 		cam.F += cf;
    22 }
    22 }
    23 
    23 
    24 void key_callback(int key, int down)
    24 void key_callback(int key, int down)
    25 {
    25 {
    26 	switch (key)
    26 	switch (key)
    58 	Raytracer rt;
    58 	Raytracer rt;
    59 
    59 
    60 	Octree top;
    60 	Octree top;
    61 	rt.setTop(&top);
    61 	rt.setTop(&top);
    62 
    62 
    63 	rt.addlight(&light);
    63 	rt.addLight(&light);
    64 
    64 
    65 	//Light light2;
    65 	//Light light2;
    66 	//light2.colour = Colour(0.7, 0.3, 0.6);
    66 	//light2.colour = Colour(0.7, 0.3, 0.6);
    67 	//rt.addlight(&light2);
    67 	//rt.addLight(&light2);
    68 
    68 
    69 	Material mat0a(Colour(0.7, 0.7, 0.7));
    69 	Material mat0a(Colour(0.7, 0.7, 0.7));
    70 	mat0a. setReflectivity(0.0);
    70 	mat0a. setReflectivity(0.0);
    71 	Box box(Vector3(-10.0, -1.2, -20.0), Vector3(10.0, -1.0, 0.0), &mat0a);
    71 	Box box(Vector3(-10.0, -1.2, -20.0), Vector3(10.0, -1.0, 0.0), &mat0a);
    72 	rt.addshape(&box);
    72 	rt.addShape(&box);
    73 
    73 
    74 	Material mat0b(Colour(0.1, 0.7, 0.8));
    74 	Material mat0b(Colour(0.1, 0.7, 0.8));
    75 	mat0b.setReflectivity(0.7);
    75 	mat0b.setReflectivity(0.7);
    76 	Box box2(Vector3(-10.0, -1.2, -20.0), Vector3(10.0, 10.0, -20.2), &mat0b);
    76 	Box box2(Vector3(-10.0, -1.2, -20.0), Vector3(10.0, 10.0, -20.2), &mat0b);
    77 	rt.addshape(&box2);
    77 	rt.addShape(&box2);
    78 
    78 
    79 	Material mat1(Colour(1.0, 0.0, 0.0));
    79 	Material mat1(Colour(1.0, 0.0, 0.0));
    80 	Sphere bigsphere(Vector3(3.0, 2.0, -7.0), 3.0, &mat1);
    80 	Sphere bigsphere(Vector3(3.0, 2.0, -7.0), 3.0, &mat1);
    81 	rt.addshape(&bigsphere);
    81 	rt.addShape(&bigsphere);
    82 
    82 
    83 	Material mat2(Colour(0.0, 1.0, 0.0));
    83 	Material mat2(Colour(0.0, 1.0, 0.0));
    84 	Sphere smallsphere(Vector3(-5.5, 1.5, -8.0), 2.0, &mat2);
    84 	Sphere smallsphere(Vector3(-5.5, 1.5, -8.0), 2.0, &mat2);
    85 	rt.addshape(&smallsphere);
    85 	rt.addShape(&smallsphere);
    86 
    86 
    87 	Material mat3(Colour(0.0, 0.0, 1.0));
    87 	Material mat3(Colour(0.0, 0.0, 1.0));
    88 	mat3.setReflectivity(0.1);
    88 	mat3.setReflectivity(0.1);
    89 	mat3.setTransmissivity(0.8, 1.5);
    89 	mat3.setTransmissivity(0.8, 1.5);
    90 	Sphere tinysphere(Vector3(-1.2, 0.0, -2.0), 0.7, &mat3);
    90 	Sphere tinysphere(Vector3(-1.2, 0.0, -2.0), 0.7, &mat3);
    91 	rt.addshape(&tinysphere);
    91 	rt.addShape(&tinysphere);
    92 
    92 
    93 	top.optimize();
    93 	top.optimize();
    94 
    94 
    95 	cam.setEye(Vector3(-2.28908, 4.30992, 12.3051));
    95 	cam.setEye(Vector3(-2.28908, 4.30992, 12.3051));
    96 	cam.p = Vector3(0.0988566, -0.139543, -0.985269);
    96 	cam.p = Vector3(0.0988566, -0.139543, -0.985269);