Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def loadAssimpSceneFromFile(inFile):
baseDir = os.path.dirname(inFile)
scene = pyassimp.load(inFile, pyassimp.postprocess.aiProcess_Triangulate)
return AssimpScene(scene, baseDir)
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
def main(filename=None):
scene = pyassimp.load(filename, processing=pyassimp.postprocess.aiProcess_Triangulate)
#the model we load
print("MODEL:" + filename)
print
#write some statistics
print("SCENE:")
print(" meshes:" + str(len(scene.meshes)))
print(" materials:" + str(len(scene.materials)))
print(" textures:" + str(len(scene.textures)))
print
print("NODES:")
recur_node(scene.rootnode)
print
def __init__(self, source):
# super(AssimpObjLoader, **kwargs)
# source = kwargs.get('source', '')
if not source:
print "no source given!"
return
self.scene = scene = load(
source, 0
| postprocess.aiProcess_Triangulate
| postprocess.aiProcess_SplitLargeMeshes
| postprocess.aiProcess_GenNormals
)
self.objects = {}
for i, mesh in enumerate(scene.meshes):
self.objects[i] = AssimpMesh(scene, mesh)
def __init__(self, source):
# super(AssimpObjLoader, **kwargs)
# source = kwargs.get('source', '')
if not source:
print "no source given!"
return
self.scene = scene = load(
source, 0
| postprocess.aiProcess_Triangulate
| postprocess.aiProcess_SplitLargeMeshes
| postprocess.aiProcess_GenNormals
)
self.objects = {}
for i, mesh in enumerate(scene.meshes):
self.objects[i] = AssimpMesh(scene, mesh)
def main(filename=None):
scene = pyassimp.load(filename, processing=pyassimp.postprocess.aiProcess_Triangulate)
#the model we load
print("MODEL:" + filename)
print
#write some statistics
print("SCENE:")
print(" meshes:" + str(len(scene.meshes)))
print(" materials:" + str(len(scene.materials)))
print(" textures:" + str(len(scene.textures)))
print
print("NODES:")
recur_node(scene.rootnode)
print
def get_pyassimp_load_options(self):
load_flags = assimp.postprocess.aiProcess_Triangulate;
load_flags = load_flags | assimp.postprocess.aiProcess_SortByPType;
load_flags = load_flags | assimp.postprocess.aiProcess_OptimizeMeshes;
load_flags = load_flags | assimp.postprocess.aiProcess_RemoveRedundantMaterials;
load_flags = load_flags | assimp.postprocess.aiProcess_FindDegenerates;
load_flags = load_flags | assimp.postprocess.aiProcess_GenSmoothNormals;
load_flags = load_flags | assimp.postprocess.aiProcess_JoinIdenticalVertices;
load_flags = load_flags | assimp.postprocess.aiProcess_ImproveCacheLocality;
load_flags = load_flags | assimp.postprocess.aiProcess_GenUVCoords;
load_flags = load_flags | assimp.postprocess.aiProcess_FindInvalidData;
return load_flags