Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
fbx_builder.cpp
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
9
11
12#ifdef MOMENTUM_WITH_FBX_SDK
13
17
18#include <unordered_map>
19
20namespace momentum {
21
22using namespace fbx_internal; // NOLINT(google-build-using-namespace)
23
24struct FbxBuilder::Impl {
25 struct CharacterData {
26 SkeletonNodeResult skeletonResult;
27 MeshBlendShapeResult meshResult;
28 std::string name;
29 };
30
31 ::fbxsdk::FbxManager* manager = nullptr;
32 ::fbxsdk::FbxScene* scene = nullptr;
33 std::unordered_map<std::string, CharacterData> characters;
34
35 Impl() {
36 manager = ::fbxsdk::FbxManager::Create();
37 auto* ios = ::fbxsdk::FbxIOSettings::Create(manager, IOSROOT);
38 manager->SetIOSettings(ios);
39 scene = ::fbxsdk::FbxScene::Create(manager, "momentum_scene");
40 }
41
42 ~Impl() {
43 if (scene != nullptr) {
44 scene->Destroy();
45 scene = nullptr;
46 }
47 if (manager != nullptr) {
48 manager->Destroy();
49 manager = nullptr;
50 }
51 }
52
53 Impl(const Impl&) = delete;
54 Impl& operator=(const Impl&) = delete;
55 Impl(Impl&&) = delete;
56 Impl& operator=(Impl&&) = delete;
57};
58
59FbxBuilder::FbxBuilder() : impl_(std::make_unique<Impl>()) {}
60
61FbxBuilder::~FbxBuilder() = default;
62
63FbxBuilder::FbxBuilder(FbxBuilder&&) noexcept = default;
64
65FbxBuilder& FbxBuilder::operator=(FbxBuilder&&) noexcept = default;
66
67void FbxBuilder::addCharacter(const Character& character, const FileSaveOptions& options) {
68 MT_THROW_IF(!impl_, "FbxBuilder has been moved from or already saved");
69 MT_THROW_IF(!impl_->scene, "FBX scene is null");
70
71 auto* root = impl_->scene->GetRootNode();
72 MT_THROW_IF(root == nullptr, "Unable to get root node from FBX scene");
73
74 // Set coordinate system
75 ::fbxsdk::FbxAxisSystem axis = toFbx(options.coordSystemInfo);
76 axis.ConvertScene(impl_->scene);
77
78 // Create skeleton hierarchy
79 auto skeletonResult = createSkeletonNodes(character, impl_->scene);
80 addMetaData(skeletonResult.rootNode, character);
81 addPhysicalProperties(character, skeletonResult.jointToNodeMap);
82
83 if (options.locators) {
84 createLocatorNodes(character, impl_->scene, skeletonResult.nodes);
85 }
86 if (options.collisions) {
87 createCollisionGeometryNodes(character, impl_->scene, skeletonResult.nodes);
88 }
89
90 // Create mesh with blend shapes (parented to scene root = skinned)
91 MeshBlendShapeResult meshResult;
92 if (options.mesh && character.mesh != nullptr) {
93 meshResult = createMeshNode(
94 character, impl_->scene, root, skeletonResult.jointToNodeMap, options.permissive);
95 }
96
97 // Add skeleton to scene root
98 if (!skeletonResult.nodes.empty()) {
99 root->AddChild(skeletonResult.rootNode);
100 }
101
102 // Store character data for later animation
103 const std::string& name = character.name;
104 impl_->characters[name] = {std::move(skeletonResult), std::move(meshResult), name};
105}
106
107void FbxBuilder::addRigidBody(
108 const Character& character,
109 const std::string& name,
110 size_t parentJoint,
111 const FileSaveOptions& options) {
112 MT_THROW_IF(!impl_, "FbxBuilder has been moved from or already saved");
113 MT_THROW_IF(!impl_->scene, "FBX scene is null");
114
115 auto* root = impl_->scene->GetRootNode();
116 MT_THROW_IF(root == nullptr, "Unable to get root node from FBX scene");
117
118 const std::string charName = name.empty() ? character.name : name;
119
120 // Create skeleton hierarchy
121 auto skeletonResult = createSkeletonNodes(character, impl_->scene);
122 addMetaData(skeletonResult.rootNode, character);
123 addPhysicalProperties(character, skeletonResult.jointToNodeMap);
124
125 // Prefix skeleton joint names with charName to avoid collisions when
126 // multiple rigid bodies share the scene (e.g. "root" -> "controller_l:root").
127 if (!name.empty()) {
128 for (auto* node : skeletonResult.nodes) {
129 std::string prefixed = charName + ":" + node->GetName();
130 node->SetName(prefixed.c_str());
131 if (auto* attr = node->GetNodeAttribute()) {
132 attr->SetName(prefixed.c_str());
133 }
134 }
135 }
136
137 // Resolve which joint node to parent the mesh under
139 parentJoint >= skeletonResult.nodes.size(),
140 "parentJoint index {} out of range for skeleton with {} joints",
141 parentJoint,
142 skeletonResult.nodes.size());
143 ::fbxsdk::FbxNode* meshParentNode = skeletonResult.nodes[parentJoint];
144
145 // Create mesh parented under the target joint (no skin deformer = rigid body)
146 MeshBlendShapeResult meshResult;
147 if (options.mesh && character.mesh != nullptr) {
148 // Create mesh node with vertices, normals, and UVs but no skin deformer.
149 // Parent it under the target joint so it moves rigidly with that joint.
150 const auto numVertices = static_cast<int>(character.mesh->vertices.size());
151 ::fbxsdk::FbxNode* meshNode =
152 ::fbxsdk::FbxNode::Create(impl_->scene, (charName + "_mesh").c_str());
153 ::fbxsdk::FbxMesh* lMesh = ::fbxsdk::FbxMesh::Create(impl_->scene, "mesh");
154 lMesh->SetControlPointCount(numVertices);
155 lMesh->InitNormals(numVertices);
156 for (int i = 0; i < numVertices; i++) {
157 FbxVector4 point(
158 character.mesh->vertices[i].x(),
159 character.mesh->vertices[i].y(),
160 character.mesh->vertices[i].z());
161 FbxVector4 normal(
162 character.mesh->normals[i].x(),
163 character.mesh->normals[i].y(),
164 character.mesh->normals[i].z());
165 lMesh->SetControlPointAt(point, normal, i);
166 }
167 writePolygonsToFbxMesh(*character.mesh, lMesh);
168 lMesh->BuildMeshEdgeArray();
169 meshNode->SetNodeAttribute(lMesh);
170
171 // Add texture coordinates
172 if (!character.mesh->texcoords.empty()) {
173 const fbxsdk::FbxLayerElement::EType uvType = fbxsdk::FbxLayerElement::eTextureDiffuse;
174 lMesh->InitTextureUV(0, uvType);
175 lMesh->InitTextureUVIndices(
176 ::fbxsdk::FbxLayerElement::EMappingMode::eByPolygonVertex, uvType);
177 for (const auto& texcoords : character.mesh->texcoords) {
178 lMesh->AddTextureUV(::fbxsdk::FbxVector2(texcoords[0], 1.0f - texcoords[1]), uvType);
179 }
180 writeTextureUVIndicesToFbxMesh(*character.mesh, lMesh, uvType);
181 }
182
183 // No skin deformer — parent mesh under target joint for rigid body behavior
184 if (meshParentNode != nullptr) {
185 meshParentNode->AddChild(meshNode);
186 }
187 }
188
189 // Add skeleton to scene root
190 if (!skeletonResult.nodes.empty()) {
191 root->AddChild(skeletonResult.rootNode);
192 }
193
194 impl_->characters[character.name] = {std::move(skeletonResult), std::move(meshResult), charName};
195}
196
197void FbxBuilder::addMotion(
198 const Character& character,
199 float fps,
200 const MatrixXf& motion,
201 const VectorXf& offsets) {
202 MT_THROW_IF(!impl_, "FbxBuilder has been moved from or already saved");
203
204 auto it = impl_->characters.find(character.name);
206 it == impl_->characters.end(),
207 "Character '{}' has not been added to the builder",
208 character.name);
209
210 if (motion.cols() == 0) {
211 return;
212 }
213
214 // Convert model params to joint params via CharacterState
215 CharacterParameters params;
216 if (offsets.size() == character.parameterTransform.numJointParameters()) {
217 params.offsets = offsets;
218 } else {
219 params.offsets = character.parameterTransform.bindPose();
220 }
221
222 CharacterState state;
223 MatrixXf jointValues;
224 params.pose = motion.col(0);
225 state.set(params, character, false, false, false);
226
227 jointValues.resize(state.skeletonState.jointParameters.v.size(), motion.cols());
228 jointValues.col(0) = state.skeletonState.jointParameters.v;
229
230 for (Eigen::Index f = 1; f < motion.cols(); f++) {
231 params.pose = motion.col(f);
232 state.set(params, character, false, false, false);
233 jointValues.col(f) = state.skeletonState.jointParameters.v;
234 }
235
236 const auto& charData = it->second;
237 if (jointValues.rows() == character.parameterTransform.numJointParameters()) {
239 character, impl_->scene, charData.skeletonResult.nodes, jointValues, fps, false);
240 }
241
242 // Blend shape animation
243 const MatrixXf blendShapeWeights = extractBlendShapeWeights(character, motion);
244 if (blendShapeWeights.cols() > 0 && !charData.meshResult.blendShapeChannels.empty()) {
246 impl_->scene, charData.meshResult.blendShapeChannels, blendShapeWeights, fps);
247 }
248 const MatrixXf faceExpressionWeights = extractFaceExpressionWeights(character, motion);
249 if (faceExpressionWeights.cols() > 0 && !charData.meshResult.faceExprChannels.empty()) {
251 impl_->scene, charData.meshResult.faceExprChannels, faceExpressionWeights, fps);
252 }
253}
254
255void FbxBuilder::addMotionWithJointParams(
256 const Character& character,
257 float fps,
258 const MatrixXf& jointParams) {
259 MT_THROW_IF(!impl_, "FbxBuilder has been moved from or already saved");
260
261 auto it = impl_->characters.find(character.name);
263 it == impl_->characters.end(),
264 "Character '{}' has not been added to the builder",
265 character.name);
266
267 if (jointParams.cols() == 0) {
268 return;
269 }
270
271 const auto& charData = it->second;
273 character,
274 impl_->scene,
275 charData.skeletonResult.nodes,
276 jointParams,
277 fps,
278 true); // skipActiveJointParamCheck = true
279}
280
281namespace {
282
283// Writes each entry as a user-defined FBX property. The eUserDefined flag is what
284// makes DCC tools treat these as the object's custom attributes; without it they
285// are stored but not surfaced on import.
286void writeUserProperties(::fbxsdk::FbxNode* node, const FbxUserProperties& userProperties) {
287 for (const auto& entry : userProperties) {
288 const std::string& propertyName = entry.first;
289 const FbxUserPropertyValue& value = entry.second;
290 std::visit(
291 [&](const auto& typedValue) {
292 using T = std::decay_t<decltype(typedValue)>;
293 ::fbxsdk::FbxDataType dataType;
294 if constexpr (std::is_same_v<T, bool>) {
295 dataType = ::fbxsdk::FbxBoolDT;
296 } else if constexpr (std::is_same_v<T, int>) {
297 dataType = ::fbxsdk::FbxIntDT;
298 } else if constexpr (std::is_same_v<T, float>) {
299 dataType = ::fbxsdk::FbxFloatDT;
300 } else {
301 dataType = ::fbxsdk::FbxStringDT;
302 }
303 auto property = ::fbxsdk::FbxProperty::Create(node, dataType, propertyName.c_str());
304 property.ModifyFlag(::fbxsdk::FbxPropertyFlags::eUserDefined, true);
305 if constexpr (std::is_same_v<T, std::string>) {
306 property.Set(::fbxsdk::FbxString(typedValue.c_str()));
307 } else {
308 property.Set(typedValue);
309 }
310 },
311 value);
312 }
313}
314
315} // namespace
316
317void FbxBuilder::addAnimatedMesh(
318 const Character& character,
319 const std::string& name,
320 float fps,
321 const MatrixXf& jointParams,
322 const FbxUserProperties& userProperties) {
323 MT_THROW_IF(character.mesh == nullptr, "Character has no mesh");
324 addAnimatedMesh(
325 *character.mesh,
326 name,
327 fps,
328 jointParams,
329 character.skeleton.joints.empty() ? Vector3f::Zero()
330 : character.skeleton.joints[0].translationOffset,
331 userProperties);
332}
333
334void FbxBuilder::addAnimatedMesh(
335 const Mesh& mesh,
336 const std::string& name,
337 float fps,
338 const MatrixXf& jointParams,
339 const Vector3f& translationOffset,
340 const FbxUserProperties& userProperties) {
341 MT_THROW_IF(!impl_, "FbxBuilder has been moved from or already saved");
342 MT_THROW_IF(!impl_->scene, "FBX scene is null");
343 MT_THROW_IF(jointParams.cols() == 0, "jointParams is empty");
344
345 auto* root = impl_->scene->GetRootNode();
346 MT_THROW_IF(root == nullptr, "Unable to get root node from FBX scene");
347
348 // Create mesh node directly under scene root (no skeleton)
349 const auto numVertices = static_cast<int>(mesh.vertices.size());
350 ::fbxsdk::FbxNode* meshNode = ::fbxsdk::FbxNode::Create(impl_->scene, name.c_str());
351 ::fbxsdk::FbxMesh* lMesh = ::fbxsdk::FbxMesh::Create(impl_->scene, (name + "_geo").c_str());
352 lMesh->SetControlPointCount(numVertices);
353 lMesh->InitNormals(numVertices);
354 for (int i = 0; i < numVertices; i++) {
355 lMesh->SetControlPointAt(
356 FbxVector4(mesh.vertices[i].x(), mesh.vertices[i].y(), mesh.vertices[i].z()),
357 FbxVector4(mesh.normals[i].x(), mesh.normals[i].y(), mesh.normals[i].z()),
358 i);
359 }
360 writePolygonsToFbxMesh(mesh, lMesh);
361 lMesh->BuildMeshEdgeArray();
362 meshNode->SetNodeAttribute(lMesh);
363
364 if (!mesh.texcoords.empty()) {
365 const fbxsdk::FbxLayerElement::EType uvType = fbxsdk::FbxLayerElement::eTextureDiffuse;
366 lMesh->InitTextureUV(0, uvType);
367 lMesh->InitTextureUVIndices(::fbxsdk::FbxLayerElement::EMappingMode::eByPolygonVertex, uvType);
368 for (const auto& texcoords : mesh.texcoords) {
369 lMesh->AddTextureUV(::fbxsdk::FbxVector2(texcoords[0], 1.0f - texcoords[1]), uvType);
370 }
371 writeTextureUVIndicesToFbxMesh(mesh, lMesh, uvType);
372 }
373
374 writeUserProperties(meshNode, userProperties);
375
376 root->AddChild(meshNode);
377
378 // Animate the mesh node's transform using the root joint parameters.
379 setFrameRate(impl_->scene, fps);
380 auto [animStack, animBaseLayer] =
381 getOrCreateAnimStackAndLayer(impl_->scene, "Skeleton Animation Stack");
382
383 // jointParams is (nJointParams x nFrames) in C++ convention.
384 // FBX uses 9 channels; momentum uses 7 (uniform scale maps to all three).
385 Joint rootJoint;
386 rootJoint.translationOffset = translationOffset;
387
388 const auto nFrames = jointParams.cols();
389
390 // Set static default transform (used for constant channels)
391 FbxDouble3 staticTrans(
392 jointParamToFbx(jointParams(0, 0), 0, rootJoint),
393 jointParamToFbx(jointParams(1, 0), 1, rootJoint),
394 jointParamToFbx(jointParams(2, 0), 2, rootJoint));
395 meshNode->LclTranslation.Set(staticTrans);
396 FbxDouble3 staticRot(
397 jointParamToFbx(jointParams(3, 0), 3, rootJoint),
398 jointParamToFbx(jointParams(4, 0), 4, rootJoint),
399 jointParamToFbx(jointParams(5, 0), 5, rootJoint));
400 meshNode->LclRotation.Set(staticRot);
401 const Eigen::Index scaleRow = std::min(static_cast<Eigen::Index>(6), jointParams.rows() - 1);
402 const float staticScale = jointParamToFbx(jointParams(scaleRow, 0), 6, rootJoint);
403 meshNode->LclScaling.Set(FbxDouble3(staticScale, staticScale, staticScale));
404
405 // Only create curve nodes and curves for non-constant channels to avoid
406 // empty curves overriding the static property values in DCC tools.
407 const std::array<::fbxsdk::FbxProperty*, 3> properties = {
408 &meshNode->LclTranslation,
409 &meshNode->LclRotation,
410 &meshNode->LclScaling,
411 };
412 const std::array<const char*, 3> components = {
413 FBXSDK_CURVENODE_COMPONENT_X,
414 FBXSDK_CURVENODE_COMPONENT_Y,
415 FBXSDK_CURVENODE_COMPONENT_Z,
416 };
417
418 ::fbxsdk::FbxTime time;
419 for (size_t c = 0; c < 9; c++) {
420 const auto paramRow = static_cast<Eigen::Index>(std::min(c, size_t(6)));
421 if (paramRow >= jointParams.rows()) {
422 break;
423 }
424
425 bool isConstant = true;
426 const float firstVal = jointParams(paramRow, 0);
427 for (Eigen::Index f = 1; f < nFrames; f++) {
428 if (jointParams(paramRow, f) != firstVal) {
429 isConstant = false;
430 break;
431 }
432 }
433 if (isConstant) {
434 continue;
435 }
436
437 auto* prop = properties[c / 3];
438 prop->GetCurveNode(true);
439 auto* curve = prop->GetCurve(animBaseLayer, components[c % 3], true);
440
441 curve->KeyModifyBegin();
442 for (Eigen::Index f = 0; f < nFrames; f++) {
443 const float val = jointParamToFbx(jointParams(paramRow, f), c, rootJoint);
444 time.SetSecondDouble(static_cast<double>(f) / fps);
445 const auto keyIndex = curve->KeyAdd(time);
446 curve->KeySet(keyIndex, time, val);
447 }
448 curve->KeyModifyEnd();
449 }
450}
451
452void FbxBuilder::addMarkerSequence(float fps, std::span<const std::vector<Marker>> markerSequence) {
453 MT_THROW_IF(!impl_, "FbxBuilder has been moved from or already saved");
454
455 if (!markerSequence.empty()) {
456 createMarkerNodes(impl_->scene, markerSequence, fps);
457 }
458}
459
460void FbxBuilder::save(const filesystem::path& filename) {
461 MT_THROW_IF(!impl_, "FbxBuilder has been moved from or already saved");
462
463 auto* lExporter = ::fbxsdk::FbxExporter::Create(impl_->manager, "");
464
465 std::string sFilename = filename.string();
466 bool lExportStatus =
467 lExporter->Initialize(sFilename.c_str(), -1, impl_->manager->GetIOSettings());
468
470 !lExportStatus,
471 "Unable to initialize fbx exporter: {}",
472 lExporter->GetStatus().GetErrorString());
473
474 lExporter->Export(impl_->scene);
475 lExporter->Destroy();
476
477 // Clean up — the builder is consumed after save
478 impl_.reset();
479}
480
481} // namespace momentum
482
483#else // !MOMENTUM_WITH_FBX_SDK
484
485namespace momentum {
486
488
490 MT_THROW(
491 "FbxBuilder requires the Autodesk FBX SDK. FBX loading is available via OpenFBX, but building scenes requires the full SDK.");
492}
493
494FbxBuilder::~FbxBuilder() = default;
495
496FbxBuilder::FbxBuilder(FbxBuilder&&) noexcept = default;
497
498FbxBuilder& FbxBuilder::operator=(FbxBuilder&&) noexcept = default;
499
501 MT_THROW("FbxBuilder requires the Autodesk FBX SDK.");
502}
503
505 const Character&,
506 const std::string&,
507 size_t,
508 const FileSaveOptions&) {
509 MT_THROW("FbxBuilder requires the Autodesk FBX SDK.");
510}
511
512void FbxBuilder::addMotion(const Character&, float, const MatrixXf&, const VectorXf&) {
513 MT_THROW("FbxBuilder requires the Autodesk FBX SDK.");
514}
515
517 MT_THROW("FbxBuilder requires the Autodesk FBX SDK.");
518}
519
521 const Character&,
522 const std::string&,
523 float,
524 const MatrixXf&,
525 const FbxUserProperties&) {
526 MT_THROW("FbxBuilder requires the Autodesk FBX SDK.");
527}
528
530 const Mesh&,
531 const std::string&,
532 float,
533 const MatrixXf&,
534 const Vector3f&,
535 const FbxUserProperties&) {
536 MT_THROW("FbxBuilder requires the Autodesk FBX SDK.");
537}
538
539void FbxBuilder::addMarkerSequence(float, std::span<const std::vector<Marker>>) {
540 MT_THROW("FbxBuilder requires the Autodesk FBX SDK.");
541}
542
543void FbxBuilder::save(const filesystem::path&) {
544 MT_THROW("FbxBuilder requires the Autodesk FBX SDK.");
545}
546
547} // namespace momentum
548
549#endif // MOMENTUM_WITH_FBX_SDK
Builder class for creating FBX files with multiple characters and animations.
Definition fbx_builder.h:49
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.
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.
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).
#define MT_THROW(...)
Throws a std::runtime_error with a formatted message.
Definition exception.h:31
#define MT_THROW_IF(Condition,...)
Conditionally throws a std::runtime_error with a formatted message if the condition is true.
Definition exception.h:55
MatrixXf extractBlendShapeWeights(const Character &character, const MatrixXf &poses)
void addPhysicalProperties(const Character &character, const std::unordered_map< size_t, fbxsdk::FbxNode * > &jointToNodeMap)
std::pair<::fbxsdk::FbxAnimStack *, ::fbxsdk::FbxAnimLayer * > getOrCreateAnimStackAndLayer(::fbxsdk::FbxScene *scene, const char *stackName)
void createAnimationCurves(const Character &character, ::fbxsdk::FbxScene *scene, const std::vector<::fbxsdk::FbxNode * > &skeletonNodes, const MatrixXf &jointValues, const double framerate, const bool skipActiveJointParamCheck)
void setFrameRate(::fbxsdk::FbxScene *scene, const double framerate)
std::vector<::fbxsdk::FbxNode * > createMarkerNodes(::fbxsdk::FbxScene *scene, std::span< const std::vector< Marker > > markerSequence, const double framerate)
void writeTextureUVIndicesToFbxMesh(const Mesh &mesh, ::fbxsdk::FbxMesh *lMesh, fbxsdk::FbxLayerElement::EType uvType)
::fbxsdk::FbxAxisSystem::EUpVector toFbx(const FbxUpVector upVector)
void createBlendShapeAnimationCurves(::fbxsdk::FbxScene *scene, const std::vector<::fbxsdk::FbxBlendShapeChannel * > &channels, const MatrixXf &weights, const double framerate)
MatrixXf extractFaceExpressionWeights(const Character &character, const MatrixXf &poses)
void createLocatorNodes(const Character &character, ::fbxsdk::FbxScene *scene, const std::vector<::fbxsdk::FbxNode * > &skeletonNodes)
float jointParamToFbx(float value, size_t curveOffset, const Joint &joint)
Convert a raw momentum joint parameter to the FBX-native value.
void createCollisionGeometryNodes(const Character &character, ::fbxsdk::FbxScene *scene, const std::vector<::fbxsdk::FbxNode * > &skeletonNodes)
SkeletonNodeResult createSkeletonNodes(const Character &character, ::fbxsdk::FbxScene *scene)
MeshBlendShapeResult createMeshNode(const Character &character, ::fbxsdk::FbxScene *scene, ::fbxsdk::FbxNode *parentNode, const std::unordered_map< size_t, fbxsdk::FbxNode * > &jointToNodeMap, Permissive permissive, const std::string &meshName="body_mesh")
void writePolygonsToFbxMesh(const Mesh &mesh, ::fbxsdk::FbxMesh *lMesh)
void addMetaData(::fbxsdk::FbxNode *skeletonRootNode, const Character &character)
T normal(const T &mean, const T &sigma)
Normally distributed value via the global Random singleton.
Definition random-inl.h:382
CharacterStateT< float > CharacterState
Definition fwd.h:92
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
CharacterParametersT< float > CharacterParameters
Definition types.h:168
JointT< float > Joint
Definition fwd.h:206
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.
Vector3< T > translationOffset
Constant translation offset from the parent joint's origin to this joint's origin,...
Definition joint.h:36