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

scene: trade.SceneData, field: trade.SceneField, global_transformation: Matrix3 = Matrix(1, 0, 0, 0, 1, 0, 0, 0, 1)) -> typing.List[Matrix3]
Calculate absolute 2D transformations for given field
scene: trade.SceneData, field_id: int, global_transformation: Matrix3 = Matrix(1, 0, 0, 0, 1, 0, 0, 0, 1)) -> typing.List[Matrix3]
Calculate absolute 2D transformations for given named field
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)) -> typing.List[Matrix4]
Calculate absolute 3D transformations for given field
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)) -> typing.List[Matrix4]
Calculate absolute 2D transformations for given named field
Retrieve children in a depth-first order
Combine scene fields together
Filter a scene to contain everything the selected subset of named fields
Filter individual entries of named fields in a scene
Filter individual entries of named fields in a scene
Filter a scene to contain only the selected subset of fields
Filter objects in a scene
Filter a scene to contain only the selected subset of named fields
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)) -> typing.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)) -> typing.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)) -> typing.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)) -> typing.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) -> typing.List[typing.Tuple[int, int]]

Retrieve children in a depth-first order

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

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

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

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

AssertionError If size of `objects_to_keep` is different than trade.SceneData.mapping_bound
AssertionError If `scene` does not have trade.SceneField.PARENT