當前位置: 首頁>>代碼示例>>Python>>正文


Python pyassimp.release方法代碼示例

本文整理匯總了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 
開發者ID:DLR-RM,項目名稱:AugmentedAutoencoder,代碼行數:20,代碼來源:geometry.py

示例2: __del__

# 需要導入模塊: import pyassimp [as 別名]
# 或者: from pyassimp import release [as 別名]
def __del__(self):
    scene = self.scene
    assimp.release(scene) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:5,代碼來源:swiftshader_renderer.py

示例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 
開發者ID:jhu-lcsr,項目名稱:costar_plan,代碼行數:41,代碼來源:urdf_to_collision_object.py


注:本文中的pyassimp.release方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。