Welcome to Python-flavored Magnum! Please note that, while already being rather stable, this functionality is still considered experimental and some APIs might get changed without preserving full backwards compatibility.

magnum.scenetools module

Scene manipulation and optimization tools

Functions

def absolute_field_transformations2d(scene: trade.SceneData, field: trade.SceneField, global_transformation: Matrix3 = Matrix(1, 0, 0, 0, 1, 0, 0, 0, 1)) -> list[Matrix3]
Calculate absolute 2D transformations for given field
def absolute_field_transformations2d(scene: trade.SceneData, field_id: int, global_transformation: Matrix3 = Matrix(1, 0, 0, 0, 1, 0, 0, 0, 1)) -> list[Matrix3]
Calculate absolute 2D transformations for given named field
def absolute_field_transformations3d(scene: trade.SceneData, field: trade.SceneField, global_transformation: Matrix4 = Matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)) -> list[Matrix4]
Calculate absolute 3D transformations for given field
def absolute_field_transformations3d(scene: trade.SceneData, field_id: int, global_transformation: Matrix4 = Matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)) -> list[Matrix4]
Calculate absolute 2D transformations for given named field
def children_depth_first(scene: trade.SceneData) -> list[tuple[int, int]]
Retrieve children in a depth-first order
def combine_fields(mapping_type: trade.SceneMappingType, mapping_bound: int, fields: list[trade.SceneFieldData]) -> trade.SceneData
Combine scene fields together
def filter_except_fields(scene: trade.SceneData, fields: list[trade.SceneField]) -> trade.SceneData
Filter a scene to contain everything the selected subset of named fields
def filter_field_entries(scene: trade.SceneData, entries_to_keep: list[tuple[trade.SceneField, corrade.containers.BitArrayView]]) -> trade.SceneData
Filter individual entries of named fields in a scene
def filter_field_entries(scene: trade.SceneData, entries_to_keep: list[tuple[int, corrade.containers.BitArrayView]]) -> trade.SceneData
Filter individual entries of named fields in a scene
def filter_fields(scene: trade.SceneData, fields_to_keep: corrade.containers.BitArrayView) -> trade.SceneData
Filter a scene to contain only the selected subset of fields
def filter_objects(scene: trade.SceneData, objects_to_keep: corrade.containers.BitArrayView) -> trade.SceneData
Filter objects in a scene
def filter_only_fields(scene: trade.SceneData, fields: list[trade.SceneField]) -> trade.SceneData
Filter a scene to contain only the selected subset of named fields
def parents_breadth_first(scene: trade.SceneData) -> list[tuple[int, int]]
Retrieve parents in a breadth-first order

Function documentation

def magnum.scenetools.absolute_field_transformations2d(scene: trade.SceneData, field: trade.SceneField, global_transformation: Matrix3 = Matrix(1, 0, 0, 0, 1, 0, 0, 0, 1)) -> list[Matrix3]

Calculate absolute 2D transformations for given field

Exceptions
KeyError If field does not exist in scene
AssertionError If scene is not 2D
AssertionError If scene does not have trade.SceneField.PARENT

def magnum.scenetools.absolute_field_transformations2d(scene: trade.SceneData, field_id: int, global_transformation: Matrix3 = Matrix(1, 0, 0, 0, 1, 0, 0, 0, 1)) -> list[Matrix3]

Calculate absolute 2D transformations for given named field

Exceptions
IndexError If field_id negative or not less than trade.SceneData.field_count
AssertionError If scene is not 2D
AssertionError If scene does not have trade.SceneField.PARENT

def magnum.scenetools.absolute_field_transformations3d(scene: trade.SceneData, field: trade.SceneField, global_transformation: Matrix4 = Matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)) -> list[Matrix4]

Calculate absolute 3D transformations for given field

Exceptions
KeyError If field does not exist in scene
AssertionError If scene is not 2D
AssertionError If scene does not have trade.SceneField.PARENT

def magnum.scenetools.absolute_field_transformations3d(scene: trade.SceneData, field_id: int, global_transformation: Matrix4 = Matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)) -> list[Matrix4]

Calculate absolute 2D transformations for given named field

Exceptions
IndexError If field_id negative or not less than trade.SceneData.field_count
AssertionError If scene is not 2D
AssertionError If scene does not have trade.SceneField.PARENT

def magnum.scenetools.children_depth_first(scene: trade.SceneData) -> list[tuple[int, int]]

Retrieve children in a depth-first order

Exceptions
AssertionError If scene does not have trade.SceneField.PARENT

def magnum.scenetools.filter_field_entries(scene: trade.SceneData, entries_to_keep: list[tuple[trade.SceneField, corrade.containers.BitArrayView]]) -> trade.SceneData

Filter individual entries of named fields in a scene

Exceptions
AssertionError If any field in entries_to_keep does not exist in scene
AssertionError If any field in entries_to_keep is listed more than once
AssertionError If size of any array in entries_to_keep does not match trade.SceneData.field_size() for given field

def magnum.scenetools.filter_field_entries(scene: trade.SceneData, entries_to_keep: list[tuple[int, corrade.containers.BitArrayView]]) -> trade.SceneData

Filter individual entries of named fields in a scene

Exceptions
AssertionError If any field in entries_to_keep does not exist in scene
AssertionError If any field in entries_to_keep is listed more than once
AssertionError If size of any array in entries_to_keep does not match trade.SceneData.field_size() for given field

def magnum.scenetools.filter_fields(scene: trade.SceneData, fields_to_keep: corrade.containers.BitArrayView) -> trade.SceneData

Filter a scene to contain only the selected subset of fields

Exceptions
AssertionError If size of fields_to_keep is different than trade.SceneData.field_count

def magnum.scenetools.filter_objects(scene: trade.SceneData, objects_to_keep: corrade.containers.BitArrayView) -> trade.SceneData

Filter objects in a scene

Exceptions
AssertionError If size of objects_to_keep is different than trade.SceneData.mapping_bound

def magnum.scenetools.parents_breadth_first(scene: trade.SceneData) -> list[tuple[int, int]]

Retrieve parents in a breadth-first order

Exceptions
AssertionError If scene does not have trade.SceneField.PARENT