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 module

Data format exchange

Classes

class AbstractImageConverter
Interface for image converter plugins
class AbstractImporter
Interface for importer plugins
class AbstractSceneConverter
Interface for scene converter plugins
class ImageConverterManager
Manager for AbstractImageConverter plugin instances
class ImageData1D
One-dimensional image data
class ImageData2D
Two-dimensional image data
class ImageData3D
Three-dimensional image data
class ImporterManager
Manager for AbstractImporter plugin instances
class MaterialData
Material data
class MeshAttributeData
Mesh attribute data
class MeshData
Mesh data
class SceneConverterManager
Manager for AbstractSceneConverter plugin instances
class SceneData
Scene data
class SceneFieldData
Scene field data
class TextureData
Texture data

Enums

class DataFlags: OWNED = 1 EXTERNALLY_OWNED = 8 GLOBAL = 16 MUTABLE = 4 NONE = 0
Data flags
class ImageConverterFeatures: CONVERT1D = 1 CONVERT2D = 2 CONVERT3D = 8 CONVERT_COMPRESSED1D = 16 CONVERT_COMPRESSED2D = 32 CONVERT_COMPRESSED3D = 64 CONVERT1D_TO_FILE = 128 CONVERT2D_TO_FILE = 256 CONVERT3D_TO_FILE = 512 CONVERT_COMPRESSED1D_TO_FILE = 1024 CONVERT_COMPRESSED2D_TO_FILE = 2048 CONVERT_COMPRESSED3D_TO_FILE = 4096 CONVERT1D_TO_DATA = 8320 CONVERT2D_TO_DATA = 8448 CONVERT3D_TO_DATA = 8704 CONVERT_COMPRESSED1D_TO_DATA = 9216 CONVERT_COMPRESSED2D_TO_DATA = 10240 CONVERT_COMPRESSED3D_TO_DATA = 12288 LEVELS = 16384 NONE = 0
Features supported by an image converter
class ImageConverterFlags: QUIET = 2 VERBOSE = 1 NONE = 0
Image converter flags
class ImporterFeatures: OPEN_DATA = 1 OPEN_STATE = 2 FILE_CALLBACK = 4 NONE = 0
Features supported by an image converter
class ImporterFlags: QUIET = 2 VERBOSE = 1 NONE = 0
Importer flags
class MaterialAlphaMode: OPAQUE = 0 MASK = 1 BLEND = 2
Material alpha mode
class MaterialAttribute: LAYER_NAME = 1 ALPHA_MASK = 2 ALPHA_BLEND = 3 DOUBLE_SIDED = 4 AMBIENT_COLOR = 5 AMBIENT_TEXTURE = 6 AMBIENT_TEXTURE_MATRIX = 7 AMBIENT_TEXTURE_COORDINATES = 8 AMBIENT_TEXTURE_LAYER = 9 DIFFUSE_COLOR = 10 DIFFUSE_TEXTURE = 11 DIFFUSE_TEXTURE_MATRIX = 12 DIFFUSE_TEXTURE_COORDINATES = 13 DIFFUSE_TEXTURE_LAYER = 14 SPECULAR_COLOR = 15 SPECULAR_TEXTURE = 16 SPECULAR_TEXTURE_SWIZZLE = 17 SPECULAR_TEXTURE_MATRIX = 18 SPECULAR_TEXTURE_COORDINATES = 19 SPECULAR_TEXTURE_LAYER = 20 SHININESS = 21 BASE_COLOR = 22 BASE_COLOR_TEXTURE = 23 BASE_COLOR_TEXTURE_MATRIX = 24 BASE_COLOR_TEXTURE_COORDINATES = 25 BASE_COLOR_TEXTURE_LAYER = 26 METALNESS = 27 METALNESS_TEXTURE = 28 METALNESS_TEXTURE_SWIZZLE = 29 METALNESS_TEXTURE_MATRIX = 30 METALNESS_TEXTURE_COORDINATES = 31 METALNESS_TEXTURE_LAYER = 32 ROUGHNESS = 33 ROUGHNESS_TEXTURE = 34 ROUGHNESS_TEXTURE_SWIZZLE = 35 ROUGHNESS_TEXTURE_MATRIX = 36 ROUGHNESS_TEXTURE_COORDINATES = 37 ROUGHNESS_TEXTURE_LAYER = 38 NONE_ROUGHNESS_METALLIC_TEXTURE = 39 GLOSSINESS = 40 GLOSSINESS_TEXTURE = 41 GLOSSINESS_TEXTURE_SWIZZLE = 42 GLOSSINESS_TEXTURE_MATRIX = 43 GLOSSINESS_TEXTURE_COORDINATES = 44 GLOSSINESS_TEXTURE_LAYER = 45 SPECULAR_GLOSSINESS_TEXTURE = 46 NORMAL_TEXTURE = 47 NORMAL_TEXTURE_SCALE = 48 NORMAL_TEXTURE_SWIZZLE = 49 NORMAL_TEXTURE_MATRIX = 50 NORMAL_TEXTURE_COORDINATES = 51 NORMAL_TEXTURE_LAYER = 52 OCCLUSION_TEXTURE = 53 OCCLUSION_TEXTURE_STRENGTH = 54 OCCLUSION_TEXTURE_SWIZZLE = 55 OCCLUSION_TEXTURE_MATRIX = 56 OCCLUSION_TEXTURE_COORDINATES = 57 OCCLUSION_TEXTURE_LAYER = 58 EMISSIVE_COLOR = 59 EMISSIVE_TEXTURE = 60 EMISSIVE_TEXTURE_MATRIX = 61 EMISSIVE_TEXTURE_COORDINATES = 62 EMISSIVE_TEXTURE_LAYER = 63 LAYER_FACTOR = 64 LAYER_FACTOR_TEXTURE = 65 LAYER_FACTOR_TEXTURE_SWIZZLE = 66 LAYER_FACTOR_TEXTURE_MATRIX = 67 LAYER_FACTOR_TEXTURE_COORDINATES = 68 LAYER_FACTOR_TEXTURE_LAYER = 69 TEXTURE_MATRIX = 70 TEXTURE_COORDINATES = 71 TEXTURE_LAYER = 72
Material attribute name
class MaterialAttributeType: BOOL = 1 FLOAT = 2 DEG = 3 RAD = 4 UNSIGNED_INT = 5 INT = 6 UNSIGNED_LONG = 7 LONG = 8 VECTOR2 = 9 VECTOR2UI = 10 VECTOR2I = 11 VECTOR3 = 12 VECTOR3UI = 13 VECTOR3I = 14 VECTOR4 = 15 VECTOR4UI = 16 VECTOR4I = 17 MATRIX2X2 = 18 MATRIX2X3 = 19 MATRIX2X4 = 20 MATRIX3X2 = 21 MATRIX3X3 = 22 MATRIX3X4 = 23 MATRIX4X2 = 24 MATRIX4X3 = 25 POINTER = 26 MUTABLE_POINTER = 27 STRING = 28 BUFFER = 29 TEXTURE_SWIZZLE = 30
Material attribute type
class MaterialLayer: CLEAR_COAT = 1
Material layer name
class MaterialTextureSwizzle: R = 82 G = 71 B = 66 A = 65 RG = 18258 GB = 16967 GA = 16711 BA = 16706 RGB = 4343634 GBA = 4276807 RGBA = 1094862674
Material texture swizzle
class MaterialTypes: FLAT = 1 PHONG = 2 PBR_METALLIC_ROUGHNESS = 4 PBR_SPECULAR_GLOSSINESS = 8 PBR_CLEAR_COAT = 16 NONE = 0 ALL = 4294967295
Material types
class MeshAttribute: POSITION = 1 TANGENT = 2 BITANGENT = 3 NORMAL = 4 TEXTURE_COORDINATES = 5 COLOR = 6 JOINT_IDS = 7 WEIGHTS = 8 OBJECT_ID = 9
Mesh attribute name
class SceneContents: SCENES = 1 ANIMATIONS = 2 LIGHTS = 4 CAMERAS = 8 SKINS2D = 16 SKINS3D = 32 MESHES = 64 MATERIALS = 128 TEXTURES = 256 IMAGES1D = 512 IMAGES2D = 1024 IMAGES3D = 2048 MESH_LEVELS = 4096 IMAGE_LEVELS = 8192 NAMES = 16384 ALL = 4294967295
Scene contents
class SceneConverterFeatures: CONVERT_MESH = 1 CONVERT_MESH_IN_PLACE = 2 CONVERT_MESH_TO_FILE = 4 CONVERT_MESH_TO_DATA = 12 CONVERT_MULTIPLE = 16 CONVERT_MULTIPLE_TO_FILE = 32 CONVERT_MULTIPLE_TO_DATA = 96 ADD_SCENES = 128 ADD_ANIMATIONS = 256 ADD_LIGHTS = 512 ADD_CAMERAS = 1024 ADD_SKINS2D = 2048 ADD_SKINS3D = 4096 ADD_MESHES = 8192 ADD_MATERIALS = 16384 ADD_TEXTURES = 32768 ADD_IMAGES1D = 65536 ADD_IMAGES2D = 131072 ADD_IMAGES3D = 262144 ADD_COMPRESSED_IMAGES1D = 524288 ADD_COMPRESSED_IMAGES2D = 1048576 ADD_COMPRESSED_IMAGES3D = 2097152 MESH_LEVELS = 4194304 IMAGE_LEVELS = 8388608 NONE = 0
Features supported by a scene converter
class SceneConverterFlags: QUIET = 2 VERBOSE = 1 NONE = 0
Scene converter flags
class SceneField: PARENT = 1 TRANSFORMATION = 2 TRANSLATION = 3 ROTATION = 4 SCALING = 5 MESH = 6 MESH_MATERIAL = 7 LIGHT = 8 CAMERA = 9 SKIN = 10 IMPORTER_STATE = 11
Scene field name
class SceneFieldFlags: OFFSET_ONLY = 1 ORDERED_MAPPING = 2 IMPLICIT_MAPPING = 6 MULTI_ENTRY = 16 NULL_TERMINATED_STRING = 8 NONE = 0
Scene field flags
class SceneFieldType: BIT = 13 FLOAT = 14 HALF = 15 DOUBLE = 16 UNSIGNED_BYTE = 17 BYTE = 18 UNSIGNED_SHORT = 19 SHORT = 20 UNSIGNED_INT = 21 INT = 22 UNSIGNED_LONG = 23 LONG = 24 VECTOR2 = 25 VECTOR2H = 26 VECTOR2D = 27 VECTOR2UB = 28 VECTOR2B = 29 VECTOR2US = 30 VECTOR2S = 31 VECTOR2UI = 32 VECTOR2I = 33 VECTOR3 = 34 VECTOR3H = 35 VECTOR3D = 36 VECTOR3UB = 37 VECTOR3B = 38 VECTOR3US = 39 VECTOR3S = 40 VECTOR3UI = 41 VECTOR3I = 42 VECTOR4 = 43 VECTOR4H = 44 VECTOR4D = 45 VECTOR4UB = 46 VECTOR4B = 47 VECTOR4US = 48 VECTOR4S = 49 VECTOR4UI = 50 VECTOR4I = 51 MATRIX2X2 = 52 MATRIX2X2H = 53 MATRIX2X2D = 54 MATRIX2X3 = 55 MATRIX2X3H = 56 MATRIX2X3D = 57 MATRIX2X4 = 58 MATRIX2X4H = 59 MATRIX2X4D = 60 MATRIX3X2 = 61 MATRIX3X2H = 62 MATRIX3X2D = 63 MATRIX3X3 = 64 MATRIX3X3H = 65 MATRIX3X3D = 66 MATRIX3X4 = 67 MATRIX3X4H = 68 MATRIX3X4D = 69 MATRIX4X2 = 70 MATRIX4X2H = 71 MATRIX4X2D = 72 MATRIX4X3 = 73 MATRIX4X3H = 74 MATRIX4X3D = 75 MATRIX4X4 = 76 MATRIX4X4H = 77 MATRIX4X4D = 78 RANGE1D = 79 RANGE1DH = 80 RANGE1DD = 81 RANGE1DI = 82 RANGE2D = 83 RANGE2DH = 84 RANGE2DD = 85 RANGE2DI = 86 RANGE3D = 87 RANGE3DH = 88 RANGE3DD = 89 RANGE3DI = 90 COMPLEX = 91 COMPLEXD = 92 DUAL_COMPLEX = 93 DUAL_COMPLEXD = 94 QUATERNION = 95 QUATERNIOND = 96 DUAL_QUATERNION = 97 DUAL_QUATERNIOND = 98 DEG = 99 DEGH = 100 DEGD = 101 RAD = 102 RADH = 103 RADD = 104 POINTER = 105 MUTABLE_POINTER = 106 STRING_OFFSET32 = 3 STRING_OFFSET8 = 1 STRING_OFFSET16 = 2 STRING_OFFSET64 = 4 STRING_RANGE32 = 7 STRING_RANGE8 = 5 STRING_RANGE16 = 6 STRING_RANGE64 = 8 STRING_RANGE_NULL_TERMINATED32 = 11 STRING_RANGE_NULL_TERMINATED8 = 9 STRING_RANGE_NULL_TERMINATED16 = 10 STRING_RANGE_NULL_TERMINATED64 = 12
Scene field type
class SceneMappingType: UNSIGNED_BYTE = 1 UNSIGNED_SHORT = 2 UNSIGNED_INT = 3 UNSIGNED_LONG = 4
Scene object mapping type
class TextureType: TEXTURE1D = 0 TEXTURE1D_ARRAY = 1 TEXTURE2D = 2 TEXTURE2D_ARRAY = 3 TEXTURE3D = 4 CUBE_MAP = 5 CUBE_MAP_ARRAY = 6
Texture type

