예제 #1
0
def generate_texture_mapping(texture, wall_aspect_ratio=1.0, scale=1.0):
    aspect_ratio = texture.shape[1] / texture.shape[0]
    uv_coordinates = np.array([
        [0, 1 / scale],
        [wall_aspect_ratio / aspect_ratio / scale, 1 / scale],
        [0, 0],
        [wall_aspect_ratio / aspect_ratio / scale, 0],
    ],
                              dtype=np.float32)
    mapping = rtx.TextureMapping(texture, uv_coordinates)
    return mapping
예제 #2
0
파일: room.py 프로젝트: sxcgc/python-rtx
scene.add(wall)

# floor
geometry = rtx.PlainGeometry(grid_size + eps, grid_size + eps)
geometry.set_rotation((-math.pi / 2, 0, 0))
geometry.set_position((0, -wall_height / 2, 0))
material = rtx.LambertMaterial(0.95)
texture = load_texture_image(
    "/home/musyoku/sandbox/gqn-dataset-renderer/textures/pink dust.png")
uv_coordinates = np.array([
    [0, 1],
    [1, 1],
    [0, 0],
    [1, 0],
], dtype=np.float32)
mapping = rtx.TextureMapping(texture, uv_coordinates)
floor = rtx.Object(geometry, material, mapping)
scene.add(floor)

# place cylinder
geometry = rtx.CylinderGeometry(1, 1)
geometry.set_position((0, -1, 2))
material = rtx.LambertMaterial(0.4)
mapping = rtx.SolidColorMapping((0, 1, 0))
cylinder = rtx.Object(geometry, material, mapping)
scene.add(cylinder)

# place cone
geometry = rtx.ConeGeometry(0.5, 1)
geometry.set_position((2, -1, 0))
material = rtx.LambertMaterial(0.4)