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.trade.AbstractSceneConverter class

Interface for scene converter plugins

Similarly to C++, image converter plugins are loaded through SceneConverterManager:

>>> manager = trade.SceneConverterManager()
>>> converter = manager.load_and_instantiate('StanfordSceneConverter')

Unlike C++, errors in both API usage and file parsing are reported by raising an exception. See particular function documentation for detailed behavior.

Methods

def abort(self, /) -> None
Abort any in-progress conversion
def add(self, scene: SceneData, name: str = '') -> int
Add a scene
def add(self, mesh: MeshData, name: str = '') -> int
Add a mesh
def add(self, image: ImageData2D, name: str = '') -> int
Add a 2D image
def add(self, material: MaterialData, name: str = '') -> int
Add a material
def add_importer_contents(self, importer: AbstractImporter, contents: SceneContents = SceneContents.ALL) -> None
Add importer contents
def add_supported_importer_contents(self, importer: AbstractImporter, contents: SceneContents = SceneContents.ALL) -> None
Add supported importer contents
def begin_file(self, filename: str) -> None
Begin converting a scene to a file
def convert(self, mesh: MeshData) -> typing.Optional[MeshData]
Convert a mesh
def convert_in_place(self, mesh: MeshData) -> None
Convert a mesh in-place
def convert_to_file(self, mesh: MeshData, filename: str) -> None
Convert a mesh to a file
def end_file(self, /) -> None
End converting a scene to a file
def set_default_scene(self, id: int) -> None
Set default scene
def set_mesh_attribute_name(self, attribute: MeshAttribute, name: str) -> None
Set name of a custom mesh attribute
def set_scene_field_name(self, field: SceneField, name: str) -> None
Set name of a custom scene field

Properties

configuration: corrade.utility.ConfigurationGroup get
Plugin-specific configuration
features: SceneConverterFeatures get
Features supported by this converter
flags: SceneConverterFlags get set
Converter flags
image2d_count: int get
Count of added 2D images
is_converting: bool get
Whether any conversion is in progress
manager: object get
Manager owning this plugin instance
material_count: int get
Count of added materials
mesh_count: int get
Count of added meshes
metadata: corrade.pluginmanager.PluginMetadata get
Plugin metadata
plugin: str get
Plugin identifier string
scene_count: int get
Count of added scenes

Data

plugin_interface: str
Plugin interface string
plugin_metadata_suffix: str
Plugin metadata suffix
plugin_search_paths: typing.List[str]
Plugin search paths
plugin_suffix: str
Plugin suffix

Method documentation

def magnum.trade.AbstractSceneConverter.add(self, scene: SceneData, name: str = '') -> int

Add a scene

Exceptions
AssertionError If SceneConverterFeatures.ADD_SCENES is not supported
AssertionError If no conversion is in progress
RuntimeError If adding the data fails

def magnum.trade.AbstractSceneConverter.add(self, mesh: MeshData, name: str = '') -> int

Add a mesh

Exceptions
AssertionError If SceneConverterFeatures.ADD_MESHES is not supported, or alternatively at least one of SceneConverterFeatures.CONVERT_MESH, SceneConverterFeatures.CONVERT_MESH_TO_DATA or SceneConverterFeatures.CONVERT_MESH_TO_FILE is not supported
AssertionError If no conversion is in progress
RuntimeError If adding the data fails

def magnum.trade.AbstractSceneConverter.add(self, image: ImageData2D, name: str = '') -> int

Add a 2D image

Exceptions
AssertionError If ImageData2D.is_compressed is False and SceneConverterFeatures.ADD_IMAGES2D is not supported
AssertionError If ImageData2D.is_compressed is True and SceneConverterFeatures.ADD_COMPRESSED_IMAGES2D is not supported
AssertionError If no conversion is in progress
RuntimeError If adding the data fails

def magnum.trade.AbstractSceneConverter.add(self, material: MaterialData, name: str = '') -> int

Add a material

Exceptions
AssertionError If SceneConverterFeatures.ADD_MATERIALS is not supported
AssertionError If no conversion is in progress
RuntimeError If adding the data fails

