Magnum::Trade::SceneData class

Scene data.

Contains scene node hierarchy, transformations, resource assignment as well as any other data associated with the scene. Populated instances of this class are returned from AbstractImporter::scene() as well as from various SceneTools algorithms.

Data representation and terminology

materials textures meshes transforms parents physics camera material mesh skin material mesh light material mesh skin light camera light transform transform transform transform transform transform mesh transform transform material 3 5 7 0 6 2 1 4 material #2 mesh #2

The usual mental image of a scene is a tree hierarchy with varying amount of data attached to each node, like shown in the first diagram. The SceneData however decouples the hierarchy from the data and stores everything in linear arrays, like in the second diagram.

This allows for a more efficient storage, as only the actually needed information is stored. For example, three nodes in the tree have an implicit transformation, which we can simply omit, or because there might be way less materials than meshes, their references can be in a smaller type. It's also more flexible — having multiple meshes per node is just about having multiple entries associated with the same node.

materials skins meshes transforms parents lights cameras 7 1 0 5 3 6 2 4 1 0 5 6 2 1 1 5 0 4 5 6 3 2 5 6 3 2 2 6 6

From a high-level perspective, the scene data storage can thought of as a set of Fields, with field entries mapped to Objects. Scene Nodes are a special case of Objects.

An Object is an arbitrary numeric identifier, not containing anything on its own. All objects referenced by a particular scene are contained in a range from 0 up to mappingBound() minus one. The range is allowed to be sparse.

A Field is a list of data — for example transformations, mesh IDs, or parent objects. The SceneField enum lists all predefined fields together with possible restrictions and the expected SceneFieldType they're expected to be in. Custom fields are supported as well. Field entries are mapped to objects with the same 8-, 16-, 32- or 64-bit type for all fields, indicated with SceneMappingType. Generally there's a 1:N mapping between objects and fields (not all objects need to have a transformation, a single object can reference multiple meshes...), but certain field types expect various restrictions (such as an object allowed to only have one parent or transformation).

Finally, scene Nodes are Objects that have the SceneField::Parent field associated. An Object thus doesn't have to represent just a node in the hierarchy. For example, a scene can also contain an alternative representation in the form of an octree, and thus some objects would be nodes and some octree cells.

Object identifiers and multiple scenes

For a standalone scene, a common case is that the object identifiers form a contigous range of numbers, and each of the objects has at least one field assigned.

The AbstractImporter supports files with multiple scenes. All imported scenes share a single object range, from 0 to AbstractImporter::objectCount(). A particular object can be part of any of the scenes, causing the SceneData::mappingBound() ranges to be sparse — a particular scene having certain object IDs that have no fields assigned. This is something to be aware of when consuming the scene data, that not all objects identifiers in the mapping range may actually exist.

It's also possible for a single object identifier to be contained in multiple scenes at the same time — for example, when two scenes are variants of the same model, with most data shared but certain textures or colors different. Another theoretical use case is that an object could identify a building in a 3D scene and a corresponding area on a map in a 2D scene. There's no set of rules the objects should follow, but such identifier reusal should not be abused for completely unrelated objects.

Basic usage

A simple goal could be to populate a SceneGraph with a node hierarchy and attach drawables for meshes where appropriate. First we check if the scene is 3D with is3D(), because if it's not, it could mean it's either 2D or that it has no transformation field altogether, suggesting a need for specialized handling. It's also of no use for this example if there's no node hierarchy, or if there are no meshes we could draw.

Then we create the scene instance and an array of pointers that will act as a map from object identifiers to live objects. The mappingBound() is an upper bound to all object identifiers referenced by the scene, but as mentioned above, not all of them may be actual nodes so we don't allocate actual scene graph object instances for them yet. Alternatively, for very sparse ranges, a hashmap could be also used here.

Trade::SceneData data = ;
if(!data.is3D() ||
   !data.hasField(Trade::SceneField::Parent) ||
   !data.hasField(Trade::SceneField::Mesh))
    Fatal{} << "Oh noes!";

Scene3D scene;
Containers::Array<Object3D*> objects{std::size_t(data.mappingBound())};

Next we go through objects that have an associated parent using parentsAsArray(). Those are the actual nodes we want, so we allocate a scene graph object for each ...

auto parents = data.parentsAsArray();
for(Containers::Pair<UnsignedInt, Int>& parent: parents)
    objects[parent.first()] = new Object3D{};

... and then we assign a proper parent, or add it directly to the scene if the parent is -1. We do this in a separate pass to ensure the parent object is already allocated by the time we pass it to SceneGraph::Object::setParent() — generally there's no guarantee that a parent appears in the field before its children.

for(Containers::Pair<UnsignedInt, Int>& parent: parents)
    objects[parent.first()]->setParent(
        parent.second() == -1 ? &scene : objects[parent.second()]
    );

With the hierarchy done, we assign transformations. The transformation field can be present for only a subset of the nodes, with the rest implicitly having an indentity transformation, but it can also be present for objects that aren't nodes, so we only set it for objects present in our hierarchy. The transformations3DAsArray() function also conveniently converts separate transformation / rotation / scaling fields into a matrix for us, if the scene contains only those.

for(Containers::Pair<UnsignedInt, Matrix4>& transformation:
    data.transformations3DAsArray())
{
    if(Object3D* const object = objects[transformation.first()])
        object->setTransformation(transformation.second());
}

Finally, assuming there's a Drawable class derived from SceneGraph::Drawable that accepts a mesh and material ID (retrieving them subsequently from AbstractImporter::mesh() / material(), for example), the process of assigning actual meshes to corresponding scene nodes is just another for loop over meshesMaterialsAsArray():

class Drawable: public SceneGraph::Drawable3D {
    public:
        explicit Drawable(Object3D& object, UnsignedInt mesh, Int material, );

    
};

for(const Containers::Pair<UnsignedInt, Containers::Pair<UnsignedInt, Int>>&
    meshMaterial: data.meshesMaterialsAsArray())
{
    if(Object3D* const object = objects[meshMaterial.first()])
        new Drawable{*object, meshMaterial.second().first(),
                              meshMaterial.second().second(), };
}

Advanced usage

The parentsAsArray(), ... functions shown above always return a newly-allocated Containers::Array instance in a well-defined canonical type. While that's convenient and fine at a smaller scale, it may prove problematic with huge scenes. Or maybe the internal representation is already optimized for best processing efficiency and the convenience functions would ruin that. The SceneData class thus provides access directly to the stored object mapping and field data using the mapping() and field() accessors, together with specialized fieldBits() for accessing bit fields and fieldStrings() for accessing string fields.

However, since each SceneField can be in a variety of types, you're expected to either check that the type is indeed what you expect using fieldType(SceneField) const, or at least check with documentation of the corresponding importer. For example, because glTF files represent the scene in a textual form, GltfImporter will always parse the data into canonical 32-bit types. With that assumption, the above snippet that used transformations3DAsArray() can be rewritten to a zero-copy form like this:

Containers::StridedArrayView1D<const UnsignedInt> transformationMapping =
    data.mapping<UnsignedInt>(Trade::SceneField::Transformation);
Containers::StridedArrayView1D<const Matrix4> transformations =
    data.field<Matrix4>(Trade::SceneField::Transformation);
for(std::size_t i = 0; i != transformationMapping.size(); ++i) {
    if(Object3D* const object = objects[transformationMapping[i]])
        object->setTransformation(transformations[i]);
}

Per-object access

While the designated way to access scene data is by iterating through the field and object arrays, it's also possible to directly look at fields for a particular object without having to do a lookup on your own and with simplified error handling. The parentFor(), childrenFor(), transformation3DFor(), meshesMaterialsFor() and other functions return either an Containers::Optional or an Containers::Array depending on whether there's expected just one occurence of the field or more, returning an empty optional or array if the field is not present in the scene or if the object was not found in the field array.

For example, together with an AbstractImporter instance the scene comes from, the following snippet lists meshes and material names that are associated with a "Chair" object, assuming such object exists:

Containers::Pointer<Trade::AbstractImporter> importer = ;

for(const Containers::Pair<UnsignedInt, Int>& meshMaterial:
   data.meshesMaterialsFor(importer->objectForName("Chair")))
{
    Debug{} << "Mesh:" << importer->meshName(meshMaterial.first());
    if(meshMaterial.second() != -1)
        Debug{} << "With a material:" << importer->materialName(meshMaterial.second());
}

The actual object ID lookup is done by findFieldObjectOffset() and depending on what SceneFieldFlags are present for given field, it can be done in constant, logarithmic or, worst case, linear time. As such, for general scene representations these are suited mainly for introspection and debugging purposes and retrieving field data for many objects is better achieved by accessing the field data directly.

Mutable data access

The interfaces implicitly provide const views on the contained object and field data through the data(), mapping() and field() accessors. This is done because in general case the data can also refer to a memory-mapped file or constant memory. In cases when it's desirable to modify the data in-place, there's the mutableData(), mutableMapping() and mutableField() set of functions. To use these, you need to check that the data are mutable using dataFlags() first. The following snippet updates all transformations with the live state of a scene imported earlier, for example in order to bake in a certain animation state:

Containers::StridedArrayView1D<const UnsignedInt> transformationMapping =
    data.mapping<UnsignedInt>(Trade::SceneField::Transformation);
Containers::StridedArrayView1D<Matrix4> mutableTransformations =
    data.mutableField<Matrix4>(Trade::SceneField::Transformation);
for(std::size_t i = 0; i != transformationMapping.size(); ++i) {
    if(Object3D* const object = objects[transformationMapping[i]])
        mutableTransformations[i] = object->transformation();
}

Populating an instance

The actual data in a SceneData instance are represented as a single block of contiguous memory, which all object and field views point to. This is easiest to achieve with an Containers::ArrayTuple. In the example below, all objects have a parent and a transformation field, which are stored together in a struct, while a subset of them has a mesh and a material assigned, which are stored in separate arrays. And because the scene is small, we save space by using just 16-bit indices for everything.

struct Common {
    UnsignedShort mapping;
    Short parent;
    Matrix4 transformation;
};

Containers::StridedArrayView1D<Common> common;
Containers::ArrayView<UnsignedShort> meshMaterialMapping;
Containers::ArrayView<UnsignedShort> meshes;
Containers::ArrayView<UnsignedShort> meshMaterials;
Containers::Array<char> data = Containers::ArrayTuple{
    {nodeCount, common},
    {meshAssignmentCount, meshMaterialMapping},
    {meshAssignmentCount, meshes},
    {meshAssignmentCount, meshMaterials}
};

// populate the views ...

Trade::SceneData scene{
    Trade::SceneMappingType::UnsignedShort, nodeCount,
    std::move(data), {
        Trade::SceneFieldData{Trade::SceneField::Parent,
            common.slice(&Common::mapping),
            common.slice(&Common::parent)},
        Trade::SceneFieldData{Trade::SceneField::Transformation,
            common.slice(&Common::mapping), common.slice(&Common::transformation)},
        Trade::SceneFieldData{Trade::SceneField::Mesh,
            meshMaterialMapping,
            meshes},
        Trade::SceneFieldData{Trade::SceneField::MeshMaterial,
            meshMaterialMapping,
            meshMaterials}
    }};

Note that the above layout is just an example, you're free to choose any representation that matches your use case best, with fields interleaved together or not. See also the SceneFieldData class documentation for additional ways how to specify and annotate the data.

Non-owned instances and static data layouts

