Merge branch 'master' into fix/cross-platform-filepaths
This commit is contained in:
commit
87b8d887f8
|
@ -18,6 +18,8 @@
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const std::string FBX2GLTF_VERSION = "0.9.5";
|
||||||
|
|
||||||
#include <fmt/printf.h>
|
#include <fmt/printf.h>
|
||||||
#include <fbxsdk.h>
|
#include <fbxsdk.h>
|
||||||
|
|
||||||
|
|
|
@ -1263,7 +1263,7 @@ static void ReadAnimations(RawModel &raw, FbxScene *pScene)
|
||||||
for (int targetIx = 0; targetIx < targetCount; targetIx++) {
|
for (int targetIx = 0; targetIx < targetCount; targetIx++) {
|
||||||
if (curve) {
|
if (curve) {
|
||||||
float result = findInInterval(influence, targetIx-1);
|
float result = findInInterval(influence, targetIx-1);
|
||||||
if (!isnan(result)) {
|
if (!std::isnan(result)) {
|
||||||
// we're transitioning into targetIx
|
// we're transitioning into targetIx
|
||||||
channel.weights.push_back(result);
|
channel.weights.push_back(result);
|
||||||
hasMorphs = true;
|
hasMorphs = true;
|
||||||
|
@ -1271,7 +1271,7 @@ static void ReadAnimations(RawModel &raw, FbxScene *pScene)
|
||||||
}
|
}
|
||||||
if (targetIx != targetCount-1) {
|
if (targetIx != targetCount-1) {
|
||||||
result = findInInterval(influence, targetIx);
|
result = findInInterval(influence, targetIx);
|
||||||
if (!isnan(result)) {
|
if (!std::isnan(result)) {
|
||||||
// we're transitioning AWAY from targetIx
|
// we're transitioning AWAY from targetIx
|
||||||
channel.weights.push_back(1.0f - result);
|
channel.weights.push_back(1.0f - result);
|
||||||
hasMorphs = true;
|
hasMorphs = true;
|
||||||
|
|
|
@ -1191,10 +1191,12 @@ ModelData *Raw2Gltf(
|
||||||
}
|
}
|
||||||
|
|
||||||
json glTFJson {
|
json glTFJson {
|
||||||
{"asset", {{"generator", "FBX2glTF"}, {"version", "2.0"}}},
|
{ "asset", {
|
||||||
{"scene", rootScene.ix}};
|
{ "generator", "FBX2glTF v" + FBX2GLTF_VERSION },
|
||||||
if (!extensionsUsed.empty())
|
{ "version", "2.0" }}},
|
||||||
{
|
{ "scene", rootScene.ix }
|
||||||
|
};
|
||||||
|
if (!extensionsUsed.empty()) {
|
||||||
glTFJson["extensionsUsed"] = extensionsUsed;
|
glTFJson["extensionsUsed"] = extensionsUsed;
|
||||||
}
|
}
|
||||||
if (!extensionsRequired.empty())
|
if (!extensionsRequired.empty())
|
||||||
|
|
|
@ -269,11 +269,20 @@ void RawModel::Condense()
|
||||||
|
|
||||||
surfaces.clear();
|
surfaces.clear();
|
||||||
|
|
||||||
|
std::set<int> survivingSurfaceIds;
|
||||||
for (auto &triangle : triangles) {
|
for (auto &triangle : triangles) {
|
||||||
|
int oldSurfaceIndex = triangle.surfaceIndex;
|
||||||
const RawSurface &surface = oldSurfaces[triangle.surfaceIndex];
|
const RawSurface &surface = oldSurfaces[triangle.surfaceIndex];
|
||||||
const int surfaceIndex = AddSurface(surface.name.c_str(), surface.id);
|
const int surfaceIndex = AddSurface(surface.name.c_str(), surface.id);
|
||||||
surfaces[surfaceIndex] = surface;
|
surfaces[surfaceIndex] = surface;
|
||||||
triangle.surfaceIndex = surfaceIndex;
|
triangle.surfaceIndex = surfaceIndex;
|
||||||
|
survivingSurfaceIds.emplace(surface.id);
|
||||||
|
}
|
||||||
|
// clear out references to meshes that no longer exist
|
||||||
|
for (auto &node : nodes) {
|
||||||
|
if (node.surfaceId != 0 && survivingSurfaceIds.find(node.surfaceId) == survivingSurfaceIds.end()) {
|
||||||
|
node.surfaceId = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,7 +350,9 @@ void RawModel::TransformGeometry(ComputeNormalsOption normals)
|
||||||
|
|
||||||
if (verboseOutput) {
|
if (verboseOutput) {
|
||||||
if (normals == ComputeNormalsOption::BROKEN) {
|
if (normals == ComputeNormalsOption::BROKEN) {
|
||||||
|
if (computedNormalsCount > 0) {
|
||||||
fmt::printf("Repaired %lu empty normals.\n", computedNormalsCount);
|
fmt::printf("Repaired %lu empty normals.\n", computedNormalsCount);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt::printf("Computed %lu normals.\n", computedNormalsCount);
|
fmt::printf("Computed %lu normals.\n", computedNormalsCount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
cxxopts::Options options(
|
cxxopts::Options options(
|
||||||
"FBX2glTF",
|
"FBX2glTF",
|
||||||
"FBX2glTF 2.0: Generate a glTF 2.0 representation of an FBX model.");
|
fmt::sprintf("FBX2glTF %s: Generate a glTF 2.0 representation of an FBX model.", FBX2GLTF_VERSION)
|
||||||
|
);
|
||||||
|
|
||||||
std::string inputPath;
|
std::string inputPath;
|
||||||
std::string outputPath;
|
std::string outputPath;
|
||||||
|
@ -98,11 +99,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.count("version")) {
|
if (options.count("version")) {
|
||||||
fmt::printf(
|
fmt::printf("FBX2glTF version %s\nCopyright (c) 2016-2017 Oculus VR, LLC.\n", FBX2GLTF_VERSION);
|
||||||
R"(
|
|
||||||
FBX2glTF version 2.0
|
|
||||||
Copyright (c) 2016-2017 Oculus VR, LLC.
|
|
||||||
)");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue