Ejemplo n.º 1
0
def scene2():
    scene = Scene()

    obj = GameObject('0')
    obj.load_mesh('../data/camero.obj')
    obj.load_texture('../data/camero.png', 256)
    obj.set_scale(20)
    obj.rotate_y(-45)
    scene.objects += [obj]

    scene.light = Light()
    scene.light.shadow_map_dim = 512
    scene.light.shadow_map_bias = 1
    scene.light.translate_z(1000)
    scene.light.translate_y(1500)
    scene.light.translate_x(2000)
    scene.light.rotate_y(100)
    scene.light.rotate_x(45)

    image_width = 640
    image_height = 480

    scene.camera = Camera(0.98, 0.735, image_width, image_height, 1, 10000, 20,
                          np.eye(4))
    scene.camera.translate_y(40)
    scene.camera.translate_z(60)
    scene.camera.rotate_x(35)

    return scene
Ejemplo n.º 2
0
def scene1():
    scene = Scene()

    obj = GameObject('0')
    obj.load_mesh('../data/deer.obj')
    obj.set_scale(1 / 30)
    obj.translate_x(10)
    obj.rotate_y(-35)
    scene.objects += [obj]

    obj = GameObject('1')
    obj.load_mesh('../data/cube.obj')
    obj.set_scale(100)
    obj.translate_x(-50)
    obj.translate_y(-100)
    obj.translate_z(-50)
    scene.objects += [obj]

    obj = GameObject('2')
    obj.load_mesh('../data/camero.obj')
    obj.load_texture('../data/camero.png', 64)
    obj.set_scale(10)
    obj.translate_x(-20)
    obj.translate_z(8)
    obj.rotate_y(-45)
    scene.objects += [obj]

    scene.light = Light()
    scene.light.shadow_map_dim = 64
    scene.light.shadow_map_bias = 1
    scene.light.translate_z(1000)
    scene.light.translate_y(1500)
    scene.light.translate_x(2000)
    scene.light.rotate_y(100)
    scene.light.rotate_x(35)

    image_width = 320
    image_height = 240

    scene.camera = Camera(0.98, 0.735, image_width, image_height, 1, 10000, 20,
                          np.eye(4))
    scene.camera.translate_y(60)
    scene.camera.translate_z(60)
    scene.camera.rotate_x(35)

    print(scene.camera.world_to_camera)

    return scene
Ejemplo n.º 3
0
def export_txtr(obj):
    txtr_array = np.zeros((64, 64)).astype(np.uint32)
    texture = (obj.texture * 255).astype(np.uint32)
    texture = np.transpose(texture, (1, 0, 2))
    texture = texture[:, ::-1, :]
    txtr_array = texture[:, :,
                         2] + texture[:, :, 0] * 256 + texture[:, :,
                                                               1] * 256 * 256
    return txtr_array.flatten()


if __name__ == '__main__':
    obj = GameObject('0')
    obj.load_mesh('../data/deer.obj')
    obj.set_scale(1 / 30)
    mesh_array = export_mesh(obj)
    np.save('01_mesh.npy', mesh_array)
    obj.translate_x(10)
    obj.rotate_y(-35)
    np.save('01_trns.npy', obj.transform)

    obj = GameObject('1')
    obj.load_mesh('../data/cube.obj')
    obj.set_scale(100)
    mesh_array = export_mesh(obj)
    np.save('02_mesh.npy', mesh_array)
    obj.translate_x(-50)
    obj.translate_y(-100)
    obj.translate_z(-50)
    np.save('02_trns.npy', obj.transform)