blenderproc.python.loader.SuncgLoader module¶
-
class
blenderproc.python.loader.SuncgLoader.
SuncgLoader
[source]¶ Bases:
object
-
static
_adjust_material_nodes
(mat, adjustments)[source]¶ Adjust the material node of the given material according to the given adjustments.
Textures or diffuse colors will be changed according to the given material_adjustments.
Parameters:
-
_collection_of_loaded_mats
= {}¶
-
_collection_of_loaded_objs
= {}¶
-
static
_correct_bbox_frame
(bbox)[source]¶ Corrects the coordinate frame of the given bbox.
Parameters: bbox ( dict
) – The bbox.Return type: dict
Returns: The corrected bbox.
-
static
_get_type_and_value_from_mat
(mat)[source]¶ Returns the type of the material -> either diffuse or with texture (there are only two in SUNCG)
Parameters: mat ( Material
) – the material where the type and value should be determinedReturn type: Tuple
[str
,str
]Returns: mat_type, value: mat_type is either “diffuse” or “texture”, the value contains either name of the image or the color mapped to an RGB string of the values
-
static
_load_box
(node, material_adjustments, transform, parent, label_mapping)[source]¶ Creates a cube inside blender which follows the specifications of the given node.
Parameters: - node (
Dict
[str
,Any
]) – The node dict which contains information from house.json.. - material_adjustments (
List
[Dict
[str
,str
]]) – Adjustments to the materials which were specified inside house.json. - transform (
Matrix
) – The transformation that should be applied to the loaded objects. - parent (
Entity
) – The parent object to which the ground should be linked
Return type: Returns: The list of loaded mesh objects.
- node (
-
static
_load_ground
(node, metadata, material_adjustments, transform, house_id, parent, label_mapping)[source]¶ Load the ground specified in the given node.
Parameters: - node (
Dict
[str
,Any
]) – The node dict which contains information from house.json.. - metadata (
Dict
[str
,Union
[str
,int
]]) – A dict of metadata which will be written into the object’s custom data. - material_adjustments (
List
[Dict
[str
,str
]]) – Adjustments to the materials which were specified inside house.json. - transform (
Matrix
) – The transformation that should be applied to the loaded objects. - house_id (
str
) – The id of the current house. - parent (
Entity
) – The parent object to which the ground should be linked
Return type: Returns: The list of loaded mesh objects.
- node (
-
static
_load_obj
(path, metadata, material_adjustments, transform=None, parent=None)[source]¶ Load the wavefront object file from the given path and adjust according to the given arguments.
Parameters: - path (
str
) – The path to the .obj file. - metadata (
Dict
[str
,Union
[str
,int
]]) – A dict of metadata which will be written into the object’s custom data. - material_adjustments (
List
[Dict
[str
,str
]]) – Adjustments to the materials which were specified inside house.json. - transform (
Optional
[Matrix
]) – The transformation that should be applied to the loaded objects. - parent (
Optional
[Entity
]) – The parent object to which the object should be linked
Return type: Returns: The list of loaded mesh objects.
- path (
-
static
_load_object
(node, metadata, material_adjustments, transform, parent)[source]¶ Load the object specified in the given node.
Parameters: - node (
Dict
[str
,Any
]) – The node dict which contains information from house.json.. - metadata (
Dict
[str
,Union
[str
,int
]]) – A dict of metadata which will be written into the object’s custom data. - material_adjustments (
List
[Dict
[str
,str
]]) – Adjustments to the materials which were specified inside house.json. - transform (
Matrix
) – The transformation that should be applied to the loaded objects. - parent (
Entity
) – The parent object to which the ground should be linked
Return type: Returns: The list of loaded mesh objects.
- node (
-
static
_load_room
(node, metadata, material_adjustments, transform, house_id, parent, room_per_object, label_mapping)[source]¶ Load the room specified in the given node.
Parameters: - node (
Dict
[str
,Any
]) – The node dict which contains information from house.json.. - metadata (
Dict
[str
,Union
[str
,int
]]) – A dict of metadata which will be written into the object’s custom data. - material_adjustments (
List
[Dict
[str
,str
]]) – Adjustments to the materials which were specified inside house.json. - transform (
Matrix
) – The transformation that should be applied to the loaded objects. - house_id (
str
) – The id of the current house. - parent (
Entity
) – The parent object to which the room should be linked - room_per_object (
Dict
[int
,Entity
]) – A dict for object -> room lookup (Will be written into)
Return type: Returns: The list of loaded mesh objects.
- node (
-
static
_read_model_category_mapping
(path)[source]¶ Reads in the model category mapping csv.
Parameters: path ( str
) – The path to the csv file.
-
static
_recreate_material_nodes
(mat, force_texture)[source]¶ Remove all nodes and recreate a diffuse node, optionally with texture.
This will replace all material nodes with only a diffuse and a texturing node (to speedup rendering).
Parameters:
-
static
_rename_materials
()[source]¶ Rename all materials based on their texture if they have one
This makes the accessing later on easier
-
_suncg_dir
= None¶
-
static
_transform_and_colorize_object
(object, material_adjustments, transform=None, parent=None)[source]¶ Applies the given transformation to the object and refactors its materials.
Material is replaced with an existing material if possible or is changed according to the material_adjustments
Parameters: - object (
MeshObject
) – The object to use. - material_adjustments (
List
[Dict
[str
,str
]]) – A list of adjustments to make. (Each element i corresponds to material_i) - transform (
Optional
[Matrix
]) – The transformation matrix to apply - parent (
Optional
[Entity
]) – The parent object to which the object should be linked
- object (
-
static
-
blenderproc.python.loader.SuncgLoader.
load_suncg
(house_path, label_mapping, suncg_dir=None)[source]¶ Loads a house.json file into blender.
- Loads all objects files specified in the house.json file.
- Orders them hierarchically (level -> room -> object)
- Writes metadata into the custom properties of each object
Parameters: Return type: Returns: The list of loaded mesh objects.