In some cases you may want the SceneData instance to only refer to external data without taking ownership, for example with a memory-mapped file, global data etc. For that, instead of moving in an Containers::Array, pass DataFlags describing data mutability and ownership together with an Containers::ArrayView to the SceneData(SceneMappingType, UnsignedLong, DataFlags, Containers::ArrayView<const void>, Containers::Array<SceneFieldData>&&, const void*) constructor:

constexpr struct Data {
    UnsignedShort mapping;
    Short parent;
    Matrix4 transformation;
} data[objectCount]{
    
};

Trade::SceneData scene{
    Trade::SceneMappingType::UnsignedShort, objectCount,
    Trade::DataFlag::Global, data, {
        Trade::SceneFieldData{Trade::SceneField::Parent,
            Containers::stridedArrayView(data).slice(&Data::mapping),
            Containers::stridedArrayView(data).slice(&Data::parent)},
        
    }};

The SceneFieldData list is still implicitly allocated in the above case, but it can also be defined externally and referenced via sceneFieldDataNonOwningArray() instead if desired. Finally, if the data layout is constant but the actual data is allocated / populated at runtime, the SceneFieldData instances can be defined in a global array as offset-only and then subsequently referenced from a SceneData with a concrete data array:

struct Data {
    UnsignedInt mapping;
    Int parent;
    Matrix4 transformation;
};

/* Layout defined statically */
constexpr Trade::SceneFieldData fields[]{
    Trade::SceneFieldData{Trade::SceneField::Parent, objectCount,
        Trade::SceneMappingType::UnsignedInt, offsetof(Data, mapping), sizeof(Data),
        Trade::SceneFieldType::Int, offsetof(Data, parent), sizeof(Data)},
    Trade::SceneFieldData{Trade::SceneField::Transformation, objectCount,
        Trade::SceneMappingType::UnsignedInt, offsetof(Data, mapping), sizeof(Data),
        Trade::SceneFieldType::Matrix4x4, offsetof(Data, transformation), sizeof(Data)}
};

/* Actual data populated later */
Containers::Array<char> data{objectCount*sizeof(Data)};


/* Using the statically defined field layout */
Trade::SceneData scene{Trade::SceneMappingType::UnsignedInt, objectCount,
    std::move(data), Trade::sceneFieldDataNonOwningArray(fields)};

See also the corresponding SceneFieldData documentation for offset-only fields.

Custom scene fields and non-node objects

Let's say that, in addition to the node hierarchy from above, our scene contains also a precomputed camera-space light culling grid, where each cell of the grid contains a list of lights that affect given area of the screen. And we want to add it into the SceneData for verification with external tools.

For simplicity let's assume we have a 32x24 grid and the shader we have can work with up to 8 lights. So there will be a fixed-size array for each of those cells, and we save calculated frustums for inspection as well. For the new data we allocate object IDs from a range after nodeCount, and copy in the actual data.


Containers::ArrayView<UnsignedShort> cellMapping;
Containers::ArrayView<Matrix4> cellFrustums;
Containers::StridedArrayView2D<Int> cellLights;
Containers::Array<char> data = Containers::ArrayTuple{
    
    {32*24, cellMapping},
    {32*24, cellFrustums},
    {{32*24, 8}, cellLights},
};

for(std::size_t i = 0; i != cellMapping.size(); ++i) {
    cellMapping[i] = nodeCount + i;
    cellFrustums[i] = ;
    for(std::size_t j = 0; j != cellLights[i].size(); ++j)
        cellLights[i][j] = ;
}

Then, similarly as with MeshData, the scene can have custom fields as well, created with sceneFieldCustom(). We create one for the cell light reference array and one for the cell frustum and then use them to annotate the views allocated above. Note that we also increased the total object count to include the light culling grid cells as well.

constexpr Trade::SceneField SceneFieldCellFrustum = Trade::sceneFieldCustom(0);
constexpr Trade::SceneField SceneFieldCellLights = Trade::sceneFieldCustom(1);

Trade::SceneData scene{
    Trade::SceneMappingType::UnsignedShort, nodeCount + cellMapping.size(),
    std::move(data), {
        
        Trade::SceneFieldData{SceneFieldCellFrustum, cellMapping, cellFrustums},
        Trade::SceneFieldData{SceneFieldCellLights, cellMapping, cellLights},
    }};

Later, the fields can be retrieved back using the same custom identifiers. The light references are actually a 2D array (8 lights for each cell), so a [] needs to be used:

Containers::StridedArrayView1D<const Matrix4> cellFrustums =
    scene.field<Matrix4>(SceneFieldCellFrustum);
Containers::StridedArrayView2D<const Int> cellLights =
    scene.field<Int[]>(SceneFieldCellLights);

String fields

Besides fixed-size types and their arrays, the SceneData class is capable of storing strings. A string field consists of a base pointer and a list containing offsets or ranges relative to that base pointer. Such separation allows more efficient storage compared to storing a full pointer (or a pair of a pointer and size) for every field, as it's possible to choose a smaller offset type if the referenced strings fit into a 8- or 16-bit range.

To cover different use cases, there's multiple ways how to store the string references:

  • SceneFieldType::StringOffset32 and its 8-, 16- and 64-bit variants store a running offset into the string array. For example, offsets {3, 11, 23} would mean the first string is from byte 0 to 3, second is from byte 3 to 11 and third from byte 11 to 23. This storage type is most efficient if the strings are unique for each entry — such as various names or external data filenames.
  • SceneFieldType::StringRange32 and its 8-, 16- and 64-bit variants store a pair of offset and size. For example, ranges {{11, 5}, {4, 7}, {11, 5}} would mean the first and third string is from byte 11 to 16 and the second string is from byte 4 to 11. This storage type is thus most efficient when there's many duplicates — such as various object tags or categories.
  • SceneFieldType::StringRangeNullTerminated32 and its 8-, 16- and 64-bit variants are similar to SceneFieldType::StringRange32, but stores just the offset and size is implicitly until the next '\0' byte. Thus it trades a slightly better space efficiency for the cost of a runtime std::strlen() call on every access.

String fields can also have SceneFieldFlag::NullTerminatedString set, in which case the returned Containers::StringView instances will have Containers::StringViewFlag::NullTerminated set, which may be useful for example to avoid an allocation when passing filenames to OS APIs in Utility::Path::read(). The null terminators of course have to be stored in the data itself, see a particular SceneFieldType for information about how it affects the field encoding.

The following example shows populating a SceneData with a "tag" string field, stored as null-terminated 8-bit string array ranges. In other words — assuming there's enough stored data — the space efficiency is the same as if a just a numeric value of an 8-bit enum would be stored, but here it includes human-readable string names.

constexpr Containers::StringView CategoryStrings =
    "wall\0furniture\0lighting\0artwork"_s;
constexpr UnsignedByte CategoryWall = 0;
constexpr UnsignedByte CategoryFurniture = 5;
constexpr UnsignedByte CategoryLighting = 15;
constexpr UnsignedByte CategoryArtwork = 24;

Containers::MutableStringView categoryStrings;
Containers::ArrayView<UnsignedInt> mapping;
Containers::ArrayView<UnsignedByte> categories;
Containers::ArrayTuple data{
    {CategoryStrings.size(), categoryStrings},
    {, mapping},
    {, categories},
};

Utility::copy(CategoryStrings, categoryStrings);
mapping[0] = 7;
categories[0] = CategoryWall;
mapping[1] = 19;
categories[1] = CategoryFurniture;


constexpr Trade::SceneField SceneFieldCategory = Trade::sceneFieldCustom(25);
Trade::SceneData scene{Trade::SceneMappingType::UnsignedInt, , std::move(data), {
    Trade::SceneFieldData{SceneFieldCategory, mapping,
        categoryStrings.data(), Trade::SceneFieldType::StringRangeNullTerminated8,
        categories}
}};

While there's many options how to store the string, retrieving of any string SceneFieldType can be conveniently done using fieldStrings():

Containers::StringIterable categories = scene.fieldStrings(SceneFieldCategory);

// Prints "furniture"
Debug{} << categories[scene.fieldObjectOffset(SceneFieldCategory, 19)];

Constructors, destructors, conversion operators

SceneData(SceneMappingType mappingType, UnsignedLong mappingBound, Containers::Array<char>&& data, Containers::Array<SceneFieldData>&& fields, const void* importerState = nullptr) explicit noexcept new in Git master
Construct scene data.
SceneData(SceneMappingType mappingType, UnsignedLong mappingBound, Containers::Array<char>&& data, std::initializer_list<SceneFieldData> fields, const void* importerState = nullptr) explicit new in Git master
SceneData(SceneMappingType mappingType, UnsignedLong mappingBound, DataFlags dataFlags, Containers::ArrayView<const void> data, Containers::Array<SceneFieldData>&& fields, const void* importerState = nullptr) explicit noexcept new in Git master
Construct non-owned scene data.
SceneData(SceneMappingType mappingType, UnsignedLong mappingBound, DataFlags dataFlags, Containers::ArrayView<const void> data, std::initializer_list<SceneFieldData> fields, const void* importerState = nullptr) explicit new in Git master
SceneData(std::vector<UnsignedInt> children2D, std::vector<UnsignedInt> children3D, const void* importerState = nullptr) deprecated in Git master explicit
Constructor.
SceneData(const SceneData&) deleted
Copying is not allowed.
SceneData(SceneData&&) noexcept
Move constructor.

Public functions

