|
| 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 | + |
| 10 | +#include <string_view> |
| 11 | + |
| 12 | +namespace momentum { |
| 13 | + |
| 14 | +// ============================================================================ |
| 15 | +// GLTF File Format |
| 16 | +// ============================================================================ |
| 17 | + |
| 18 | +/// File format in which the character is saved |
| 19 | +enum class GltfFileFormat { |
| 20 | + Extension = 0, // The file extension is used for deduction (e.g. ".gltf" --> ASCII) |
| 21 | + GltfBinary = 1, // Binary format (generally .glb) |
| 22 | + GltfAscii = 2, // ASCII format (generally .gltf) |
| 23 | +}; |
| 24 | + |
| 25 | +/// Options for GLTF file export |
| 26 | +struct GltfOptions { |
| 27 | + /// Include GLTF extensions in the output. |
| 28 | + bool extensions = true; |
| 29 | + /// Include collision geometry in the output. |
| 30 | + bool collisions = true; |
| 31 | + /// Include locators in the output. |
| 32 | + bool locators = true; |
| 33 | + /// Include mesh geometry in the output. |
| 34 | + bool mesh = true; |
| 35 | + /// Include blend shapes in the output. |
| 36 | + bool blendShapes = true; |
| 37 | +}; |
| 38 | + |
| 39 | +// ============================================================================ |
| 40 | +// FBX Coordinate System Options |
| 41 | +// ===================================================================== |
| 42 | + |
| 43 | +/// Specifies which canonical axis represents up in the system (typically Y or Z). |
| 44 | +/// Maps to fbxsdk::FbxAxisSystem::EUpVector |
| 45 | +enum class FBXUpVector { XAxis = 1, YAxis = 2, ZAxis = 3 }; |
| 46 | + |
| 47 | +/// Vector with origin at the screen pointing toward the camera. |
| 48 | +/// This is a subset of enum EUpVector because axis cannot be repeated. |
| 49 | +/// We use the system of "parity" to define this vector because its value (X,Y or |
| 50 | +/// Z axis) really depends on the up-vector. |
| 51 | +/// Maps to fbxsdk::FbxAxisSystem::EFrontVector |
| 52 | +enum class FBXFrontVector { ParityEven = 1, ParityOdd = 2 }; |
| 53 | + |
| 54 | +/// Specifies the third vector of the system. |
| 55 | +/// Maps to fbxsdk::FbxAxisSystem::ECoordSystem |
| 56 | +enum class FBXCoordSystem { RightHanded, LeftHanded }; |
| 57 | + |
| 58 | +/// A struct containing the up, front vectors and coordinate system for FBX export. |
| 59 | +struct FBXCoordSystemInfo { |
| 60 | + /// Default to the same orientations as FbxAxisSystem::eMayaYUp |
| 61 | + FBXUpVector upVector = FBXUpVector::YAxis; |
| 62 | + FBXFrontVector frontVector = FBXFrontVector::ParityOdd; |
| 63 | + FBXCoordSystem coordSystem = FBXCoordSystem::RightHanded; |
| 64 | +}; |
| 65 | + |
| 66 | +// ============================================================================ |
| 67 | +// Unified File Save Options |
| 68 | +// ============================================================================ |
| 69 | + |
| 70 | +/// Unified options for saving files in both FBX and GLTF formats. |
| 71 | +/// |
| 72 | +/// This struct consolidates save options that were previously scattered across |
| 73 | +/// multiple function parameters. Format-specific options (e.g., FBX coordinate |
| 74 | +/// system, GLTF extensions) are included but only used by their respective formats. |
| 75 | +struct FileSaveOptions { |
| 76 | + // ---- Common Options (used by both FBX and GLTF) ---- |
| 77 | + |
| 78 | + /// Include mesh geometry in the output (default: true) |
| 79 | + bool mesh = true; |
| 80 | + |
| 81 | + /// Include locators in the output (default: true) |
| 82 | + bool locators = true; |
| 83 | + |
| 84 | + /// Include collision geometry in the output (default: true) |
| 85 | + bool collisions = true; |
| 86 | + |
| 87 | + /// Include blend shapes in the output (default: true) |
| 88 | + bool blendShapes = true; |
| 89 | + |
| 90 | + /// Permissive mode: allow saving mesh-only characters without skin weights (default: false) |
| 91 | + bool permissive = false; |
| 92 | + |
| 93 | + // ---- FBX-Specific Options ---- |
| 94 | + |
| 95 | + /// FBX coordinate system configuration (default: Maya Y-up) |
| 96 | + FBXCoordSystemInfo coordSystemInfo = {}; |
| 97 | + |
| 98 | + /// Optional namespace prefix for FBX node names (e.g., "ns" becomes "ns:") |
| 99 | + /// Only used for FBX output (default: empty = no namespace) |
| 100 | + std::string_view fbxNamespace = ""; |
| 101 | + |
| 102 | + // ---- GLTF-Specific Options ---- |
| 103 | + |
| 104 | + /// Enable GLTF extensions (default: true) |
| 105 | + /// Only used for GLTF output |
| 106 | + bool extensions = true; |
| 107 | + |
| 108 | + /// GLTF file format selection (default: Extension) |
| 109 | + /// Only used for GLTF output |
| 110 | + GltfFileFormat gltfFileFormat = GltfFileFormat::Extension; |
| 111 | +}; |
| 112 | + |
| 113 | +} // namespace momentum |
0 commit comments