Resolve various minor merge conflicts.
This commit is contained in:
commit
dcf14d1039
|
@ -17,10 +17,11 @@ set(CMAKE_CXX_STANDARD 11)
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
|
|
||||||
if(NOT EXISTS "${CMAKE_BINARY_DIR}/Findboost_filesystem.cmake")
|
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan_paths.cmake")
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"The Conan package manager must run ('install') first. ${typical_usage_str}")
|
"The Conan package manager must run ('install') first. ${typical_usage_str}")
|
||||||
endif()
|
endif()
|
||||||
|
include("${CMAKE_BINARY_DIR}/conan_paths.cmake")
|
||||||
|
|
||||||
# FBX
|
# FBX
|
||||||
foreach (FBXSDK_VERSION "2019.2")
|
foreach (FBXSDK_VERSION "2019.2")
|
||||||
|
|
|
@ -46,6 +46,8 @@ Options:
|
||||||
Whether to use 32-bit indices.
|
Whether to use 32-bit indices.
|
||||||
--compute-normals (never|broken|missing|always)
|
--compute-normals (never|broken|missing|always)
|
||||||
When to compute vertex normals from mesh geometry.
|
When to compute vertex normals from mesh geometry.
|
||||||
|
--anim-framerate (bake24|bake30|bake60)
|
||||||
|
Select baked animation framerate.
|
||||||
--flip-u Flip all U texture coordinates.
|
--flip-u Flip all U texture coordinates.
|
||||||
--no-flip-u Don't flip U texture coordinates.
|
--no-flip-u Don't flip U texture coordinates.
|
||||||
--flip-v Flip all V texture coordinates.
|
--flip-v Flip all V texture coordinates.
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
import {assert, expect} from 'chai';
|
import {assert, expect} from 'chai';
|
||||||
import * as fbx2gltf from 'fbx2gltf';
|
import * as fbx2gltf from 'fbx2gltf';
|
||||||
import {readFileSync} from 'fs';
|
import {readFileSync} from 'fs';
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
# Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This source code is licensed under the BSD-style license found in the
|
||||||
|
# LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
# of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
|
||||||
--ui mocha-typescript
|
--ui mocha-typescript
|
||||||
--require source-map-support/register
|
--require source-map-support/register
|
||||||
--recursive test
|
--recursive test
|
||||||
|
|
|
@ -96,6 +96,26 @@ int main(int argc, char* argv[]) {
|
||||||
"When to compute vertex normals from mesh geometry.")
|
"When to compute vertex normals from mesh geometry.")
|
||||||
->type_name("(never|broken|missing|always)");
|
->type_name("(never|broken|missing|always)");
|
||||||
|
|
||||||
|
app.add_option(
|
||||||
|
"--anim-framerate",
|
||||||
|
[&](std::vector<std::string> choices) -> bool {
|
||||||
|
for (const std::string choice : choices) {
|
||||||
|
if (choice == "bake24") {
|
||||||
|
gltfOptions.animationFramerate = AnimationFramerateOptions::BAKE24;
|
||||||
|
} else if (choice == "bake30") {
|
||||||
|
gltfOptions.animationFramerate = AnimationFramerateOptions::BAKE30;
|
||||||
|
} else if (choice == "bake60") {
|
||||||
|
gltfOptions.animationFramerate = AnimationFramerateOptions::BAKE60;
|
||||||
|
} else {
|
||||||
|
fmt::printf("Unknown --anim-framerate: %s\n", choice);
|
||||||
|
throw CLI::RuntimeError(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
"Select baked animation framerate.")
|
||||||
|
->type_name("(bake24|bake30|bake60)");
|
||||||
|
|
||||||
const auto opt_flip_u = app.add_flag("--flip-u", "Flip all U texture coordinates.");
|
const auto opt_flip_u = app.add_flag("--flip-u", "Flip all U texture coordinates.");
|
||||||
const auto opt_no_flip_u = app.add_flag("--no-flip-u", "Don't flip U texture coordinates.");
|
const auto opt_no_flip_u = app.add_flag("--no-flip-u", "Don't flip U texture coordinates.");
|
||||||
const auto opt_flip_v = app.add_flag("--flip-v", "Flip all V texture coordinates.");
|
const auto opt_flip_v = app.add_flag("--flip-v", "Flip all V texture coordinates.");
|
||||||
|
@ -295,7 +315,7 @@ int main(int argc, char* argv[]) {
|
||||||
if (verboseOutput) {
|
if (verboseOutput) {
|
||||||
fmt::printf("Loading FBX File: %s\n", inputPath);
|
fmt::printf("Loading FBX File: %s\n", inputPath);
|
||||||
}
|
}
|
||||||
if (!LoadFBXFile(raw, inputPath, {"png", "jpg", "jpeg"})) {
|
if (!LoadFBXFile(raw, inputPath, {"png", "jpg", "jpeg"}, gltfOptions)) {
|
||||||
fmt::fprintf(stderr, "ERROR:: Failed to parse FBX: %s\n", inputPath);
|
fmt::fprintf(stderr, "ERROR:: Failed to parse FBX: %s\n", inputPath);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,12 @@ enum class UseLongIndicesOptions {
|
||||||
ALWAYS, // only ever use 32-bit indices
|
ALWAYS, // only ever use 32-bit indices
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class AnimationFramerateOptions {
|
||||||
|
BAKE24, // bake animations at 24 fps
|
||||||
|
BAKE30, // bake animations at 30 fps
|
||||||
|
BAKE60, // bake animations at 60 fps
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User-supplied options that dictate the nature of the glTF being generated.
|
* User-supplied options that dictate the nature of the glTF being generated.
|
||||||
*/
|
*/
|
||||||
|
@ -115,4 +121,6 @@ struct GltfOptions {
|
||||||
ComputeNormalsOption computeNormals = ComputeNormalsOption::BROKEN;
|
ComputeNormalsOption computeNormals = ComputeNormalsOption::BROKEN;
|
||||||
/** When to use 32-bit indices. */
|
/** When to use 32-bit indices. */
|
||||||
UseLongIndicesOptions useLongIndices = UseLongIndicesOptions::AUTO;
|
UseLongIndicesOptions useLongIndices = UseLongIndicesOptions::AUTO;
|
||||||
|
/** Select baked animation framerate. */
|
||||||
|
AnimationFramerateOptions animationFramerate = AnimationFramerateOptions::BAKE24;
|
||||||
};
|
};
|
||||||
|
|
|
@ -721,8 +721,19 @@ static void ReadNodeHierarchy(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReadAnimations(RawModel& raw, FbxScene* pScene) {
|
static void ReadAnimations(RawModel& raw, FbxScene* pScene, const GltfOptions& options) {
|
||||||
FbxTime::EMode eMode = FbxTime::eFrames24;
|
FbxTime::EMode eMode = FbxTime::eFrames24;
|
||||||
|
switch (options.animationFramerate) {
|
||||||
|
case AnimationFramerateOptions::BAKE24:
|
||||||
|
eMode = FbxTime::eFrames24;
|
||||||
|
break;
|
||||||
|
case AnimationFramerateOptions::BAKE30:
|
||||||
|
eMode = FbxTime::eFrames30;
|
||||||
|
break;
|
||||||
|
case AnimationFramerateOptions::BAKE60:
|
||||||
|
eMode = FbxTime::eFrames60;
|
||||||
|
break;
|
||||||
|
}
|
||||||
const double epsilon = 1e-5f;
|
const double epsilon = 1e-5f;
|
||||||
|
|
||||||
const int animationCount = pScene->GetSrcObjectCount<FbxAnimStack>();
|
const int animationCount = pScene->GetSrcObjectCount<FbxAnimStack>();
|
||||||
|
@ -1027,7 +1038,8 @@ static void FindFbxTextures(
|
||||||
bool LoadFBXFile(
|
bool LoadFBXFile(
|
||||||
RawModel& raw,
|
RawModel& raw,
|
||||||
const std::string fbxFileName,
|
const std::string fbxFileName,
|
||||||
const std::set<std::string>& textureExtensions) {
|
const std::set<std::string>& textureExtensions,
|
||||||
|
const GltfOptions& options) {
|
||||||
FbxManager* pManager = FbxManager::Create();
|
FbxManager* pManager = FbxManager::Create();
|
||||||
FbxIOSettings* pIoSettings = FbxIOSettings::Create(pManager, IOSROOT);
|
FbxIOSettings* pIoSettings = FbxIOSettings::Create(pManager, IOSROOT);
|
||||||
pManager->SetIOSettings(pIoSettings);
|
pManager->SetIOSettings(pIoSettings);
|
||||||
|
@ -1073,7 +1085,7 @@ bool LoadFBXFile(
|
||||||
|
|
||||||
ReadNodeHierarchy(raw, pScene, pScene->GetRootNode(), 0, "");
|
ReadNodeHierarchy(raw, pScene, pScene->GetRootNode(), 0, "");
|
||||||
ReadNodeAttributes(raw, pScene, pScene->GetRootNode(), textureLocations);
|
ReadNodeAttributes(raw, pScene, pScene->GetRootNode(), textureLocations);
|
||||||
ReadAnimations(raw, pScene);
|
ReadAnimations(raw, pScene, options);
|
||||||
|
|
||||||
pScene->Destroy();
|
pScene->Destroy();
|
||||||
pManager->Destroy();
|
pManager->Destroy();
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
bool LoadFBXFile(
|
bool LoadFBXFile(
|
||||||
RawModel& raw,
|
RawModel& raw,
|
||||||
const std::string fbxFileName,
|
const std::string fbxFileName,
|
||||||
const std::set<std::string>& textureExtensions);
|
const std::set<std::string>& textureExtensions,
|
||||||
|
const GltfOptions& options);
|
||||||
|
|
||||||
json TranscribeProperty(FbxProperty& prop);
|
json TranscribeProperty(FbxProperty& prop);
|
|
@ -75,7 +75,8 @@ FbxSkinningAccess::FbxSkinningAccess(const FbxMesh* pMesh, FbxScene* pScene, Fbx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < controlPointCount; i++) {
|
for (int i = 0; i < controlPointCount; i++) {
|
||||||
vertexJointWeights[i] = vertexJointWeights[i].Normalized();
|
const float weightSumRcp = 1.0 / (vertexJointWeights[i][0] + vertexJointWeights[i][1] + vertexJointWeights[i][2] + vertexJointWeights[i][3]);
|
||||||
|
vertexJointWeights[i] *= weightSumRcp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue