import render_mesh
import dolly_zoom
import render_shapes
import camera_transforms
import render_generic
import extra_credit
import matplotlib.pyplot as plt
cow_path = "../data/cow.obj"
image_size = 256
cow_360_gif_path = "../images/cow_360.gif"
render_mesh.render_cow(cow_path=cow_path, image_size=image_size, output_path=cow_360_gif_path)
num_frames = 10
duration = 3
dolly_gif_path = "../images/dolly.gif"
dolly_zoom.dolly_zoom(
image_size=image_size,
num_frames=num_frames,
duration=duration,
output_file=dolly_gif_path,
)
tetragedron_gif_path = "../images/tetrahedron.gif"
render_shapes.render_tetrahedon(output_file=tetragedron_gif_path, image_size=image_size)
cube_gif_path = "../images/cube.gif"
render_shapes.render_cube(output_file=cube_gif_path, image_size=image_size)
cow_color_gif_path = "../images/cow_color.gif"
render_shapes.render_cow_color(output_file=cow_color_gif_path, image_size=image_size)
In this case, color1 = [1, 0.5, 0]
is saffron and color2 = [0, 0.5, 0]
is green.
cow_obj_path = "../data/cow.obj"
cow_transform_img_path = "../images/transform_cow.jpg"
R_relative = [[0, 1, 0], [-1, 0, 0], [0, 0, 1]]
T_relative = [0, 0, 0]
output_path = cow_transform_img_path[:-4] + "_Trans_1" + cow_transform_img_path[-4:]
plt.imsave(output_path,
camera_transforms.render_textured_cow(cow_path=cow_obj_path,
image_size=image_size,
R_relative=R_relative,
T_relative=T_relative))
R_relative = [[0, 1, 0], [-1, 0, 0], [0, 0, 1]]
T_relative = [0, 0, 0]
output_path = cow_transform_img_path[:-4] + "_Trans_2" + cow_transform_img_path[-4:]
plt.imsave(output_path,
camera_transforms.render_textured_cow(cow_path=cow_obj_path,
image_size=image_size,
R_relative=R_relative,
T_relative=T_relative))
R_relative = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
T_relative = [0.5, -0.5, 0]
output_path = cow_transform_img_path[:-4] + "_Trans_3" + cow_transform_img_path[-4:]
plt.imsave(output_path,
camera_transforms.render_textured_cow(cow_path=cow_obj_path,
image_size=image_size,
R_relative=R_relative,
T_relative=T_relative))
R_relative = [[0, 0, 1], [0, 1, 0], [-1, 0, 0]]
T_relative = [-3, 0, 3]
output_path = cow_transform_img_path[:-4] + "_Trans_4" + cow_transform_img_path[-4:]
plt.imsave(output_path,
camera_transforms.render_textured_cow(cow_path=cow_obj_path,
image_size=image_size,
R_relative=R_relative,
T_relative=T_relative))
# transform 1 - rotate around z axis
R_relative = [[0, 1, 0], [-1, 0, 0], [0, 0, 1]]
T_relative = [0, 0, 0]
#
output_path = cow_transform_img_path[:-4] + "_Trans_1" + cow_transform_img_path[-4:]
plt.imsave(output_path,
camera_transforms.render_textured_cow(cow_path=cow_obj_path,
image_size=image_size,
R_relative=R_relative,
T_relative=T_relative))
# # transform 2 - move back - z axis
R_relative = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
T_relative = [0, 0, 2]
output_path = cow_transform_img_path[:-4] + "_Trans_2" + cow_transform_img_path[-4:]
plt.imsave(output_path,
camera_transforms.render_textured_cow(cow_path=cow_obj_path,
image_size=image_size,
R_relative=R_relative,
T_relative=T_relative))
# transform 3 - slight translation along x and y
R_relative = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
T_relative = [0.5, -0.5, 0]
output_path = cow_transform_img_path[:-4] + "_Trans_3" + cow_transform_img_path[-4:]
plt.imsave(output_path,
camera_transforms.render_textured_cow(cow_path=cow_obj_path,
image_size=image_size,
R_relative=R_relative,
T_relative=T_relative))
# transform 4 - rotate around y axis and shift
R_relative = [[0, 0, 1], [0, 1, 0], [-1, 0, 0]]
T_relative = [-3, 0, 3]
output_path = cow_transform_img_path[:-4] + "_Trans_4" + cow_transform_img_path[-4:]
plt.imsave(output_path,
camera_transforms.render_textured_cow(cow_path=cow_obj_path,
image_size=image_size,
R_relative=R_relative,
T_relative=T_relative))
output_torus_file = '../images/torus_param.gif'
num_samples = 200
render_generic.render_torus(image_size=image_size, num_samples=num_samples, device=None, output_file=output_torus_file)
In your writeup, include a 360-degree gif of your torus point cloud, and make sure the hole is visible. You may choose to texture your point cloud however you wish.
output_torus_file = '../images/torus_impl.gif'
voxel_size = 64
render_generic.render_torus_mesh(image_size=image_size, voxel_size=voxel_size,
device=None, output_file=output_torus_file)
In your writeup, include a 360-degree gif of your torus mesh, and make sure the hole is visible. In addition, discuss some of the tradeoffs between rendering as a mesh vs a point cloud. Things to consider might include rendering speed, rendering quality, ease of use, memory usage, etc.
out_fun_file = "../images/cow_rainbow.gif"
render_shapes.render_cow_rainbow(cow_path=cow_obj_path,
image_size=256,
device=None,
output_file=out_fun_file)
Here I did a texture based on rainbow colors.
num_samples = 1000
out_cow_pts_path = "../images/cow_pts.gif"
extra_credit.render_cow_ptc(out_path=out_cow_pts_path, image_size=image_size, num_samples=num_samples)
For this part, write a function that takes a triangle mesh and the number of samples and outputs a point cloud. Then, using the cow mesh, randomly sample 10, 100, 1000, and 10000 points. Render each pointcloud and the original cow mesh side-by-side, and include the gif in your writeup.*