ccdemos/spheres_shadow.cc
branchpyrit
changeset 91 9d66d323c354
parent 88 f7edb3b90816
child 92 9af5c039b678
equal deleted inserted replaced
90:f6a72eb99631 91:9d66d323c354
     2 #include "octree.h"
     2 #include "octree.h"
     3 
     3 
     4 #include "common_sdl.h"
     4 #include "common_sdl.h"
     5 
     5 
     6 Camera cam;
     6 Camera cam;
     7 Light light(Vector3(-2.0, 10.0, -2.0), Colour(0.9, 0.9, 0.9));
     7 Light light(Vector(-2.0, 10.0, -2.0), Colour(0.9, 0.9, 0.9));
     8 
     8 
     9 Float lx, ly, lz, cf;
     9 Float lx, ly, lz, cf;
    10 
    10 
    11 void update_callback(Float*)
    11 void update_callback(Float*)
    12 {
    12 {
    65 	//light2.colour = Colour(0.7, 0.3, 0.6);
    65 	//light2.colour = Colour(0.7, 0.3, 0.6);
    66 	//rt.addLight(&light2);
    66 	//rt.addLight(&light2);
    67 
    67 
    68 	Material mat0a(Colour(0.7, 0.7, 0.7));
    68 	Material mat0a(Colour(0.7, 0.7, 0.7));
    69 	mat0a. setReflectivity(0.0);
    69 	mat0a. setReflectivity(0.0);
    70 	Box box(Vector3(-10.0, -1.2, -20.0), Vector3(10.0, -1.0, 0.0), &mat0a);
    70 	Box box(Vector(-10.0, -1.2, -20.0), Vector(10.0, -1.0, 0.0), &mat0a);
    71 	rt.addShape(&box);
    71 	rt.addShape(&box);
    72 
    72 
    73 	Material mat0b(Colour(0.1, 0.7, 0.8));
    73 	Material mat0b(Colour(0.1, 0.7, 0.8));
    74 	mat0b.setReflectivity(0.7);
    74 	mat0b.setReflectivity(0.7);
    75 	Box box2(Vector3(-10.0, -1.2, -20.0), Vector3(10.0, 10.0, -20.2), &mat0b);
    75 	Box box2(Vector(-10.0, -1.2, -20.0), Vector(10.0, 10.0, -20.2), &mat0b);
    76 	rt.addShape(&box2);
    76 	rt.addShape(&box2);
    77 
    77 
    78 	Material mat1(Colour(1.0, 0.0, 0.0));
    78 	Material mat1(Colour(1.0, 0.0, 0.0));
    79 	Sphere bigsphere(Vector3(3.0, 2.0, -7.0), 3.0, &mat1);
    79 	Sphere bigsphere(Vector(3.0, 2.0, -7.0), 3.0, &mat1);
    80 	rt.addShape(&bigsphere);
    80 	rt.addShape(&bigsphere);
    81 
    81 
    82 	Material mat2(Colour(0.0, 1.0, 0.0));
    82 	Material mat2(Colour(0.0, 1.0, 0.0));
    83 	Sphere smallsphere(Vector3(-5.5, 1.5, -8.0), 2.0, &mat2);
    83 	Sphere smallsphere(Vector(-5.5, 1.5, -8.0), 2.0, &mat2);
    84 	rt.addShape(&smallsphere);
    84 	rt.addShape(&smallsphere);
    85 
    85 
    86 	Material mat3(Colour(0.0, 0.0, 1.0));
    86 	Material mat3(Colour(0.0, 0.0, 1.0));
    87 	mat3.setReflectivity(0.1);
    87 	mat3.setReflectivity(0.1);
    88 	mat3.setTransmissivity(0.8, 1.5);
    88 	mat3.setTransmissivity(0.8, 1.5);
    89 	Sphere tinysphere(Vector3(-1.2, 0.0, -2.0), 0.7, &mat3);
    89 	Sphere tinysphere(Vector(-1.2, 0.0, -2.0), 0.7, &mat3);
    90 	rt.addShape(&tinysphere);
    90 	rt.addShape(&tinysphere);
    91 
    91 
    92 	top.optimize();
    92 	top.optimize();
    93 
    93 
    94 	cam.setEye(Vector3(-2.28908, 4.30992, 12.3051));
    94 	cam.setEye(Vector(-2.28908, 4.30992, 12.3051));
    95 	cam.p = Vector3(0.0988566, -0.139543, -0.985269);
    95 	cam.p = Vector(0.0988566, -0.139543, -0.985269);
    96 	cam.u = Vector3(-0.995004, 0, -0.0998334);
    96 	cam.u = Vector(-0.995004, 0, -0.0998334);
    97 	cam.v = Vector3(0.0139311, 0.990216, -0.138846);
    97 	cam.v = Vector(0.0139311, 0.990216, -0.138846);
    98 	rt.setCamera(&cam);
    98 	rt.setCamera(&cam);
    99 
    99 
   100 	w = 800;
   100 	w = 800;
   101 	h = 600;
   101 	h = 600;
   102 
   102