auto operator=(const SceneData&) -> SceneData& deleted
Copying is not allowed.
auto operator=(SceneData&&) -> SceneData& noexcept
Move assignment.
auto dataFlags() const -> DataFlags new in Git master
Data flags.
auto data() const & -> Containers::ArrayView<const char> new in Git master
Raw data.
auto data() const && -> Containers::ArrayView<const char> deleted new in Git master
Taking a view to a r-value instance is not allowed.
auto mutableData() & -> Containers::ArrayView<char> new in Git master
Mutable raw data.
auto mutableData() && -> Containers::ArrayView<char> deleted new in Git master
Taking a view to a r-value instance is not allowed.
auto mappingType() const -> SceneMappingType new in Git master
Type used for object mapping.
auto mappingBound() const -> UnsignedLong new in Git master
Object mapping bound.
auto fieldCount() const -> UnsignedInt new in Git master
Field count.
auto fieldSizeBound() const -> std::size_t new in Git master
Field size bound.
auto fieldData() const & -> Containers::ArrayView<const SceneFieldData> new in Git master
Raw field metadata.
auto fieldData() const && -> Containers::ArrayView<const SceneFieldData> deleted new in Git master
Taking a view to a r-value instance is not allowed.
auto fieldData(UnsignedInt id) const -> SceneFieldData new in Git master
Raw field data.
auto fieldName(UnsignedInt id) const -> SceneField new in Git master
Field name.
auto fieldFlags(UnsignedInt id) const -> SceneFieldFlags new in Git master
Field flags.
auto fieldType(UnsignedInt id) const -> SceneFieldType new in Git master
Field type.
auto fieldSize(UnsignedInt id) const -> std::size_t new in Git master
Number of entries in a field.
auto fieldArraySize(UnsignedInt id) const -> UnsignedShort new in Git master
Field array size.
auto is2D() const -> bool new in Git master
Whether the scene is two-dimensional.
auto is3D() const -> bool new in Git master
Whether the scene is three-dimensional.
auto findFieldId(SceneField name) const -> Containers::Optional<UnsignedInt> new in Git master
Find an absolute ID of a named field.
auto fieldId(SceneField name) const -> UnsignedInt new in Git master
Absolute ID of a named field.
auto hasField(SceneField name) const -> bool new in Git master
Whether the scene has given field.
auto findFieldObjectOffset(UnsignedInt fieldId, UnsignedLong object, std::size_t offset = 0) const -> Containers::Optional<std::size_t> new in Git master
Find offset of an object in given field.
auto findFieldObjectOffset(SceneField fieldName, UnsignedLong object, std::size_t offset = 0) const -> Containers::Optional<std::size_t> new in Git master
Find offset of an object in given named field.
auto fieldObjectOffset(UnsignedInt fieldId, UnsignedLong object, std::size_t offset = 0) const -> std::size_t new in Git master
Offset of an object in given field.
auto fieldObjectOffset(SceneField fieldName, UnsignedLong object, std::size_t offset = 0) const -> std::size_t new in Git master
Offset of an object in given named field.
auto hasFieldObject(UnsignedInt fieldId, UnsignedLong object) const -> bool new in Git master
Whether a scene field has given object.
auto hasFieldObject(SceneField fieldName, UnsignedLong object) const -> bool new in Git master
Whether a named scene field has given object.
auto fieldFlags(SceneField name) const -> SceneFieldFlags new in Git master
Flags of a named field.
auto fieldType(SceneField name) const -> SceneFieldType new in Git master
Type of a named field.
auto fieldSize(SceneField name) const -> std::size_t new in Git master
Number of entries in a named field.
auto fieldArraySize(SceneField name) const -> UnsignedShort new in Git master
Array size of a named field.
auto mapping(UnsignedInt fieldId) const -> Containers::StridedArrayView2D<const char> new in Git master
Object mapping data for given field.
auto mutableMapping(UnsignedInt fieldId) -> Containers::StridedArrayView2D<char> new in Git master
Mutable object mapping data for given field.
template<class T>
auto mapping(UnsignedInt fieldId) const -> Containers::StridedArrayView1D<const T> new in Git master
Object mapping for given field.
template<class T>
auto mutableMapping(UnsignedInt fieldId) -> Containers::StridedArrayView1D<T> new in Git master
Mutable object mapping for given field.
auto mapping(SceneField fieldName) const -> Containers::StridedArrayView2D<const char> new in Git master
Object mapping data for given named field.
auto mutableMapping(SceneField fieldName) -> Containers::StridedArrayView2D<char> new in Git master
Mutable object mapping data for given named field.
template<class T>
auto mapping(SceneField fieldName) const -> Containers::StridedArrayView1D<const T> new in Git master
Object mapping for given named field.
template<class T>
auto mutableMapping(SceneField fieldName) -> Containers::StridedArrayView1D<T> new in Git master
Mutable object mapping for given named field.
auto field(UnsignedInt id) const -> Containers::StridedArrayView2D<const char> new in Git master
Data for given field.
auto mutableField(UnsignedInt id) -> Containers::StridedArrayView2D<char> new in Git master
Mutable data for given field.
template<class T, class = typename std::enable_if<!std::is_array<T>::value>::type>
auto field(UnsignedInt id) const -> Containers::StridedArrayView1D<const T> new in Git master
Data for given field in a concrete type.
template<class T, class = typename std::enable_if<std::is_array<T>::value>::type>
auto field(UnsignedInt id) const -> Containers::StridedArrayView2D<const typename std::remove_extent<T>::type> new in Git master
Data for given array field in a concrete type.
template<class T, class = typename std::enable_if<!std::is_array<T>::value>::type>
auto mutableField(UnsignedInt id) -> Containers::StridedArrayView1D<T> new in Git master
Mutable data for given field in a concrete type.
template<class T, class = typename std::enable_if<std::is_array<T>::value>::type>
auto mutableField(UnsignedInt id) -> Containers::StridedArrayView2D<typename std::remove_extent<T>::type> new in Git master
Mutable data for given array field in a concrete type.
auto field(SceneField name) const -> Containers::StridedArrayView2D<const char> new in Git master
Data for given named field.
auto mutableField(SceneField name) -> Containers::StridedArrayView2D<char> new in Git master
Mutable data for given named field.
template<class T, class = typename std::enable_if<!std::is_array<T>::value>::type>
auto field(SceneField name) const -> Containers::StridedArrayView1D<const T> new in Git master
Data for given named field in a concrete type.
template<class T, class = typename std::enable_if<std::is_array<T>::value>::type>
auto field(SceneField name) const -> Containers::StridedArrayView2D<const typename std::remove_extent<T>::type> new in Git master
Data for given named array field in a concrete type.
template<class T, class = typename std::enable_if<!std::is_array<T>::value>::type>
auto mutableField(SceneField name) -> Containers::StridedArrayView1D<T> new in Git master
Mutable data for given named field.
template<class T, class = typename std::enable_if<std::is_array<T>::value>::type>
auto mutableField(SceneField name) -> Containers::StridedArrayView2D<typename std::remove_extent<T>::type> new in Git master
Mutable data for given named array field in a concrete type.
auto fieldBits(UnsignedInt id) const -> Containers::StridedBitArrayView1D new in Git master
Contents of given bit field.
auto fieldBitArrays(UnsignedInt id) const -> Containers::StridedBitArrayView2D new in Git master
Contents of given array bit field.
auto mutableFieldBits(UnsignedInt id) -> Containers::MutableStridedBitArrayView1D new in Git master
Mutable contents of given bit field.
auto mutableFieldBitArrays(UnsignedInt id) -> Containers::MutableStridedBitArrayView2D new in Git master
Mutable contents of given array bit field.
auto fieldBits(SceneField name) const -> Containers::StridedBitArrayView1D new in Git master
Contents of given named bit field.
auto fieldBitArrays(SceneField name) const -> Containers::StridedBitArrayView2D new in Git master
Contents of given array bit field.
auto mutableFieldBits(SceneField name) -> Containers::MutableStridedBitArrayView1D new in Git master
Mutable contents of given bit field.
auto mutableFieldBitArrays(SceneField name) -> Containers::MutableStridedBitArrayView2D new in Git master
Mutable contents of given array bit field.
auto fieldStringData(UnsignedInt id) const -> const char* new in Git master
Base data pointer for given string field.
auto fieldStringData(SceneField name) const -> const char* new in Git master
Base data pointer for given named string field.
auto fieldStrings(UnsignedInt id) const -> Containers::StringIterable new in Git master
Contents of given string field.
auto fieldStrings(SceneField name) const -> Containers::StringIterable new in Git master
Contents of given string field.
auto mappingAsArray(UnsignedInt fieldId) const -> Containers::Array<UnsignedInt> new in Git master
Object mapping for given field as 32-bit integers.
void mappingInto(UnsignedInt fieldId, const Containers::StridedArrayView1D<UnsignedInt>& destination) const new in Git master
Object mapping for given field as 32-bit integers into a pre-allocated view.
auto mappingInto(UnsignedInt fieldId, std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& destination) const -> std::size_t new in Git master
A subrange of object mapping for given field as 32-bit integers into a pre-allocated view.
auto mappingAsArray(SceneField fieldName) const -> Containers::Array<UnsignedInt> new in Git master
Object mapping for given named field as 32-bit integers.
void mappingInto(SceneField fieldName, const Containers::StridedArrayView1D<UnsignedInt>& destination) const new in Git master
Object mapping for given named field as 32-bit integers into a pre-allocated view.
auto mappingInto(SceneField fieldName, std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& destination) const -> std::size_t new in Git master
A subrange of object mapping for given named field as 32-bit integers into a pre-allocated view.
auto parentsAsArray() const -> Containers::Array<Containers::Pair<UnsignedInt, Int>> new in Git master
Parent indices as 32-bit integers.
void parentsInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Int>& fieldDestination) const new in Git master
Parent indices as 32-bit integers into a pre-allocated view.
auto parentsInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Int>& fieldDestination) const -> std::size_t new in Git master
A subrange of parent indices as 32-bit integers into a pre-allocated view.
auto transformationFieldSize() const -> std::size_t new in Git master
Transformation field size.
auto transformations2DAsArray() const -> Containers::Array<Containers::Pair<UnsignedInt, Matrix3>> new in Git master
2D transformations as 3x3 float matrices
void transformations2DInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Matrix3>& fieldDestination) const new in Git master
2D transformations as 3x3 float matrices into a pre-allocated view
auto transformations2DInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Matrix3>& fieldDestination) const -> std::size_t new in Git master
A subrange of 2D transformations as 3x3 float matrices into a pre-allocated view.
auto translationsRotationsScalings2DAsArray() const -> Containers::Array<Containers::Pair<UnsignedInt, Containers::Triple<Vector2, Complex, Vector2>>> new in Git master
2D transformations as float translation, rotation and scaling components
void translationsRotationsScalings2DInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Vector2>& translationDestination, const Containers::StridedArrayView1D<Complex>& rotationDestination, const Containers::StridedArrayView1D<Vector2>& scalingDestination) const new in Git master
2D transformations as float translation, rotation and scaling components into a pre-allocated view
auto translationsRotationsScalings2DInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Vector2>& translationDestination, const Containers::StridedArrayView1D<Complex>& rotationDestination, const Containers::StridedArrayView1D<Vector2>& scalingDestination) const -> std::size_t new in Git master
A subrange of 2D transformations as float translation, rotation and scaling components into a pre-allocated view.
auto transformations3DAsArray() const -> Containers::Array<Containers::Pair<UnsignedInt, Matrix4>> new in Git master
3D transformations as 4x4 float matrices
void transformations3DInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Matrix4>& destination) const new in Git master
3D transformations as 4x4 float matrices into a pre-allocated view
auto transformations3DInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Matrix4>& destination) const -> std::size_t new in Git master
A subrange of 3D transformations as 4x4 float matrices into a pre-allocated view.
auto translationsRotationsScalings3DAsArray() const -> Containers::Array<Containers::Pair<UnsignedInt, Containers::Triple<Vector3, Quaternion, Vector3>>> new in Git master
3D transformations as float translation, rotation and scaling components
void translationsRotationsScalings3DInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Vector3>& translationDestination, const Containers::StridedArrayView1D<Quaternion>& rotationDestination, const Containers::StridedArrayView1D<Vector3>& scalingDestination) const new in Git master
3D transformations as float translation, rotation and scaling components into a pre-allocated view
auto translationsRotationsScalings3DInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Vector3>& translationDestination, const Containers::StridedArrayView1D<Quaternion>& rotationDestination, const Containers::StridedArrayView1D<Vector3>& scalingDestination) const -> std::size_t new in Git master
A subrange of 3D transformations as float translation, rotation and scaling components into a pre-allocated view.
auto meshesMaterialsAsArray() const -> Containers::Array<Containers::Pair<UnsignedInt, Containers::Pair<UnsignedInt, Int>>> new in Git master
Mesh and material IDs as 32-bit integers.
void meshesMaterialsInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& meshDestination, const Containers::StridedArrayView1D<Int>& meshMaterialDestination) const new in Git master
Mesh and material IDs as 32-bit integers into a pre-allocated view.
auto meshesMaterialsInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& meshDestination, const Containers::StridedArrayView1D<Int>& meshMaterialsDestination) const -> std::size_t new in Git master
A subrange of mesh and material IDs as 32-bit integers into a pre-allocated view.
auto lightsAsArray() const -> Containers::Array<Containers::Pair<UnsignedInt, UnsignedInt>> new in Git master
Light IDs as 32-bit integers.
void lightsInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& fieldDestination) const new in Git master
Light IDs as 32-bit integers into a pre-allocated view.
auto lightsInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& fieldDestination) const -> std::size_t new in Git master
A subrange of light IDs as 32-bit integers into a pre-allocated view.
auto camerasAsArray() const -> Containers::Array<Containers::Pair<UnsignedInt, UnsignedInt>> new in Git master
Camera IDs as 32-bit integers.
void camerasInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& fieldDestination) const new in Git master
Camera IDs as 32-bit integers into a pre-allocated view.
auto camerasInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& fieldDestination) const -> std::size_t new in Git master
A subrange of camera IDs as 32-bit integers into a pre-allocated view.
auto skinsAsArray() const -> Containers::Array<Containers::Pair<UnsignedInt, UnsignedInt>> new in Git master
Skin IDs as 32-bit integers.
void skinsInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& fieldDestination) const new in Git master
Skin IDs as 32-bit integers into a pre-allocated view.
auto skinsInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& fieldDestination) const -> std::size_t new in Git master
A subrange of skin IDs as 32-bit integers into a pre-allocated view.
auto importerStateAsArray() const -> Containers::Array<Containers::Pair<UnsignedInt, const void*>> new in Git master
Per-object importer state as void pointers.
void importerStateInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<const void*>& fieldDestination) const new in Git master
Per-object importer state as void pointers into a pre-allocated view.
auto importerStateInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<const void*>& fieldDestination) const -> std::size_t new in Git master
A subrange of per-object importer state as void pointers into a pre-allocated view.
auto parentFor(UnsignedLong object) const -> Containers::Optional<Long> new in Git master
Parent for given object.
auto childrenFor(Long object) const -> Containers::Array<UnsignedLong> new in Git master
Children for given object.
auto transformation2DFor(UnsignedLong object) const -> Containers::Optional<Matrix3> new in Git master
2D transformation for given object
auto translationRotationScaling2DFor(UnsignedLong object) const -> Containers::Optional<Containers::Triple<Vector2, Complex, Vector2>> new in Git master
2D translation, rotation and scaling for given object
auto transformation3DFor(UnsignedLong object) const -> Containers::Optional<Matrix4> new in Git master
3D transformation for given object
auto translationRotationScaling3DFor(UnsignedLong object) const -> Containers::Optional<Containers::Triple<Vector3, Quaternion, Vector3>> new in Git master
3D translation, rotation and scaling for given object
auto meshesMaterialsFor(UnsignedLong object) const -> Containers::Array<Containers::Pair<UnsignedInt, Int>> new in Git master
Meshes and materials for given object.
auto lightsFor(UnsignedLong object) const -> Containers::Array<UnsignedInt> new in Git master
Lights for given object.
auto camerasFor(UnsignedLong object) const -> Containers::Array<UnsignedInt> new in Git master
Cameras for given object.
auto skinsFor(UnsignedLong object) const -> Containers::Array<UnsignedInt> new in Git master
Skins for given object.
auto importerStateFor(UnsignedLong object) const -> Containers::Optional<const void*> new in Git master
Importer state for given object.
auto children2D() const -> std::vector<UnsignedInt> deprecated in Git master
Two-dimensional root scene objects.
auto children3D() const -> std::vector<UnsignedInt> deprecated in Git master
Three-dimensional root scene objects.
auto releaseFieldData() -> Containers::Array<SceneFieldData> new in Git master
Release field data storage.
auto releaseData() -> Containers::Array<char> new in Git master
Release data storage.
auto importerState() const -> const void*
Importer-specific state.

