本文整理汇总了Python中pyassimp.release方法的典型用法代码示例。如果您正苦于以下问题:Python pyassimp.release方法的具体用法?Python pyassimp.release怎么用?Python pyassimp.release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyassimp
的用法示例。
在下文中一共展示了pyassimp.release方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_meshes
# 需要导入模块: import pyassimp [as 别名]
# 或者: from pyassimp import release [as 别名]
def load_meshes(obj_files, vertex_tmp_store_folder, recalculate_normals=False):
hashed_file_name = hashlib.md5((''.join(obj_files) + 'load_meshes' + str(recalculate_normals)).encode('utf-8') ).hexdigest() + '.npy'
out_file = os.path.join( vertex_tmp_store_folder, hashed_file_name)
if os.path.exists(out_file):
return np.load(out_file)
else:
bar = progressbar.ProgressBar()
attributes = []
for model_path in bar(obj_files):
scene = pyassimp.load(model_path, pyassimp.postprocess.aiProcess_Triangulate)
mesh = scene.meshes[0]
vertices = mesh.vertices
normals = calc_normals(vertices) if recalculate_normals else mesh.normals
attributes.append( (vertices, normals) )
pyassimp.release(scene)
np.save(out_file, attributes)
return attributes
示例2: __del__
# 需要导入模块: import pyassimp [as 别名]
# 或者: from pyassimp import release [as 别名]
def __del__(self):
scene = self.scene
assimp.release(scene)
示例3: _make_mesh
# 需要导入模块: import pyassimp [as 别名]
# 或者: from pyassimp import release [as 别名]
def _make_mesh(self, c, scale = (1, 1, 1)):
'''
This was taken from moveit commander and slightly modified.
'''
filename = c.geometry.filename
if pyassimp is False:
raise RuntimeError("Pyassimp needs patch https://launchpadlibrarian.net/319496602/patchPyassim.txt")
scene = pyassimp.load(filename)
if not scene.meshes or len(scene.meshes) == 0:
raise MoveItCommanderException("There are no meshes in the file")
if len(scene.meshes[0].faces) == 0:
raise MoveItCommanderException("There are no faces in the mesh")
mesh = Mesh()
first_face = scene.meshes[0].faces[0]
if hasattr(first_face, '__len__'):
for face in scene.meshes[0].faces:
if len(face) == 3:
triangle = MeshTriangle()
triangle.vertex_indices = [face[0], face[1], face[2]]
mesh.triangles.append(triangle)
elif hasattr(first_face, 'indices'):
for face in scene.meshes[0].faces:
if len(face.indices) == 3:
triangle = MeshTriangle()
triangle.vertex_indices = [face.indices[0],
face.indices[1],
face.indices[2]]
mesh.triangles.append(triangle)
else:
raise RuntimeError("Unable to build triangles from mesh due to mesh object structure")
for vertex in scene.meshes[0].vertices:
point = Point()
point.x = vertex[0]*scale[0]
point.y = vertex[1]*scale[1]
point.z = vertex[2]*scale[2]
mesh.vertices.append(point)
pyassimp.release(scene)
return mesh