blenderproc.python.modules.constructor.BasicMeshInitializer module¶
-
class
blenderproc.python.modules.constructor.BasicMeshInitializer.
BasicMeshInitializer
(config)[source]¶ Bases:
blenderproc.python.modules.main.Module.Module
Adds/initializes basic mesh objects in the scene. Allows setting the basic attribute values. Can initialize a default ‘Principled BSDF’ shader-based material for each of added objects. For more precise and powerful object manipulation use manipulators.EntityManipulator module.
Example 1: Add a plane “Ground_plane” object to the scene.
{ "module": "constructor.BasicMeshInitializer", "config": { "meshes_to_add": [ { "type": "plane", "name": "Ground_plane" } ] } }
Example 2: Add a rotated “Cube_1” cube object, a displaced “Torus_2” torus object, and a scaled “Cone_3” cone object to the scene.
{ "module": "constructor.BasicMeshInitializer", "config": { "meshes_to_add": [ { "type": "cube", "name": "Cube_1", "rotation": [1.1, 0.2, 0.2] }, { "type": "torus", "name": "Torus_2", "location": [0, 0, 3] }, { "type": "cone", "name": "Cone_3", "scale": [2, 3, 4] } ] } }
Configuration:
Parameter Description Type meshes_to_add List that contains object configuration data in each cell. See table below for available parameters per cell. list init_materials Flag that controls whether the added objects will be assigned a default Principled BSDF shader-based material (if value is True), or not (if value is False). Material’s name is derived from the object’s name. Default: True. boolean meshes_to_add cell configuration:
Parameter Description Type type Type of mesh object to add. Available types: ‘plane’, ‘cube’, ‘circle’, ‘uvsphere’, ‘icosphere’, ‘cylinder’, ‘cone’, ‘torus’. string name Name of the mesh object. string location Location of the mesh object. Default: [0, 0, 0]. mathutils.Vector rotation Rotation (3 Euler angles) of the mesh object. Default: [0, 0, 0]. mathutils.Vector scale Scale of the mesh object. Default: [1, 1, 1]. mathutils.Vector -
_add_obj
(obj_type)[source]¶ Adds an object to the scene.
Parameters: obj_type – Type of the object to add. Type: string. Returns: Added object. Type: bpy.types.Object.
-
_init_material
(obj_name)[source]¶ Adds a new default material and assigns it to the added mesh object.
Parameters: obj_name – Name of the object. Type: string.
-
_set_attrs
(new_obj, obj_name, obj_location, obj_rotation, obj_scale)[source]¶ Sets the attribute values of the added object.
Parameters: - new_obj – New object to modify. Type: bpy.types.Object.
- obj_name – Name of the object. Type: string.
- obj_location – XYZ location of the object. Type: mathutils.Vector.
- obj_rotation – Rotation (3 Euler angles) of the object. Type: mathutils.Vector.
- obj_scale – Scale of the object. Type: mathutils.Vector.
-