add texture to the sides of cylinder
xfang1363 opened this issue · comments
import numpy as np
from PIL import Image
import trimesh
radius = 0.5
height = 1.0
cylinder = trimesh.creation.cylinder(radius=radius, height=height)
print(cylinder)
t_coords = np.zeros((cylinder.vertices.shape[0], 2))
t_coords[:, 0] = (np.arctan2(cylinder.vertices[:, 0], cylinder.vertices[:, 2]) + np.pi) / (2 * np.pi)
t_coords[:, 1] = (cylinder.vertices[:, 1] + height/2) / height
image_path = "puppy.jpg"
im = Image.open(image_path)
cylinder.visual = trimesh.visual.TextureVisuals(uv=t_coords, image=im)
cylinder.show()
There is also texture on the bottom of the cylinder,how to add texture to only the sides of a cylinder?