Function documentation

Magnum::Trade::SceneData::SceneData(SceneMappingType mappingType, UnsignedLong mappingBound, Containers::Array<char>&& data, Containers::Array<SceneFieldData>&& fields, const void* importerState = nullptr) explicit noexcept new in Git master

Construct scene data.

Parameters
mappingType Object mapping type
mappingBound Upper bound on object mapping indices in the scene
data Data for all fields and object mappings
fields Description of all scene field data
importerState Importer-specific state

The mappingType is expected to be large enough to index mappingBound objects. The fields are expected to reference (sparse) sub-ranges of data, each having an unique SceneField, and SceneMappingType equal to mappingType. Particular fields can have additional restrictions, see documentation of SceneField values for more information.

The dataFlags() are implicitly set to a combination of DataFlag::Owned and DataFlag::Mutable. For non-owned data use the SceneData(SceneMappingType, UnsignedLong, DataFlags, Containers::ArrayView<const void>, Containers::Array<SceneFieldData>&&, const void*) constructor or its variants instead.

Magnum::Trade::SceneData::SceneData(SceneMappingType mappingType, UnsignedLong mappingBound, Containers::Array<char>&& data, std::initializer_list<SceneFieldData> fields, const void* importerState = nullptr) explicit new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Magnum::Trade::SceneData::SceneData(SceneMappingType mappingType, UnsignedLong mappingBound, DataFlags dataFlags, Containers::ArrayView<const void> data, Containers::Array<SceneFieldData>&& fields, const void* importerState = nullptr) explicit noexcept new in Git master

Construct non-owned scene data.

Parameters
mappingType Object mapping type
mappingBound Upper bound on object mapping indices in the scene
dataFlags Data flags
data View on data for all fields and object mappings
fields Description of all scene field data
importerState Importer-specific state

Compared to SceneData(SceneMappingType, UnsignedLong, Containers::Array<char>&&, Containers::Array<SceneFieldData>&&, const void*) creates an instance that doesn't own the passed data. The dataFlags parameter can contain DataFlag::Mutable to indicate the external data can be modified, and is expected to not have DataFlag::Owned set.

Magnum::Trade::SceneData::SceneData(SceneMappingType mappingType, UnsignedLong mappingBound, DataFlags dataFlags, Containers::ArrayView<const void> data, std::initializer_list<SceneFieldData> fields, const void* importerState = nullptr) explicit new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Magnum::Trade::SceneData::SceneData(std::vector<UnsignedInt> children2D, std::vector<UnsignedInt> children3D, const void* importerState = nullptr) explicit

Constructor.

Parameters
children2D Two-dimensional child objects
children3D Three-dimensional child objects
importerState Importer-specific state

DataFlags Magnum::Trade::SceneData::dataFlags() const new in Git master

Data flags.

Containers::ArrayView<const char> Magnum::Trade::SceneData::data() const & new in Git master

Raw data.

Returns nullptr if the scene has no data.

Containers::ArrayView<char> Magnum::Trade::SceneData::mutableData() & new in Git master

Mutable raw data.

Like data(), but returns a non-const view. Expects that the scene is mutable.

SceneMappingType Magnum::Trade::SceneData::mappingType() const new in Git master

Type used for object mapping.

Type returned from mapping() and mutableMapping(). It's the same for all fields and is guaranteed to be large enough to fit mappingBound() objects.

UnsignedLong Magnum::Trade::SceneData::mappingBound() const new in Git master

Object mapping bound.

Upper bound on object mapping indices of all fields in the scene. Note that an object can have a certain field associated with it multiple times with different values (for example an object having multiple meshes), and thus a field size can be larger than mappingBound() — see fieldSizeBound() for an upper bound for all field sizes.

UnsignedInt Magnum::Trade::SceneData::fieldCount() const new in Git master

Field count.

Count of different fields contained in the scene, or 0 for a scene with no fields. Each SceneField can be present only once, however an object can have a certain field associated with it multiple times with different values (for example an object having multiple meshes).

std::size_t Magnum::Trade::SceneData::fieldSizeBound() const new in Git master

Field size bound.

A maximum of all fieldSize() or 0 for a scene with no fields. Note that an object can have a certain field associated with it multiple times with different values (for example an object having multiple meshes), and thus a field size can be larger than mappingBound().

Containers::ArrayView<const SceneFieldData> Magnum::Trade::SceneData::fieldData() const & new in Git master

Raw field metadata.

Returns the raw data that are used as a base for all field*() accessors, or nullptr if the scene has no fields. In most cases you don't want to access those directly, but rather use the mapping(), field(), fieldName(), fieldType(), fieldSize() and fieldArraySize() accessors. Compared to those and to fieldData(UnsignedInt) const, the SceneFieldData instances returned by this function may have different data pointers, and some of them might have SceneFieldFlag::OffsetOnly set — use this function only if you really know what are you doing.

SceneFieldData Magnum::Trade::SceneData::fieldData(UnsignedInt id) const new in Git master

Raw field data.

Returns the raw data that are used as a base for all field*() accessors. In most cases you don't want to access those directly, but rather use the mapping(), field(), fieldName(), fieldType(), fieldSize() and fieldArraySize() accessors. This is also the reason why there's no overload taking a SceneField, unlike the other accessors.

Unlike with fieldData() and releaseFieldData(), returned instances are guaranteed to always have an absolute data pointer (i.e., SceneFieldData::flags() never having SceneFieldFlag::OffsetOnly set). The id is expected to be smaller than fieldCount().

SceneFieldFlags Magnum::Trade::SceneData::fieldFlags(UnsignedInt id) const new in Git master

Field flags.

The id is expected to be smaller than fieldCount().

SceneFieldType Magnum::Trade::SceneData::fieldType(UnsignedInt id) const new in Git master

Field type.

The id is expected to be smaller than fieldCount(). You can also use fieldType(SceneField) const to directly get a type of given named field.

std::size_t Magnum::Trade::SceneData::fieldSize(UnsignedInt id) const new in Git master

Number of entries in a field.

Size of the view returned by mapping() / mutableMapping() and field() / mutableField() for given id. Since an object can have multiple entries of the same field (for example multiple meshes associated with an object), the size doesn't necessarily match the number of objects having given field.

The id is expected to be smaller than fieldCount(). You can also use fieldSize(SceneField) const to directly get a size of given named field.

UnsignedShort Magnum::Trade::SceneData::fieldArraySize(UnsignedInt id) const new in Git master

Field array size.

In case given field is an array (the euqivalent of e.g. int[30]), returns array size, otherwise returns 0. At the moment only custom fields can be arrays, no builtin SceneField is an array field. Additionally, fields with SceneFieldType::StringOffset*, SceneFieldType::StringRange* or SceneFieldType::StringRangeNullTerminated* can't be arrays, for them the function always returns 0.

Note that this is different from the count of entries for given field, which is exposed through fieldSize(). See Custom scene fields and non-node objects for an example.

The id is expected to be smaller than fieldCount(). You can also use fieldArraySize(SceneField) const to directly get a type of given named field.

bool Magnum::Trade::SceneData::is2D() const new in Git master

Whether the scene is two-dimensional.

Returns true if the present SceneField::Transformation, Translation, Rotation and Scaling fields have a 2D type, false otherwise.

If there's no transformation-related field, the scene is treated as neither 2D nor 3D and both is2D() and is3D() return false. On the other hand, a scene can't be both 2D and 3D.

bool Magnum::Trade::SceneData::is3D() const new in Git master

Whether the scene is three-dimensional.

Returns true if the present SceneField::Transformation, Translation, Rotation and Scaling fields have a 3D type, false otherwise.

If there's no transformation-related field, the scene is treated as neither 2D nor 3D and both is2D() and is3D() return false. On the other hand, a scene can't be both 2D and 3D.

Containers::Optional<UnsignedInt> Magnum::Trade::SceneData::findFieldId(SceneField name) const new in Git master

Find an absolute ID of a named field.

If name doesn't exist, returns Containers::NullOpt. The lookup is done in an $ \mathcal{O}(n) $ complexity with $ n $ being the field count.

UnsignedInt Magnum::Trade::SceneData::fieldId(SceneField name) const new in Git master

Absolute ID of a named field.

Like findFieldId(), but the name is expected to exist.

bool Magnum::Trade::SceneData::hasField(SceneField name) const new in Git master

Whether the scene has given field.

Containers::Optional<std::size_t> Magnum::Trade::SceneData::findFieldObjectOffset(UnsignedInt fieldId, UnsignedLong object, std::size_t offset = 0) const new in Git master

