Magnum::Trade::PrimitiveImporter class new in 2020.06

Primitive importer plugin.

Exposes primitives from the Primitives library through importer APIs. Applications that have an importer pipeline already set up can use this plugin to access builtin primitives for prototyping and testing purposes without needing to write explicit code. For applications that don't have an importer pipeline, using the Primitives library directly is more straightforward.

Usage

This plugin depends on the Trade library and is built if WITH_PRIMITIVEIMPORTER is enabled when building Magnum Plugins. To use as a dynamic plugin, load "PrimitiveImporter" via Corrade::PluginManager::Manager.

Additionally, if you're using Magnum as a CMake subproject, bundle the magnum-plugins repository and do the following:

set(WITH_PRIMITIVEIMPORTER ON CACHE BOOL "" FORCE)
add_subdirectory(magnum-plugins EXCLUDE_FROM_ALL)

# So the dynamically loaded plugin gets built implicitly
add_dependencies(your-app MagnumPlugins::PrimitiveImporter)

To use as a static plugin or as a dependency of another plugin with CMake, put FindMagnumPlugins.cmake into your modules/ directory, request the PrimitiveImporter component the MagnumPlugins package and link to the MagnumPlugins::PrimitiveImporter target:

find_package(MagnumPlugins REQUIRED PrimitiveImporter)

# ...
target_link_libraries(your-app PRIVATE MagnumPlugins::PrimitiveImporter)

See Downloading and building plugins, Plugin usage with CMake and Loading and using plugins for more information.

Behavior

Upon calling openData() with arbitrary data (or openFile() with an arbitrary existing file), the importer will expose all primitives through mesh() and additionally list one scene with all primitives as direct 2D or 3D child objects for easy import to existing scenes. Both objects and meshes can be accessed through name of the respective function in the Primitives namespace (so e.g. loading a uvSphereSolid mesh will give you Primitives::uvSphereSolid()).

Plugin-specific config

By default the primitives are created with the same options that were used to create screenshots in the Primitives names. Those options can be then customized through various import options through configuration(). See below for all options and their default values:

[configuration]

[configuration/capsule2DWireframe]
hemisphereRings=8
cylinderRings=1
halfLength=0.75

[configuration/capsule3DSolid]
hemisphereRings=4
cylinderRings=1
segments=12
halfLength=0.75
textureCoordinates=false
tangents=false

[configuration/capsule3DWireframe]
hemisphereRings=8
cylinderRings=1
segments=16
halfLength=1.0

[configuration/circle2DSolid]
segments=16
textureCoordinates=false

[configuration/circle2DWireframe]
segments=32

[configuration/circle3DSolid]
segments=16
textureCoordinates=false
tangents=false

[configuration/circle3DWireframe]
segments=32

[configuration/coneSolid]
rings=1
segments=12
halfLength=1.25
textureCoordinates=false
tangents=false
capEnd=true

[configuration/coneWireframe]
segments=32
halfLength=1.25

[configuration/cylinderSolid]
rings=1
segments=12
halfLength=1.0
textureCoordinates=false
tangents=false
capEnds=true

[configuration/cylinderWireframe]
rings=1
segments=32
halfLength=1.0

# Shared by gradient2D and gradient2DHorizontal / gradient2DVertical, in the
# latter two cases the a / b is ignored
[configuration/gradient2D]
a=1.0 -2.0
b=-1.0 2.0
colorA=0.184314 0.513725 0.8 1.0
colorB=0.231373 0.823529 0.403921 1.0

# Shared by gradient3D and gradient3DHorizontal / gradient3DVertical, in the
# latter two cases the a / b is ignored
[configuration/gradient3D]
a=1.0 -2.0 -1.5
b=-1.0 2.0 -1.5
colorA=0.184314 0.513725 0.8 1.0
colorB=0.231373 0.823529 0.403921 1.0

[configuration/grid3DSolid]
subdivisions=5 3
textureCoordinates=false
tangents=false
normals=true

[configuration/grid3DWireframe]
subdivisions=5 3

[configuration/icosphereSolid]
subdivisions=1

[configuration/line2D]
a=-1.0 0.0
b=1.0 0.0

[configuration/line3D]
a=-1.0 0.0 0.0
b=1.0 0.0 0.0

[configuration/planeSolid]
textureCoordinates=false
tangents=false

[configuration/squareSolid]
textureCoordinates=false

[configuration/uvSphereSolid]
rings=8
segments=16
textureCoordinates=false
tangents=false

[configuration/uvSphereWireframe]
rings=16
segments=32

Base classes

class AbstractImporter
Base for importer plugins.

Constructors, destructors, conversion operators

PrimitiveImporter(PluginManager::AbstractManager& manager, const std::string& plugin) explicit
Plugin manager constructor.