MCPcopy Index your code
hub / github.com/DLR-RM/BlenderProc / load_obj

Method load_obj

blenderproc/python/loader/SuncgLoader.py:281–314  ·  view source on GitHub ↗

Load the wavefront object file from the given path and adjust according to the given arguments. :param path: The path to the .obj file. :param metadata: A dict of metadata which will be written into the object's custom data. :param material_adjustments: Adjustments to the m

(path: str, metadata: Dict[str, Union[str, int]], material_adjustments: List[Dict[str, str]],
                 transform: Optional[Matrix] = None, parent: Optional[Entity] = None)

Source from the content-addressed store, hash-verified

279
280 @staticmethod
281 def load_obj(path: str, metadata: Dict[str, Union[str, int]], material_adjustments: List[Dict[str, str]],
282 transform: Optional[Matrix] = None, parent: Optional[Entity] = None) -> List[MeshObject]:
283 """ Load the wavefront object file from the given path and adjust according to the given arguments.
284
285 :param path: The path to the .obj file.
286 :param metadata: A dict of metadata which will be written into the object's custom data.
287 :param material_adjustments: Adjustments to the materials which were specified inside house.json.
288 :param transform: The transformation that should be applied to the loaded objects.
289 :param parent: The parent object to which the object should be linked
290 :return: The list of loaded mesh objects.
291 """
292 if not os.path.exists(path):
293 print(f"Warning: {path} is missing!")
294 return []
295 object_already_loaded = path in _SuncgLoader.collection_of_loaded_objs
296 loaded_objects = load_obj(filepath=path, cached_objects=_SuncgLoader.collection_of_loaded_objs)
297 if object_already_loaded:
298 print(f"Duplicate object: {path}")
299 for obj in loaded_objects:
300 # the original object matrix from the .obj loader -> is not an identity matrix
301 obj.set_local2world_mat(Matrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]))
302 # remove all custom properties
303 obj.clear_all_cps()
304 # Go through all imported objects
305 for obj in loaded_objects:
306 for key in metadata.keys():
307 used_key = key
308 if key == "type":
309 used_key = "suncg_type"
310 obj.set_cp(used_key, metadata[key])
311
312 _SuncgLoader.transform_and_colorize_object(obj, material_adjustments, transform, parent)
313
314 return loaded_objects
315
316 @staticmethod
317 def transform_and_colorize_object(obj: MeshObject, material_adjustments: List[Dict[str, str]],

Callers 15

load_roomMethod · 0.80
load_groundMethod · 0.80
load_objectMethod · 0.80
test_object_loaderMethod · 0.80
main.pyFile · 0.80
main.pyFile · 0.80
main.pyFile · 0.80
main.pyFile · 0.80

Calls 5

load_objFunction · 0.90
set_local2world_matMethod · 0.80
clear_all_cpsMethod · 0.80
set_cpMethod · 0.80