Find offset of an object in given field.

If object isn't present in fieldId starting at offset, returns Containers::NullOpt. The fieldId is expected to be smaller than fieldCount(), object smaller than mappingBound() and offset not larger than fieldSize(UnsignedInt) const.

If the field has SceneFieldFlag::ImplicitMapping, the lookup is done in an $ \mathcal{O}(1) $ complexity. Otherwise, if the field has SceneFieldFlag::OrderedMapping, the lookup is done in an $ \mathcal{O}(\log{} n) $ complexity with $ n $ being the size of the field. Otherwise, the lookup is done in an $ \mathcal{O}(n) $ complexity.

You can also use findFieldObjectOffset(SceneField, UnsignedLong, std::size_t) const to directly find offset of an object in given named field.

Containers::Optional<std::size_t> Magnum::Trade::SceneData::findFieldObjectOffset(SceneField fieldName, UnsignedLong object, std::size_t offset = 0) const new in Git master

Find offset of an object in given named field.

If object isn't present in fieldName starting at offset, returns Containers::NullOpt. The fieldName is expected to exist, object is expected to be smaller than mappingBound() and offset not be larger than fieldSize(SceneField) const.

If the field has SceneFieldFlag::ImplicitMapping, the lookup is done in an $ \mathcal{O}(m) $ complexity with $ m $ being the field count. Otherwise, if the field has SceneFieldFlag::OrderedMapping, the lookup is done in an $ \mathcal{O}(m + \log{} n) $ complexity with $ m $ being the field count and $ n $ the size of the field. Otherwise, the lookup is done in an $ \mathcal{O}(m + n) $ complexity.

std::size_t Magnum::Trade::SceneData::fieldObjectOffset(UnsignedInt fieldId, UnsignedLong object, std::size_t offset = 0) const new in Git master

Offset of an object in given field.

Like findFieldObjectOffset(UnsignedInt, UnsignedLong, std::size_t) const, but object is additionally expected to be present in fieldId starting at offset.

You can also use fieldObjectOffset(SceneField, UnsignedLong, std::size_t) const to directly get offset of an object in given named field.

std::size_t Magnum::Trade::SceneData::fieldObjectOffset(SceneField fieldName, UnsignedLong object, std::size_t offset = 0) const new in Git master

Offset of an object in given named field.

Like findFieldObjectOffset(SceneField, UnsignedLong, std::size_t) const, but object is additionally expected to be present in fieldName starting at offset.

bool Magnum::Trade::SceneData::hasFieldObject(UnsignedInt fieldId, UnsignedLong object) const new in Git master

Whether a scene field has given object.

The fieldId is expected to be smaller than fieldCount() and object smaller than mappingBound().

You can also use hasFieldObject(SceneField, UnsignedLong) const to directly query object presence in given named field.

bool Magnum::Trade::SceneData::hasFieldObject(SceneField fieldName, UnsignedLong object) const new in Git master

Whether a named scene field has given object.

The fieldName is expected to exist and object is expected to be smaller than mappingBound().

SceneFieldFlags Magnum::Trade::SceneData::fieldFlags(SceneField name) const new in Git master

Flags of a named field.

The name is expected to exist.

SceneFieldType Magnum::Trade::SceneData::fieldType(SceneField name) const new in Git master

Type of a named field.

The name is expected to exist.

std::size_t Magnum::Trade::SceneData::fieldSize(SceneField name) const new in Git master

Number of entries in a named field.

The name is expected to exist.

UnsignedShort Magnum::Trade::SceneData::fieldArraySize(SceneField name) const new in Git master

Array size of a named field.

The name is expected to exist. Note that this is different from the count of entries for given field, which is exposed through fieldSize(SceneField) const. See fieldArraySize(UnsignedInt) const for more information.

Containers::StridedArrayView2D<const char> Magnum::Trade::SceneData::mapping(UnsignedInt fieldId) const new in Git master

Object mapping data for given field.

The fieldId is expected to be smaller than fieldCount(). The second dimension represents the actual data type (its size is equal to SceneMappingType size) and is guaranteed to be contiguous. Use the templated overload below to get the mapping in a concrete type. You can also use mapping(SceneField) const to directly get object mapping data for given named field.

Containers::StridedArrayView2D<char> Magnum::Trade::SceneData::mutableMapping(UnsignedInt fieldId) new in Git master

Mutable object mapping data for given field.

Like mapping(UnsignedInt) const, but returns a mutable view. Expects that the scene is mutable.

template<class T>
Containers::StridedArrayView1D<const T> Magnum::Trade::SceneData::mapping(UnsignedInt fieldId) const new in Git master

Object mapping for given field.

The fieldId is expected to be smaller than fieldCount() and T is expected to correspond to mappingType().

You can also use the non-templated mappingAsArray() accessor (or the combined parentsAsArray(), transformations2DAsArray(), transformations3DAsArray(), translationsRotationsScalings2DAsArray(), translationsRotationsScalings3DAsArray(), meshesMaterialsAsArray(), lightsAsArray(), camerasAsArray(), skinsAsArray(), importerStateAsArray() accessors) to get the object mapping converted to the usual type, but note that these operations involve extra allocation and data conversion.

template<class T>
Containers::StridedArrayView1D<T> Magnum::Trade::SceneData::mutableMapping(UnsignedInt fieldId) new in Git master

Mutable object mapping for given field.

Like mapping(UnsignedInt) const, but returns a mutable view. Expects that the scene is mutable.

Containers::StridedArrayView2D<const char> Magnum::Trade::SceneData::mapping(SceneField fieldName) const new in Git master

Object mapping data for given named field.

The fieldName is expected to exist. See mapping(UnsignedInt) const for more information. Use the templated overload below to get the object mapping in a concrete type.

Containers::StridedArrayView2D<char> Magnum::Trade::SceneData::mutableMapping(SceneField fieldName) new in Git master

Mutable object mapping data for given named field.

Like mapping(SceneField) const, but returns a mutable view. Expects that the scene is mutable.

template<class T>
Containers::StridedArrayView1D<const T> Magnum::Trade::SceneData::mapping(SceneField fieldName) const new in Git master

Object mapping for given named field.

The fieldName is expected to exist and T is expected to correspond to mappingType().

You can also use the non-templated mappingAsArray() accessor (or the combined parentsAsArray(), transformations2DAsArray(), transformations3DAsArray(), translationsRotationsScalings2DAsArray(), translationsRotationsScalings3DAsArray(), meshesMaterialsAsArray(), lightsAsArray(), camerasAsArray(), skinsAsArray(), importerStateAsArray() accessors) to get the object mapping converted to the usual type, but note that these operations involve extra allocation and data conversion.

template<class T>
Containers::StridedArrayView1D<T> Magnum::Trade::SceneData::mutableMapping(SceneField fieldName) new in Git master

Mutable object mapping for given named field.

Like mapping(SceneField) const, but returns a mutable view. Expects that the scene is mutable.

Containers::StridedArrayView2D<const char> Magnum::Trade::SceneData::field(UnsignedInt id) const new in Git master

Data for given field.

The id is expected to be smaller than fieldCount(). The second dimension represents the actual data type (its size is equal to SceneFieldType size, possibly multiplied by array size) and is guaranteed to be contiguous. Use the templated overload below to get the field in a concrete type. You can also use field(SceneField) const to directly get data for given named field.

For SceneFieldType::Bit use fieldBits() or fieldBitArrays() instead.

Containers::StridedArrayView2D<char> Magnum::Trade::SceneData::mutableField(UnsignedInt id) new in Git master

Mutable data for given field.

Like field(UnsignedInt) const, but returns a mutable view. Expects that the scene is mutable.

template<class T, class = typename std::enable_if<!std::is_array<T>::value>::type>
Containers::StridedArrayView1D<const T> Magnum::Trade::SceneData::field(UnsignedInt id) const new in Git master

Data for given field in a concrete type.

The id is expected to be smaller than fieldCount() and T is expected to correspond to fieldType(UnsignedInt) const. The field is also expected to not be an array, in that case you need to use the overload below by using T[] instead of T. For SceneFieldType::Bit use fieldBits() or fieldBitArrays() instead.

You can also use the non-templated parentsAsArray(), transformations2DAsArray(), transformations3DAsArray(), translationsRotationsScalings2DAsArray(), translationsRotationsScalings3DAsArray(), meshesMaterialsAsArray(), lightsAsArray(), camerasAsArray(), skinsAsArray(), importerStateAsArray() accessors to get common fields converted to usual types, but note that these operations involve extra allocation and data conversion.

template<class T, class = typename std::enable_if<std::is_array<T>::value>::type>
Containers::StridedArrayView2D<const typename std::remove_extent<T>::type> Magnum::Trade::SceneData::field(UnsignedInt id) const new in Git master

Data for given array field in a concrete type.

Same as above, except that it works with array fields as well — you're expected to select this overload by passing T[] instead of T. The second dimension is guaranteed to be contiguous and have the same size as reported by fieldArraySize(UnsignedInt) const for given field. For non-array fields the second dimension has a size of 1.

template<class T, class = typename std::enable_if<!std::is_array<T>::value>::type>
Containers::StridedArrayView1D<T> Magnum::Trade::SceneData::mutableField(UnsignedInt id) new in Git master

Mutable data for given field in a concrete type.

Like field(UnsignedInt) const, but returns a mutable view. Expects that the scene is mutable.

template<class T, class = typename std::enable_if<std::is_array<T>::value>::type>
Containers::StridedArrayView2D<typename std::remove_extent<T>::type> Magnum::Trade::SceneData::mutableField(UnsignedInt id) new in Git master

Mutable data for given array field in a concrete type.

Same as above, except that it works with array fields as well — you're expected to select this overload by passing T[] instead of T. The second dimension is guaranteed to be contiguous and have the same size as reported by fieldArraySize(UnsignedInt) const for given field. For non-array fields the second dimension has a size of 1.

Containers::StridedArrayView2D<const char> Magnum::Trade::SceneData::field(SceneField name) const new in Git master

Data for given named field.

The name is expected to exist. See field(UnsignedInt) const for more information. Use the templated overload below to get the field in a concrete type.

Containers::StridedArrayView2D<char> Magnum::Trade::SceneData::mutableField(SceneField name) new in Git master

Mutable data for given named field.

Like field(SceneField) const, but returns a mutable view. Expects that the scene is mutable.

template<class T, class = typename std::enable_if<!std::is_array<T>::value>::type>
Containers::StridedArrayView1D<const T> Magnum::Trade::SceneData::field(SceneField name) const new in Git master

Data for given named field in a concrete type.

The name is expected to exist and T is expected to correspond to fieldType(SceneField) const. The field is also expected to not be an array, in that case you need to use the overload below by using T[] instead of T.

You can also use the non-templated parentsAsArray(), transformations2DAsArray(), transformations3DAsArray(), translationsRotationsScalings2DAsArray(), translationsRotationsScalings3DAsArray(), meshesMaterialsAsArray(), lightsAsArray(), camerasAsArray(), skinsAsArray(), importerStateAsArray() accessors to get common fields converted to usual types, but note that these operations involve extra allocation and data conversion.

template<class T, class = typename std::enable_if<std::is_array<T>::value>::type>
Containers::StridedArrayView2D<const typename std::remove_extent<T>::type> Magnum::Trade::SceneData::field(SceneField name) const new in Git master

Data for given named array field in a concrete type.

Same as above, except that it works with array fields as well — you're expected to select this overload by passing T[] instead of T. The second dimension is guaranteed to be contiguous and have the same size as reported by fieldArraySize(SceneField) const for given field. For non-array fields the second dimension has a size of 1.

