Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
fbx_builder.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
14#include <momentum/math/mesh.h>
15#include <momentum/math/types.h>
16
17#include <map>
18#include <span>
19#include <string>
20#include <variant>
21
22namespace momentum {
23
25using FbxUserPropertyValue = std::variant<bool, int, float, std::string>;
26
32using FbxUserProperties = std::map<std::string, FbxUserPropertyValue>;
33
49class FbxBuilder final {
50 public:
51 FbxBuilder();
52
54
55 FbxBuilder(FbxBuilder const&) = delete;
56
57 void operator=(FbxBuilder const&) = delete;
58
60
61 FbxBuilder& operator=(FbxBuilder&&) noexcept;
62
70 void addCharacter(const Character& character, const FileSaveOptions& options = FileSaveOptions());
71
82 void addRigidBody(
83 const Character& character,
84 const std::string& name = "",
85 size_t parentJoint = 0,
86 const FileSaveOptions& options = FileSaveOptions());
87
98 void addMotion(
99 const Character& character,
100 float fps,
101 const MatrixXf& motion = {},
102 const VectorXf& offsets = {});
103
112 void addMotionWithJointParams(const Character& character, float fps, const MatrixXf& jointParams);
113
126 void addAnimatedMesh(
127 const Character& character,
128 const std::string& name,
129 float fps,
130 const MatrixXf& jointParams,
131 const FbxUserProperties& userProperties = {});
132
148 void addAnimatedMesh(
149 const Mesh& mesh,
150 const std::string& name,
151 float fps,
152 const MatrixXf& jointParams,
153 const Vector3f& translationOffset = Vector3f::Zero(),
154 const FbxUserProperties& userProperties = {});
155
160 void addMarkerSequence(float fps, std::span<const std::vector<Marker>> markerSequence);
161
167 void save(const filesystem::path& filename);
168
169 private:
170 struct Impl;
171 std::unique_ptr<Impl> impl_;
172};
173
174} // namespace momentum
void addMarkerSequence(float fps, std::span< const std::vector< Marker > > markerSequence)
Add a marker sequence to the scene.
void addMotionWithJointParams(const Character &character, float fps, const MatrixXf &jointParams)
Add joint-parameter animation for a previously added character.
FbxBuilder(FbxBuilder &&) noexcept
void save(const filesystem::path &filename)
Save the FBX scene to a file.
void operator=(FbxBuilder const &)=delete
void addRigidBody(const Character &character, const std::string &name="", size_t parentJoint=0, const FileSaveOptions &options=FileSaveOptions())
Add a rigid body (skeleton + mesh parented to a joint, no skinning).
void addMotion(const Character &character, float fps, const MatrixXf &motion={}, const VectorXf &offsets={})
Add model-parameter animation for a previously added character.
void addCharacter(const Character &character, const FileSaveOptions &options=FileSaveOptions())
Add a skinned character (skeleton + mesh with skin weights) to the scene.
FbxBuilder(FbxBuilder const &)=delete
void addAnimatedMesh(const Character &character, const std::string &name, float fps, const MatrixXf &jointParams, const FbxUserProperties &userProperties={})
Add an animated mesh (mesh node with per-frame transform, no skeleton).
std::variant< bool, int, float, std::string > FbxUserPropertyValue
Value of a user-defined FBX property.
Definition fbx_builder.h:25
MeshT< float > Mesh
Definition fwd.h:20
std::map< std::string, FbxUserPropertyValue > FbxUserProperties
User-defined FBX properties, keyed by property name.
Definition fbx_builder.h:32
Vector3< float > Vector3f
Definition types.h:251
VectorX< float > VectorXf
Definition types.h:209
MatrixX< float > MatrixXf
Definition types.h:82
A character model with skeletal structure, mesh, and optional components.
Definition character.h:32
Unified options for saving files in both FBX and GLTF formats.