From ac0cfc8d9cd2ebfa959053d822e4846a814cf053 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 1 Dec 2025 14:17:45 +0100 Subject: [PATCH] Feature/pjoe fix fbx export (#6405) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: texture paths issues with fbx export * Update LICENSE (#6327) * FBX: Fix offset calculation by adding cursor check (#6337) - closes https://github.com/assimp/assimp/issues/6336 * [CMake] -l (#6329) - Fix zlib linkage. Co-authored-by: Kim Kulling * Add null check for aiNode in AddNode method (#6348) - Added null check for node in AddNode function. - closes https://github.com/assimp/assimp/issues/6347 * fix large glb reading by providing a proper helper for reading size_t type (#6307) Co-authored-by: Vitaly Ovchinnikov Co-authored-by: Kim Kulling * Updated doc/Preamble.txt & SECURITY.md (#6338) * Update LICENSE * Update Preamble.txt * Update SECURITY.md * Remove GitHub's default comment * Better README! Fixed discord link as well (#6351) * Better README! * PyAssimp: Re-add 'aiProcess_Triangulate' (#6335) apparently, b9bfac0418c30e969b3052953e63fbced29ccfd4 accidentally removed a couple of lines with a botched copy'n'paste. Co-authored-by: IOhannes m zmölnig Co-authored-by: Kim Kulling * Fixed Build.md (#6354) * Fixed itch.io spelling from itchi.io * Fix hasTangentsAndBitangents method in AiMesh.java (#6345) original code m_tangents != null && m_tangents != null; triggers error prone Co-authored-by: Kim Kulling * Added tangent handedness to glTF export (#6322) * Added tangent handedness to glTF export * Restore merging of near-identical vertices for JoinIdenticalVertices (#6278) * Restore merging of near-identical vertices for JoinIdenticalVertices --------- Co-authored-by: Kim Kulling * Add BOM skip and fix mtl parsing (#6253) * Add BOM skip and fix mtl parsing * Remove old code * Fix #5635 * Add all attributes to ObjFileData --------- Co-authored-by: Kim Kulling * Clone meshlab/tinyusdz repos in default location (#6239) * Leave FETCHCONTENT_BASE_DIR as default to avoid target platform generated build file conflicts * Attempt address sonarCloud complaint about generic-looking include file (bare "Parser.h") --------- Co-authored-by: tellypresence Co-authored-by: Kim Kulling * Fix an invalid offsetof warning-as-error (#6359) The code already disables the warning on clang. It's also caused on GCC in some circumstances (particularly when building with -D_GLIBCXX_DEBUG). * Add unit test for subdivision modifier on Blender importer (#5345) * Add unit test for subdivision modifier on Blender importer Blend file is composed of default cube with subdivision modifier applied and same cube with subdivision modifier. * Update utBlenderImportExport.cpp Fix compiler warning. --------- Co-authored-by: Kim Kulling * Change strcpy to strncpy for format hint safety (#6365) * Update default material name handling (#6366) * Replace strcpy by strncpy * Bugfix/fix sonarcube findings (#6369) * Fix sonarcube findings. --------- Co-authored-by: Kim Kulling * Update texture output format in AssxmlFileWriter (#6372) * Update texture output format in AssxmlFileWriter * Collada: Fix overflow in CopyVertex (#6374) * Fix overflow in CopyVertex * COB: fix validation for ascii header (#6376) * COB: fix validation for ascii header * MD5: Fix face index allocation in MD5Parser (#6380) - Ensure face indices are properly allocated and resized. - closes https://github.com/assimp/assimp/issues/6379 * Removed unnecessary copy constructor declaration in aiVector3t (#6384) * Removed unnecessary copy constructor declaration in aiVector3t * Added copy constructor back in aiVector3t * Added explicit declaration of assignment operator in aiVector3t * Bump actions/upload-artifact from 4 to 5 (#6383) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kim Kulling * Bump actions/download-artifact from 5 to 6 (#6382) Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 5 to 6. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v5...v6) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Made the README more tidy & fix Build.md (#6371) * Update LICENSE * Update Preamble.txt * Update SECURITY.md * Remove GitHub's default comment * Better README! * Fix discord link! Boom, that's how it's done * Fixed itch.io spelling from itchi.io * Make README more tidy :) AR is back! Anyways, I'm working on my horror game & making devlogs so I don't have time to write. Here's a small summary: - Just placed the dir structure information correctly in one place so the README looks tidy. * Add international download link for Visual Studio * Fix out-of-range access cause of aiProcess_GenNormals : array size inconsistency of members of mesh after process (#6332) * Fix aiProcess_GenNormals process: copy members of mesh corresponding with additional vertices * Fix aiProcess_GenNormals process: Refoctoring * refactoring: fix SonarQube Issue * Update GenFaceNormalsProcess.cpp: fix small findings --------- Co-authored-by: Kim Kulling * Fix Heap-buffer-overflow in Q3DImporter::InternReadFile (#6370) Checks if multiplying texture width and height would overflow before performing the operation. This avoids incorrect memory allocations and potential crashes with very large textures. Fixes #6358 Co-authored-by: Kim Kulling * Revert "Refactoring: use using types (#6266)" (#6324) * Revert "Refactoring: use using types (#6266)" * fix: write textures to folder of PBRT file (#6099) * fix: write textures to folder of PBRT file * Refactor condition checks for empty vectors (#6385) * Refactor based on SonarCube. * Fix sonarcube stuff (#6387) * Fix sonarcube stuff * Update contact email for reporting vulnerabilities (#6389) * [PyAssimp] Create `pyproject.toml` (#6378) * Create pyproject.toml * glTF2: Avoid lookups for generating IDs (#6120) * glTF2: Reduce lookups for generating IDs - closes https://github.com/assimp/assimp/issues/5661 * Refactor string checks and variable declarations (#6392) * Refactor string checks and variable declarations * Change string check from contains to find * Fix syntax error in mesh node creation loop * Fix the doxygen documentation from public headers (#6394) * Add documentation comments to DeboneProcess.h * Added static cast for conversion from uLong to unsigned int for compiler error (#6393) Co-authored-by: Kim Kulling * Reorganize code top prevent security warning. (#6395) * Reorganize code to prevent security warning. * Fix linkage (#6388) * Fix linkage when all importers aren't part of the build. * Update LineSplitter.h (#6396) * Added missing scene extras properties for glTF2Importer (#6397) * WiP. Passing USD prims along with render nodes to look for USD references. Save reference path to metaData['ref'] (#5807) Signed-off-by: AMZN-Gene Co-authored-by: Kim Kulling * Bump actions/checkout from 5 to 6 (#6401) Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v5...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kim Kulling * Update Readme.md (#6402) * Update Readme.md - Reorganize readme for code structure * Update Readme.md * Delete test/other/streamload.py (#6403) * Update Readme.md - Reorganize readme for code structure * Update Readme.md * Delete test/other/streamload.py * Delete test/regression directory * Update AndroidJNIIOSystem.cpp * Update BundledAssetIOSystem.cpp * Fixed DXFHelper using float instead of ai_real (#6404) * Fixed DXFHelper using float instead of ai_real * fixed cmake presets --------- Co-authored-by: Kim Kulling --------- Signed-off-by: dependabot[bot] Signed-off-by: AMZN-Gene Co-authored-by: Pelle Johnsen Co-authored-by: AbdulRehman Co-authored-by: Steven French <95558717+ZeunO8@users.noreply.github.com> Co-authored-by: Vitaly Ovchinnikov Co-authored-by: Vitaly Ovchinnikov Co-authored-by: umläute Co-authored-by: IOhannes m zmölnig Co-authored-by: fifth_light Co-authored-by: Luca Della Vedova Co-authored-by: Matt Penny Co-authored-by: Paul Bauriegel Co-authored-by: Steve M Co-authored-by: tellypresence Co-authored-by: Sami Liedes Co-authored-by: Alexandre Avenel Co-authored-by: Kim Kulling Co-authored-by: EddieBreeg Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: sSsA01 <59872472+Riv1s-sSsA01@users.noreply.github.com> Co-authored-by: Jan Grulich Co-authored-by: Jan Honsbrok Co-authored-by: thedestroyer4312 Co-authored-by: Jerome St-Louis Co-authored-by: John Curley Co-authored-by: Orleonn <76880668+Orleonn@users.noreply.github.com> Co-authored-by: Gene Walters <32776221+AMZN-Gene@users.noreply.github.com> Co-authored-by: JakobPer --- code/AssetLib/FBX/FBXExporter.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/FBX/FBXExporter.cpp b/code/AssetLib/FBX/FBXExporter.cpp index d4bcaafa2..2f6964a2f 100644 --- a/code/AssetLib/FBX/FBXExporter.cpp +++ b/code/AssetLib/FBX/FBXExporter.cpp @@ -1582,6 +1582,7 @@ void FBXExporter::WriteObjects () { } } + std::map tpath_by_image; // FbxVideo - stores images used by textures. for (const auto &it : uid_by_image) { FBX::Node n("Video"); @@ -1601,10 +1602,21 @@ void FBXExporter::WriteObjects () { std::stringstream newPath; if (embedded_texture->mFilename.length > 0) { newPath << embedded_texture->mFilename.C_Str(); + // If newPath doesn't end in an extension, add extension from embedded_texture->achFormatHint + std::string np = newPath.str(); + size_t dot_pos = np.find_last_of('.'); + if (dot_pos == std::string::npos || dot_pos < np.find_last_of("/\\")) { + // No extension found, add one + newPath << "." << embedded_texture->achFormatHint; + } } else if (embedded_texture->achFormatHint[0]) { int texture_index = std::stoi(path.substr(1, path.size() - 1)); newPath << texture_index << "." << embedded_texture->achFormatHint; } + auto elem = tpath_by_image.find(path); + if (elem == tpath_by_image.end()) { + tpath_by_image[path] = newPath.str(); + } path = newPath.str(); // embed the texture size_t texture_size = static_cast(embedded_texture->mWidth * std::max(embedded_texture->mHeight, 1u)); @@ -1723,6 +1735,17 @@ void FBXExporter::WriteObjects () { unsigned int max = sizeof(aiUVTransform); aiGetMaterialFloatArray(mat, AI_MATKEY_UVTRANSFORM(aiTextureType_DIFFUSE, 0), (ai_real *)&trafo, &max); + auto tp_elem = tpath_by_image.find(texture_path); + std::string tfile_path = texture_path; + if (tp_elem != tpath_by_image.end()) { + tfile_path = tp_elem->second; + } else { + std::stringstream err; + err << "Texture path not found for texure " << texture_path; + err << " on material " << i; + ASSIMP_LOG_WARN(err.str()); + } + // now write the actual texture node FBX::Node tnode("Texture"); // TODO: some way to determine texture name? @@ -1743,8 +1766,8 @@ void FBXExporter::WriteObjects () { // can't easily determine which texture path will be correct, // so just store what we have in every field. // these being incorrect is a common problem with FBX anyway. - tnode.AddChild("FileName", texture_path); - tnode.AddChild("RelativeFilename", texture_path); + tnode.AddChild("FileName", tp_elem->second); + tnode.AddChild("RelativeFilename", tp_elem->second); tnode.AddChild("ModelUVTranslation", double(0.0), double(0.0)); tnode.AddChild("ModelUVScaling", double(1.0), double(1.0)); tnode.AddChild("Texture_Alpha_Source", "None");