Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
fbx_io.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/types.h>
15
16#include <span>
17
18#include <string_view>
19
20namespace momentum {
21
22// KeepLocators Specifies whether Nulls in the transform hierarchy should be turned into Locators.
23enum class KeepLocators { No, Yes };
24
25// LoadBlendShapes Specifies whether blendshapes should be loaded or not
26enum class LoadBlendShapes { No, Yes };
27
28// Using keepLocators means the Nulls in the transform hierarchy will be turned into Locators.
29// This is different from historical momentum behavior so it's off by default.
30// Permissive mode allows loading mesh-only characters (without skin weights).
31Character loadFbxCharacter(
32 const filesystem::path& inputPath,
33 KeepLocators keepLocators = KeepLocators::No,
34 Permissive permissive = Permissive::No,
35 LoadBlendShapes loadBlendShapes = LoadBlendShapes::No,
36 bool stripNamespaces = true);
37
38// Using keepLocators means the Nulls in the transform hierarchy will be turned into Locators.
39// This is different from historical momentum behavior so it's off by default.
40// Permissive mode allows loading mesh-only characters (without skin weights).
41Character loadFbxCharacter(
42 std::span<const std::byte> inputSpan,
43 KeepLocators keepLocators = KeepLocators::No,
44 Permissive permissive = Permissive::No,
45 LoadBlendShapes loadBlendShapes = LoadBlendShapes::No,
46 bool stripNamespaces = true);
47
48// Permissive mode allows loading mesh-only characters (without skin weights).
49std::tuple<Character, std::vector<MatrixXf>, float> loadFbxCharacterWithMotion(
50 const filesystem::path& inputPath,
51 KeepLocators keepLocators = KeepLocators::No,
52 Permissive permissive = Permissive::No,
53 LoadBlendShapes loadBlendShapes = LoadBlendShapes::No,
54 bool stripNamespaces = true);
55
56// Permissive mode allows loading mesh-only characters (without skin weights).
57std::tuple<Character, std::vector<MatrixXf>, float> loadFbxCharacterWithMotion(
58 std::span<const std::byte> inputSpan,
59 KeepLocators keepLocatorss = KeepLocators::No,
60 Permissive permissive = Permissive::No,
62 bool stripNamespaces = true);
63
77void saveFbx(
78 const filesystem::path& filename,
79 const Character& character,
80 const MatrixXf& poses = MatrixXf(),
81 const VectorXf& identity = VectorXf(),
82 double framerate = 120.0,
83 std::span<const std::vector<Marker>> markerSequence = {},
84 const FileSaveOptions& options = FileSaveOptions());
85
101 const filesystem::path& filename,
102 const Character& character,
103 const MatrixXf& jointParams = MatrixXf(),
104 double framerate = 120.0,
105 std::span<const std::vector<Marker>> markerSequence = {},
106 const FileSaveOptions& options = FileSaveOptions());
107
120 const filesystem::path& filename,
121 const Character& character,
122 std::span<const SkeletonState> skeletonStates,
123 double framerate = 120.0,
124 std::span<const std::vector<Marker>> markerSequence = {},
125 const FileSaveOptions& options = FileSaveOptions());
126
131void saveFbxModel(
132 const filesystem::path& filename,
133 const Character& character,
134 const FileSaveOptions& options = FileSaveOptions());
135
144MatrixXf loadFbxBlendShapeWeights(const filesystem::path& filename);
145
159MarkerSequence loadFbxMarkerSequence(const filesystem::path& filename, bool stripNamespaces = true);
160
170 std::span<const std::byte> inputSpan,
171 bool stripNamespaces = true);
172
173} // namespace momentum
void saveFbxWithJointParams(const filesystem::path &, const Character &, const MatrixXf &, const double, std::span< const std::vector< Marker > >, const FileSaveOptions &)
Save a character with animation using joint parameters directly.
Definition fbx_io.cpp:436
void saveFbxWithSkeletonStates(const filesystem::path &, const Character &, std::span< const SkeletonState >, const double, std::span< const std::vector< Marker > >, const FileSaveOptions &)
Save a character with animation using skeleton states directly.
Definition fbx_io.cpp:447
void saveFbx(const filesystem::path &, const Character &, const MatrixXf &, const VectorXf &, const double, std::span< const std::vector< Marker > >, const FileSaveOptions &)
Save a character with animation to an FBX file.
Definition fbx_io.cpp:424
Character loadFbxCharacter(const filesystem::path &inputPath, KeepLocators keepLocators, Permissive permissive, LoadBlendShapes loadBlendShapes, bool stripNamespaces)
Definition fbx_io.cpp:178
std::tuple< Character, std::vector< MatrixXf >, float > loadFbxCharacterWithMotion(const filesystem::path &inputPath, KeepLocators keepLocators, Permissive permissive, LoadBlendShapes loadBlendShapes, bool stripNamespaces)
Definition fbx_io.cpp:198
BlendShape loadBlendShape(const filesystem::path &filename, int expectedShapes, int expectedVertices)
Loads a blend shape from a file, including base shape and shape vectors.
MarkerSequence loadFbxMarkerSequence(const filesystem::path &filename, bool stripNamespaces)
Loads a MarkerSequence from an FBX file.
Definition fbx_io.cpp:218
LoadBlendShapes
Definition fbx_io.h:26
KeepLocators
Definition fbx_io.h:23
VectorX< float > VectorXf
Definition types.h:209
MatrixXf loadFbxBlendShapeWeights(const filesystem::path &)
Load per-frame blend shape animation weights from an FBX file.
Definition fbx_io.cpp:466
void saveFbxModel(const filesystem::path &, const Character &, const FileSaveOptions &)
Save a character model (skeleton and mesh) without animation.
Definition fbx_io.cpp:458
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.
All frames from a single motion capture sequence for one subject (actor).
Definition marker.h:37