demos/spheres_glass.py
branchpyrit
changeset 96 9eb71e76c7fd
parent 95 ca7d4c665531
equal deleted inserted replaced
95:ca7d4c665531 96:9eb71e76c7fd
    21 box = Box(L=(-10.0, 0.0, 50.0), H=(30.0, 1.0, -1.0), material=mat0)
    21 box = Box(L=(-10.0, 0.0, 50.0), H=(30.0, 1.0, -1.0), material=mat0)
    22 rt.addShape(box)
    22 rt.addShape(box)
    23 
    23 
    24 mat1 = Material(colour=(1.0, 0.2, 0.1))
    24 mat1 = Material(colour=(1.0, 0.2, 0.1))
    25 mat1.setReflectivity(0.7)
    25 mat1.setReflectivity(0.7)
    26 bigsphere = Sphere(centre=(12.0, 4.0, 6.0), radius=2.5, material=mat1)
    26 bigsphere = Sphere(center=(12.0, 4.0, 6.0), radius=2.5, material=mat1)
    27 rt.addShape(bigsphere)
    27 rt.addShape(bigsphere)
    28 
    28 
    29 mat2 = Material(colour=(0.1, 0.4, 0.2))
    29 mat2 = Material(colour=(0.1, 0.4, 0.2))
    30 mat2.setReflectivity(0.6)
    30 mat2.setReflectivity(0.6)
    31 smallsphere = Sphere(centre=(6.5, 3.5, 8.0), radius=2.0, material=mat2)
    31 smallsphere = Sphere(center=(6.5, 3.5, 8.0), radius=2.0, material=mat2)
    32 rt.addShape(smallsphere)
    32 rt.addShape(smallsphere)
    33 
    33 
    34 mat3 = Material(colour=(0.9, 0.9, 1.0))
    34 mat3 = Material(colour=(0.9, 0.9, 1.0))
    35 mat3.setPhong(0.2, 1.0, 0.2)
    35 mat3.setPhong(0.2, 1.0, 0.2)
    36 mat3.setTransmissivity(0.88)
    36 mat3.setTransmissivity(0.88)
    37 mat3.setReflectivity(0.1)
    37 mat3.setReflectivity(0.1)
    38 for i in range(10):
    38 for i in range(10):
    39 	sph = Sphere(centre=(5.0+i, 1.5, 4.0), radius=0.5, material=mat3)
    39 	sph = Sphere(center=(5.0+i, 1.5, 4.0), radius=0.5, material=mat3)
    40 	rt.addShape(sph)
    40 	rt.addShape(sph)
    41 
    41 
    42 top.optimize()
    42 top.optimize()
    43 
    43 
    44 sampler = DefaultSampler(800, 600)
    44 sampler = DefaultSampler(800, 600)
       
    45 sampler.setOversample(1)
    45 rt.setSampler(sampler)
    46 rt.setSampler(sampler)
    46 rt.render()
    47 rt.render()
    47 sampler.getPixmap().writePNG('spheres_glass.png')
    48 sampler.getPixmap().writePNG('spheres_glass.png')