template<class T, class = typename std::enable_if<!std::is_array<T>::value>::type>
Containers::StridedArrayView1D<T> Magnum::Trade::SceneData::mutableField(SceneField name) new in Git master

Mutable data for given named field.

Like field(SceneField) const, but returns a mutable view. Expects that the scene is mutable.

template<class T, class = typename std::enable_if<std::is_array<T>::value>::type>
Containers::StridedArrayView2D<typename std::remove_extent<T>::type> Magnum::Trade::SceneData::mutableField(SceneField name) new in Git master

Mutable data for given named array field in a concrete type.

Same as above, except that it works with array fields as well — you're expected to select this overload by passing T[] instead of T. The second dimension is guaranteed to be contiguous and have the same size as reported by fieldArraySize(SceneField) const for given field. For non-array fields the second dimension has a size of 1.

Containers::StridedBitArrayView1D Magnum::Trade::SceneData::fieldBits(UnsignedInt id) const new in Git master

Contents of given bit field.

Expects that id is smaller than fieldCount() const and that the field is SceneFieldType::Bit. The field is also expected to not be an array, in that case you need to use fieldBitArrays(UnsignedInt) const instead.

Containers::StridedBitArrayView2D Magnum::Trade::SceneData::fieldBitArrays(UnsignedInt id) const new in Git master

Contents of given array bit field.

Same as above, except that it works with array fields as well. The second dimension is guaranteed to be contiguous and have the same size as reported by fieldArraySize(UnsignedInt) const for given field. For non-array fields the second dimension has a size of 1.

Containers::MutableStridedBitArrayView1D Magnum::Trade::SceneData::mutableFieldBits(UnsignedInt id) new in Git master

Mutable contents of given bit field.

Like fieldBits(UnsignedInt) const, but returns a mutable view. Expects that the scene is mutable.

Containers::MutableStridedBitArrayView2D Magnum::Trade::SceneData::mutableFieldBitArrays(UnsignedInt id) new in Git master

Mutable contents of given array bit field.

Same as above, except that it works with array fields as well. The second dimension is guaranteed to be contiguous and have the same size as reported by fieldArraySize(UnsignedInt) const for given field. For non-array fields the second dimension has a size of 1.

Containers::StridedBitArrayView1D Magnum::Trade::SceneData::fieldBits(SceneField name) const new in Git master

Contents of given named bit field.

Expects that name exists and that the field is SceneFieldType::Bit. The field is also expected to not be an array, in that case you need to use fieldBitArrays(SceneField) const instead.

Containers::StridedBitArrayView2D Magnum::Trade::SceneData::fieldBitArrays(SceneField name) const new in Git master

Contents of given array bit field.

Same as above, except that it works with array fields as well. The second dimension is guaranteed to be contiguous and have the same size as reported by fieldArraySize(SceneField) const for given field. For non-array fields the second dimension has a size of 1.

Containers::MutableStridedBitArrayView1D Magnum::Trade::SceneData::mutableFieldBits(SceneField name) new in Git master

Mutable contents of given bit field.

Like fieldBits(SceneField) const, but returns a mutable view. Expects that the scene is mutable.

Containers::MutableStridedBitArrayView2D Magnum::Trade::SceneData::mutableFieldBitArrays(SceneField name) new in Git master

Mutable contents of given array bit field.

Same as above, except that it works with array fields as well. The second dimension is guaranteed to be contiguous and have the same size as reported by fieldArraySize(SceneField) const for given field. For non-array fields the second dimension has a size of 1.

const char* Magnum::Trade::SceneData::fieldStringData(UnsignedInt id) const new in Git master

Base data pointer for given string field.

Raw string offsets and ranges returned from field() are relative to this pointer. For more convenient access use fieldStrings() instead. Expects that id is smaller than fieldCount() const and that the field is SceneFieldType::StringOffset*, SceneFieldType::StringRange* or SceneFieldType::StringRangeNullTerminated*. You can also use fieldStringData(SceneField) const to directly get a data pointer for given named string field.

const char* Magnum::Trade::SceneData::fieldStringData(SceneField name) const new in Git master

Base data pointer for given named string field.

Expects that name exists and is SceneFieldType::StringOffset*, SceneFieldType::StringRange* or SceneFieldType::StringRangeNullTerminated*. See fieldStringData(UnsignedInt) const for more information.

Containers::StringIterable Magnum::Trade::SceneData::fieldStrings(UnsignedInt id) const new in Git master

Contents of given string field.

The returned views point to strings owned by this instance. If the field has SceneFieldFlag::NullTerminatedString set, the returned views all have Containers::StringViewFlag::NullTerminated set. Expects that id is smaller than fieldCount() const and that the field is SceneFieldType::StringOffset*, SceneFieldType::StringRange* or SceneFieldType::StringRangeNullTerminated*. You can also use fieldStrings(SceneField) const to directly get contents of given named string field.

The raw string data can be accessed using fieldStringData() and field(). See a particular SceneFieldType for information about how to interpret the data.

Containers::StringIterable Magnum::Trade::SceneData::fieldStrings(SceneField name) const new in Git master

Contents of given string field.

Expects that name exists and that the field is SceneFieldType::StringOffset*, SceneFieldType::StringRange*, SceneFieldType::StringRangeNullTerminated*. See fieldStrings(UnsignedInt) const for more information.

Containers::Array<UnsignedInt> Magnum::Trade::SceneData::mappingAsArray(UnsignedInt fieldId) const new in Git master

Object mapping for given field as 32-bit integers.

Convenience alternative to the templated mapping(UnsignedInt) const that converts the field from an arbitrary underlying type and returns it in a newly-allocated array. The fieldId is expected to be smaller than fieldCount().

Note that, for common fields, you can also use the parentsAsArray(), transformations2DAsArray(), transformations3DAsArray(), translationsRotationsScalings2DAsArray(), translationsRotationsScalings3DAsArray(), meshesMaterialsAsArray(), lightsAsArray(), camerasAsArray(), skinsAsArray(), importerStateAsArray() accessors, which give out the object mapping together with the field data.

void Magnum::Trade::SceneData::mappingInto(UnsignedInt fieldId, const Containers::StridedArrayView1D<UnsignedInt>& destination) const new in Git master

Object mapping for given field as 32-bit integers into a pre-allocated view.

Like mappingAsArray(UnsignedInt) const, but puts the result into destination instead of allocating a new array. Expects that destination is sized to contain exactly all data.

Note that, for common fields, you can also use the parentsInto(), transformations2DInto(), transformations3DInto(), translationsRotationsScalings2DInto(), translationsRotationsScalings3DInto(), meshesMaterialsInto(), lightsInto(), camerasInto(), skinsInto(), importerStateInto() accessors, which can give out the object mapping together with the field data.

std::size_t Magnum::Trade::SceneData::mappingInto(UnsignedInt fieldId, std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& destination) const new in Git master

A subrange of object mapping for given field as 32-bit integers into a pre-allocated view.

Compared to mappingInto(UnsignedInt, const Containers::StridedArrayView1D<UnsignedInt>&) const extracts only a subrange of the object mapping defined by offset and size of the destination view, returning the count of items actually extracted. The offset is expected to not be larger than the field size.

Note that, for common fields, you can also use the parentsInto(), transformations2DInto(), transformations3DInto(), translationsRotationsScalings2DInto(), translationsRotationsScalings3DInto(), meshesMaterialsInto(), lightsInto(), camerasInto(), skinsInto(), importerStateInto() accessors, which can give out the object mapping together with the field data.

Containers::Array<UnsignedInt> Magnum::Trade::SceneData::mappingAsArray(SceneField fieldName) const new in Git master

Object mapping for given named field as 32-bit integers.

Convenience alternative to the templated mapping(SceneField) const that converts the field from an arbitrary underlying type and returns it in a newly-allocated array. The fieldName is expected to exist.

Note that, for common fields, you can also use the parentsAsArray(), transformations2DAsArray(), transformations3DAsArray(), translationsRotationsScalings2DAsArray(), translationsRotationsScalings3DAsArray(), meshesMaterialsAsArray(), lightsAsArray(), camerasAsArray(), skinsAsArray(), importerStateAsArray() accessors, which give out the object mapping together with the field data.

void Magnum::Trade::SceneData::mappingInto(SceneField fieldName, const Containers::StridedArrayView1D<UnsignedInt>& destination) const new in Git master

Object mapping for given named field as 32-bit integers into a pre-allocated view.

Like mappingAsArray(SceneField) const, but puts the result into destination instead of allocating a new array. Expects that destination is sized to contain exactly all data.

Note that, for common fields, you can also use the parentsInto(), transformations2DInto(), transformations3DInto(), translationsRotationsScalings2DInto(), translationsRotationsScalings3DInto(), meshesMaterialsInto(), lightsInto(), camerasInto(), skinsInto(), importerStateInto() accessors, which can give out the object mapping together with the field data.

std::size_t Magnum::Trade::SceneData::mappingInto(SceneField fieldName, std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& destination) const new in Git master

A subrange of object mapping for given named field as 32-bit integers into a pre-allocated view.

Compared to mappingInto(SceneField, const Containers::StridedArrayView1D<UnsignedInt>&) const extracts only a subrange of the object mapping defined by offset and size of the destination view, returning the count of items actually extracted. The offset is expected to not be larger than the field size.

Note that, for common fields, you can also use the parentsInto(), transformations2DInto(), transformations3DInto(), translationsRotationsScalings2DInto(), translationsRotationsScalings3DInto(), meshesMaterialsInto(), lightsInto(), camerasInto(), skinsInto(), importerStateInto() accessors, which can give out the object mapping together with the field data.

Containers::Array<Containers::Pair<UnsignedInt, Int>> Magnum::Trade::SceneData::parentsAsArray() const new in Git master

Parent indices as 32-bit integers.

Convenience alternative to mapping(SceneField) const together with field(SceneField) const with SceneField::Parent as the argument. Converts the object mapping and the field from arbitrary underlying types and returns them in a newly-allocated array. The field is expected to exist.

void Magnum::Trade::SceneData::parentsInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Int>& fieldDestination) const new in Git master

Parent indices as 32-bit integers into a pre-allocated view.

Like parentsAsArray(), but puts the result into mappingDestination and fieldDestination instead of allocating a new array. Expects that each view is either nullptr or sized to contain exactly all data. If fieldDestination is nullptr, the effect is the same as calling mappingInto() with SceneField::Parent.

std::size_t Magnum::Trade::SceneData::parentsInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Int>& fieldDestination) const new in Git master

A subrange of parent indices as 32-bit integers into a pre-allocated view.

Compared to parentsInto(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<Int>&) const extracts only a subrange of the field defined by offset and size of the views, returning the count of items actually extracted. The offset is expected to not be larger than the field size, views that are not nullptr are expected to have the same size.

std::size_t Magnum::Trade::SceneData::transformationFieldSize() const new in Git master

Transformation field size.

Returns the size of the SceneField::Transformation field, or, if not present, of any of the SceneField::Translation, SceneField::Rotation and SceneField::Scaling fields that's present. Expects that at least one transformation field is present.

Containers::Array<Containers::Pair<UnsignedInt, Matrix3>> Magnum::Trade::SceneData::transformations2DAsArray() const new in Git master

2D transformations as 3x3 float matrices

Convenience alternative to mapping(SceneField) const together with field(SceneField) const with SceneField::Transformation as the argument, or, if not present, to a matrix created out of a subset of the SceneField::Translation, SceneField::Rotation and SceneField::Scaling fields that's present. Converts the object mapping and the fields from arbitrary underlying types and returns them in a newly-allocated array. At least one of the fields is expected to exist and they are expected to have a type corresponding to 2D, otherwise you're supposed to use transformations3DAsArray().

