|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Helper class to build a glb scene. More...
#include <gltf_builder.h>
Classes | |
| struct | Impl |
Public Types | |
| enum class | MarkerMesh : uint8_t { None , UnitCube } |
| Specify how marker mesh is represented in the glb file. More... | |
Public Member Functions | |
| GltfBuilder () | |
| ~GltfBuilder () | |
| GltfBuilder (GltfBuilder const &)=delete | |
| void | operator= (GltfBuilder const &)=delete |
| GltfBuilder (GltfBuilder &&) noexcept | |
| GltfBuilder & | operator= (GltfBuilder &&) noexcept |
| void | addCharacter (const Character &character, const Vector3f &positionOffset=Vector3f::Zero(), const Quaternionf &rotationOffset=Quaternionf::Identity(), const FileSaveOptions &options=FileSaveOptions()) |
| Add a character to the scene. | |
| void | addMesh (const Mesh &mesh, const std::string &name, bool addColor=false) |
| Add a static mesh, such as an environment or a target scan. | |
| void | setFps (float fps) |
| void | setAnimationInterpolation (GltfAnimationInterpolation interpolation) |
| Set how the joint and blend shape animation samplers added afterwards interpolate between their keys (default: Step). | |
| GltfAnimationInterpolation | getAnimationInterpolation () const |
| void | addMotion (const Character &character, float fps=120.0f, const MotionParameters &motion={}, const IdentityParameters &offsets={}, bool addExtensions=true, const std::string &customName="default", std::span< const int64_t > timestamps={}) |
| Add a motion to the provided character. | |
| void | addSkeletonStates (const Character &character, float fps, std::span< const SkeletonState > skeletonStates, const std::string &customName="default") |
| Add a skeleton states to the provided character. | |
| void | addMarkerSequence (float fps, std::span< const std::vector< momentum::Marker > > markerSequence, MarkerMesh markerMesh=MarkerMesh::UnitCube, const std::string &animName="default") |
| Add marker data to the file. | |
| void | save (const filesystem::path &filename, GltfFileFormat fileFormat=GltfFileFormat::Auto, bool embedResources=false) |
| void | forceEmbedResources () |
| Set all existing buffers to embed resources. | |
| const fx::gltf::Document & | getDocument () |
| Allow copy the document, but do not allow modify the file outside of the builder to keep metadata consistent. | |
| size_t | getNumCharacters () |
| size_t | getCharacterRootIndex (const std::string &name) |
| size_t | getNumJoints (const std::string &name) |
| size_t | getNumMotions () |
| float | getFps () |
| std::vector< size_t > | getCharacterMotions (const std::string &characterName) |
Static Public Member Functions | |
| static void | save (fx::gltf::Document &document, const filesystem::path &filename, GltfFileFormat fileFormat=GltfFileFormat::Auto, bool embedResources=false) |
| static void | forceEmbedResources (fx::gltf::Document &document) |
Helper class to build a glb scene.
It supports adding multiple characters and motions for each character. By default, momentum extension is added to the glb nodes. This is required if you want to correctly load the exported character back.
Definition at line 33 of file gltf_builder.h.
|
strong |
Specify how marker mesh is represented in the glb file.
| Enumerator | |
|---|---|
| None | |
| UnitCube | |
Definition at line 48 of file gltf_builder.h.
| momentum::GltfBuilder::GltfBuilder | ( | ) |
Definition at line 959 of file gltf_builder.cpp.
Referenced by addCharacter(), GltfBuilder(), GltfBuilder(), operator=(), and operator=().
|
default |
|
delete |
References GltfBuilder().
|
defaultnoexcept |
References GltfBuilder().
| void momentum::GltfBuilder::addCharacter | ( | const Character & | character, |
| const Vector3f & | positionOffset = Vector3f::Zero(), | ||
| const Quaternionf & | rotationOffset = Quaternionf::Identity(), | ||
| const FileSaveOptions & | options = FileSaveOptions() ) |
Add a character to the scene.
Each character will have a root node with the character's name as the parent of the skeleton root and the character mesh. positionOffset and rotationOffset can be provided as an initial offset to the character.
Definition at line 970 of file gltf_builder.cpp.
References addCharacter(), momentum::fromMomentumQuaternionf(), momentum::fromMomentumVec3f(), GltfBuilder(), MT_CHECK, momentum::parameterLimitsToJson(), momentum::parameterSetsToJson(), momentum::parameterTransformToJson(), and momentum::poseConstraintsToJson().
Referenced by addCharacter(), addMotion(), addSkeletonStates(), and momentum::makeCharacterDocument().
| void momentum::GltfBuilder::addMarkerSequence | ( | float | fps, |
| std::span< const std::vector< momentum::Marker > > | markerSequence, | ||
| MarkerMesh | markerMesh = MarkerMesh::UnitCube, | ||
| const std::string & | animName = "default" ) |
Add marker data to the file.
| [in] | fps | The frame rate of the motion capture data in frames per second. |
| [in] | markerSequence | A 2D vector specifying the Marker data (name/position/occlusion) for all markers across all captured frames. Size: [numFrames][numMarkers] |
| [in] | markerMesh | Optional parameter specifying the MarkerMesh type (default is MarkerMesh::None). |
| [in] | animName | Optional parameter specifying the animation name (default is "default"). |
Definition at line 1164 of file gltf_builder.cpp.
References setFps().
Referenced by momentum::makeCharacterDocument(), and momentum::saveMotion().
| void momentum::GltfBuilder::addMesh | ( | const Mesh & | mesh, |
| const std::string & | name, | ||
| bool | addColor = false ) |
Add a static mesh, such as an environment or a target scan.
Definition at line 1032 of file gltf_builder.cpp.
References MT_LOGW.
| void momentum::GltfBuilder::addMotion | ( | const Character & | character, |
| float | fps = 120.0f, | ||
| const MotionParameters & | motion = {}, | ||
| const IdentityParameters & | offsets = {}, | ||
| bool | addExtensions = true, | ||
| const std::string & | customName = "default", | ||
| std::span< const int64_t > | timestamps = {} ) |
Add a motion to the provided character.
If addCharacter is not called before adding the motion, the character will be automatically added with the default settings.
| [in] | character | The character to add motion for. |
| [in] | fps | Frame rate of the motion in frames per second. |
| [in] | motion | Motion parameters (parameter names and poses matrix). |
| [in] | offsets | Identity/offset parameters (joint names and offsets vector). |
| [in] | addExtensions | Whether to add momentum extensions to the document. |
| [in] | customName | Custom name for the animation (default is "default"). |
| [in] | timestamps | Per-frame timestamps. Size should match motion columns. |
Definition at line 1091 of file gltf_builder.cpp.
References addCharacter(), MT_THROW_IF, momentum::Character::name, and setFps().
Referenced by momentum::makeCharacterDocument(), and momentum::saveMotion().
| void momentum::GltfBuilder::addSkeletonStates | ( | const Character & | character, |
| float | fps, | ||
| std::span< const SkeletonState > | skeletonStates, | ||
| const std::string & | customName = "default" ) |
Add a skeleton states to the provided character.
If addCharacter is not called before adding the skeleton states, the character will be automatically added with the default settings.
Definition at line 1205 of file gltf_builder.cpp.
References addCharacter(), momentum::Character::name, and setFps().
| void momentum::GltfBuilder::forceEmbedResources | ( | ) |
Set all existing buffers to embed resources.
Definition at line 1190 of file gltf_builder.cpp.
References forceEmbedResources().
Referenced by forceEmbedResources(), momentum::makeCharacterDocument(), and save().
|
static |
Definition at line 1180 of file gltf_builder.cpp.
|
nodiscard |
Definition at line 1073 of file gltf_builder.cpp.
| std::vector< size_t > momentum::GltfBuilder::getCharacterMotions | ( | const std::string & | characterName | ) |
Definition at line 1157 of file gltf_builder.cpp.
| size_t momentum::GltfBuilder::getCharacterRootIndex | ( | const std::string & | name | ) |
Definition at line 1055 of file gltf_builder.cpp.
References momentum::kInvalidIndex.
| const fx::gltf::Document & momentum::GltfBuilder::getDocument | ( | ) |
Allow copy the document, but do not allow modify the file outside of the builder to keep metadata consistent.
Definition at line 1186 of file gltf_builder.cpp.
Referenced by momentum::makeCharacterDocument().
| float momentum::GltfBuilder::getFps | ( | ) |
Definition at line 1148 of file gltf_builder.cpp.
| size_t momentum::GltfBuilder::getNumCharacters | ( | ) |
Definition at line 1051 of file gltf_builder.cpp.
| size_t momentum::GltfBuilder::getNumJoints | ( | const std::string & | name | ) |
Definition at line 1062 of file gltf_builder.cpp.
References momentum::kInvalidIndex.
| size_t momentum::GltfBuilder::getNumMotions | ( | ) |
Definition at line 1144 of file gltf_builder.cpp.
|
defaultnoexcept |
References GltfBuilder().
|
delete |
References GltfBuilder().
| void momentum::GltfBuilder::save | ( | const filesystem::path & | filename, |
| GltfFileFormat | fileFormat = GltfFileFormat::Auto, | ||
| bool | embedResources = false ) |
Definition at line 1173 of file gltf_builder.cpp.
References save().
Referenced by save(), momentum::saveGltfCharacter(), momentum::saveGltfCharacter(), and momentum::saveMotion().
|
static |
Definition at line 1194 of file gltf_builder.cpp.
References forceEmbedResources().
| void momentum::GltfBuilder::setAnimationInterpolation | ( | GltfAnimationInterpolation | interpolation | ) |
Set how the joint and blend shape animation samplers added afterwards interpolate between their keys (default: Step).
Marker animation always uses Step.
| [in] | interpolation | Sampler interpolation for addMotion and addSkeletonStates. |
Definition at line 1069 of file gltf_builder.cpp.
Referenced by momentum::makeCharacterDocument().
| void momentum::GltfBuilder::setFps | ( | float | fps | ) |
Definition at line 1077 of file gltf_builder.cpp.
References MT_LOGW.
Referenced by addMarkerSequence(), addMotion(), and addSkeletonStates().