blenderproc.python.object.FaceSlicer module
Can split an object in two, by extracting faces which point in a certain direction.
- class blenderproc.python.object.FaceSlicer.FaceSlicer[source]
Bases:
object
Slicing the faces from an object away.
- static check_face_angle(face, matrix_world, up_vector, cmp_angle)[source]
Checks if a face.normal in world coordinates angular difference to the up_vec is closer as cmp_anlge.
- Parameters:
face (
BMFace
) – The face, which will be checkedmatrix_world (
Union
[Matrix
,ndarray
]) – The matrix_world of the object, to which the face belongsup_vector (
Union
[Vector
,ndarray
]) – Vector, which is used for comparing the face.normal againstcmp_angle (
float
) – Angle, which is used to compare against the up_vec in radians.
- Return type:
bool
- Returns:
bool: Returns true if the face is close the height_value and is inside of the cmp_angle range
- static check_face_with(face, matrix_world, height_value, cmp_height, up_vector, cmp_angle)[source]
Check if the face is on a certain height_value by checking if it is inside of the band spanned by cmp_height -> [height_value - cmp_height, height_value + cmp_height] and then if the face has a similar angle to the given up_vec, the difference must be smaller than cmp_angle.
- Parameters:
face (
BMFace
) – The face, which will be checkedmatrix_world (
Union
[Matrix
,ndarray
]) – The matrix_world of the object, to which the face belongsheight_value (
float
) – Height value which is used for comparing the faces median point againstcmp_height (
float
) – Defines the range in which the face median is compared to the height value.up_vector (
Union
[Vector
,ndarray
]) – Vector, which is used for comparing the face.normal againstcmp_angle (
float
) – Angle, which is used to compare against the up_vec in radians.
- Return type:
bool
- Returns:
bool: Returns true if the face is close the height_value and is inside of the cmp_angle range
- static get_median_face_pose(face, matrix_world)[source]
Returns the median face pose of all its vertices in the world coordinate frame.
- Parameters:
face (
BMFace
) – Current selected frame, its vertices are used to calculate the medianmatrix_world (
Union
[Matrix
,ndarray
]) – The matrix of the current object to which this face belongs
- Return type:
Vector
- Returns:
mathutils.Vector(): The current median point of the vertices in world coordinates
- static select_at_height_value(bm, height_value, compare_height, up_vector, cmp_angle, matrix_world)[source]
Selects for a given height_value all faces, which are inside the given compare_height band and also face upwards. This is done by comparing the face.normal in world coordinates to the up_vector and the resulting angle must be smaller than compare_angle.
- Parameters:
bm (
BMesh
) – The object as BMesh in edit mode. The face should be structured, meaning a lookup was performed on them before.height_value (
float
) – Height value which is used for comparing the faces median point againstcompare_height (
float
) – Defines the range in which the face median is compared to the height value.up_vector (
Union
[Vector
,ndarray
]) – Vector, which is used for comparing the face.normal againstcmp_angle (
float
) – Angle, which is used to compare against the up_vec in radians.matrix_world (
Union
[Matrix
,ndarray
]) – The matrix_world of the object, to which the face belongs
- Return type:
int
- blenderproc.python.object.FaceSlicer.extract_floor(mesh_objects, compare_angle_degrees=7.5, compare_height=0.15, up_vector_upwards=True, height_list_path=None, new_name_for_object='Floor', should_skip_if_object_is_already_there=False)[source]
Extracts floors in the following steps: 1. Searchs for the specified object. 2. Splits the surfaces which point upwards at a specified level away.
- Parameters:
mesh_objects (
List
[MeshObject
]) – Objects to where all polygons will be extracted.compare_angle_degrees (
float
) – Maximum difference between the up vector and the current polygon normal in degrees.compare_height (
float
) – Maximum difference in Z direction between the polygons median point and the specified height of the room.up_vector_upwards (
bool
) – If this is True the up_vec points upwards -> [0, 0, 1] if not it points downwards: [0, 0, -1] in world coordinates. This vector is used for the compare_angle_degrees option.height_list_path (
Optional
[str
]) – Path to a file with height values. If none is provided, a ceiling and floor is automatically detected. This might fail. The height_list_values can be specified in a list like fashion in the file: [0.0, 2.0]. These values are in the same size the dataset is in, which is usually meters. The content must always be a list, e.g. [0.0].new_name_for_object (
str
) – Name for the newly created object, which faces fulfill the given parameters.should_skip_if_object_is_already_there (
bool
) – If this is true no extraction will be done, if an object is there, which has the same name as name_for_split_obj, which would be used for the newly created object.
- Return type:
List
[MeshObject
]- Returns:
The extracted floor objects.
- blenderproc.python.object.FaceSlicer.slice_faces_with_normals(mesh_object, compare_angle_degrees=7.5, up_vector_upwards=None, new_name_for_object='Surface')[source]
Extracts normal faces like floors in the following steps: 1. Searchs for the specified object. 2. Splits the surfaces which point upwards at a specified level away.
- Parameters:
mesh_object (
MeshObject
) – Object to which all polygons will be extracted.compare_angle_degrees (
float
) – Maximum difference between the up vector and the current polygon normal in degrees.up_vector_upwards (
Optional
[array
]) – If this is True the up_vec points upwards -> [0, 0, 1] if not it points downwards: [0, 0, -1] in world coordinates. This vector is used for the compare_angle_degrees option.new_name_for_object (
str
) – Name for the newly created object, which faces fulfill the given parameters.
- Return type:
Optional
[MeshObject
]- Returns:
The extracted surface of the object.