void Magnum::Trade::SceneData::transformations2DInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Matrix3>& fieldDestination) const new in Git master

2D transformations as 3x3 float matrices into a pre-allocated view

Like transformations2DAsArray(), but puts the result into mappingDestination and fieldDestination instead of allocating a new array. Expects that each view is either nullptr or sized to contain exactly all data. If fieldDestination is nullptr, the effect is the same as calling mappingInto() with the first of the SceneField::Transformation, SceneField::Translation, SceneField::Rotation and SceneField::Scaling fields that's present.

std::size_t Magnum::Trade::SceneData::transformations2DInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Matrix3>& fieldDestination) const new in Git master

A subrange of 2D transformations as 3x3 float matrices into a pre-allocated view.

Compared to transformations2DInto(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<Matrix3>&) const extracts only a subrange of the field defined by offset and size of the views, returning the count of items actually extracted. The offset is expected to not be larger than the field size, views that are not nullptr are expected to have the same size.

Containers::Array<Containers::Pair<UnsignedInt, Containers::Triple<Vector2, Complex, Vector2>>> Magnum::Trade::SceneData::translationsRotationsScalings2DAsArray() const new in Git master

2D transformations as float translation, rotation and scaling components

Convenience alternative to mapping(SceneField) const together with field(SceneField) const with SceneField::Translation, SceneField::Rotation and SceneField::Scaling as the arguments, as these are required to share the same object mapping. Converts the object mapping and the fields from arbitrary underlying types and returns them in a newly-allocated array. At least one of the fields is expected to exist and they are expected to have a type corresponding to 2D, otherwise you're supposed to use translationsRotationsScalings3DAsArray(). If the SceneField::Translation field isn't present, the first returned value is a zero vector. If the Rotation field isn't present, the second value is an identity rotation. If the Scaling field isn't present, the third value is an identity scaling (1.0f in both dimensions).

void Magnum::Trade::SceneData::translationsRotationsScalings2DInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Vector2>& translationDestination, const Containers::StridedArrayView1D<Complex>& rotationDestination, const Containers::StridedArrayView1D<Vector2>& scalingDestination) const new in Git master

2D transformations as float translation, rotation and scaling components into a pre-allocated view

Like translationsRotationsScalings2DAsArray(), but puts the result into mappingDestination, translationDestination, rotationDestination and scalingDestination instead of allocating a new array. Expects that each view is either nullptr or sized to contain exactly all data. If translationDestination, rotationDestination and scalingDestination are all nullptr, the effect is the same as calling mappingInto() with one of the SceneField::Translation, SceneField::Rotation and SceneField::Scaling fields that's present.

std::size_t Magnum::Trade::SceneData::translationsRotationsScalings2DInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Vector2>& translationDestination, const Containers::StridedArrayView1D<Complex>& rotationDestination, const Containers::StridedArrayView1D<Vector2>& scalingDestination) const new in Git master

A subrange of 2D transformations as float translation, rotation and scaling components into a pre-allocated view.

Compared to translationsRotationsScalings2DInto(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<Vector2>&, const Containers::StridedArrayView1D<Complex>&, const Containers::StridedArrayView1D<Vector2>&) const extracts only a subrange of the field defined by offset and size of the views, returning the count of items actually extracted. The offset is expected to not be larger than the field size, views that are not nullptr are expected to have the same size.

Containers::Array<Containers::Pair<UnsignedInt, Matrix4>> Magnum::Trade::SceneData::transformations3DAsArray() const new in Git master

3D transformations as 4x4 float matrices

Convenience alternative to mapping(SceneField) const together with field(SceneField) const with SceneField::Transformation as the argument, or, if not present, to a matrix created out of a subset of the SceneField::Translation, SceneField::Rotation and SceneField::Scaling fields that's present. Converts the object mapping and the fields from arbitrary underlying types and returns them in a newly-allocated array. At least one of the fields is expected to exist and they are expected to have a type corresponding to 3D, otherwise you're supposed to use transformations2DAsArray().

void Magnum::Trade::SceneData::transformations3DInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Matrix4>& destination) const new in Git master

3D transformations as 4x4 float matrices into a pre-allocated view

Like transformations3DAsArray(), but puts the result into mappingDestination and fieldDestination instead of allocating a new array. Expects that the two views are either nullptr or sized to contain exactly all data. If fieldDestination is nullptr, the effect is the same as calling mappingInto() with the first of the SceneField::Transformation, SceneField::Translation, SceneField::Rotation and SceneField::Scaling fields that's present.

std::size_t Magnum::Trade::SceneData::transformations3DInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Matrix4>& destination) const new in Git master

A subrange of 3D transformations as 4x4 float matrices into a pre-allocated view.

Compared to transformations3DInto(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<Matrix4>&) const extracts only a subrange of the field defined by offset and size of the views, returning the count of items actually extracted. The offset is expected to not be larger than the field size, views that are not nullptr are expected to have the same size.

Containers::Array<Containers::Pair<UnsignedInt, Containers::Triple<Vector3, Quaternion, Vector3>>> Magnum::Trade::SceneData::translationsRotationsScalings3DAsArray() const new in Git master

3D transformations as float translation, rotation and scaling components

Convenience alternative to mapping(SceneField) const together with field(SceneField) const with SceneField::Translation, SceneField::Rotation and SceneField::Scaling as the arguments, as these are required to share the same object mapping. Converts the object mapping and the fields from arbitrary underlying types and returns them in a newly-allocated array. At least one of the fields is expected to exist and they are expected to have a type corresponding to 3D, otherwise you're supposed to use translationsRotationsScalings2DAsArray(). If the SceneField::Translation field isn't present, the first returned value is a zero vector. If the Rotation field isn't present, the second value is an identity rotation. If the Scaling field isn't present, the third value is an identity scaling (1.0f in all dimensions).

void Magnum::Trade::SceneData::translationsRotationsScalings3DInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Vector3>& translationDestination, const Containers::StridedArrayView1D<Quaternion>& rotationDestination, const Containers::StridedArrayView1D<Vector3>& scalingDestination) const new in Git master

3D transformations as float translation, rotation and scaling components into a pre-allocated view

Like translationsRotationsScalings3DAsArray(), but puts the result into mappingDestination, translationDestination, rotationDestination and scalingDestination instead of allocating a new array. Expects that each view is either nullptr or sized to contain exactly all data. If translationDestination, rotationDestination and scalingDestination are all nullptr, the effect is the same as calling mappingInto() with one of the SceneField::Translation, SceneField::Rotation and SceneField::Scaling fields that's present.

std::size_t Magnum::Trade::SceneData::translationsRotationsScalings3DInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<Vector3>& translationDestination, const Containers::StridedArrayView1D<Quaternion>& rotationDestination, const Containers::StridedArrayView1D<Vector3>& scalingDestination) const new in Git master

A subrange of 3D transformations as float translation, rotation and scaling components into a pre-allocated view.

Compared to translationsRotationsScalings3DInto(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<Vector3>&, const Containers::StridedArrayView1D<Quaternion>&, const Containers::StridedArrayView1D<Vector3>&) const extracts only a subrange of the field defined by offset and size of the views, returning the count of items actually extracted. The offset is expected to not be larger than the field size, views that are not nullptr are expected to have the same size.

Containers::Array<Containers::Pair<UnsignedInt, Containers::Pair<UnsignedInt, Int>>> Magnum::Trade::SceneData::meshesMaterialsAsArray() const new in Git master

Mesh and material IDs as 32-bit integers.

Convenience alternative to mapping(SceneField) const together with field(SceneField) const with SceneField::Mesh and SceneField::MeshMaterial as the argument, as the two are required to share the same object mapping. Converts the object mapping and the fields from arbitrary underlying types and returns them in a newly-allocated array. The SceneField::Mesh field is expected to exist, if SceneField::MeshMaterial isn't present, the second returned values are all -1.

void Magnum::Trade::SceneData::meshesMaterialsInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& meshDestination, const Containers::StridedArrayView1D<Int>& meshMaterialDestination) const new in Git master

Mesh and material IDs as 32-bit integers into a pre-allocated view.

Like meshesMaterialsAsArray(), but puts the results into mappingDestination, meshDestination and meshMaterialDestination instead of allocating a new array. Expects that each view is either nullptr or sized to contain exactly all data. If meshDestination and meshMaterialDestination are both nullptr, the effect is the same as calling mappingInto() with SceneField::Mesh.

std::size_t Magnum::Trade::SceneData::meshesMaterialsInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& meshDestination, const Containers::StridedArrayView1D<Int>& meshMaterialsDestination) const new in Git master

A subrange of mesh and material IDs as 32-bit integers into a pre-allocated view.

Compared to meshesMaterialsInto(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<Int>&) const extracts only a subrange of the field defined by offset and size of the views, returning the count of items actually extracted. The offset is expected to not be larger than the field size, views that are not nullptr are expected to have the same size.

Containers::Array<Containers::Pair<UnsignedInt, UnsignedInt>> Magnum::Trade::SceneData::lightsAsArray() const new in Git master

Light IDs as 32-bit integers.

Convenience alternative to mapping(SceneField) const together with field(SceneField) const with SceneField::Light as the argument. Converts the object mapping and the field from arbitrary underlying types and returns them in a newly-allocated array. The field is expected to exist.

void Magnum::Trade::SceneData::lightsInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& fieldDestination) const new in Git master

Light IDs as 32-bit integers into a pre-allocated view.

Like lightsAsArray(), but puts the result into mappingDestination and fieldDestination instead of allocating a new array. Expects that each view is either nullptr or sized to contain exactly all data. If fieldDestination is nullptr, the effect is the same as calling lightsInto() with SceneField::Light.

std::size_t Magnum::Trade::SceneData::lightsInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& fieldDestination) const new in Git master

A subrange of light IDs as 32-bit integers into a pre-allocated view.

Compared to lightsInto(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<UnsignedInt>&) const extracts only a subrange of the field defined by offset and size of the views, returning the count of items actually extracted. The offset is expected to not be larger than the field size, views that are not nullptr are expected to have the same size.

Containers::Array<Containers::Pair<UnsignedInt, UnsignedInt>> Magnum::Trade::SceneData::camerasAsArray() const new in Git master

Camera IDs as 32-bit integers.

Convenience alternative to mapping(SceneField) const together with field(SceneField) const with SceneField::Camera as the argument. Converts the object mapping and the field from arbitrary underlying types and returns them in a newly-allocated array. The field is expected to exist.

void Magnum::Trade::SceneData::camerasInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& fieldDestination) const new in Git master

Camera IDs as 32-bit integers into a pre-allocated view.

Like camerasAsArray(), but puts the result into mappingDestination and fieldDestination instead of allocating a new array. Expects that each view is either nullptr or sized to contain exactly all data. If fieldDestination is nullptr, the effect is the same as calling mappingInto() with SceneField::Camera.

std::size_t Magnum::Trade::SceneData::camerasInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& fieldDestination) const new in Git master

A subrange of camera IDs as 32-bit integers into a pre-allocated view.

Compared to camerasInto(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<UnsignedInt>&) const extracts only a subrange of the field defined by offset and size of the views, returning the count of items actually extracted. The offset is expected to not be larger than the field size, views that are not nullptr are expected to have the same size.

Containers::Array<Containers::Pair<UnsignedInt, UnsignedInt>> Magnum::Trade::SceneData::skinsAsArray() const new in Git master

Skin IDs as 32-bit integers.

