本文整理汇总了Python中trimesh.load_mesh方法的典型用法代码示例。如果您正苦于以下问题:Python trimesh.load_mesh方法的具体用法?Python trimesh.load_mesh怎么用?Python trimesh.load_mesh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trimesh
的用法示例。
在下文中一共展示了trimesh.load_mesh方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import load_mesh [as 别名]
def __init__(self, fname):
self.mesh = trimesh.load_mesh(fname)
median = np.mean(self.mesh.bounds[:, :], axis=0)
self.mesh.apply_translation(-median)
max_length = np.max(np.abs(self.mesh.bounds[:, :]))
length = 1.0 / (max_length * 2.0)
self.mesh.apply_scale(length)
示例2: read_3d_obj
# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import load_mesh [as 别名]
def read_3d_obj(fname="lion_data.npy", fname_obj="lion-reference.obj"):
if os.path.isfile(fname):
return np.load(fname)
else:
mesh = trimesh.load_mesh(fname_obj)
a = np.array(mesh.vertices)
x,y,z = -a[:,0],a[:,2],a[:,1]
data = np.array(list(zip(x,y,z)))
np.save(fname, data)
return data
示例3: __call__
# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import load_mesh [as 别名]
def __call__(self, path):
mesh = trimesh.load_mesh(path)
mesh.remove_degenerate_faces()
mesh.fix_normals()
mesh.fill_holes()
mesh.remove_duplicate_faces()
mesh.remove_infinite_values()
mesh.remove_unreferenced_vertices()
mesh.apply_translation(-mesh.centroid)
r = np.max(np.linalg.norm(mesh.vertices, axis=-1))
mesh.apply_scale(1 / r)
if self.tr > 0:
tr = np.random.rand() * self.tr
rot = rnd_rot()
mesh.apply_transform(rot)
mesh.apply_translation([tr, 0, 0])
if not self.rot:
mesh.apply_transform(rot.T)
if self.rot:
mesh.apply_transform(rnd_rot())
r = np.max(np.linalg.norm(mesh.vertices, axis=-1))
mesh.apply_scale(0.99 / r)
return mesh
示例4: load_mesh
# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import load_mesh [as 别名]
def load_mesh(mesh_path):
"""Loads a mesh from file &computes it's centroid using V-REP style."""
mesh = trimesh.load_mesh(mesh_path)
# V-REP encodes the object centroid as the literal center of the object,
# so we need to make sure the points are centered the same way
center = lib.utils.calc_mesh_centroid(mesh, center_type='vrep')
mesh.vertices -= center
return mesh
示例5: plot_mesh
# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import load_mesh [as 别名]
def plot_mesh(mesh_path, workspace2obj, axis=None):
"""Visualize where we will sample grasp candidates from
Parameters
----------
mesh_path : path to a given mesh
workspace2obj : 4x4 transform matrix from the workspace to object
axis : (optional) a matplotlib axis for plotting a figure
"""
if axis is None:
figure = plt.figure()
axis = Axes3D(figure)
axis.autoscale(False)
# Load the object mesh
mesh = trimesh.load_mesh(mesh_path)
# V-REP encodes the object centroid as the literal center of the object,
# so we need to make sure the points are centered the same way
center = calc_mesh_centroid(mesh, center_type='vrep')
mesh.vertices -= center
# Rotate the vertices so they're in the frame of the workspace
mesh.apply_transform(workspace2obj)
# Construct a 3D mesh via matplotlibs 'PolyCollection'
poly = Poly3DCollection(mesh.triangles, linewidths=0.05, alpha=0.25)
poly.set_facecolor([0.5, 0.5, 1])
axis.add_collection3d(poly)
return plot_equal_aspect(mesh.vertices, axis)
示例6: _getMesh
# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import load_mesh [as 别名]
def _getMesh(fname, change_units_from='mm'):
change_units_from = change_units_from.lower()
mesh = trimesh.load_mesh(fname)
if change_units_from is not 'mm':
mesh.units = change_units_from
mesh.convert_units('mm')
return mesh