class
SceneDataScene data
Memory ownership and reference counting
The class can be both owning an non-owning depending on the value of
data_flags. If they contain neither DataFlags.OWNED nor
DataFlags.GLOBAL, the owner property references the object
actually owning the data the scene points to. This ensures calling
del
on the original object will not invalidate the data.
Field data access
The class makes use of Python’s dynamic nature and provides direct access to mapping and field data in their concrete types via mapping() and field(). The returned views point to the underlying scene data, element access coverts to a type corresponding to a particular SceneFieldType and for performance-oriented access the view implements a buffer protocol with a corresponding type annotation:
>>> scene = importer.scene(0) >>> list(scene.mapping(trade.SceneField.TRANSLATION)) [1, 3, 0] >>> list(scene.field(trade.SceneField.TRANSLATION)) [Vector(1, 2, 3), Vector(4, 5, 6), Vector(7, 8, 9)] >>> np.array(scene.field(trade.SceneField.TRANSLATION), copy=False)[1] array([4., 5., 6.], dtype=float32)
Depending on the value of data_flags it’s also possible to access the data in a mutable way via mutable_mapping() and mutable_field().
Methods
- def field(self, name: SceneField) -> object
- Data for given named field
- def field(self, id: int) -> object
- Data for given field
- def field_array_size(self, name: SceneField) -> int
- Array size of a named field
- def field_array_size(self, id: int) -> int
- Field array size
- def field_flags(self, name: SceneField) -> SceneFieldFlags
- Flags of a named field
- def field_flags(self, id: int) -> SceneFieldFlags
- Field flags
- def field_id(self, name: SceneField) -> int
- Absolute ID of a named field
- def field_name(self, id: int) -> SceneField
- Field name
- def field_object_offset(self, field_name: SceneField, object: int, offset: int = 0) -> int
- Offset of an object in given name field
- def field_object_offset(self, field_id: int, object: int, offset: int = 0) -> int
- Offset of an object in given field
- def field_size(self, name: SceneField) -> int
- Number of entries in a named field
- def field_size(self, id: int) -> int
- Number of entries in a field
- def field_type(self, name: SceneField) -> SceneFieldType
- Type of a named field
- def field_type(self, id: int) -> SceneFieldType
- Field type
- def has_field(self, arg0: SceneField, /) -> bool
- Whether the scene has given field
- def has_field_object(self, field_name: SceneField, object: int) -> bool
- Whether a scene field has given object
- def has_field_object(self, field_id: int, object: int) -> bool
- Whether a scene field has given object
- def mapping(self, name: SceneField) -> corrade.containers.StridedArrayView1D
- Object mapping data for given named field
- def mapping(self, id: int) -> corrade.containers.StridedArrayView1D
- Object mapping data for given field
- def mutable_field(self, name: SceneField) -> object
- Mutable data for given named field
- def mutable_field(self, id: int) -> object
- Mutable data for given field
- def mutable_mapping(self, name: SceneField) -> corrade.containers.MutableStridedArrayView1D
- Mutable object mapping data for given named field
- def mutable_mapping(self, id: int) -> corrade.containers.MutableStridedArrayView1D
- Mutable object mapping data for given field
Properties
- data_flags: DataFlags get
- Data flags
- field_count: int get
- Field count
- field_size_bound: int get
- Field size bound
- is_2d: bool get
- Whether the scene is two-dimensional
- is_3d: bool get
- Whether the scene is three-dimensional
- mapping_bound: int get
- Object mapping bound
- mapping_type: SceneMappingType get
- Type used for object mapping
- owner: object get
- Memory owner
Method documentation
def magnum. trade. SceneData. field(self,
name: SceneField) -> object
Data for given named field
Exceptions | |
---|---|
KeyError | If name does not exist |
NotImplementedError | If field_array_size() for given field is
not 0 |
NotImplementedError | If field_type() for given field is a string type |
def magnum. trade. SceneData. field(self,
id: int) -> object
Data for given field
Exceptions | |
---|---|
IndexError | If id is negative or not less than
field_count |
NotImplementedError | If field_array_size() for given field is
not 0 |
NotImplementedError | If field_type() for given field is a string type |
def magnum. trade. SceneData. field_array_size(self,
name: SceneField) -> int
Array size of a named field
Exceptions | |
---|---|
KeyError | If name does not exist |
def magnum. trade. SceneData. field_array_size(self,
id: int) -> int
Field array size
Exceptions | |
---|---|
IndexError | If id is negative or not less than
field_count |
def magnum. trade. SceneData. field_flags(self,
name: SceneField) -> SceneFieldFlags
Flags of a named field
Exceptions | |
---|---|
KeyError | If name does not exist |
def magnum. trade. SceneData. field_flags(self,
id: int) -> SceneFieldFlags
Field flags
Exceptions | |
---|---|
IndexError | If id is negative or not less than
field_count |
def magnum. trade. SceneData. field_id(self,
name: SceneField) -> int
Absolute ID of a named field
Exceptions | |
---|---|
KeyError | If name does not exist |
def magnum. trade. SceneData. field_name(self,
id: int) -> SceneField
Field name
Exceptions | |
---|---|
IndexError | If id is negative or not less than
field_count |
def magnum. trade. SceneData. field_object_offset(self,
field_name: SceneField,
object: int,
offset: int = 0) -> int
Offset of an object in given name field
Exceptions | |
---|---|
KeyError | If field_name does not exist |
IndexError | If object is negative or not less than
mapping_bound |
IndexError | If offset is negative or larger than
field_size() for given field |
LookupError | If object is not found |
def magnum. trade. SceneData. field_object_offset(self,
field_id: int,
object: int,
offset: int = 0) -> int
Offset of an object in given field
Exceptions | |
---|---|
IndexError | If field_id is negative or not less than
field_count |
IndexError | If object is negative or not less than
mapping_bound |
IndexError | If offset is negative or larger than
field_size() for given field |
LookupError | If object is not found |
def magnum. trade. SceneData. field_size(self,
name: SceneField) -> int
Number of entries in a named field
Exceptions | |
---|---|
KeyError | If name does not exist |
def magnum. trade. SceneData. field_size(self,
id: int) -> int
Number of entries in a field
Exceptions | |
---|---|
IndexError | If id is negative or not less than
field_count |
def magnum. trade. SceneData. field_type(self,
name: SceneField) -> SceneFieldType
Type of a named field
Exceptions | |
---|---|
KeyError | If name does not exist |
def magnum. trade. SceneData. field_type(self,
id: int) -> SceneFieldType
Field type
Exceptions | |
---|---|
IndexError | If id is negative or not less than
field_count |
def magnum. trade. SceneData. has_field_object(self,
field_name: SceneField,
object: int) -> bool
Whether a scene field has given object
Exceptions | |
---|---|
KeyError | If field_name does not exist |
IndexError | If object is negative or not less than
mapping_bound |
def magnum. trade. SceneData. has_field_object(self,
field_id: int,
object: int) -> bool
Whether a scene field has given object
Exceptions | |
---|---|
IndexError | If field_id is negative or not less than
field_count |
IndexError | If object is negative or not less than
mapping_bound |
def magnum. trade. SceneData. mapping(self,
name: SceneField) -> corrade.containers.StridedArrayView1D
Object mapping data for given named field
Exceptions | |
---|---|
KeyError | If name does not exist |
def magnum. trade. SceneData. mapping(self,
id: int) -> corrade.containers.StridedArrayView1D
Object mapping data for given field
Exceptions | |
---|---|
IndexError | If id is negative or not less than
field_count |
def magnum. trade. SceneData. mutable_field(self,
name: SceneField) -> object
Mutable data for given named field
Exceptions | |
---|---|
KeyError | If name does not exist |
AttributeError | If data_flags doesn’t contain DataFlags.MUTABLE |
NotImplementedError | If field_array_size() for given field is
not 0 |
NotImplementedError | If field_type() for given field is a string type |
def magnum. trade. SceneData. mutable_field(self,
id: int) -> object
Mutable data for given field
Exceptions | |
---|---|
IndexError | If id is negative or not less than
field_count |
AttributeError | If data_flags doesn’t contain DataFlags.MUTABLE |
NotImplementedError | If field_array_size() for given field is
not 0 |
NotImplementedError | If field_type() for given field is a string type |
def magnum. trade. SceneData. mutable_mapping(self,
name: SceneField) -> corrade.containers.MutableStridedArrayView1D
Mutable object mapping data for given named field
Exceptions | |
---|---|
KeyError | If name does not exist |
AttributeError | If data_flags doesn’t contain DataFlags.MUTABLE |
def magnum. trade. SceneData. mutable_mapping(self,
id: int) -> corrade.containers.MutableStridedArrayView1D
Mutable object mapping data for given field
Exceptions | |
---|---|
IndexError | If id is negative or not less than
field_count |
AttributeError | If data_flags doesn’t contain DataFlags.MUTABLE |