def magnum.trade.AbstractSceneConverter.add_importer_contents(self, importer: AbstractImporter, contents: SceneContents = SceneContents.ALL) -> None

Add importer contents

Exceptions
AssertionError If no conversion is in progress
RuntimeError If adding the importer contents fails

def magnum.trade.AbstractSceneConverter.add_supported_importer_contents(self, importer: AbstractImporter, contents: SceneContents = SceneContents.ALL) -> None

Add supported importer contents

Exceptions
AssertionError If importer is not opened
AssertionError If no conversion is in progress
RuntimeError If adding the importer contents fails

def magnum.trade.AbstractSceneConverter.begin_file(self, filename: str) -> None

Begin converting a scene to a file

Exceptions
AssertionError If neither SceneConverterFeatures.CONVERT_MULTIPLE_TO_FILE nor SceneConverterFeatures.CONVERT_MESH_TO_FILE is supported
RuntimeError If beginning the conversion fails

For compatibility with os.path, on Windows this function converts all backslashes in filename to forward slashes before passing it to Trade::AbstractSceneConverter::beginFile(), which expects forward slashes as directory separators on all platforms.

def magnum.trade.AbstractSceneConverter.convert(self, mesh: MeshData) -> typing.Optional[MeshData]

Convert a mesh

Exceptions
AssertionError If trade.SceneConverterFeatures.CONVERT_MESH is not supported
RuntimeError If conversion fails

def magnum.trade.AbstractSceneConverter.convert_in_place(self, mesh: MeshData) -> None

Convert a mesh in-place

Exceptions
AssertionError If trade.SceneConverterFeatures.CONVERT_MESH_IN_PLACE is not supported
RuntimeError If conversion fails

def magnum.trade.AbstractSceneConverter.convert_to_file(self, mesh: MeshData, filename: str) -> None

Convert a mesh to a file

Exceptions
AssertionError If neither SceneConverterFeatures.CONVERT_MESH_TO_FILE nor the combination of SceneConverterFeatures.CONVERT_MULTIPLE_TO_FILE and SceneConverterFeatures.ADD_MESHES is supported
RuntimeError If conversion fails

For compatibility with os.path, on Windows this function converts all backslashes in filename to forward slashes before passing it to Trade::AbstractSceneConverter::convertToFile(), which expects forward slashes as directory separators on all platforms.

def magnum.trade.AbstractSceneConverter.end_file(self, /) -> None

End converting a scene to a file

Exceptions
AssertionError If no conversion is in progress
RuntimeError If ending the conversion fails

def magnum.trade.AbstractSceneConverter.set_default_scene(self, id: int) -> None

Set default scene

Exceptions
AssertionError If trade.SceneConverterFeatures.ADD_SCENES is not supported
AssertionError If no conversion is in progress
AssertionError If id is negative or not less than scene_count

def magnum.trade.AbstractSceneConverter.set_mesh_attribute_name(self, attribute: MeshAttribute, name: str) -> None

Set name of a custom mesh attribute

Exceptions
AssertionError If none of SceneConverterFeatures.ADD_MESHES, SceneConverterFeatures.CONVERT_MESH, SceneConverterFeatures.CONVERT_MESH_IN_PLACE, SceneConverterFeatures.CONVERT_MESH_TO_DATA or SceneConverterFeatures.CONVERT_MESH_TO_FILE is supported
AssertionError If no conversion is in progress
AssertionError If attribute is not custom

def magnum.trade.AbstractSceneConverter.set_scene_field_name(self, field: SceneField, name: str) -> None

Set name of a custom scene field

Exceptions
AssertionError If trade.SceneConverterFeatures.ADD_SCENES is not supported
AssertionError If no conversion is in progress
AssertionError If field is not custom

Property documentation

magnum.trade.AbstractSceneConverter.material_count: int get

Count of added materials

Exceptions
AssertionError If no conversion is in progress

magnum.trade.AbstractSceneConverter.mesh_count: int get

Count of added meshes

Exceptions
AssertionError If no conversion is in progress

magnum.trade.AbstractSceneConverter.scene_count: int get

Count of added scenes

Exceptions
AssertionError If no conversion is in progress