Enum documentation

class magnum.trade.MaterialAttribute()

Material attribute name

The equivalent to C++ Trade::materialAttributeName() is the string property, as name is reserved for the Python enum name.

>>> attribute = trade.MaterialAttribute.BASE_COLOR_TEXTURE_MATRIX
>>> attribute.name
'BASE_COLOR_TEXTURE_MATRIX'
>>> attribute.string
'BaseColorTextureMatrix'

class magnum.trade.MaterialLayer()

Material layer name

The equivalent to C++ Trade::materialLayerName() is the string property, as name is reserved for the Python enum name.

>>> layer = trade.MaterialLayer.CLEAR_COAT
>>> layer.name
'CLEAR_COAT'
>>> layer.string
'ClearCoat'

class magnum.trade.MaterialTextureSwizzle()

Material texture swizzle

The component_count property matches Trade::materialTextureSwizzleComponentCount().

>>> trade.MaterialTextureSwizzle.GA.component_count
2

class magnum.trade.MeshAttribute()

Mesh attribute name

The equivalent to C++ Trade::meshAttributeCustom() is creating an enum value using a CUSTOM() named constructor. The is_custom property then matches Trade::isMeshAttributeCustom() and you can retrieve the custom ID again with a custom_value property.

>>> attribute = trade.MeshAttribute.CUSTOM(17)
>>> attribute.name
'CUSTOM(17)'
>>> attribute.is_custom
True
>>> attribute.custom_value
17

class magnum.trade.SceneContents()

Scene contents

The equivalent to C++ Trade::sceneContentsFor() is creating an enum value using a FOR() named constructor, passing either an AbstractSceneConverter or an opened AbstractImporter to it.

class magnum.trade.SceneField()

Scene field name

The equivalent to C++ Trade::sceneFieldCustom() is creating an enum value using a CUSTOM() named constructor. The is_custom property then matches Trade::isSceneFieldCustom() and you can retrieve the custom ID again with a custom_value property.

>>> attribute = trade.SceneField.CUSTOM(17)
>>> attribute.name
'CUSTOM(17)'
>>> attribute.is_custom
True
>>> attribute.custom_value
17