Convenience alternative to mapping(SceneField) const together with field(SceneField) const with SceneField::Skin as the argument. Converts the object mapping and the field from arbitrary underlying types and returns them in a newly-allocated array. The field is expected to exist.

void Magnum::Trade::SceneData::skinsInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& fieldDestination) const new in Git master

Skin IDs as 32-bit integers into a pre-allocated view.

Like skinsAsArray(), but puts the result into mappingDestination and fieldDestination instead of allocating a new array. Expects that each view is either nullptr or sized to contain exactly all data. If fieldDestination is nullptr, the effect is the same as calling mappingInto() with SceneField::Skin.

std::size_t Magnum::Trade::SceneData::skinsInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<UnsignedInt>& fieldDestination) const new in Git master

A subrange of skin IDs as 32-bit integers into a pre-allocated view.

Compared to skinsInto(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<UnsignedInt>&) const extracts only a subrange of the field defined by offset and size of the views, returning the count of items actually extracted. The offset is expected to not be larger than the field size, views that are not nullptr are expected to have the same size.

Containers::Array<Containers::Pair<UnsignedInt, const void*>> Magnum::Trade::SceneData::importerStateAsArray() const new in Git master

Per-object importer state as void pointers.

Convenience alternative to mapping(SceneField) const together with field(SceneField) const with SceneField::ImporterState as the argument. Converts the object mapping and the field from arbitrary underlying types and returns them in a newly-allocated array. The field is expected to exist.

This is different from importerState(), which returns importer state for the scene itself, not particular objects.

void Magnum::Trade::SceneData::importerStateInto(const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<const void*>& fieldDestination) const new in Git master

Per-object importer state as void pointers into a pre-allocated view.

Like importerStateAsArray(), but puts the result into mappingDestination and fieldDestination instead of allocating a new array. Expects that each view is either nullptr or sized to contain exactly all data. If fieldDestination is nullptr, the effect is the same as calling mappingInto() with SceneField::ImporterState.

std::size_t Magnum::Trade::SceneData::importerStateInto(std::size_t offset, const Containers::StridedArrayView1D<UnsignedInt>& mappingDestination, const Containers::StridedArrayView1D<const void*>& fieldDestination) const new in Git master

A subrange of per-object importer state as void pointers into a pre-allocated view.

Compared to importerStateInto(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<const void*>&) const extracts only a subrange of the field defined by offset and size of the views, returning the count of items actually extracted. The offset is expected to not be larger than the field size, views that are not nullptr are expected to have the same size.

Containers::Optional<Long> Magnum::Trade::SceneData::parentFor(UnsignedLong object) const new in Git master

Parent for given object.

Looks up the SceneField::Parent field for object equivalently to findFieldObjectOffset(SceneField, UnsignedLong, std::size_t) const and then converts the field from an arbitrary underlying type the same way as parentsAsArray(). See the lookup function documentation for operation complexity — for retrieving parent info for many objects it's recommended to access the field data directly.

If the SceneField::Parent field is not present or if there's no parent for object, returns Containers::NullOpt. If object is top-level, returns -1.

The object is expected to be less than mappingBound().

Containers::Array<UnsignedLong> Magnum::Trade::SceneData::childrenFor(Long object) const new in Git master

Children for given object.

Looks up object in the object mapping array for SceneField::Parent equivalently to findFieldObjectOffset(SceneField, UnsignedLong, std::size_t) const, converts the fields from an arbitrary underlying type the same way as parentsAsArray(), returning a list of all object IDs that have it listed as the parent. See the lookup function documentation for operation complexity — for retrieving parent/child info for many objects it's recommended to access the field data directly.

If the SceneField::Parent field doesn't exist or there are no objects which would have object listed as their parent, returns an empty array. Pass -1 to get a list of top-level objects.

The object is expected to be less than mappingBound().

Containers::Optional<Matrix3> Magnum::Trade::SceneData::transformation2DFor(UnsignedLong object) const new in Git master

2D transformation for given object

Looks up the SceneField::Transformation field for object equivalently to findFieldObjectOffset(SceneField, UnsignedLong, std::size_t) const or combines it from a SceneField::Translation, Rotation and Scaling, converting the fields from arbitrary underlying types the same way as transformations2DAsArray(). See the lookup function documentation for operation complexity — for retrieving transformation info for many objects it's recommended to access the field data directly.

If neither SceneField::Transformation nor any of SceneField::Translation, Rotation or Scaling is present, the fields represent a 3D transformation or there's no transformation for object, returns Containers::NullOpt.

The object is expected to be less than mappingBound().

Containers::Optional<Containers::Triple<Vector2, Complex, Vector2>> Magnum::Trade::SceneData::translationRotationScaling2DFor(UnsignedLong object) const new in Git master

2D translation, rotation and scaling for given object

Looks up the SceneField::Translation, Rotation and Scaling fields for object equivalently to findFieldObjectOffset(SceneField, UnsignedLong, std::size_t) const and then converts the fields from arbitrary underlying types the same way as translationsRotationsScalings2DAsArray(). See the lookup function documentation for operation complexity — for retrieving transformation info for many objects it's recommended to access the field data directly.

If the SceneField::Translation field isn't present, the first returned value is a zero vector. If the Rotation field isn't present, the second value is an identity rotation. If the Scaling field isn't present, the third value is an identity scaling (1.0f in both dimensions). If neither of those fields is present, if any of the fields represents a 3D transformation or if there's no transformation for object, returns Containers::NullOpt.

The object is expected to be less than mappingBound().

Containers::Optional<Matrix4> Magnum::Trade::SceneData::transformation3DFor(UnsignedLong object) const new in Git master

3D transformation for given object

Looks up the SceneField::Transformation field for object equivalently to findFieldObjectOffset(SceneField, UnsignedLong, std::size_t) const or combines it from a SceneField::Translation, Rotation and Scaling, converting the fields from arbitrary underlying types the same way as transformations3DAsArray(). See the lookup function documentation for operation complexity — for retrieving transformation info for many objects it's recommended to access the field data directly.

If neither SceneField::Transformation nor any of SceneField::Translation, Rotation or Scaling is present, the fields represent a 2D transformation or there's no transformation for object, returns Containers::NullOpt.

The object is expected to be less than mappingBound().

Containers::Optional<Containers::Triple<Vector3, Quaternion, Vector3>> Magnum::Trade::SceneData::translationRotationScaling3DFor(UnsignedLong object) const new in Git master

3D translation, rotation and scaling for given object

Looks up the SceneField::Translation, Rotation and Scaling fields for object equivalently to findFieldObjectOffset(SceneField, UnsignedLong, std::size_t) const and then converts the fields from arbitrary underlying types the same way as translationsRotationsScalings2DAsArray(). See the lookup function documentation for operation complexity — for retrieving transformation info for many objects it's recommended to access the field data directly.

If the SceneField::Translation field isn't present, the first returned value is a zero vector. If the Rotation field isn't present, the second value is an identity rotation. If the Scaling field isn't present, the third value is an identity scaling (1.0f in all dimensions). If neither of those fields is present, if any of the fields represents a 2D transformation or if there's no transformation for object, returns Containers::NullOpt.

The object is expected to be less than mappingBound().

Containers::Array<Containers::Pair<UnsignedInt, Int>> Magnum::Trade::SceneData::meshesMaterialsFor(UnsignedLong object) const new in Git master

Meshes and materials for given object.

Looks up all SceneField::Mesh and SceneField::MeshMaterial Scaling fields for object equivalently to findFieldObjectOffset(SceneField, UnsignedLong, std::size_t) const and then converts the field from an arbitrary underlying type the same way as meshesMaterialsAsArray(). See the lookup function documentation for operation complexity — for retrieving mesh and material info for many objects it's recommended to access the field data directly.

If the SceneField::MeshMaterial field is not present, the second returned value is always -1. If SceneField::Mesh is not present or if there's no mesh for object, returns an empty array.

The object is expected to be less than mappingBound().

Containers::Array<UnsignedInt> Magnum::Trade::SceneData::lightsFor(UnsignedLong object) const new in Git master

Lights for given object.

Looks up all SceneField::Light fields for object equivalently to findFieldObjectOffset(SceneField, UnsignedLong, std::size_t) const and then converts the field from an arbitrary underlying type the same way as lightsAsArray(). See the lookup function documentation for operation complexity — for retrieving light info for many objects it's recommended to access the field data directly.

If the SceneField::Light field is not present or if there's no light for object, returns an empty array.

The object is expected to be less than mappingBound().

Containers::Array<UnsignedInt> Magnum::Trade::SceneData::camerasFor(UnsignedLong object) const new in Git master

Cameras for given object.

Looks up all SceneField::Camera fields for object equivalently to findFieldObjectOffset(SceneField, UnsignedLong, std::size_t) const and then converts the field from an arbitrary underlying type the same way as camerasAsArray(). See the lookup function documentation for operation complexity — for retrieving camera info for many objects it's recommended to access the field data directly.

If the SceneField::Camera field is not present or if there's no camera for object, returns an empty array.

The object is expected to be less than mappingBound().

Containers::Array<UnsignedInt> Magnum::Trade::SceneData::skinsFor(UnsignedLong object) const new in Git master

Skins for given object.

Looks up all SceneField::Skin fields for object equivalently to findFieldObjectOffset(SceneField, UnsignedLong, std::size_t) const and then converts the field from an arbitrary underlying type the same way as skinsAsArray(). See the lookup function documentation for operation complexity — for retrieving skin info for many objects it's recommended to access the field data directly.

If the SceneField::Skin field is not present or if there's no skin for object, returns an empty array.

The object is expected to be less than mappingBound().

Containers::Optional<const void*> Magnum::Trade::SceneData::importerStateFor(UnsignedLong object) const new in Git master

Importer state for given object.

Looks up the SceneField::ImporterState field for object equivalently to findFieldObjectOffset(SceneField, UnsignedLong, std::size_t) const and then converts the field from an arbitrary underlying type the same way as importerStateAsArray(). See the lookup function documentation for operation complexity — for retrieving importer state info for many objects it's recommended to access the field data directly.

If the SceneField::ImporterState field is not present or if there's no importer state for object, returns Containers::NullOpt.

The object is expected to be less than mappingBound().

std::vector<UnsignedInt> Magnum::Trade::SceneData::children2D() const

Two-dimensional root scene objects.

std::vector<UnsignedInt> Magnum::Trade::SceneData::children3D() const

Three-dimensional root scene objects.

Containers::Array<SceneFieldData> Magnum::Trade::SceneData::releaseFieldData() new in Git master

Release field data storage.

Releases the ownership of the field data array and resets internal field-related state to default. The scene then behaves like if it has no fields (but it can still have non-empty data). Note that the returned array has a custom no-op deleter when the data are not owned by the scene, and while the returned array type is mutable, the actual memory might be not. Additionally, the returned SceneFieldData instances may have different data pointers and sizes than what's returned by the field() and fieldData(UnsignedInt) const accessors as some of them might have SceneFieldFlag::OffsetOnly — use this function only if you really know what are you doing.

Containers::Array<char> Magnum::Trade::SceneData::releaseData() new in Git master

Release data storage.

Releases the ownership of the data array. Note that the returned array has a custom no-op deleter when the data are not owned by the scene, and while the returned array type is mutable, the actual memory might be not.

const void* Magnum::Trade::SceneData::importerState() const

Importer-specific state.

Scene-specific importer state. For object-specific importer state look for the SceneField::ImporterState field or access it via importerStateAsArray(), importerStateFor() and related convenience functions. See AbstractImporter::importerState() for general information about importer state pointers.