Beispiel #1
0
def Phong(object1):
    #	interpolate vertex's normals
    results = Interpolation.ScanConversion(object1)
    i_buffer, t_buffer = Interpolation.Z_buffer(results)
    #	illmination
    for y_index, y in enumerate(i_buffer):
        for x_index, color1 in enumerate(y):
            if color1 != -1:
                i_buffer[y_index][x_index] = illuminate(
                    color1, c_pos, light, i_light, ks, ka, kd)
                pos = t_buffer[y_index][x_index]
                t_buffer[y_index][x_index] = object1.color
    #	rendering
    Rendering.renderforpixel(i_buffer, t_buffer)
Beispiel #2
0
def Ground(object1):
    #	vertex's intensites
    v_intensities = []
    for v_normal in object1.v_normals:
        v_intensities.append(
            illuminate(v_normal, c_pos, light, i_light, ks, ka, kd))
    object1.v_normals = v_intensities
    #	interpolate intensities
    results = Interpolation.ScanConversion(object1)
    i_buffer, t_buffer = Interpolation.Z_buffer(results)
    #	illmination
    for y_index, y in enumerate(i_buffer):
        for x_index, color1 in enumerate(y):
            if color1 != -1:
                t_buffer[y_index][x_index] = object1.color
    #	rendering
    Rendering.renderforpixel(i_buffer, t_buffer)
Beispiel #3
0
def AddTexture(object1):
    #data=Texture.textureimage()
    image = Image.open(imagefile)
    data = np.asarray(image)
    #	interpolate vertex's normals
    results = Interpolation.ScanConversion(object1)
    i_buffer, t_buffer = Interpolation.Z_buffer(results)
    #	illmination
    for y_index, y in enumerate(i_buffer):
        for x_index, color1 in enumerate(y):
            if color1 != -1:
                i_buffer[y_index][x_index] = illuminate(
                    color1, c_pos, light, i_light, ks, ka, kd)
                pos = t_buffer[y_index][x_index]
                t_buffer[y_index][x_index] = data[int(pos[0] * 400 -
                                                      1)][int(pos[1] * 600 -
                                                              1)]
    #	rendering
    Rendering.renderforpixel(i_buffer, t_buffer)