Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fca842926 | ||
|
|
8b79298ba5 |
@@ -65,7 +65,7 @@ jobs:
|
|||||||
- name: Cache DX SDK
|
- name: Cache DX SDK
|
||||||
id: dxcache
|
id: dxcache
|
||||||
if: contains(matrix.name, 'windows')
|
if: contains(matrix.name, 'windows')
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: '${{ github.workspace }}/DX_SDK'
|
path: '${{ github.workspace }}/DX_SDK'
|
||||||
key: ${{ runner.os }}-DX_SDK
|
key: ${{ runner.os }}-DX_SDK
|
||||||
@@ -109,7 +109,7 @@ jobs:
|
|||||||
run: cd build/bin && ./unit ${{ steps.hunter_extra_test_args.outputs.args }}
|
run: cd build/bin && ./unit ${{ steps.hunter_extra_test_args.outputs.args }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v6
|
- uses: actions/upload-artifact@v5
|
||||||
if: matrix.name == 'windows-msvc'
|
if: matrix.name == 'windows-msvc'
|
||||||
with:
|
with:
|
||||||
name: 'assimp-bins-${{ matrix.name }}'
|
name: 'assimp-bins-${{ matrix.name }}'
|
||||||
@@ -141,7 +141,7 @@ jobs:
|
|||||||
prerelease: true
|
prerelease: true
|
||||||
- run: |
|
- run: |
|
||||||
echo '${{steps.create-release.outputs.upload_url}}' > release_upload_url.txt
|
echo '${{steps.create-release.outputs.upload_url}}' > release_upload_url.txt
|
||||||
- uses: actions/upload-artifact@v6
|
- uses: actions/upload-artifact@v5
|
||||||
with:
|
with:
|
||||||
name: create-release
|
name: create-release
|
||||||
path: release_upload_url.txt
|
path: release_upload_url.txt
|
||||||
@@ -188,7 +188,7 @@ jobs:
|
|||||||
- id: upload-url
|
- id: upload-url
|
||||||
run: |
|
run: |
|
||||||
echo "url=$(cat create-release/release_upload_url.txt)" >> $GITHUB_OUTPUT
|
echo "url=$(cat create-release/release_upload_url.txt)" >> $GITHUB_OUTPUT
|
||||||
- uses: actions/download-artifact@v7
|
- uses: actions/download-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: 'assimp-bins-${{ matrix.name }}-${{ github.sha }}'
|
name: 'assimp-bins-${{ matrix.name }}-${{ github.sha }}'
|
||||||
- uses: actions/upload-release-asset@v1
|
- uses: actions/upload-release-asset@v1
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ jobs:
|
|||||||
dry-run: false
|
dry-run: false
|
||||||
language: c++
|
language: c++
|
||||||
- name: Upload Crash
|
- name: Upload Crash
|
||||||
uses: actions/upload-artifact@v6
|
uses: actions/upload-artifact@v5
|
||||||
if: failure() && steps.build.outcome == 'success'
|
if: failure() && steps.build.outcome == 'success'
|
||||||
with:
|
with:
|
||||||
name: artifacts
|
name: artifacts
|
||||||
|
|||||||
@@ -0,0 +1,607 @@
|
|||||||
|
----------------------------------------------------------------------
|
||||||
|
CHANGELOG
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
4.1.0 (2017-12):
|
||||||
|
- FEATURES:
|
||||||
|
- Export 3MF ( experimental )
|
||||||
|
- Import / Export glTF 2
|
||||||
|
- Introduce new zib-lib to eb able to export zip-archives
|
||||||
|
- FIXES/HOUSEKEEPING:
|
||||||
|
- Added missing include to stdlib.h and remove load library call
|
||||||
|
- Fix install for builds with MSVC compiler and NMake.
|
||||||
|
- Update list of supported file formats.
|
||||||
|
- Add TriLib to the official list of supported ports.
|
||||||
|
- Re-enabling PACK_STRUCT for MDL files.
|
||||||
|
- Use std.::unique_ptr
|
||||||
|
- Update D3MFExporter.h
|
||||||
|
- Update MD3Loader.cpp, using index
|
||||||
|
- Fix all warnings on MSVC14
|
||||||
|
- Copy assimp dll to unit folder on windows
|
||||||
|
- Update jvm port supported formats
|
||||||
|
- Add support for building Mac OS X Framework bundles
|
||||||
|
- Check for nullptr dereferencing before copying scene data
|
||||||
|
- Update ValidateDataStructure.h, typo
|
||||||
|
- Enable data structure validation in cases where it doesn't cause failures
|
||||||
|
- Remove some dead assignments
|
||||||
|
- fast_atof: Silence some uninitialized variable warnings
|
||||||
|
- Check for area test if the face is a triangle.
|
||||||
|
- Set mNumUVComponents to 0 when deleting texture coordinate sets
|
||||||
|
- Only scale the root node because this will rescale all children nodes as well.
|
||||||
|
- Issue 1514: Fix frame pointer arithmetic
|
||||||
|
- Prevent failing stringstream to crash the export process
|
||||||
|
- powf -> pow
|
||||||
|
- add Defines.h to include folder for install.
|
||||||
|
- Android:
|
||||||
|
- Fix android build
|
||||||
|
- Fix assimp for cross compile for android
|
||||||
|
- Use define for D_FILE_OFFSET_BITS only for not-android systems.
|
||||||
|
- FBX:
|
||||||
|
- Fix handling with embedded textures
|
||||||
|
- FBX 7500 Binary reading
|
||||||
|
- Remove dead assignment
|
||||||
|
- Fix export of deleted meshes; Add LazyDict::Remove method
|
||||||
|
- Log an error instead of letting the fbx-importer crash. ( issue 213 )
|
||||||
|
- Replace bad pointer casting with memcpy
|
||||||
|
- Remove useless const qualifier from return value
|
||||||
|
- Add explicit instantiation of log_prefix so other FBX source files can see it
|
||||||
|
- add missing inversion of postrotation matrix for fbx.
|
||||||
|
- FIReader: Silence uninitialized variable warning
|
||||||
|
- Update version check in FBX reader to check for version >= 7500
|
||||||
|
- Use actual min/max of anim keys when start/stop time is missing
|
||||||
|
- GLTF1:
|
||||||
|
- Fix output of glTF 1 version string
|
||||||
|
- Fix delete / delete[] mismatch in glTFAsset
|
||||||
|
- Don’t ignore rgba(1,1,1,1) color properties
|
||||||
|
- glTF2 primitives fixes
|
||||||
|
- Don’t ignore rgba(1,1,1,1) color properties
|
||||||
|
- Fix delete / delete[] mismatch in glTFAsset
|
||||||
|
- Remove KHR_binary_glTF code
|
||||||
|
- glTF nodes can only hold one mesh. this simply assigns to and check’s a Node’s Mesh
|
||||||
|
- version in glb header is stored as uint32_t
|
||||||
|
- GLTF2:
|
||||||
|
- node name conflict fix
|
||||||
|
- Fix transform matrices multiplication order
|
||||||
|
- Preserve node names when importing
|
||||||
|
- Add support for tangents in import
|
||||||
|
- Fix typo on gltf2 camera parameters
|
||||||
|
- Moved byteStride from accessor to bufferView
|
||||||
|
- Implemented reading binary glTF2 (glb) files
|
||||||
|
- Fix signed/unsigned warning
|
||||||
|
- Add postprocess step for scaling
|
||||||
|
- Fix shininess to roughness conversion
|
||||||
|
- Prefer “BLEND” over “MASK” as an alphaMode default
|
||||||
|
- Approximate specularity / glossiness in metallicRoughness materials
|
||||||
|
- Diffuse color and diffuse texture import and export improvements
|
||||||
|
- Addressed some mismatched news/deletes caused by the new glTF2 sources.
|
||||||
|
- Fix delete / delete[] mismatches in glTF2 importer
|
||||||
|
- use correct name of exporter to gltf2
|
||||||
|
- Fix possible infinite loop when exporting to gltf2
|
||||||
|
- Fix glTF2::Asset::FindUniqueID() when the input string is >= 256 chars
|
||||||
|
- Fix glTF2 alphaMode storage and reading
|
||||||
|
- Fix glTF 2.0 multi-primitive support
|
||||||
|
- Load gltf .bin files from correct directory
|
||||||
|
- Add support for importing both glTF and glTF2 files
|
||||||
|
- ampler improvements; Add new LazyDict method
|
||||||
|
- Changes to GLTF2 materials
|
||||||
|
- Remove Light, Technique references
|
||||||
|
- Start removing materials common, and adding pbrSpecularGlossiness
|
||||||
|
- Use !ObjectEmpty() vs. MemberCount() > 0
|
||||||
|
- Working read, import, export, and write of gltf2 (pbr) material
|
||||||
|
- Check in gltf2 models to test directory
|
||||||
|
- Remove un-needed test models
|
||||||
|
- Start managing and importing gltf2 pbr materials
|
||||||
|
- Update glTF2 Asset to use indexes
|
||||||
|
- Duplicate gltfImporter as gltf2Importer; Include glTF2 importer in CMake List
|
||||||
|
- glTF2: Fix animation export
|
||||||
|
- use opacity for diffuse alpha + alphaMode
|
||||||
|
- STL:
|
||||||
|
- Restore import of multi mesh binary STLs
|
||||||
|
- Blender:
|
||||||
|
- Silence warning about uninitialized member
|
||||||
|
- MDLImporter:
|
||||||
|
- Don't take address of packed struct member
|
||||||
|
- assimp_cmd:
|
||||||
|
- Fix strict-aliasing warnings
|
||||||
|
- Open3DGC:
|
||||||
|
- Fix strict-aliasing warnings
|
||||||
|
- Add assertions to silence static analyzer warnings
|
||||||
|
- Remove redundant const qualifiers from return types
|
||||||
|
- Fix some uninitialized variable warnings
|
||||||
|
- Remove OPEN3DGC and compression references
|
||||||
|
- unzip:
|
||||||
|
- Remove dead assignment
|
||||||
|
- Bail on bad compression method
|
||||||
|
- Fix possibly uninitialized variables
|
||||||
|
- clipper:
|
||||||
|
- Add assertion to silence a static analyzer warning
|
||||||
|
- OpenDDLExport:
|
||||||
|
- Reduce scope of a variable
|
||||||
|
- Remove dead variable
|
||||||
|
- Remove dead assignment
|
||||||
|
- Fix another potential memory leak
|
||||||
|
- X3DImporter:
|
||||||
|
- Add assertions to silence static analyzer warnings
|
||||||
|
- Add missing unittest
|
||||||
|
- Workaround for buggy Android NDK (issue #1361)
|
||||||
|
- TerragenLoader:
|
||||||
|
- Remove unused variable
|
||||||
|
- SIBImporter:
|
||||||
|
- Add assertions to silence static analyzer warnings
|
||||||
|
- IFC:
|
||||||
|
- Remove dead code
|
||||||
|
- Add explicit instantiation of log_prefix so IFCMaterial.cpp can see it
|
||||||
|
- PLY:
|
||||||
|
- Remove dead assignment and reduce scope of a variable
|
||||||
|
- fix vertex attribute lookup.
|
||||||
|
- OpenGEX:
|
||||||
|
- Add assertion to silence a static analyzer warning
|
||||||
|
- Fix for TextureFile with number in file name
|
||||||
|
- Return early when element is TextureFile
|
||||||
|
- NFF:
|
||||||
|
- Add assertions to silence static analyzer warnings
|
||||||
|
- Split up some complicated assignments
|
||||||
|
- Raw: Fix misleading indentation warning
|
||||||
|
- Reduce scope of a variable
|
||||||
|
- LWO
|
||||||
|
- Reduce scope of a variable
|
||||||
|
- IRRLoader:
|
||||||
|
- Fix confusing boolean casting
|
||||||
|
- AssbinExporter:
|
||||||
|
- Add assertion to silence a static analyzer warning
|
||||||
|
- ASE:
|
||||||
|
- Add assertion to silence a static analyzer warning
|
||||||
|
- AMFImporter:
|
||||||
|
- Add assertion to silence a static analyzer warning
|
||||||
|
- Add a block
|
||||||
|
- OptimizeGraph:
|
||||||
|
- Fix possible null pointer dereference
|
||||||
|
- RemoveRedundantMaterials:
|
||||||
|
- Add assertion to silence a static analyzer warning
|
||||||
|
- ImproveCacheLocality:
|
||||||
|
- Add assertion to silence a static analyzer warning
|
||||||
|
- RemoveRedundantMaterials:
|
||||||
|
- Set pointer to nullptr after deleting it
|
||||||
|
- Travis:
|
||||||
|
- Disable unit tests in scan-build config
|
||||||
|
- Move slower builds earlier to improve parallelization
|
||||||
|
- Add static analysis to build
|
||||||
|
- Remove unused branch rule for travis.
|
||||||
|
- Add Clang UBSan build configuration
|
||||||
|
- Treat warnings as errors, without typos this time
|
||||||
|
- Unittests:
|
||||||
|
- Add VS-based source groups for the unittests.
|
||||||
|
- Collada:
|
||||||
|
- export <library_animations> tag
|
||||||
|
- Update ColladaExporter.cpp
|
||||||
|
- Silence uninitialized variable warning
|
||||||
|
- Add support for line strip primitives
|
||||||
|
- Obj Wavefront:
|
||||||
|
- check in exporting against out-of-bounds-access .
|
||||||
|
- Issue 1351: use correct name for obj-meshname export for groups.
|
||||||
|
- fix mem-lead: face will be not released in case of an error.
|
||||||
|
- Anatoscope obj exporter nomtl
|
||||||
|
- Raise exception when obj file contains invalid face indices
|
||||||
|
- Added alternative displacement texture token in OBJ MTL material.
|
||||||
|
- Obj: rename attribute from exporter.
|
||||||
|
- Fix OBJ discarding all material names if the material library is missing
|
||||||
|
- Step:
|
||||||
|
- use correct lookup for utf32
|
||||||
|
- MD2:
|
||||||
|
- Fix MD2 frames containing garbage
|
||||||
|
- STL
|
||||||
|
- add missing const.
|
||||||
|
- Fix memory-alignment bug.
|
||||||
|
- Fix issue 104: deal with more solids in one STL file.
|
||||||
|
- CMake
|
||||||
|
- Fix issue 213: use correct include folder for assimp
|
||||||
|
- Doxygen
|
||||||
|
- Fix issue 1513: put irrXML onto exclucde list for doxygen run
|
||||||
|
- PyAssimp:
|
||||||
|
- Search for libassimp.so in LD_LIBRARY_PATH if available.
|
||||||
|
- Fix operator precedence issue in header check
|
||||||
|
- Split setup.py into multiple lines
|
||||||
|
- Detect if Anaconda and fixed 3d_viewer for Python 3
|
||||||
|
- created a python3 version of the 3dviewer and fixed the / = float in py3
|
||||||
|
- Blender:
|
||||||
|
- Fix invalid access to mesh array when the array is empty.
|
||||||
|
- Fix short overflow.
|
||||||
|
- Silence warning about inline function which is declared but not defined
|
||||||
|
- JAssimp
|
||||||
|
- Changed license header for IHMC contributions from Apache 2.0 to BSD
|
||||||
|
- Add Node metadata to the Jassmip Java API
|
||||||
|
- Added supported for custom IO Systems in Java. Implemented ClassLoader IO System
|
||||||
|
- Added a link to pure jvm assimp port
|
||||||
|
- Clang sanitizer:
|
||||||
|
- Undefined Behavior sanitizer
|
||||||
|
- Fixed a divide by zero error in IFCBoolean that was latent, but nevertheless a bug
|
||||||
|
- B3DImporter:
|
||||||
|
- Replace bad pointer casting with memcpy
|
||||||
|
- AppVeyor:
|
||||||
|
- Cleanup and Addition of VS 2017 and running Tests
|
||||||
|
- Fixed File Size reported as 0 in tests that use temporary files
|
||||||
|
- x86 isn't a valid VS platform. Win32 it is, then.
|
||||||
|
- Replaced the worker image name, which doesn't work as generator name, with a manually created generator name.
|
||||||
|
- Cleaned up appveyor setup, added VS 2017 to the build matrix and attempted to add running of tests.
|
||||||
|
- Treat warnings as errors on Appveyor
|
||||||
|
- Disable warning 4351 on MSVC 2013
|
||||||
|
- OpenGEXImporter:
|
||||||
|
- Copy materials to scene
|
||||||
|
- Store RefInfo in unique_ptr so they get automatically cleaned up
|
||||||
|
- Fix IOStream leak
|
||||||
|
- Store ChildInfo in unique_ptr so they get automatically cleaned up
|
||||||
|
- improve logging to be able to detect error-prone situations.
|
||||||
|
- AMFImporter:
|
||||||
|
- Fix memory leak
|
||||||
|
- UnrealLoader:
|
||||||
|
- Fix IOStream leak
|
||||||
|
- Upgrade RapidJSON to get rid of a clang warning
|
||||||
|
- zlib:
|
||||||
|
- Update zlib contribution
|
||||||
|
- Removed unnecessary files from zlib contribution
|
||||||
|
- Replaced unsigned long for the crc table to z_crc_t, to match what is returned by get-crc_table
|
||||||
|
- MakeVerboseFormat:
|
||||||
|
- Fix delete / delete[] mismatches in MakeVerboseFormat
|
||||||
|
- MaterialSystem:
|
||||||
|
- Fix out-of-bounds read in MaterialSystem unit test
|
||||||
|
- SIB:
|
||||||
|
- Added support for SIB models from Silo 2.5
|
||||||
|
- AssbinExporter:
|
||||||
|
- Fix strict aliasing violation
|
||||||
|
- Add Write specialization for aiColor3D
|
||||||
|
- DefaultLogger:
|
||||||
|
- Whitespace cleanup to fix GCC misleading indentation warning
|
||||||
|
- MDP:
|
||||||
|
- Fix encoding issues.
|
||||||
|
- PreTransformVertices:
|
||||||
|
- fix name lost in mesh and nodes when load with flag
|
||||||
|
- C4D:
|
||||||
|
- Fixes for C4D importer
|
||||||
|
- Unzip:
|
||||||
|
- Latest greatest.
|
||||||
|
|
||||||
|
4.0.1 (2017-07-28)
|
||||||
|
- FIXES/HOUSEKEEPING:
|
||||||
|
- fix version test.
|
||||||
|
- Not compiling when using ASSIMP_DOUBLE_PRECISION
|
||||||
|
- Added support for python3
|
||||||
|
- Check if cmake is installed with brew
|
||||||
|
- Low performance in OptimizeMeshesProcess::ProcessNode with huge numbers of meshes
|
||||||
|
- Elapsed seconds not shown correctly
|
||||||
|
- StreamReader: fix out-of-range exception
|
||||||
|
- PPdPmdParser: fix compilation for clang
|
||||||
|
|
||||||
|
|
||||||
|
4.0.0 (2017-07-18)
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
- Double precision support provided ( available via cmake option )
|
||||||
|
- QT-Widget based assimp-viewer ( works for windows, linux, osx )
|
||||||
|
- Open3DGC codec supported by glFT-importer
|
||||||
|
- glTF: Read and write transparency values
|
||||||
|
- Add Triangulate post-processing step to glTF exporters
|
||||||
|
- Update rapidjson to v1.0.2
|
||||||
|
- Added method to append new metadata to structure
|
||||||
|
- Unittests: intoduce a prototype model differ
|
||||||
|
- X3D support
|
||||||
|
- AMF support
|
||||||
|
- Lugdunum3D support
|
||||||
|
- Obj-Importer: obj-homogeneous_coords support
|
||||||
|
- Obj-Importer: new streaming handling
|
||||||
|
- Added support for 64 bit version header introduced in FbxSdk2016
|
||||||
|
- Travis: enable coverall support.
|
||||||
|
- PyAssimp: New version of the pyASSIMP 3D viewer, with much improved 3D controls
|
||||||
|
- Morph animation support for collada
|
||||||
|
- Added support for parameters Ni and Tf in OBJ/MTL file format
|
||||||
|
- aiScene: add method to add children
|
||||||
|
- Added new option to IFC importer to control tessellation angle + removed unused IFC option
|
||||||
|
- aiMetaData: introduce aiMetaData::Dealloc
|
||||||
|
- Samples: add a DX11 example
|
||||||
|
- travis ci: test on OXS ( XCode 6.3 ) as well
|
||||||
|
- travis ci: enable sudo support.
|
||||||
|
- openddlparser: integrate release v0.4.0
|
||||||
|
- aiMetaData: Added support for metadata in assbin format
|
||||||
|
|
||||||
|
FIXES/HOUSEKEEPING:
|
||||||
|
- Introduce usage of #pragma statement
|
||||||
|
- Put cmake-scripts into their own folder
|
||||||
|
- Fix install pathes ( issue 938 )
|
||||||
|
- Fix object_compare in blender importer( issue 946 )
|
||||||
|
- Fix OSX compilation error
|
||||||
|
- Fix unzip path when no other version was found ( issue 967 )
|
||||||
|
- Set _FILE_OFFSET_BITS=64 for 32-bit linux ( issue 975 )
|
||||||
|
- Fix constructor for radjson on OSX
|
||||||
|
- Use Assimp namespace to fix build for big-endian architectures
|
||||||
|
- Add -fPIC to C Flags for 64bit linux Shared Object builds
|
||||||
|
- MDLLoader: fix resource leak.
|
||||||
|
- MakeVerboseFormat: fix invalid delete statement
|
||||||
|
- IFC: fix possible use after free access bug
|
||||||
|
- ComputeUVMappingprocess: add missing initialization for scalar value
|
||||||
|
- Fix invalid release of mat + mesh
|
||||||
|
- IrrImporter: Fix release functions
|
||||||
|
- Split mesh before exporting gltf ( issue 995 )
|
||||||
|
- 3MFImporter: add source group for visual studio
|
||||||
|
- IFC: Switch generated file to 2 files to fix issue related to <mingw4.9 ( Thanks Qt! )
|
||||||
|
- ObjImporter: fix test for vertices import
|
||||||
|
- export scene combiner ( issues177 )
|
||||||
|
- FBX: make lookup test less strict ( issues 994 )
|
||||||
|
- OpenGEX-Importer: add import of vertex colors ( issue 954 )
|
||||||
|
- fix bug when exporting mRotationKeys data
|
||||||
|
- fix mingw build (mingw supports stat64 nowadays)
|
||||||
|
- cfileio: fix leaks by not closing files in the destructor
|
||||||
|
- Fix OBJ parser mtllib statement parsing bug.
|
||||||
|
- Q3BSP-Importer: remove dead code
|
||||||
|
- Fix BlenderDNA for clang cross compiler.
|
||||||
|
- ScenePreprocessor: fix invalid index counter.
|
||||||
|
- Fix compiler warnings ( issue 957 )
|
||||||
|
- Fix obj .mtl file loading
|
||||||
|
- Fixed a compile error on MSVC14 x64 caused by the /bigobj flag failing to be set for the 1 and 2-suffixed versions introduced in commit 0a25b076b8968b7ea2aa96d7d1b4381be2d72ce6
|
||||||
|
- Fixed build warnings on MSVC14 x64
|
||||||
|
- Remove scaling of specular exponent in OBJFileImporter.cpp
|
||||||
|
- use ai_assert instead of assert ( issue 1076 )
|
||||||
|
- Added a preprocessor definition for MSVC to silence safety warnings regarding C library functions. This addresses all warnings for MSVC x86 and x64 when building zlib, tools and viewer as a static lib
|
||||||
|
- fix parsing of texture name ( issue 899 )
|
||||||
|
- add warning when detecting invalid mat definition ( issue 1111 )
|
||||||
|
- copy aiTexture type declaration instead of using decltype for declaration to fix iOS build( issue 1101 )
|
||||||
|
- FBX: Add additional material properties
|
||||||
|
- FBX: Correct camera position and clip planes
|
||||||
|
- FBX: Add correct light locations and falloff values
|
||||||
|
- fix typo ( issue 1141 )
|
||||||
|
- Fix collada export. Don't duplicate TEXCOORD/NORMALS/COLORS in <vertices> and <polylist> ( issue 1084 )
|
||||||
|
- OBJParser: set material index when changing current material
|
||||||
|
- OBJ: check for null mesh before updating material index
|
||||||
|
- add vertex color export support ( issue 809 )
|
||||||
|
- Fix memory leak in Collada importer ( issue 1169 )
|
||||||
|
- add stp to the list of supported extensions for step-files ( issue 1183 )
|
||||||
|
- fix clang build ( Issue-1169 )
|
||||||
|
- fix for FreeBSD
|
||||||
|
- Import FindPkgMacros to main CMake Configuration
|
||||||
|
- Extended support for tessellation parameter to more IFC shapes
|
||||||
|
- defensice handling of utf-8 decode issues ( issue 1211 )
|
||||||
|
- Fixed compiler error on clang 4.0 running on OSX
|
||||||
|
- use test extension for exported test files ( issue 1228 )
|
||||||
|
- Set UVW index material properties for OBJ files
|
||||||
|
- Fixed no member named 'atop' in global namespace issue for Android NDK compilation
|
||||||
|
- Apply mechanism to decide use for IrrXML external or internal
|
||||||
|
- Fix static init ordering bug in OpenGEX importer
|
||||||
|
- GLTF exporter: ensure animation accessors have same count
|
||||||
|
- GLTF exporter: convert animation time from ticks to seconds
|
||||||
|
- Add support for reading texture coordinates from PLY meshes with properties named 'texture_u' and 'texture_v'
|
||||||
|
- Added TokensForSearch in BlenderLoader to allow CanRead return true for in-memory files.
|
||||||
|
- fix wrong delete ( issue 1266 )
|
||||||
|
- OpenGEX: fix invalid handling with color4 token ( issue 1262 )
|
||||||
|
- LWOLoader: fix link in loader description
|
||||||
|
- Fix error when custom CMAKE_C_FLAGS is specified
|
||||||
|
- Fast-atof: log overflow errors
|
||||||
|
- Obj-Importer: do not break when detecting an overflow ( issue 1244 )
|
||||||
|
- Obj-Importer: fix parsing of multible line data definitions
|
||||||
|
- Fixed bug where IFC models with multiple IFCSite only loaded 1 site instead of the complete model
|
||||||
|
- PLYImporter: - optimize memory and speed on ply importer / change parser to use a file stream - manage texture path in ply
|
||||||
|
import - manage texture coords on faces in ply import - correction on point cloud faces generation
|
||||||
|
- Utf8: integrate new lib ( issue 1158 )
|
||||||
|
- fixed CMAKE_MODULE_PATH overwriting previous values
|
||||||
|
- OpenGEX: Fixed bug in material color processing ( issue 1271 )
|
||||||
|
- SceneCombiner: move header for scenecombiner to public folder.
|
||||||
|
- GLTF exporter: ensure buffer view byte offsets are correctly aligned
|
||||||
|
- X3D importer: Added EXPORT and IMPORT to the list of ignored XML tags
|
||||||
|
- X3D Exporter: fixed missing attributes
|
||||||
|
- X3D importer: Fixed import of normals for the single index / normal per vertex case
|
||||||
|
- X3D importer: Fixed handling of inlined files
|
||||||
|
- X3D importer: fixed whitespace handling (issue 1202)
|
||||||
|
- X3D importer: Fixed iterator on MSVC 2015
|
||||||
|
- X3D importer: Fixed problems with auto, override and regex on older compilers
|
||||||
|
- X3D importer: Fixed missing header file
|
||||||
|
- X3D importer: Fixed path handling
|
||||||
|
- X3D importer: Implemented support for binary X3D files
|
||||||
|
- fix build without 3DS ( issue 1319 )
|
||||||
|
- pyassimp: Fixed indices for IndexedTriangleFanSet, IndexedTriangleSet and IndexedTriangleStripSet
|
||||||
|
- Fixes parameters to pyassimp.load
|
||||||
|
- Obj-Importe: Fixed texture bug due simultaneously using 'usemtl' and 'usemap' attributes
|
||||||
|
- check if all exporters are disabled ( issue 1320 )
|
||||||
|
- Remove std functions deprecated by C++11.
|
||||||
|
- X-Importer: make it deal with lines
|
||||||
|
- use correct path for compilers ( issue 1335 )
|
||||||
|
- Collada: add workaround to deal with polygon with holes
|
||||||
|
- update python readme
|
||||||
|
- Use unique node names when loading Collada files
|
||||||
|
- Fixed many FBX bugs
|
||||||
|
|
||||||
|
API COMPATIBILITY:
|
||||||
|
- Changed ABI-compatibility to v3.3.1, please rebuild your precompiled libraries ( see issue 1182 )
|
||||||
|
- VS2010 outdated
|
||||||
|
|
||||||
|
3.3.1 (2016-07-08)
|
||||||
|
|
||||||
|
FIXES/HOUSEKEEPING:
|
||||||
|
- Setup of default precision for 17 exporters
|
||||||
|
- Fix xcode project files
|
||||||
|
- Fix BlenderTesselator: offsetof operator
|
||||||
|
- Invalid version in cmake file
|
||||||
|
- Update pstdint.h to latest greatest
|
||||||
|
|
||||||
|
|
||||||
|
3.3.0 (2016-07-05)
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
- C++11 support enabled
|
||||||
|
- New regression-test-UI
|
||||||
|
- Experimental glTF-importer support
|
||||||
|
- OpenGEX: add support for cameras and lights
|
||||||
|
- C4D: update to latest Melange-SDK
|
||||||
|
- Add a gitter channel
|
||||||
|
- Coverity check enabled
|
||||||
|
- Switch to <...> include brackets for public headers
|
||||||
|
- Enable export by pyAssimp
|
||||||
|
- CI: check windows build
|
||||||
|
- Add functionality to perform a singlepost-processing step
|
||||||
|
- many more, just check the history
|
||||||
|
|
||||||
|
FIXES/HOUSEKEEPING:
|
||||||
|
- Fix of many resource leaks in unittests and main lib
|
||||||
|
- Fix iOS-buildfor X64
|
||||||
|
- Choosing zlib manually for cmake
|
||||||
|
- many more, just check the history
|
||||||
|
|
||||||
|
|
||||||
|
3.2.1 (2016-010-10)
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
- Updated glTF exporter to meet 1.0 specification.
|
||||||
|
|
||||||
|
FIXES/HOUSEKEEPING:
|
||||||
|
- Fixed glTF Validator errors for exported glTF format.
|
||||||
|
|
||||||
|
ISSUES:
|
||||||
|
- Hard coded sampler setting for
|
||||||
|
- magFilter
|
||||||
|
- minFilter
|
||||||
|
- void* in ExportData for accessor max and min.
|
||||||
|
|
||||||
|
|
||||||
|
3.2.0 (2015-11-03)
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
- OpenDDL-Parser is part of contrib-source.
|
||||||
|
- Experimental OpenGEX-support
|
||||||
|
- CI-check for linux and windows
|
||||||
|
- Coverity check added
|
||||||
|
- New regression testsuite.
|
||||||
|
|
||||||
|
FIXES/HOUSEKEEPING:
|
||||||
|
- Hundreds of bugfixes in all parts of the library
|
||||||
|
- Unified line endings
|
||||||
|
|
||||||
|
|
||||||
|
API COMPATIBILITY:
|
||||||
|
- Removed precompiled header to increase build speed for linux
|
||||||
|
|
||||||
|
|
||||||
|
3.1.1 (2014-06-15)
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
- Support for FBX 2013 and newer, binary and ASCII (this is partly
|
||||||
|
work from Google Summer of Code 2012)
|
||||||
|
- Support for OGRE binary mesh and skeleton format
|
||||||
|
- Updated BLEND support for newer Blender versions
|
||||||
|
- Support for arbitrary meta data, used to hold FBX and DAE metadata
|
||||||
|
- OBJ Export now produces smaller files
|
||||||
|
- Meshes can now have names, this is supported by the major importers
|
||||||
|
- Improved IFC geometry generation
|
||||||
|
- M3 support has been removed
|
||||||
|
|
||||||
|
FIXES/HOUSEKEEPING:
|
||||||
|
- Hundreds of bugfixes in all parts of the library
|
||||||
|
- CMake is now the primary build system
|
||||||
|
|
||||||
|
API COMPATIBILITY:
|
||||||
|
- 3.1.1 is not binary compatible to 3.0 due to aiNode::mMetaData
|
||||||
|
and aiMesh::mName
|
||||||
|
- Export interface has been cleaned up and unified
|
||||||
|
- Other than that no relevant changes
|
||||||
|
|
||||||
|
|
||||||
|
3.0 (2012-07-07)
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
- new export interface similar to the import API.
|
||||||
|
- Supported export formats: Collada, OBJ, PLY and STL
|
||||||
|
- added new import formats: XGL/ZGL, M3 (experimental)
|
||||||
|
- new postprocessing steps: Debone
|
||||||
|
- vastly improved IFC (Industry Foundation Classes) support
|
||||||
|
- introduced API to query importer meta information (such as supported
|
||||||
|
format versions, full name, maintainer info).
|
||||||
|
- reworked Ogre XML import
|
||||||
|
- C-API now supports per-import properties
|
||||||
|
|
||||||
|
FIXES/HOUSEKEEPING:
|
||||||
|
|
||||||
|
- hundreds of bugfixes in all parts of the library
|
||||||
|
- unified naming and cleanup of public headers
|
||||||
|
- improved CMake build system
|
||||||
|
- templatized math library
|
||||||
|
- reduce dependency on boost.thread, only remaining spot
|
||||||
|
is synchronization for the C logging API
|
||||||
|
|
||||||
|
API COMPATIBILITY:
|
||||||
|
- renamed headers, export interface, C API properties and meta data
|
||||||
|
prevent compatibility with code written for 2.0, but in
|
||||||
|
most cases these can be easily resolved
|
||||||
|
- Note: 3.0 is not binary compatible with 2.0
|
||||||
|
|
||||||
|
|
||||||
|
2.0 (2010-11-21)
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
- Add support for static Blender (*.blend) scenes
|
||||||
|
- Add support for Q3BSP scenes
|
||||||
|
- Add a windows-based OpenGL sample featuring texturing & basic materials
|
||||||
|
- Add an experimental progress feedback interface.
|
||||||
|
- Vastly improved performance (up to 500%, depending on mesh size and
|
||||||
|
spatial structure) in some expensive postprocessing steps
|
||||||
|
- AssimpView now uses a reworked layout which leaves more space
|
||||||
|
to the scene hierarchy window
|
||||||
|
|
||||||
|
- Add C# bindings ('Assimp.NET')
|
||||||
|
- Keep BSD-licensed and otherwise free test files in separate
|
||||||
|
folders (./test/models and ./test/models-nonbsd).
|
||||||
|
|
||||||
|
FIXES:
|
||||||
|
- Many Collada bugfixes, improve fault tolerance
|
||||||
|
- Fix possible crashes in the Obj loader
|
||||||
|
- Improve the Ogre XML loader
|
||||||
|
- OpenGL-sample now works with MinGW
|
||||||
|
- Fix Importer::FindLoader failing on uppercase file extensions
|
||||||
|
- Fix flawed path handling when locating external files
|
||||||
|
- Limit the maximum number of vertices, faces, face indices and
|
||||||
|
weights that Assimp is able to handle. This is to avoid
|
||||||
|
crashes due to overflowing counters.
|
||||||
|
|
||||||
|
- Updated XCode project files
|
||||||
|
- Further CMAKE build improvements
|
||||||
|
|
||||||
|
|
||||||
|
API CHANGES:
|
||||||
|
- Add data structures for vertex-based animations (These are not
|
||||||
|
currently used, however ...)
|
||||||
|
- Some Assimp::Importer methods are const now.
|
||||||
|
|
||||||
|
|
||||||
|
1.1 (2010-04-17)
|
||||||
|
This is the list of relevant changes from the 1.0 (r412) release to 1.1 (r700).
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
- Vastly improved Collada support
|
||||||
|
- Add MS3D (Milkshape 3D) support
|
||||||
|
- Add support for Ogre XML static meshes
|
||||||
|
- Add experimental COB (TrueSpace) support
|
||||||
|
- Automatic test suite to quickly locate regressions
|
||||||
|
- D bindings (`dAssimp`)
|
||||||
|
- Python 2.n bindings (`PyAssimp`)
|
||||||
|
- Add basic support for Unicode input files (utf8, utf16 and utf32)
|
||||||
|
- Add further utilities to the `assimp` tool (xml/binary dumps, quick file stats)
|
||||||
|
- Switch to a CMAKE-based build system including an install target for unix'es
|
||||||
|
- Automatic evaluation of subdivision surfaces for some formats.
|
||||||
|
- Add `Importer::ReadFileFromMemory` and the corresponding C-API `aiReadFileFromMemory`
|
||||||
|
- Expose further math utilities via the C-API (i.e. `aiMultiplyMatrix4`)
|
||||||
|
|
||||||
|
- Move noboost files away from the public include directory
|
||||||
|
- Many, many bugfixes and improvements in existing loaders and postprocessing steps
|
||||||
|
- Documentation improved and clarified in many places.
|
||||||
|
- Add a sample on using Assimp in conjunction with OpenGL
|
||||||
|
|
||||||
|
- Distribution/packaging: comfortable SDK installer for Windows
|
||||||
|
- Distribution/packaging: improved release packages for other architectures
|
||||||
|
|
||||||
|
CRITICAL FIXES:
|
||||||
|
- Resolve problems with clashing heap managers, STL ABIs and runtime libraries (win32)
|
||||||
|
- Fix automatic detection of file type if no file extension is given
|
||||||
|
- Improved exception safety and robustness, prevent leaking of exceptions through the C interface
|
||||||
|
- Fix possible heap corruption due to material properties pulled in incorrectly
|
||||||
|
- Avoid leaking in certain error scenarios
|
||||||
|
- Fix 64 bit compatibility problems in some loaders (i.e. MDL)
|
||||||
|
|
||||||
|
BREAKING API CHANGES:
|
||||||
|
- None -
|
||||||
|
|
||||||
|
MINOR API BEHAVIOUR CHANGES:
|
||||||
|
- Change quaternion orientation to suit to the more common convention (-w).
|
||||||
|
- aiString is utf8 now. Not yet consistent, however.
|
||||||
-3961
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -362,7 +362,7 @@ ELSEIF(MSVC)
|
|||||||
elseif((GENERATOR_IS_MULTI_CONFIG) OR (CMAKE_BUILD_TYPE MATCHES Release))
|
elseif((GENERATOR_IS_MULTI_CONFIG) OR (CMAKE_BUILD_TYPE MATCHES Release))
|
||||||
message("-- MSVC PDB generation disabled. Release binary will not be debuggable.")
|
message("-- MSVC PDB generation disabled. Release binary will not be debuggable.")
|
||||||
endif()
|
endif()
|
||||||
if(NOT CMAKE_CXX_FLAGS MATCHES "/utf-8")
|
if(NOT /utf-8 IN_LIST CMAKE_CXX_FLAGS)
|
||||||
# Source code is encoded in UTF-8
|
# Source code is encoded in UTF-8
|
||||||
ADD_COMPILE_OPTIONS(/source-charset:utf-8)
|
ADD_COMPILE_OPTIONS(/source-charset:utf-8)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -14,16 +14,6 @@
|
|||||||
"ASSIMP_BUILD_ASSIMP_TOOLS": "OFF"
|
"ASSIMP_BUILD_ASSIMP_TOOLS": "OFF"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "assimp_static",
|
|
||||||
"binaryDir": "${sourceDir}",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BUILD_SHARED_LIBS": "OFF",
|
|
||||||
"ASSIMP_BUILD_ASSIMP_TOOLS": "OFF",
|
|
||||||
"ASSIMP_DOUBLE_PRECISION": "ON"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "assimp_double_precision",
|
"name": "assimp_double_precision",
|
||||||
"binaryDir": "${sourceDir}",
|
"binaryDir": "${sourceDir}",
|
||||||
@@ -39,15 +29,6 @@
|
|||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"ASSIMP_BUILD_ASSIMP_TOOLS": "ON"
|
"ASSIMP_BUILD_ASSIMP_TOOLS": "ON"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "assimp_all",
|
|
||||||
"binaryDir": "${sourceDir}",
|
|
||||||
"cacheVariables": {
|
|
||||||
"ASSIMP_BUILD_ASSIMP_TOOLS": "ON",
|
|
||||||
"ASSIMP_BUILD_SAMPLES": "ON",
|
|
||||||
"ASSIMP_BUILD_DOCS": "ON"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||||
|
|
||||||
|
#.rst:
|
||||||
|
# FindDevIL
|
||||||
|
# ---------
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# This module locates the developer's image library.
|
||||||
|
# http://openil.sourceforge.net/
|
||||||
|
#
|
||||||
|
# This module sets:
|
||||||
|
#
|
||||||
|
# ::
|
||||||
|
#
|
||||||
|
# IL_LIBRARIES - the name of the IL library. These include the full path to
|
||||||
|
# the core DevIL library. This one has to be linked into the
|
||||||
|
# application.
|
||||||
|
# ILU_LIBRARIES - the name of the ILU library. Again, the full path. This
|
||||||
|
# library is for filters and effects, not actual loading. It
|
||||||
|
# doesn't have to be linked if the functionality it provides
|
||||||
|
# is not used.
|
||||||
|
# ILUT_LIBRARIES - the name of the ILUT library. Full path. This part of the
|
||||||
|
# library interfaces with OpenGL. It is not strictly needed
|
||||||
|
# in applications.
|
||||||
|
# IL_INCLUDE_DIR - where to find the il.h, ilu.h and ilut.h files.
|
||||||
|
# IL_FOUND - this is set to TRUE if all the above variables were set.
|
||||||
|
# This will be set to false if ILU or ILUT are not found,
|
||||||
|
# even if they are not needed. In most systems, if one
|
||||||
|
# library is found all the others are as well. That's the
|
||||||
|
# way the DevIL developers release it.
|
||||||
|
|
||||||
|
# TODO: Add version support.
|
||||||
|
# Tested under Linux and Windows (MSVC)
|
||||||
|
|
||||||
|
#include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
find_path(IL_INCLUDE_DIR il.h
|
||||||
|
PATH_SUFFIXES include IL
|
||||||
|
DOC "The path to the directory that contains il.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
#message("IL_INCLUDE_DIR is ${IL_INCLUDE_DIR}")
|
||||||
|
|
||||||
|
find_library(IL_LIBRARIES
|
||||||
|
NAMES IL DEVIL
|
||||||
|
PATH_SUFFIXES lib64 lib lib32
|
||||||
|
DOC "The file that corresponds to the base il library."
|
||||||
|
)
|
||||||
|
|
||||||
|
#message("IL_LIBRARIES is ${IL_LIBRARIES}")
|
||||||
|
|
||||||
|
find_library(ILUT_LIBRARIES
|
||||||
|
NAMES ILUT
|
||||||
|
PATH_SUFFIXES lib64 lib lib32
|
||||||
|
DOC "The file that corresponds to the il (system?) utility library."
|
||||||
|
)
|
||||||
|
|
||||||
|
#message("ILUT_LIBRARIES is ${ILUT_LIBRARIES}")
|
||||||
|
|
||||||
|
find_library(ILU_LIBRARIES
|
||||||
|
NAMES ILU
|
||||||
|
PATH_SUFFIXES lib64 lib lib32
|
||||||
|
DOC "The file that corresponds to the il utility library."
|
||||||
|
)
|
||||||
|
|
||||||
|
#message("ILU_LIBRARIES is ${ILU_LIBRARIES}")
|
||||||
|
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(IL DEFAULT_MSG
|
||||||
|
IL_LIBRARIES IL_INCLUDE_DIR)
|
||||||
@@ -64,7 +64,7 @@ class Parser;
|
|||||||
class Element;
|
class Element;
|
||||||
|
|
||||||
using ScopeList = std::vector<Scope*>;
|
using ScopeList = std::vector<Scope*>;
|
||||||
using ElementMap = std::multimap< std::string, Element*>;
|
using ElementMap = std::fbx_unordered_multimap< std::string, Element*>;
|
||||||
using ElementCollection = std::pair<ElementMap::const_iterator,ElementMap::const_iterator>;
|
using ElementCollection = std::pair<ElementMap::const_iterator,ElementMap::const_iterator>;
|
||||||
|
|
||||||
#define new_Scope new (allocator.Allocate(sizeof(Scope))) Scope
|
#define new_Scope new (allocator.Allocate(sizeof(Scope))) Scope
|
||||||
|
|||||||
@@ -390,21 +390,13 @@ void MD3Importer::ValidateHeaderOffsets() {
|
|||||||
void MD3Importer::ValidateSurfaceHeaderOffsets(const MD3::Surface *pcSurf) {
|
void MD3Importer::ValidateSurfaceHeaderOffsets(const MD3::Surface *pcSurf) {
|
||||||
// Calculate the relative offset of the surface
|
// Calculate the relative offset of the surface
|
||||||
const int32_t ofs = int32_t((const unsigned char *)pcSurf - this->mBuffer);
|
const int32_t ofs = int32_t((const unsigned char *)pcSurf - this->mBuffer);
|
||||||
if (ofs + sizeof(MD3::Surface) > fileSize) {
|
|
||||||
throw DeadlyImportError("Surface header is outside file bounds");
|
|
||||||
}
|
|
||||||
|
|
||||||
auto inRange = [this, ofs](uint32_t rel_offset, uint32_t count, size_t elem_size) -> bool {
|
|
||||||
size_t abs_offset = ofs + rel_offset;
|
|
||||||
if (count > 0 && elem_size > 0 && count > SIZE_MAX / elem_size) return false;
|
|
||||||
size_t total = abs_offset + size_t(count) * elem_size;
|
|
||||||
return abs_offset <= fileSize && total <= fileSize;
|
|
||||||
};
|
|
||||||
// Check whether all data chunks are inside the valid range
|
// Check whether all data chunks are inside the valid range
|
||||||
if (!inRange(pcSurf->OFS_TRIANGLES, pcSurf->NUM_TRIANGLES, sizeof(MD3::Triangle)) ||
|
if (pcSurf->OFS_TRIANGLES + ofs + pcSurf->NUM_TRIANGLES * sizeof(MD3::Triangle) > fileSize ||
|
||||||
!inRange(pcSurf->OFS_SHADERS, pcSurf->NUM_SHADER, sizeof(MD3::Shader)) ||
|
pcSurf->OFS_SHADERS + ofs + pcSurf->NUM_SHADER * sizeof(MD3::Shader) > fileSize ||
|
||||||
!inRange(pcSurf->OFS_ST, pcSurf->NUM_VERTICES, sizeof(MD3::TexCoord)) ||
|
pcSurf->OFS_ST + ofs + pcSurf->NUM_VERTICES * sizeof(MD3::TexCoord) > fileSize ||
|
||||||
!inRange(pcSurf->OFS_XYZNORMAL, pcSurf->NUM_VERTICES, sizeof(MD3::Vertex))) {
|
pcSurf->OFS_XYZNORMAL + ofs + pcSurf->NUM_VERTICES * sizeof(MD3::Vertex) > fileSize) {
|
||||||
|
|
||||||
throw DeadlyImportError("Invalid MD3 surface header: some offsets are outside the file");
|
throw DeadlyImportError("Invalid MD3 surface header: some offsets are outside the file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -361,19 +361,19 @@ void MD5Importer::LoadMD5MeshFile() {
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
// FIX: MD5 files exported from Blender can have empty meshes
|
// FIX: MD5 files exported from Blender can have empty meshes
|
||||||
unsigned int numMaterials = 0;
|
|
||||||
for (std::vector<MD5::MeshDesc>::const_iterator it = meshParser.mMeshes.begin(), end = meshParser.mMeshes.end(); it != end; ++it) {
|
for (std::vector<MD5::MeshDesc>::const_iterator it = meshParser.mMeshes.begin(), end = meshParser.mMeshes.end(); it != end; ++it) {
|
||||||
if (!(*it).mFaces.empty() && !(*it).mVertices.empty()) {
|
if (!(*it).mFaces.empty() && !(*it).mVertices.empty()) {
|
||||||
++numMaterials;
|
++mScene->mNumMaterials;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate all meshes
|
// generate all meshes
|
||||||
mScene->mMeshes = new aiMesh *[numMaterials];
|
mScene->mNumMeshes = mScene->mNumMaterials;
|
||||||
mScene->mMaterials = new aiMaterial *[numMaterials];
|
mScene->mMeshes = new aiMesh *[mScene->mNumMeshes];
|
||||||
|
mScene->mMaterials = new aiMaterial *[mScene->mNumMeshes];
|
||||||
|
|
||||||
// storage for node mesh indices
|
// storage for node mesh indices
|
||||||
pcNode->mNumMeshes = numMaterials;
|
pcNode->mNumMeshes = mScene->mNumMeshes;
|
||||||
pcNode->mMeshes = new unsigned int[pcNode->mNumMeshes];
|
pcNode->mMeshes = new unsigned int[pcNode->mNumMeshes];
|
||||||
for (unsigned int m = 0; m < pcNode->mNumMeshes; ++m) {
|
for (unsigned int m = 0; m < pcNode->mNumMeshes; ++m) {
|
||||||
pcNode->mMeshes[m] = m;
|
pcNode->mMeshes[m] = m;
|
||||||
@@ -386,10 +386,7 @@ void MD5Importer::LoadMD5MeshFile() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
aiMesh* mesh = new aiMesh();
|
aiMesh *mesh = mScene->mMeshes[n] = new aiMesh();
|
||||||
mScene->mMeshes[n] = mesh;
|
|
||||||
++mScene->mNumMeshes;
|
|
||||||
|
|
||||||
mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
||||||
|
|
||||||
// generate unique vertices in our internal verbose format
|
// generate unique vertices in our internal verbose format
|
||||||
@@ -511,7 +508,6 @@ void MD5Importer::LoadMD5MeshFile() {
|
|||||||
// generate a material for the mesh
|
// generate a material for the mesh
|
||||||
aiMaterial *mat = new aiMaterial();
|
aiMaterial *mat = new aiMaterial();
|
||||||
mScene->mMaterials[n] = mat;
|
mScene->mMaterials[n] = mat;
|
||||||
++mScene->mNumMaterials;
|
|
||||||
|
|
||||||
// insert the typical doom3 textures:
|
// insert the typical doom3 textures:
|
||||||
// nnn_local.tga - normal map
|
// nnn_local.tga - normal map
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ void MDCImporter::ValidateSurfaceHeader(BE_NCONST MDC::Surface *pcSurf) {
|
|||||||
AI_SWAP4(pcSurf->ulOffsetTexCoords);
|
AI_SWAP4(pcSurf->ulOffsetTexCoords);
|
||||||
AI_SWAP4(pcSurf->ulOffsetBaseVerts);
|
AI_SWAP4(pcSurf->ulOffsetBaseVerts);
|
||||||
AI_SWAP4(pcSurf->ulOffsetCompVerts);
|
AI_SWAP4(pcSurf->ulOffsetCompVerts);
|
||||||
AI_SWAP4(pcSurf->ulOffsetShaders);
|
|
||||||
AI_SWAP4(pcSurf->ulOffsetFrameBaseFrames);
|
AI_SWAP4(pcSurf->ulOffsetFrameBaseFrames);
|
||||||
AI_SWAP4(pcSurf->ulOffsetFrameCompFrames);
|
AI_SWAP4(pcSurf->ulOffsetFrameCompFrames);
|
||||||
AI_SWAP4(pcSurf->ulOffsetEnd);
|
AI_SWAP4(pcSurf->ulOffsetEnd);
|
||||||
@@ -173,8 +172,7 @@ void MDCImporter::ValidateSurfaceHeader(BE_NCONST MDC::Surface *pcSurf) {
|
|||||||
pcSurf->ulOffsetTexCoords + pcSurf->ulNumVertices * sizeof(MDC::TexturCoord) > iMax ||
|
pcSurf->ulOffsetTexCoords + pcSurf->ulNumVertices * sizeof(MDC::TexturCoord) > iMax ||
|
||||||
pcSurf->ulOffsetShaders + pcSurf->ulNumShaders * sizeof(MDC::Shader) > iMax ||
|
pcSurf->ulOffsetShaders + pcSurf->ulNumShaders * sizeof(MDC::Shader) > iMax ||
|
||||||
pcSurf->ulOffsetFrameBaseFrames + pcSurf->ulNumBaseFrames * 2 > iMax ||
|
pcSurf->ulOffsetFrameBaseFrames + pcSurf->ulNumBaseFrames * 2 > iMax ||
|
||||||
(pcSurf->ulNumCompFrames && pcSurf->ulOffsetFrameCompFrames + pcSurf->ulNumCompFrames * 2 > iMax) ||
|
(pcSurf->ulNumCompFrames && pcSurf->ulOffsetFrameCompFrames + pcSurf->ulNumCompFrames * 2 > iMax)) {
|
||||||
pcSurf->ulOffsetEnd > iMax) {
|
|
||||||
throw DeadlyImportError("Some of the offset values in the MDC surface header "
|
throw DeadlyImportError("Some of the offset values in the MDC surface header "
|
||||||
"are invalid and point somewhere behind the file.");
|
"are invalid and point somewhere behind the file.");
|
||||||
}
|
}
|
||||||
@@ -326,15 +324,6 @@ void MDCImporter::InternReadFile(
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// boundary check for pcVerts
|
|
||||||
auto surfStart = reinterpret_cast<const uint8_t*>(pcSurface);
|
|
||||||
const uint8_t* surfEnd = surfStart + pcSurface->ulOffsetEnd;
|
|
||||||
auto vertBufStart = reinterpret_cast<const uint8_t*>(pcVerts);
|
|
||||||
const size_t needVertBytes = sizeof(MDC::BaseVertex) * pcSurface->ulNumVertices;
|
|
||||||
if (vertBufStart < surfStart || vertBufStart + needVertBytes > surfEnd) {
|
|
||||||
throw DeadlyImportError("MDCImporter: pcVerts points outside of surface block.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const MDC::CompressedVertex *pcCVerts = nullptr;
|
const MDC::CompressedVertex *pcCVerts = nullptr;
|
||||||
int16_t *mdcCompVert = nullptr;
|
int16_t *mdcCompVert = nullptr;
|
||||||
|
|
||||||
@@ -346,12 +335,6 @@ void MDCImporter::InternReadFile(
|
|||||||
pcCVerts = (const MDC::CompressedVertex *)((int8_t *)pcSurface +
|
pcCVerts = (const MDC::CompressedVertex *)((int8_t *)pcSurface +
|
||||||
pcSurface->ulOffsetCompVerts) +
|
pcSurface->ulOffsetCompVerts) +
|
||||||
*mdcCompVert * pcSurface->ulNumVertices;
|
*mdcCompVert * pcSurface->ulNumVertices;
|
||||||
auto cvertBufStart = reinterpret_cast<const uint8_t*>(pcCVerts);
|
|
||||||
const size_t needCompVertBytes = sizeof(MDC::CompressedVertex) * pcSurface->ulNumVertices;
|
|
||||||
if (cvertBufStart < surfStart || cvertBufStart > surfEnd ||
|
|
||||||
needCompVertBytes > static_cast<size_t>(surfEnd - cvertBufStart)) {
|
|
||||||
throw DeadlyImportError("MDCImporter: pcCVerts points outside of surface block.");
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
mdcCompVert = nullptr;
|
mdcCompVert = nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,182 +0,0 @@
|
|||||||
/*
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
Open Asset Import Library (assimp)
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2006-2026, assimp team
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
|
||||||
with or without modification, are permitted provided that the following
|
|
||||||
conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
|
||||||
contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior
|
|
||||||
written permission of the assimp team.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file HL1DataBuffer.h
|
|
||||||
* @brief Declaration of the Half-Life 1 data buffer.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef AI_HL1DATABUFFER_INCLUDED
|
|
||||||
#define AI_HL1DATABUFFER_INCLUDED
|
|
||||||
|
|
||||||
#include <assimp/Exceptional.h>
|
|
||||||
#include <assimp/defs.h>
|
|
||||||
#include <cstddef>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Assimp {
|
|
||||||
namespace MDL {
|
|
||||||
namespace HalfLife {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Lightweight byte buffer wrapper for HL1 binary parsing.
|
|
||||||
*
|
|
||||||
* Acts as either:
|
|
||||||
* - a non-owning view into external memory, or
|
|
||||||
* - an owning buffer backed by a unique_ptr.
|
|
||||||
*
|
|
||||||
* Copy is disabled to avoid accidental double-ownership; move is supported.
|
|
||||||
*/
|
|
||||||
class HL1DataBuffer {
|
|
||||||
public:
|
|
||||||
/** \brief Construct an empty buffer (null view). */
|
|
||||||
HL1DataBuffer() AI_NO_EXCEPT : data_(nullptr),
|
|
||||||
length_(0),
|
|
||||||
owner_(nullptr) {}
|
|
||||||
|
|
||||||
/** \brief Non-copyable (buffer may own memory). */
|
|
||||||
HL1DataBuffer(const HL1DataBuffer &) = delete;
|
|
||||||
|
|
||||||
/** \brief Non-copyable (buffer may own memory). */
|
|
||||||
HL1DataBuffer &operator=(const HL1DataBuffer &) = delete;
|
|
||||||
|
|
||||||
/** \brief Move-construct, transferring ownership/view state. */
|
|
||||||
HL1DataBuffer(HL1DataBuffer &&other) AI_NO_EXCEPT : data_(other.data_),
|
|
||||||
length_(other.length_),
|
|
||||||
owner_(std::move(other.owner_)) {
|
|
||||||
other.data_ = nullptr;
|
|
||||||
other.length_ = 0;
|
|
||||||
other.owner_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Move-assign, transferring ownership/view state. */
|
|
||||||
HL1DataBuffer &operator=(HL1DataBuffer &&other) AI_NO_EXCEPT {
|
|
||||||
if (this != &other) {
|
|
||||||
data_ = other.data_;
|
|
||||||
length_ = other.length_;
|
|
||||||
owner_ = std::move(other.owner_);
|
|
||||||
|
|
||||||
other.data_ = nullptr;
|
|
||||||
other.length_ = 0;
|
|
||||||
other.owner_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Create a non-owning view into external bytes.
|
|
||||||
*
|
|
||||||
* \param[in] data Pointer to raw bytes (must outlive the view).
|
|
||||||
* \param[in] length Size in bytes.
|
|
||||||
*/
|
|
||||||
static HL1DataBuffer view(const unsigned char *data, size_t length) {
|
|
||||||
HL1DataBuffer b;
|
|
||||||
b.data_ = data;
|
|
||||||
b.length_ = length;
|
|
||||||
b.owner_ = nullptr;
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Create a non-owning view of another buffer.
|
|
||||||
*
|
|
||||||
* \param[in] other Source buffer.
|
|
||||||
*/
|
|
||||||
static HL1DataBuffer view(const HL1DataBuffer &other) {
|
|
||||||
HL1DataBuffer b;
|
|
||||||
b.data_ = other.data_;
|
|
||||||
b.length_ = other.length_;
|
|
||||||
b.owner_ = nullptr;
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Create an owning buffer by taking ownership of allocated storage.
|
|
||||||
*
|
|
||||||
* \param[in] buffer Unique buffer storage.
|
|
||||||
* \param[in] length Size in bytes.
|
|
||||||
*/
|
|
||||||
static HL1DataBuffer owning(std::unique_ptr<unsigned char[]> buffer, size_t length) {
|
|
||||||
HL1DataBuffer b;
|
|
||||||
b.data_ = buffer.get();
|
|
||||||
b.length_ = length;
|
|
||||||
b.owner_ = std::move(buffer);
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Return a typed pointer into the buffer with bounds checks.
|
|
||||||
*
|
|
||||||
* \param[in] offset Byte offset from the start of the buffer.
|
|
||||||
* \param[in] elements Number of elements to access.
|
|
||||||
* \return Pointer to the requested typed data inside the buffer.
|
|
||||||
* \throws DeadlyImportError if the request is out of range.
|
|
||||||
*/
|
|
||||||
template <typename DataType>
|
|
||||||
const DataType *get_data(int offset, int elements) const {
|
|
||||||
if (offset < 0 || elements < 0) {
|
|
||||||
throw DeadlyImportError("MDL file contains invalid data");
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t uoffset = static_cast<size_t>(offset);
|
|
||||||
const size_t uelements = static_cast<size_t>(elements);
|
|
||||||
|
|
||||||
if (uoffset > length_ || uelements > (length_ - uoffset) / sizeof(DataType)) {
|
|
||||||
throw DeadlyImportError("MDL file contains invalid data");
|
|
||||||
}
|
|
||||||
|
|
||||||
return reinterpret_cast<const DataType *>(data_ + uoffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
/** Raw byte pointer (points to owner_.get() when owning, otherwise external). */
|
|
||||||
const unsigned char *data_;
|
|
||||||
/** Buffer length in bytes. */
|
|
||||||
size_t length_;
|
|
||||||
/** Owning storage (null for views). */
|
|
||||||
std::unique_ptr<unsigned char[]> owner_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace HalfLife
|
|
||||||
} // namespace MDL
|
|
||||||
} // namespace Assimp
|
|
||||||
|
|
||||||
#endif // AI_HL1DATABUFFER_INCLUDED
|
|
||||||
@@ -78,19 +78,18 @@ HL1MDLLoader::HL1MDLLoader(
|
|||||||
aiScene *scene,
|
aiScene *scene,
|
||||||
IOSystem *io,
|
IOSystem *io,
|
||||||
const unsigned char *buffer,
|
const unsigned char *buffer,
|
||||||
size_t buffer_length,
|
|
||||||
const std::string &file_path,
|
const std::string &file_path,
|
||||||
const HL1ImportSettings &import_settings) :
|
const HL1ImportSettings &import_settings) :
|
||||||
scene_(scene),
|
scene_(scene),
|
||||||
io_(io),
|
io_(io),
|
||||||
buffer_(HL1DataBuffer::view(buffer, buffer_length)),
|
buffer_(buffer),
|
||||||
file_path_(file_path),
|
file_path_(file_path),
|
||||||
import_settings_(import_settings),
|
import_settings_(import_settings),
|
||||||
header_(nullptr),
|
header_(nullptr),
|
||||||
texture_header_(nullptr),
|
texture_header_(nullptr),
|
||||||
anim_headers_(),
|
anim_headers_(nullptr),
|
||||||
texture_buffer_(),
|
texture_buffer_(nullptr),
|
||||||
anim_buffers_(),
|
anim_buffers_(nullptr),
|
||||||
num_sequence_groups_(0),
|
num_sequence_groups_(0),
|
||||||
rootnode_children_(),
|
rootnode_children_(),
|
||||||
unique_name_generator_(),
|
unique_name_generator_(),
|
||||||
@@ -109,6 +108,28 @@ HL1MDLLoader::~HL1MDLLoader() {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void HL1MDLLoader::release_resources() {
|
void HL1MDLLoader::release_resources() {
|
||||||
|
if (buffer_ != texture_buffer_) {
|
||||||
|
delete[] texture_buffer_;
|
||||||
|
texture_buffer_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num_sequence_groups_ && anim_buffers_) {
|
||||||
|
for (int i = 1; i < num_sequence_groups_; ++i) {
|
||||||
|
if (anim_buffers_[i]) {
|
||||||
|
delete[] anim_buffers_[i];
|
||||||
|
anim_buffers_[i] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] anim_buffers_;
|
||||||
|
anim_buffers_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (anim_headers_) {
|
||||||
|
delete[] anim_headers_;
|
||||||
|
anim_headers_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Root has some children nodes. so let's proceed them
|
// Root has some children nodes. so let's proceed them
|
||||||
if (!rootnode_children_.empty()) {
|
if (!rootnode_children_.empty()) {
|
||||||
// Here, it means that the nodes were not added to the
|
// Here, it means that the nodes were not added to the
|
||||||
@@ -126,7 +147,7 @@ void HL1MDLLoader::release_resources() {
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void HL1MDLLoader::load_file() {
|
void HL1MDLLoader::load_file() {
|
||||||
try {
|
try {
|
||||||
header_ = get_buffer_data<Header_HL1>(0, 1);
|
header_ = (const Header_HL1 *)buffer_;
|
||||||
validate_header(header_, false);
|
validate_header(header_, false);
|
||||||
|
|
||||||
// Create the root scene node.
|
// Create the root scene node.
|
||||||
@@ -265,10 +286,10 @@ void HL1MDLLoader::load_texture_file() {
|
|||||||
load_file_into_buffer<Header_HL1>(texture_file_path, texture_buffer_);
|
load_file_into_buffer<Header_HL1>(texture_file_path, texture_buffer_);
|
||||||
} else {
|
} else {
|
||||||
// Model has no external texture file. This means the texture is stored inside the main MDL file.
|
// Model has no external texture file. This means the texture is stored inside the main MDL file.
|
||||||
texture_buffer_ = HL1DataBuffer::view(buffer_);
|
texture_buffer_ = const_cast<unsigned char *>(buffer_);
|
||||||
}
|
}
|
||||||
|
|
||||||
texture_header_ = get_texture_buffer_data<Header_HL1>(0, 1);
|
texture_header_ = (const Header_HL1 *)texture_buffer_;
|
||||||
|
|
||||||
// Validate texture header.
|
// Validate texture header.
|
||||||
validate_header(texture_header_, true);
|
validate_header(texture_header_, true);
|
||||||
@@ -297,8 +318,12 @@ void HL1MDLLoader::load_sequence_groups_files() {
|
|||||||
|
|
||||||
num_sequence_groups_ = header_->numseqgroups;
|
num_sequence_groups_ = header_->numseqgroups;
|
||||||
|
|
||||||
anim_buffers_.resize(num_sequence_groups_);
|
anim_buffers_ = new unsigned char *[num_sequence_groups_];
|
||||||
anim_headers_.resize(num_sequence_groups_, nullptr);
|
anim_headers_ = new SequenceHeader_HL1 *[num_sequence_groups_];
|
||||||
|
for (int i = 0; i < num_sequence_groups_; ++i) {
|
||||||
|
anim_buffers_[i] = nullptr;
|
||||||
|
anim_headers_[i] = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::string file_path_without_extension =
|
std::string file_path_without_extension =
|
||||||
DefaultIOSystem::absolutePath(file_path_) +
|
DefaultIOSystem::absolutePath(file_path_) +
|
||||||
@@ -315,14 +340,14 @@ void HL1MDLLoader::load_sequence_groups_files() {
|
|||||||
|
|
||||||
load_file_into_buffer<SequenceHeader_HL1>(sequence_file_path, anim_buffers_[i]);
|
load_file_into_buffer<SequenceHeader_HL1>(sequence_file_path, anim_buffers_[i]);
|
||||||
|
|
||||||
anim_headers_[i] = get_anim_buffer_data<SequenceHeader_HL1>(i, 0, 1);
|
anim_headers_[i] = (SequenceHeader_HL1 *)anim_buffers_[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Read an MDL texture.
|
// Read an MDL texture.
|
||||||
void HL1MDLLoader::read_texture(const Texture_HL1 *ptexture,
|
void HL1MDLLoader::read_texture(const Texture_HL1 *ptexture,
|
||||||
const uint8_t *data, const uint8_t *pal, aiTexture *pResult,
|
uint8_t *data, uint8_t *pal, aiTexture *pResult,
|
||||||
aiColor3D &last_palette_color) {
|
aiColor3D &last_palette_color) {
|
||||||
pResult->mFilename = ptexture->name;
|
pResult->mFilename = ptexture->name;
|
||||||
pResult->mWidth = static_cast<unsigned int>(ptexture->width);
|
pResult->mWidth = static_cast<unsigned int>(ptexture->width);
|
||||||
@@ -356,24 +381,24 @@ void HL1MDLLoader::read_texture(const Texture_HL1 *ptexture,
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void HL1MDLLoader::read_textures() {
|
void HL1MDLLoader::read_textures() {
|
||||||
scene_->mTextures = new aiTexture *[texture_header_->numtextures];
|
const Texture_HL1 *ptexture = (const Texture_HL1 *)((uint8_t *)texture_header_ + texture_header_->textureindex);
|
||||||
scene_->mMaterials = new aiMaterial *[texture_header_->numtextures];
|
unsigned char *pin = texture_buffer_;
|
||||||
|
|
||||||
const Texture_HL1 *ptexture = get_texture_buffer_data<Texture_HL1>(texture_header_->textureindex, texture_header_->numtextures);
|
scene_->mNumTextures = scene_->mNumMaterials = texture_header_->numtextures;
|
||||||
|
scene_->mTextures = new aiTexture *[scene_->mNumTextures];
|
||||||
|
scene_->mMaterials = new aiMaterial *[scene_->mNumMaterials];
|
||||||
|
|
||||||
for (int i = 0; i < texture_header_->numtextures; ++i) {
|
for (int i = 0; i < texture_header_->numtextures; ++i) {
|
||||||
scene_->mTextures[i] = new aiTexture();
|
scene_->mTextures[i] = new aiTexture();
|
||||||
++scene_->mNumTextures;
|
|
||||||
|
|
||||||
const uint8_t *data = get_texture_buffer_data<uint8_t>(ptexture[i].index, ptexture[i].width * ptexture[i].height);
|
|
||||||
const uint8_t *pal = get_texture_buffer_data<uint8_t>(ptexture[i].index + ptexture[i].width * ptexture[i].height, 256 * 3);
|
|
||||||
|
|
||||||
aiColor3D last_palette_color;
|
aiColor3D last_palette_color;
|
||||||
read_texture(&ptexture[i], data, pal, scene_->mTextures[i], last_palette_color);
|
read_texture(&ptexture[i],
|
||||||
|
pin + ptexture[i].index,
|
||||||
|
pin + ptexture[i].width * ptexture[i].height + ptexture[i].index,
|
||||||
|
scene_->mTextures[i],
|
||||||
|
last_palette_color);
|
||||||
|
|
||||||
aiMaterial *scene_material = new aiMaterial();
|
aiMaterial *scene_material = scene_->mMaterials[i] = new aiMaterial();
|
||||||
scene_->mMaterials[i] = scene_material;
|
|
||||||
++scene_->mNumMaterials;
|
|
||||||
|
|
||||||
const aiTextureType texture_type = aiTextureType_DIFFUSE;
|
const aiTextureType texture_type = aiTextureType_DIFFUSE;
|
||||||
aiString texture_name(ptexture[i].name);
|
aiString texture_name(ptexture[i].name);
|
||||||
@@ -410,14 +435,10 @@ void HL1MDLLoader::read_skins() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pointer to base texture index.
|
// Pointer to base texture index.
|
||||||
const short *default_skin_ptr = get_texture_buffer_data<short>(
|
short *default_skin_ptr = (short *)((uint8_t *)texture_header_ + texture_header_->skinindex);
|
||||||
texture_header_->skinindex,
|
|
||||||
texture_header_->numskinref);
|
|
||||||
|
|
||||||
// Start at first replacement skin.
|
// Start at first replacement skin.
|
||||||
const short *replacement_skin_ptr = get_texture_buffer_data<short>(
|
short *replacement_skin_ptr = default_skin_ptr + texture_header_->numskinref;
|
||||||
texture_header_->skinindex + texture_header_->numskinref * sizeof(short),
|
|
||||||
(texture_header_->numskinfamilies - 1) * texture_header_->numskinref);
|
|
||||||
|
|
||||||
for (int i = 1; i < texture_header_->numskinfamilies; ++i, replacement_skin_ptr += texture_header_->numskinref) {
|
for (int i = 1; i < texture_header_->numskinfamilies; ++i, replacement_skin_ptr += texture_header_->numskinref) {
|
||||||
for (int j = 0; j < texture_header_->numskinref; ++j) {
|
for (int j = 0; j < texture_header_->numskinref; ++j) {
|
||||||
@@ -436,7 +457,7 @@ void HL1MDLLoader::read_bones() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Bone_HL1 *pbone = get_buffer_data<Bone_HL1>(header_->boneindex, header_->numbones);
|
const Bone_HL1 *pbone = (const Bone_HL1 *)((uint8_t *)header_ + header_->boneindex);
|
||||||
|
|
||||||
std::vector<std::string> unique_bones_names(header_->numbones);
|
std::vector<std::string> unique_bones_names(header_->numbones);
|
||||||
for (int i = 0; i < header_->numbones; ++i) {
|
for (int i = 0; i < header_->numbones; ++i) {
|
||||||
@@ -568,12 +589,12 @@ void HL1MDLLoader::read_meshes() {
|
|||||||
int total_triangles = 0;
|
int total_triangles = 0;
|
||||||
total_models_ = 0;
|
total_models_ = 0;
|
||||||
|
|
||||||
const Bodypart_HL1 *pbodypart = get_buffer_data<Bodypart_HL1>(header_->bodypartindex, header_->numbodyparts);
|
const Bodypart_HL1 *pbodypart = (const Bodypart_HL1 *)((uint8_t *)header_ + header_->bodypartindex);
|
||||||
const Model_HL1 *pmodel = nullptr;
|
const Model_HL1 *pmodel = nullptr;
|
||||||
const Mesh_HL1 *pmesh = nullptr;
|
const Mesh_HL1 *pmesh = nullptr;
|
||||||
|
|
||||||
const Texture_HL1 *ptexture = get_texture_buffer_data<Texture_HL1>(texture_header_->textureindex, texture_header_->numtextures);
|
const Texture_HL1 *ptexture = (const Texture_HL1 *)((uint8_t *)texture_header_ + texture_header_->textureindex);
|
||||||
const short *pskinref = get_texture_buffer_data<short>(texture_header_->skinindex, texture_header_->numskinref);
|
short *pskinref = (short *)((uint8_t *)texture_header_ + texture_header_->skinindex);
|
||||||
|
|
||||||
scene_->mNumMeshes = 0;
|
scene_->mNumMeshes = 0;
|
||||||
|
|
||||||
@@ -585,7 +606,7 @@ void HL1MDLLoader::read_meshes() {
|
|||||||
for (int i = 0; i < header_->numbodyparts; ++i, ++pbodypart) {
|
for (int i = 0; i < header_->numbodyparts; ++i, ++pbodypart) {
|
||||||
unique_bodyparts_names[i] = pbodypart->name;
|
unique_bodyparts_names[i] = pbodypart->name;
|
||||||
|
|
||||||
pmodel = get_buffer_data<Model_HL1>(pbodypart->modelindex, pbodypart->nummodels);
|
pmodel = (Model_HL1 *)((uint8_t *)header_ + pbodypart->modelindex);
|
||||||
for (int j = 0; j < pbodypart->nummodels; ++j, ++pmodel) {
|
for (int j = 0; j < pbodypart->nummodels; ++j, ++pmodel) {
|
||||||
scene_->mNumMeshes += pmodel->nummesh;
|
scene_->mNumMeshes += pmodel->nummesh;
|
||||||
total_verts += pmodel->numverts;
|
total_verts += pmodel->numverts;
|
||||||
@@ -612,7 +633,7 @@ void HL1MDLLoader::read_meshes() {
|
|||||||
unique_name_generator_.make_unique(unique_bodyparts_names);
|
unique_name_generator_.make_unique(unique_bodyparts_names);
|
||||||
|
|
||||||
// Now do the same for each model.
|
// Now do the same for each model.
|
||||||
pbodypart = get_buffer_data<Bodypart_HL1>(header_->bodypartindex, header_->numbodyparts);
|
pbodypart = (const Bodypart_HL1 *)((uint8_t *)header_ + header_->bodypartindex);
|
||||||
|
|
||||||
// Prepare template name for bodypart models.
|
// Prepare template name for bodypart models.
|
||||||
std::vector<std::string> unique_models_names;
|
std::vector<std::string> unique_models_names;
|
||||||
@@ -621,7 +642,7 @@ void HL1MDLLoader::read_meshes() {
|
|||||||
unsigned int model_index = 0;
|
unsigned int model_index = 0;
|
||||||
|
|
||||||
for (int i = 0; i < header_->numbodyparts; ++i, ++pbodypart) {
|
for (int i = 0; i < header_->numbodyparts; ++i, ++pbodypart) {
|
||||||
pmodel = get_buffer_data<Model_HL1>(pbodypart->modelindex, pbodypart->nummodels);
|
pmodel = (Model_HL1 *)((uint8_t *)header_ + pbodypart->modelindex);
|
||||||
for (int j = 0; j < pbodypart->nummodels; ++j, ++pmodel, ++model_index)
|
for (int j = 0; j < pbodypart->nummodels; ++j, ++pmodel, ++model_index)
|
||||||
unique_models_names[model_index] = pmodel->name;
|
unique_models_names[model_index] = pmodel->name;
|
||||||
}
|
}
|
||||||
@@ -633,7 +654,7 @@ void HL1MDLLoader::read_meshes() {
|
|||||||
|
|
||||||
scene_->mMeshes = new aiMesh *[scene_->mNumMeshes];
|
scene_->mMeshes = new aiMesh *[scene_->mNumMeshes];
|
||||||
|
|
||||||
pbodypart = get_buffer_data<Bodypart_HL1>(header_->bodypartindex, header_->numbodyparts);
|
pbodypart = (const Bodypart_HL1 *)((uint8_t *)header_ + header_->bodypartindex);
|
||||||
|
|
||||||
/* Create a node that will represent the mesh hierarchy.
|
/* Create a node that will represent the mesh hierarchy.
|
||||||
|
|
||||||
@@ -717,7 +738,7 @@ void HL1MDLLoader::read_meshes() {
|
|||||||
model_index = 0;
|
model_index = 0;
|
||||||
|
|
||||||
for (int i = 0; i < header_->numbodyparts; ++i, ++pbodypart, ++bodyparts_node_ptr) {
|
for (int i = 0; i < header_->numbodyparts; ++i, ++pbodypart, ++bodyparts_node_ptr) {
|
||||||
pmodel = get_buffer_data<Model_HL1>(pbodypart->modelindex, pbodypart->nummodels);
|
pmodel = (const Model_HL1 *)((uint8_t *)header_ + pbodypart->modelindex);
|
||||||
|
|
||||||
// Create bodypart node for the mesh tree hierarchy.
|
// Create bodypart node for the mesh tree hierarchy.
|
||||||
aiNode *bodypart_node = (*bodyparts_node_ptr) = new aiNode(unique_bodyparts_names[i]);
|
aiNode *bodypart_node = (*bodyparts_node_ptr) = new aiNode(unique_bodyparts_names[i]);
|
||||||
@@ -732,12 +753,12 @@ void HL1MDLLoader::read_meshes() {
|
|||||||
for (int j = 0; j < pbodypart->nummodels;
|
for (int j = 0; j < pbodypart->nummodels;
|
||||||
++j, ++pmodel, ++bodypart_models_ptr, ++model_index) {
|
++j, ++pmodel, ++bodypart_models_ptr, ++model_index) {
|
||||||
|
|
||||||
pmesh = get_buffer_data<Mesh_HL1>(pmodel->meshindex, pmodel->nummesh);
|
pmesh = (const Mesh_HL1 *)((uint8_t *)header_ + pmodel->meshindex);
|
||||||
|
|
||||||
const uint8_t *pvertbone = get_buffer_data<uint8_t>(pmodel->vertinfoindex, pmodel->numverts);
|
uint8_t *pvertbone = ((uint8_t *)header_ + pmodel->vertinfoindex);
|
||||||
const uint8_t *pnormbone = get_buffer_data<uint8_t>(pmodel->norminfoindex, pmodel->numnorms);
|
uint8_t *pnormbone = ((uint8_t *)header_ + pmodel->norminfoindex);
|
||||||
const vec3_t *pstudioverts = get_buffer_data<vec3_t>(pmodel->vertindex, pmodel->numverts);
|
vec3_t *pstudioverts = (vec3_t *)((uint8_t *)header_ + pmodel->vertindex);
|
||||||
const vec3_t *pstudionorms = get_buffer_data<vec3_t>(pmodel->normindex, pmodel->numnorms);
|
vec3_t *pstudionorms = (vec3_t *)((uint8_t *)header_ + pmodel->normindex);
|
||||||
|
|
||||||
// Each vertex and normal is in local space, so transform
|
// Each vertex and normal is in local space, so transform
|
||||||
// each of them to bring them in bind pose.
|
// each of them to bring them in bind pose.
|
||||||
@@ -943,7 +964,7 @@ void HL1MDLLoader::read_animations() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SequenceDesc_HL1 *pseqdesc = get_buffer_data<SequenceDesc_HL1>(header_->seqindex, header_->numseq);
|
const SequenceDesc_HL1 *pseqdesc = (const SequenceDesc_HL1 *)((uint8_t *)header_ + header_->seqindex);
|
||||||
const SequenceGroup_HL1 *pseqgroup = nullptr;
|
const SequenceGroup_HL1 *pseqgroup = nullptr;
|
||||||
const AnimValueOffset_HL1 *panim = nullptr;
|
const AnimValueOffset_HL1 *panim = nullptr;
|
||||||
const AnimValue_HL1 *panimvalue = nullptr;
|
const AnimValue_HL1 *panimvalue = nullptr;
|
||||||
@@ -969,22 +990,22 @@ void HL1MDLLoader::read_animations() {
|
|||||||
// Get the number of available blend controllers for global info.
|
// Get the number of available blend controllers for global info.
|
||||||
get_num_blend_controllers(highest_num_blend_animations, num_blend_controllers_);
|
get_num_blend_controllers(highest_num_blend_animations, num_blend_controllers_);
|
||||||
|
|
||||||
pseqdesc = get_buffer_data<SequenceDesc_HL1>(header_->seqindex, header_->numseq);
|
pseqdesc = (const SequenceDesc_HL1 *)((uint8_t *)header_ + header_->seqindex);
|
||||||
|
|
||||||
aiAnimation **scene_animations_ptr = scene_->mAnimations = new aiAnimation *[scene_->mNumAnimations];
|
aiAnimation **scene_animations_ptr = scene_->mAnimations = new aiAnimation *[scene_->mNumAnimations];
|
||||||
|
|
||||||
for (int sequence = 0; sequence < header_->numseq; ++sequence, ++pseqdesc) {
|
for (int sequence = 0; sequence < header_->numseq; ++sequence, ++pseqdesc) {
|
||||||
pseqgroup = get_buffer_data<SequenceGroup_HL1>(header_->seqgroupindex + pseqdesc->seqgroup * sizeof(SequenceGroup_HL1), 1);
|
pseqgroup = (const SequenceGroup_HL1 *)((uint8_t *)header_ + header_->seqgroupindex) + pseqdesc->seqgroup;
|
||||||
|
|
||||||
if (pseqdesc->seqgroup == 0) {
|
if (pseqdesc->seqgroup == 0) {
|
||||||
panim = get_buffer_data<AnimValueOffset_HL1>(pseqgroup->unused2 + pseqdesc->animindex, pseqdesc->numblends * header_->numbones);
|
panim = (const AnimValueOffset_HL1 *)((uint8_t *)header_ + pseqgroup->unused2 + pseqdesc->animindex);
|
||||||
} else {
|
} else {
|
||||||
panim = get_anim_buffer_data<AnimValueOffset_HL1>(pseqdesc->seqgroup, pseqdesc->animindex, pseqdesc->numblends * header_->numbones);
|
panim = (const AnimValueOffset_HL1 *)((uint8_t *)anim_headers_[pseqdesc->seqgroup] + pseqdesc->animindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int blend = 0; blend < pseqdesc->numblends; ++blend, ++scene_animations_ptr) {
|
for (int blend = 0; blend < pseqdesc->numblends; ++blend, ++scene_animations_ptr) {
|
||||||
|
|
||||||
const Bone_HL1 *pbone = get_buffer_data<Bone_HL1>(header_->boneindex, header_->numbones);
|
const Bone_HL1 *pbone = (const Bone_HL1 *)((uint8_t *)header_ + header_->boneindex);
|
||||||
|
|
||||||
aiAnimation *scene_animation = (*scene_animations_ptr) = new aiAnimation();
|
aiAnimation *scene_animation = (*scene_animations_ptr) = new aiAnimation();
|
||||||
|
|
||||||
@@ -1053,7 +1074,7 @@ void HL1MDLLoader::read_sequence_groups_info() {
|
|||||||
sequence_groups_node->mNumChildren = static_cast<unsigned int>(header_->numseqgroups);
|
sequence_groups_node->mNumChildren = static_cast<unsigned int>(header_->numseqgroups);
|
||||||
sequence_groups_node->mChildren = new aiNode *[sequence_groups_node->mNumChildren];
|
sequence_groups_node->mChildren = new aiNode *[sequence_groups_node->mNumChildren];
|
||||||
|
|
||||||
const SequenceGroup_HL1 *pseqgroup = get_buffer_data<SequenceGroup_HL1>(header_->seqgroupindex, header_->numseqgroups);
|
const SequenceGroup_HL1 *pseqgroup = (const SequenceGroup_HL1 *)((uint8_t *)header_ + header_->seqgroupindex);
|
||||||
|
|
||||||
unique_sequence_groups_names_.resize(header_->numseqgroups);
|
unique_sequence_groups_names_.resize(header_->numseqgroups);
|
||||||
for (int i = 0; i < header_->numseqgroups; ++i) {
|
for (int i = 0; i < header_->numseqgroups; ++i) {
|
||||||
@@ -1085,7 +1106,7 @@ void HL1MDLLoader::read_sequence_infos() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SequenceDesc_HL1 *pseqdesc = get_buffer_data<SequenceDesc_HL1>(header_->seqindex, header_->numseq);
|
const SequenceDesc_HL1 *pseqdesc = (const SequenceDesc_HL1 *)((uint8_t *)header_ + header_->seqindex);
|
||||||
|
|
||||||
aiNode *sequence_infos_node = new aiNode(AI_MDL_HL1_NODE_SEQUENCE_INFOS);
|
aiNode *sequence_infos_node = new aiNode(AI_MDL_HL1_NODE_SEQUENCE_INFOS);
|
||||||
rootnode_children_.push_back(sequence_infos_node);
|
rootnode_children_.push_back(sequence_infos_node);
|
||||||
@@ -1157,7 +1178,7 @@ void HL1MDLLoader::read_sequence_infos() {
|
|||||||
pseqdesc->numevents, "animation events");
|
pseqdesc->numevents, "animation events");
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimEvent_HL1 *pevent = get_buffer_data<AnimEvent_HL1>(pseqdesc->eventindex, pseqdesc->numevents);
|
const AnimEvent_HL1 *pevent = (const AnimEvent_HL1 *)((uint8_t *)header_ + pseqdesc->eventindex);
|
||||||
|
|
||||||
aiNode *pEventsNode = new aiNode(AI_MDL_HL1_NODE_ANIMATION_EVENTS);
|
aiNode *pEventsNode = new aiNode(AI_MDL_HL1_NODE_ANIMATION_EVENTS);
|
||||||
sequence_info_node_children.push_back(pEventsNode);
|
sequence_info_node_children.push_back(pEventsNode);
|
||||||
@@ -1194,7 +1215,7 @@ void HL1MDLLoader::read_sequence_transitions() {
|
|||||||
aiNode *transition_graph_node = new aiNode(AI_MDL_HL1_NODE_SEQUENCE_TRANSITION_GRAPH);
|
aiNode *transition_graph_node = new aiNode(AI_MDL_HL1_NODE_SEQUENCE_TRANSITION_GRAPH);
|
||||||
rootnode_children_.push_back(transition_graph_node);
|
rootnode_children_.push_back(transition_graph_node);
|
||||||
|
|
||||||
const uint8_t *ptransitions = get_buffer_data<uint8_t>(header_->transitionindex, header_->numtransitions * header_->numtransitions);
|
uint8_t *ptransitions = ((uint8_t *)header_ + header_->transitionindex);
|
||||||
aiMetadata *md = transition_graph_node->mMetaData = aiMetadata::Alloc(header_->numtransitions * header_->numtransitions);
|
aiMetadata *md = transition_graph_node->mMetaData = aiMetadata::Alloc(header_->numtransitions * header_->numtransitions);
|
||||||
for (unsigned int i = 0; i < md->mNumProperties; ++i)
|
for (unsigned int i = 0; i < md->mNumProperties; ++i)
|
||||||
md->Set(i, std::to_string(i), static_cast<int>(ptransitions[i]));
|
md->Set(i, std::to_string(i), static_cast<int>(ptransitions[i]));
|
||||||
@@ -1205,7 +1226,7 @@ void HL1MDLLoader::read_attachments() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Attachment_HL1 *pattach = get_buffer_data<Attachment_HL1>(header_->attachmentindex, header_->numattachments);
|
const Attachment_HL1 *pattach = (const Attachment_HL1 *)((uint8_t *)header_ + header_->attachmentindex);
|
||||||
|
|
||||||
aiNode *attachments_node = new aiNode(AI_MDL_HL1_NODE_ATTACHMENTS);
|
aiNode *attachments_node = new aiNode(AI_MDL_HL1_NODE_ATTACHMENTS);
|
||||||
rootnode_children_.push_back(attachments_node);
|
rootnode_children_.push_back(attachments_node);
|
||||||
@@ -1229,7 +1250,7 @@ void HL1MDLLoader::read_hitboxes() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Hitbox_HL1 *phitbox = get_buffer_data<Hitbox_HL1>(header_->hitboxindex, header_->numhitboxes);
|
const Hitbox_HL1 *phitbox = (const Hitbox_HL1 *)((uint8_t *)header_ + header_->hitboxindex);
|
||||||
|
|
||||||
aiNode *hitboxes_node = new aiNode(AI_MDL_HL1_NODE_HITBOXES);
|
aiNode *hitboxes_node = new aiNode(AI_MDL_HL1_NODE_HITBOXES);
|
||||||
rootnode_children_.push_back(hitboxes_node);
|
rootnode_children_.push_back(hitboxes_node);
|
||||||
@@ -1256,9 +1277,7 @@ void HL1MDLLoader::read_bone_controllers() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BoneController_HL1 *pbonecontroller = get_buffer_data<BoneController_HL1>(
|
const BoneController_HL1 *pbonecontroller = (const BoneController_HL1 *)((uint8_t *)header_ + header_->bonecontrollerindex);
|
||||||
header_->bonecontrollerindex,
|
|
||||||
header_->numbonecontrollers);
|
|
||||||
|
|
||||||
aiNode *bones_controller_node = new aiNode(AI_MDL_HL1_NODE_BONE_CONTROLLERS);
|
aiNode *bones_controller_node = new aiNode(AI_MDL_HL1_NODE_BONE_CONTROLLERS);
|
||||||
rootnode_children_.push_back(bones_controller_node);
|
rootnode_children_.push_back(bones_controller_node);
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#define AI_HL1MDLLOADER_INCLUDED
|
#define AI_HL1MDLLOADER_INCLUDED
|
||||||
|
|
||||||
#include "HL1FileData.h"
|
#include "HL1FileData.h"
|
||||||
#include "HL1DataBuffer.h"
|
|
||||||
#include "HL1ImportSettings.h"
|
#include "HL1ImportSettings.h"
|
||||||
#include "UniqueNameGenerator.h"
|
#include "UniqueNameGenerator.h"
|
||||||
|
|
||||||
@@ -75,7 +74,6 @@ public:
|
|||||||
aiScene *scene,
|
aiScene *scene,
|
||||||
IOSystem *io,
|
IOSystem *io,
|
||||||
const unsigned char *buffer,
|
const unsigned char *buffer,
|
||||||
size_t buffer_length,
|
|
||||||
const std::string &file_path,
|
const std::string &file_path,
|
||||||
const HL1ImportSettings &import_settings);
|
const HL1ImportSettings &import_settings);
|
||||||
|
|
||||||
@@ -111,32 +109,10 @@ private:
|
|||||||
|
|
||||||
/** \brief Load a file and copy it's content to a buffer.
|
/** \brief Load a file and copy it's content to a buffer.
|
||||||
* \param file_path The path to the file to be loaded.
|
* \param file_path The path to the file to be loaded.
|
||||||
* \param buffer A buffer to receive the data.
|
* \param buffer A pointer to a buffer to receive the data.
|
||||||
*/
|
*/
|
||||||
template <typename MDLFileHeader>
|
template <typename MDLFileHeader>
|
||||||
void load_file_into_buffer(const std::string &file_path, HL1DataBuffer &buffer);
|
void load_file_into_buffer(const std::string &file_path, unsigned char *&buffer);
|
||||||
|
|
||||||
/** \brief Get a pointer to the specified data type in texture buffer.
|
|
||||||
* \param offset Offset in bytes.
|
|
||||||
* \param elements Elements count.
|
|
||||||
*/
|
|
||||||
template <typename DataType>
|
|
||||||
const DataType *get_texture_buffer_data(int offset, int elements);
|
|
||||||
|
|
||||||
/** \brief Get a pointer to the specified data type in animation buffer.
|
|
||||||
* \param animation Animation index.
|
|
||||||
* \param offset Offset in bytes.
|
|
||||||
* \param elements Elements count.
|
|
||||||
*/
|
|
||||||
template <typename DataType>
|
|
||||||
const DataType *get_anim_buffer_data(int animation, int offset, int elements);
|
|
||||||
|
|
||||||
/** \brief Get a pointer to the specified data type in MDL buffer.
|
|
||||||
* \param offset Offset in bytes.
|
|
||||||
* \param elements Elements count.
|
|
||||||
*/
|
|
||||||
template <typename DataType>
|
|
||||||
const DataType *get_buffer_data(int offset, int elements);
|
|
||||||
|
|
||||||
/** \brief Read an MDL texture.
|
/** \brief Read an MDL texture.
|
||||||
* \param[in] ptexture A pointer to an MDL texture.
|
* \param[in] ptexture A pointer to an MDL texture.
|
||||||
@@ -146,7 +122,7 @@ private:
|
|||||||
* \param[in,out] last_palette_color The last color from the image palette.
|
* \param[in,out] last_palette_color The last color from the image palette.
|
||||||
*/
|
*/
|
||||||
void read_texture(const Texture_HL1 *ptexture,
|
void read_texture(const Texture_HL1 *ptexture,
|
||||||
const uint8_t *data, const uint8_t *pal, aiTexture *pResult,
|
uint8_t *data, uint8_t *pal, aiTexture *pResult,
|
||||||
aiColor3D &last_palette_color);
|
aiColor3D &last_palette_color);
|
||||||
|
|
||||||
/** \brief This method reads a compressed anim value.
|
/** \brief This method reads a compressed anim value.
|
||||||
@@ -182,7 +158,7 @@ private:
|
|||||||
IOSystem *io_;
|
IOSystem *io_;
|
||||||
|
|
||||||
/** Buffer from MDLLoader class. */
|
/** Buffer from MDLLoader class. */
|
||||||
const HL1DataBuffer buffer_;
|
const unsigned char *buffer_;
|
||||||
|
|
||||||
/** The full file path to the MDL file we are trying to load.
|
/** The full file path to the MDL file we are trying to load.
|
||||||
* Used to locate other MDL files since MDL may store resources
|
* Used to locate other MDL files since MDL may store resources
|
||||||
@@ -200,13 +176,13 @@ private:
|
|||||||
|
|
||||||
/** External MDL animation headers.
|
/** External MDL animation headers.
|
||||||
* One for each loaded animation file. */
|
* One for each loaded animation file. */
|
||||||
std::vector<const SequenceHeader_HL1*> anim_headers_;
|
SequenceHeader_HL1 **anim_headers_;
|
||||||
|
|
||||||
/** Texture file data. */
|
/** Texture file data. */
|
||||||
HL1DataBuffer texture_buffer_;
|
unsigned char *texture_buffer_;
|
||||||
|
|
||||||
/** Animation files data. */
|
/** Animation files data. */
|
||||||
std::vector<HL1DataBuffer> anim_buffers_;
|
unsigned char **anim_buffers_;
|
||||||
|
|
||||||
/** The number of sequence groups. */
|
/** The number of sequence groups. */
|
||||||
int num_sequence_groups_;
|
int num_sequence_groups_;
|
||||||
@@ -250,7 +226,7 @@ private:
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
template <typename MDLFileHeader>
|
template <typename MDLFileHeader>
|
||||||
void HL1MDLLoader::load_file_into_buffer(const std::string &file_path, HL1DataBuffer &buffer) {
|
void HL1MDLLoader::load_file_into_buffer(const std::string &file_path, unsigned char *&buffer) {
|
||||||
if (!io_->Exists(file_path))
|
if (!io_->Exists(file_path))
|
||||||
throw DeadlyImportError("Missing file ", DefaultIOSystem::fileName(file_path), ".");
|
throw DeadlyImportError("Missing file ", DefaultIOSystem::fileName(file_path), ".");
|
||||||
|
|
||||||
@@ -265,30 +241,9 @@ void HL1MDLLoader::load_file_into_buffer(const std::string &file_path, HL1DataBu
|
|||||||
throw DeadlyImportError("MDL file is too small.");
|
throw DeadlyImportError("MDL file is too small.");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<unsigned char[]> data(new unsigned char[1 + file_size]);
|
buffer = new unsigned char[1 + file_size];
|
||||||
file->Read(data.get(), 1, file_size);
|
file->Read((void *)buffer, 1, file_size);
|
||||||
data[file_size] = '\0';
|
buffer[file_size] = '\0';
|
||||||
|
|
||||||
buffer = HL1DataBuffer::owning(std::move(data), file_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename DataType>
|
|
||||||
const DataType *HL1MDLLoader::get_texture_buffer_data(int offset, int elements) {
|
|
||||||
return texture_buffer_.get_data<DataType>(offset, elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename DataType>
|
|
||||||
const DataType *HL1MDLLoader::get_anim_buffer_data(int animation, int offset, int elements) {
|
|
||||||
if (animation < 0 || animation >= num_sequence_groups_) {
|
|
||||||
throw DeadlyImportError("MDL file contains invalid sequence group index (", animation, ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
return anim_buffers_[animation].get_data<DataType>(offset, elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename DataType>
|
|
||||||
const DataType *HL1MDLLoader::get_buffer_data(int offset, int elements) {
|
|
||||||
return buffer_.get_data<DataType>(offset, elements);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace HalfLife
|
} // namespace HalfLife
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2026, assimp team
|
Copyright (c) 2006-2025, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
@@ -602,9 +602,6 @@ void MDLImporter::SetupMaterialProperties_3DGS_MDL5_Quake1() {
|
|||||||
// Read a MDL 3,4,5 file
|
// Read a MDL 3,4,5 file
|
||||||
void MDLImporter::InternReadFile_3DGS_MDL345() {
|
void MDLImporter::InternReadFile_3DGS_MDL345() {
|
||||||
ai_assert(nullptr != pScene);
|
ai_assert(nullptr != pScene);
|
||||||
if (pScene == nullptr) {
|
|
||||||
throw DeadlyImportError("INvalid scene pointer detected.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// the header of MDL 3/4/5 is nearly identical to the original Quake1 header
|
// the header of MDL 3/4/5 is nearly identical to the original Quake1 header
|
||||||
BE_NCONST MDL::Header *pcHeader = (BE_NCONST MDL::Header *)this->mBuffer;
|
BE_NCONST MDL::Header *pcHeader = (BE_NCONST MDL::Header *)this->mBuffer;
|
||||||
@@ -613,10 +610,6 @@ void MDLImporter::InternReadFile_3DGS_MDL345() {
|
|||||||
#endif
|
#endif
|
||||||
ValidateHeader_Quake1(pcHeader);
|
ValidateHeader_Quake1(pcHeader);
|
||||||
|
|
||||||
if (pcHeader->synctype < 0) {
|
|
||||||
throw DeadlyImportError("Invalid synctype value in MDL header; possible corrupt file.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// current cursor position in the file
|
// current cursor position in the file
|
||||||
const unsigned char *szCurrent = (const unsigned char *)(pcHeader + 1);
|
const unsigned char *szCurrent = (const unsigned char *)(pcHeader + 1);
|
||||||
const unsigned char *szEnd = mBuffer + iFileSize;
|
const unsigned char *szEnd = mBuffer + iFileSize;
|
||||||
@@ -626,7 +619,8 @@ void MDLImporter::InternReadFile_3DGS_MDL345() {
|
|||||||
if (szCurrent + sizeof(uint32_t) > szEnd) {
|
if (szCurrent + sizeof(uint32_t) > szEnd) {
|
||||||
throw DeadlyImportError("Texture data past end of file.");
|
throw DeadlyImportError("Texture data past end of file.");
|
||||||
}
|
}
|
||||||
BE_NCONST MDL::Skin *pcSkin = (BE_NCONST MDL::Skin *)szCurrent;
|
BE_NCONST MDL::Skin *pcSkin;
|
||||||
|
pcSkin = (BE_NCONST MDL::Skin *)szCurrent;
|
||||||
AI_SWAP4(pcSkin->group);
|
AI_SWAP4(pcSkin->group);
|
||||||
// create one output image
|
// create one output image
|
||||||
unsigned int iSkip = i ? UINT_MAX : 0;
|
unsigned int iSkip = i ? UINT_MAX : 0;
|
||||||
@@ -1844,10 +1838,6 @@ void MDLImporter::GenerateOutputMeshes_3DGS_MDL7(
|
|||||||
const unsigned int iNumOutBones = pcHeader->bones_num;
|
const unsigned int iNumOutBones = pcHeader->bones_num;
|
||||||
|
|
||||||
for (std::vector<aiMaterial *>::size_type i = 0; i < shared.pcMats.size(); ++i) {
|
for (std::vector<aiMaterial *>::size_type i = 0; i < shared.pcMats.size(); ++i) {
|
||||||
if (splitGroupData.aiSplit == nullptr) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!splitGroupData.aiSplit[i]->empty()) {
|
if (!splitGroupData.aiSplit[i]->empty()) {
|
||||||
|
|
||||||
// allocate the output mesh
|
// allocate the output mesh
|
||||||
@@ -2001,7 +1991,6 @@ void MDLImporter::InternReadFile_HL1(const std::string &pFile, const uint32_t iM
|
|||||||
pScene,
|
pScene,
|
||||||
mIOHandler,
|
mIOHandler,
|
||||||
mBuffer,
|
mBuffer,
|
||||||
iFileSize,
|
|
||||||
pFile,
|
pFile,
|
||||||
mHL1ImportSettings);
|
mHL1ImportSettings);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2026, assimp team
|
Copyright (c) 2006-2025, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
@@ -471,7 +471,19 @@ void ObjFileParser::getFace(aiPrimitiveType type) {
|
|||||||
iPos = 0;
|
iPos = 0;
|
||||||
} else {
|
} else {
|
||||||
//OBJ USES 1 Base ARRAYS!!!!
|
//OBJ USES 1 Base ARRAYS!!!!
|
||||||
const int iVal = ::atoi(&(*m_DataIt));
|
int iVal;
|
||||||
|
auto end = m_DataIt;
|
||||||
|
// find either the buffer end or the '\0'
|
||||||
|
while (end < m_DataItEnd && *end != '\0')
|
||||||
|
++end;
|
||||||
|
// avoid temporary string allocation if there is a zero
|
||||||
|
if (end != m_DataItEnd) {
|
||||||
|
iVal = ::atoi(&(*m_DataIt));
|
||||||
|
} else {
|
||||||
|
// otherwise make a zero terminated copy, which is safe to pass to atoi
|
||||||
|
std::string number(&(*m_DataIt), m_DataItEnd - m_DataIt);
|
||||||
|
iVal = ::atoi(number.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// increment iStep position based off of the sign and # of digits
|
// increment iStep position based off of the sign and # of digits
|
||||||
int tmp = iVal;
|
int tmp = iVal;
|
||||||
|
|||||||
@@ -379,12 +379,7 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
|
|||||||
light->mColorSpecular = light->mColorDiffuse;
|
light->mColorSpecular = light->mColorDiffuse;
|
||||||
|
|
||||||
// We don't need the rest, but we need to know where this chunk ends.
|
// We don't need the rest, but we need to know where this chunk ends.
|
||||||
const auto t1 = stream.GetI4();
|
unsigned int temp = (unsigned int)(stream.GetI4() * stream.GetI4());
|
||||||
const auto t2 = stream.GetI4();
|
|
||||||
if (t1 < 0 || t2 < 0) {
|
|
||||||
throw DeadlyImportError("Quick3D: Overflow detected.");
|
|
||||||
}
|
|
||||||
const unsigned int temp = static_cast<unsigned int>(t1*t2);
|
|
||||||
|
|
||||||
// skip the background file name
|
// skip the background file name
|
||||||
while (stream.GetI1())
|
while (stream.GetI1())
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ static constexpr aiImporterDesc desc = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
USDImporter::USDImporter() :
|
USDImporter::USDImporter() :
|
||||||
|
|||||||
@@ -53,14 +53,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "USDLoaderImplTinyusdz.h"
|
#include "USDLoaderImplTinyusdz.h"
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
class USDImporter : public BaseImporter {
|
||||||
/// @brief USD Importer class
|
|
||||||
class USDImporter final : public BaseImporter {
|
|
||||||
public:
|
public:
|
||||||
/// @brief Constructor
|
|
||||||
USDImporter();
|
USDImporter();
|
||||||
|
|
||||||
/// @brief Destructor
|
|
||||||
~USDImporter() override = default;
|
~USDImporter() override = default;
|
||||||
|
|
||||||
/// \brief Returns whether the class can handle the format of the given file.
|
/// \brief Returns whether the class can handle the format of the given file.
|
||||||
|
|||||||
@@ -44,33 +44,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_USD_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_USD_IMPORTER
|
||||||
|
|
||||||
#include "USDLoaderImplTinyusdz.h"
|
|
||||||
#include "USDLoaderImplTinyusdzHelper.h"
|
|
||||||
#include "USDLoaderUtil.h"
|
|
||||||
#include "USDPreprocessor.h"
|
|
||||||
#include "io-util.hh" // namespace tinyusdz::io
|
|
||||||
#include "tydra/scene-access.hh"
|
|
||||||
#include "tydra/shader-network.hh"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
// internal headers
|
// internal headers
|
||||||
#include "assimp/MemoryIOWrapper.h"
|
|
||||||
#include <assimp/CreateAnimMesh.h>
|
|
||||||
#include <assimp/DefaultIOSystem.h>
|
|
||||||
#include <assimp/IOStreamBuffer.h>
|
|
||||||
#include <assimp/StreamReader.h>
|
|
||||||
#include <assimp/StringUtils.h>
|
|
||||||
#include <assimp/ai_assert.h>
|
#include <assimp/ai_assert.h>
|
||||||
#include <assimp/anim.h>
|
#include <assimp/anim.h>
|
||||||
#include <assimp/fast_atof.h>
|
#include <assimp/CreateAnimMesh.h>
|
||||||
#include <assimp/importerdesc.h>
|
#include <assimp/DefaultIOSystem.h>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/fast_atof.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
#include <assimp/importerdesc.h>
|
||||||
|
#include <assimp/IOStreamBuffer.h>
|
||||||
|
#include <assimp/IOSystem.hpp>
|
||||||
|
#include "assimp/MemoryIOWrapper.h"
|
||||||
|
#include <assimp/StringUtils.h>
|
||||||
|
#include <assimp/StreamReader.h>
|
||||||
|
#include <assimp/metadata.h>
|
||||||
|
|
||||||
|
#include "io-util.hh" // namespace tinyusdz::io
|
||||||
|
#include "tydra/scene-access.hh"
|
||||||
|
#include "tydra/shader-network.hh"
|
||||||
|
#include "USDLoaderImplTinyusdzHelper.h"
|
||||||
|
#include "USDLoaderImplTinyusdz.h"
|
||||||
|
#include "USDLoaderUtil.h"
|
||||||
|
#include "USDPreprocessor.h"
|
||||||
|
|
||||||
#include "../../../contrib/tinyusdz/assimp_tinyusdz_logging.inc"
|
#include "../../../contrib/tinyusdz/assimp_tinyusdz_logging.inc"
|
||||||
|
|
||||||
@@ -79,18 +78,17 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
using Assimp::tinyUsdzMat4ToAiMat4;
|
void USDImporterImplTinyusdz::InternReadFile(
|
||||||
using Assimp::tinyusdzNodeTypeFor;
|
const std::string &pFile,
|
||||||
using tinyusdz::tydra::NodeType;
|
aiScene *pScene,
|
||||||
using namespace tinyusdz::tydra;
|
IOSystem *pIOHandler) {
|
||||||
|
|
||||||
void USDImporterImplTinyusdz::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
|
|
||||||
// Grab filename for logging purposes
|
// Grab filename for logging purposes
|
||||||
size_t pos = pFile.find_last_of('/');
|
size_t pos = pFile.find_last_of('/');
|
||||||
std::string basePath = pFile.substr(0, pos);
|
string basePath = pFile.substr(0, pos);
|
||||||
std::string nameWExt = pFile.substr(pos + 1);
|
string nameWExt = pFile.substr(pos + 1);
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "InternReadFile(): model" << nameWExt;
|
ss << "InternReadFile(): model" << nameWExt;
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
@@ -163,10 +161,9 @@ void USDImporterImplTinyusdz::InternReadFile(const std::string &pFile, aiScene *
|
|||||||
TINYUSDZLOGE(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGE(TAG, "%s", ss.str().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
tinyusdz::tydra::RenderScene render_scene;
|
||||||
RenderScene render_scene;
|
tinyusdz::tydra::RenderSceneConverter converter;
|
||||||
RenderSceneConverter converter;
|
tinyusdz::tydra::RenderSceneConverterEnv env(stage);
|
||||||
RenderSceneConverterEnv env(stage);
|
|
||||||
std::string usd_basedir = tinyusdz::io::GetBaseDir(pFile);
|
std::string usd_basedir = tinyusdz::io::GetBaseDir(pFile);
|
||||||
env.set_search_paths({ usd_basedir }); // {} needed to convert to vector of char
|
env.set_search_paths({ usd_basedir }); // {} needed to convert to vector of char
|
||||||
|
|
||||||
@@ -223,12 +220,16 @@ void USDImporterImplTinyusdz::InternReadFile(const std::string &pFile, aiScene *
|
|||||||
textures(render_scene, pScene, nameWExt);
|
textures(render_scene, pScene, nameWExt);
|
||||||
textureImages(render_scene, pScene, nameWExt);
|
textureImages(render_scene, pScene, nameWExt);
|
||||||
buffers(render_scene, pScene, nameWExt);
|
buffers(render_scene, pScene, nameWExt);
|
||||||
|
|
||||||
|
std::map<size_t, tinyusdz::tydra::Node> meshNodes;
|
||||||
|
setupNodes(render_scene, pScene, stage, meshNodes, nameWExt);
|
||||||
pScene->mRootNode = nodesRecursive(nullptr, render_scene.nodes[0], render_scene.skeletons);
|
pScene->mRootNode = nodesRecursive(nullptr, render_scene.nodes[0], render_scene.skeletons);
|
||||||
|
|
||||||
setupBlendShapes(render_scene, pScene, nameWExt);
|
setupBlendShapes(render_scene, pScene, nameWExt);
|
||||||
}
|
}
|
||||||
|
void USDImporterImplTinyusdz::animations(
|
||||||
void USDImporterImplTinyusdz::animations(const tinyusdz::tydra::RenderScene &render_scene, aiScene *pScene) {
|
const tinyusdz::tydra::RenderScene& render_scene,
|
||||||
|
aiScene* pScene) {
|
||||||
if (render_scene.animations.empty()) {
|
if (render_scene.animations.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -268,7 +269,7 @@ void USDImporterImplTinyusdz::animations(const tinyusdz::tydra::RenderScene &ren
|
|||||||
|
|
||||||
for (const auto &[channelType, animChannel] : animationChannelMap) {
|
for (const auto &[channelType, animChannel] : animationChannelMap) {
|
||||||
switch (channelType) {
|
switch (channelType) {
|
||||||
case AnimationChannel::ChannelType::Rotation:
|
case tinyusdz::tydra::AnimationChannel::ChannelType::Rotation:
|
||||||
if (animChannel.rotations.static_value.has_value()) {
|
if (animChannel.rotations.static_value.has_value()) {
|
||||||
rotationKeys.emplace_back(0, tinyUsdzQuatToAiQuat(animChannel.rotations.static_value.value()));
|
rotationKeys.emplace_back(0, tinyUsdzQuatToAiQuat(animChannel.rotations.static_value.value()));
|
||||||
}
|
}
|
||||||
@@ -280,7 +281,7 @@ void USDImporterImplTinyusdz::animations(const tinyusdz::tydra::RenderScene &ren
|
|||||||
rotationKeys.emplace_back(rotationAnimSampler.t, tinyUsdzQuatToAiQuat(rotationAnimSampler.value));
|
rotationKeys.emplace_back(rotationAnimSampler.t, tinyUsdzQuatToAiQuat(rotationAnimSampler.value));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AnimationChannel::ChannelType::Scale:
|
case tinyusdz::tydra::AnimationChannel::ChannelType::Scale:
|
||||||
if (animChannel.scales.static_value.has_value()) {
|
if (animChannel.scales.static_value.has_value()) {
|
||||||
scalingKeys.emplace_back(0, tinyUsdzScaleOrPosToAssimp(animChannel.scales.static_value.value()));
|
scalingKeys.emplace_back(0, tinyUsdzScaleOrPosToAssimp(animChannel.scales.static_value.value()));
|
||||||
}
|
}
|
||||||
@@ -291,7 +292,7 @@ void USDImporterImplTinyusdz::animations(const tinyusdz::tydra::RenderScene &ren
|
|||||||
scalingKeys.emplace_back(scaleAnimSampler.t, tinyUsdzScaleOrPosToAssimp(scaleAnimSampler.value));
|
scalingKeys.emplace_back(scaleAnimSampler.t, tinyUsdzScaleOrPosToAssimp(scaleAnimSampler.value));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AnimationChannel::ChannelType::Transform:
|
case tinyusdz::tydra::AnimationChannel::ChannelType::Transform:
|
||||||
if (animChannel.transforms.static_value.has_value()) {
|
if (animChannel.transforms.static_value.has_value()) {
|
||||||
aiVector3D position;
|
aiVector3D position;
|
||||||
aiVector3D scale;
|
aiVector3D scale;
|
||||||
@@ -317,7 +318,7 @@ void USDImporterImplTinyusdz::animations(const tinyusdz::tydra::RenderScene &ren
|
|||||||
rotationKeys.emplace_back(transformAnimSampler.t, rotation);
|
rotationKeys.emplace_back(transformAnimSampler.t, rotation);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AnimationChannel::ChannelType::Translation:
|
case tinyusdz::tydra::AnimationChannel::ChannelType::Translation:
|
||||||
if (animChannel.translations.static_value.has_value()) {
|
if (animChannel.translations.static_value.has_value()) {
|
||||||
positionKeys.emplace_back(0, tinyUsdzScaleOrPosToAssimp(animChannel.translations.static_value.value()));
|
positionKeys.emplace_back(0, tinyUsdzScaleOrPosToAssimp(animChannel.translations.static_value.value()));
|
||||||
}
|
}
|
||||||
@@ -355,7 +356,7 @@ void USDImporterImplTinyusdz::meshes(
|
|||||||
const tinyusdz::tydra::RenderScene &render_scene,
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
aiScene *pScene,
|
aiScene *pScene,
|
||||||
const std::string &nameWExt) {
|
const std::string &nameWExt) {
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
pScene->mNumMeshes = static_cast<unsigned int>(render_scene.meshes.size());
|
pScene->mNumMeshes = static_cast<unsigned int>(render_scene.meshes.size());
|
||||||
pScene->mMeshes = new aiMesh *[pScene->mNumMeshes]();
|
pScene->mMeshes = new aiMesh *[pScene->mNumMeshes]();
|
||||||
ss.str("");
|
ss.str("");
|
||||||
@@ -367,7 +368,10 @@ void USDImporterImplTinyusdz::meshes(
|
|||||||
pScene->mMeshes[meshIdx] = new aiMesh();
|
pScene->mMeshes[meshIdx] = new aiMesh();
|
||||||
pScene->mMeshes[meshIdx]->mName.Set(render_scene.meshes[meshIdx].prim_name);
|
pScene->mMeshes[meshIdx]->mName.Set(render_scene.meshes[meshIdx].prim_name);
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " mesh[" << meshIdx << "]: " << render_scene.meshes[meshIdx].joint_and_weights.jointIndices.size() << " jointIndices, " << render_scene.meshes[meshIdx].joint_and_weights.jointWeights.size() << " jointWeights, elementSize: " << render_scene.meshes[meshIdx].joint_and_weights.elementSize;
|
ss << " mesh[" << meshIdx << "]: " <<
|
||||||
|
render_scene.meshes[meshIdx].joint_and_weights.jointIndices.size() << " jointIndices, " <<
|
||||||
|
render_scene.meshes[meshIdx].joint_and_weights.jointWeights.size() << " jointWeights, elementSize: " <<
|
||||||
|
render_scene.meshes[meshIdx].joint_and_weights.elementSize;
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " skel_id: " << render_scene.meshes[meshIdx].skel_id;
|
ss << " skel_id: " << render_scene.meshes[meshIdx].skel_id;
|
||||||
@@ -386,8 +390,12 @@ void USDImporterImplTinyusdz::meshes(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void USDImporterImplTinyusdz::verticesForMesh(const tinyusdz::tydra::RenderScene &render_scene,
|
void USDImporterImplTinyusdz::verticesForMesh(
|
||||||
aiScene *pScene, size_t meshIdx, const std::string &) {
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
|
aiScene *pScene,
|
||||||
|
size_t meshIdx,
|
||||||
|
const std::string &nameWExt) {
|
||||||
|
UNUSED(nameWExt);
|
||||||
const auto numVertices = static_cast<unsigned int>(render_scene.meshes[meshIdx].points.size());
|
const auto numVertices = static_cast<unsigned int>(render_scene.meshes[meshIdx].points.size());
|
||||||
pScene->mMeshes[meshIdx]->mNumVertices = numVertices;
|
pScene->mMeshes[meshIdx]->mNumVertices = numVertices;
|
||||||
pScene->mMeshes[meshIdx]->mVertices = new aiVector3D[pScene->mMeshes[meshIdx]->mNumVertices];
|
pScene->mMeshes[meshIdx]->mVertices = new aiVector3D[pScene->mMeshes[meshIdx]->mNumVertices];
|
||||||
@@ -446,7 +454,7 @@ void USDImporterImplTinyusdz::verticesForMesh(const tinyusdz::tydra::RenderScene
|
|||||||
|
|
||||||
std::swap_ranges(aiBonesVertexWeights[boneIndex].begin(), aiBonesVertexWeights[boneIndex].end(), pScene->mMeshes[meshIdx]->mBones[boneIndex]->mWeights);
|
std::swap_ranges(aiBonesVertexWeights[boneIndex].begin(), aiBonesVertexWeights[boneIndex].end(), pScene->mMeshes[meshIdx]->mBones[boneIndex]->mWeights);
|
||||||
}
|
}
|
||||||
} // Skinned mesh end
|
} // Skinned mesh end
|
||||||
|
|
||||||
for (size_t j = 0; j < pScene->mMeshes[meshIdx]->mNumVertices; ++j) {
|
for (size_t j = 0; j < pScene->mMeshes[meshIdx]->mNumVertices; ++j) {
|
||||||
pScene->mMeshes[meshIdx]->mVertices[j].x = render_scene.meshes[meshIdx].points[j][0];
|
pScene->mMeshes[meshIdx]->mVertices[j].x = render_scene.meshes[meshIdx].points[j][0];
|
||||||
@@ -455,8 +463,12 @@ void USDImporterImplTinyusdz::verticesForMesh(const tinyusdz::tydra::RenderScene
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void USDImporterImplTinyusdz::facesForMesh(const RenderScene &render_scene, aiScene *pScene,
|
void USDImporterImplTinyusdz::facesForMesh(
|
||||||
size_t meshIdx, const std::string &) {
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
|
aiScene *pScene,
|
||||||
|
size_t meshIdx,
|
||||||
|
const std::string &nameWExt) {
|
||||||
|
UNUSED(nameWExt);
|
||||||
pScene->mMeshes[meshIdx]->mNumFaces = static_cast<unsigned int>(render_scene.meshes[meshIdx].faceVertexCounts().size());
|
pScene->mMeshes[meshIdx]->mNumFaces = static_cast<unsigned int>(render_scene.meshes[meshIdx].faceVertexCounts().size());
|
||||||
pScene->mMeshes[meshIdx]->mFaces = new aiFace[pScene->mMeshes[meshIdx]->mNumFaces]();
|
pScene->mMeshes[meshIdx]->mFaces = new aiFace[pScene->mMeshes[meshIdx]->mNumFaces]();
|
||||||
size_t faceVertIdxOffset = 0;
|
size_t faceVertIdxOffset = 0;
|
||||||
@@ -471,8 +483,12 @@ void USDImporterImplTinyusdz::facesForMesh(const RenderScene &render_scene, aiSc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void USDImporterImplTinyusdz::normalsForMesh(const RenderScene &render_scene, aiScene *pScene,
|
void USDImporterImplTinyusdz::normalsForMesh(
|
||||||
size_t meshIdx, const std::string &) {
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
|
aiScene *pScene,
|
||||||
|
size_t meshIdx,
|
||||||
|
const std::string &nameWExt) {
|
||||||
|
UNUSED(nameWExt);
|
||||||
pScene->mMeshes[meshIdx]->mNormals = new aiVector3D[pScene->mMeshes[meshIdx]->mNumVertices];
|
pScene->mMeshes[meshIdx]->mNormals = new aiVector3D[pScene->mMeshes[meshIdx]->mNumVertices];
|
||||||
const float *floatPtr = reinterpret_cast<const float *>(render_scene.meshes[meshIdx].normals.get_data().data());
|
const float *floatPtr = reinterpret_cast<const float *>(render_scene.meshes[meshIdx].normals.get_data().data());
|
||||||
for (size_t vertIdx = 0, fpj = 0; vertIdx < pScene->mMeshes[meshIdx]->mNumVertices; ++vertIdx, fpj += 3) {
|
for (size_t vertIdx = 0, fpj = 0; vertIdx < pScene->mMeshes[meshIdx]->mNumVertices; ++vertIdx, fpj += 3) {
|
||||||
@@ -482,16 +498,20 @@ void USDImporterImplTinyusdz::normalsForMesh(const RenderScene &render_scene, ai
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void USDImporterImplTinyusdz::materialsForMesh(const RenderScene&, aiScene*,
|
void USDImporterImplTinyusdz::materialsForMesh(
|
||||||
size_t, const std::string&) {
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
// todo
|
aiScene *pScene,
|
||||||
|
size_t meshIdx,
|
||||||
|
const std::string &nameWExt) {
|
||||||
|
UNUSED(render_scene); UNUSED(pScene); UNUSED(meshIdx); UNUSED(nameWExt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void USDImporterImplTinyusdz::uvsForMesh(
|
void USDImporterImplTinyusdz::uvsForMesh(
|
||||||
const tinyusdz::tydra::RenderScene &render_scene,
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
aiScene *pScene,
|
aiScene *pScene,
|
||||||
size_t meshIdx,
|
size_t meshIdx,
|
||||||
const std::string&) {
|
const std::string &nameWExt) {
|
||||||
|
UNUSED(nameWExt);
|
||||||
const size_t uvSlotsCount = render_scene.meshes[meshIdx].texcoords.size();
|
const size_t uvSlotsCount = render_scene.meshes[meshIdx].texcoords.size();
|
||||||
if (uvSlotsCount < 1) {
|
if (uvSlotsCount < 1) {
|
||||||
return;
|
return;
|
||||||
@@ -519,8 +539,10 @@ static aiColor3D *ownedColorPtrFor(const std::array<float, 3> &color) {
|
|||||||
return colorPtr;
|
return colorPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string nameForTextureWithId(const RenderScene &render_scene, const int targetId) {
|
static std::string nameForTextureWithId(
|
||||||
std::stringstream ss;
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
|
const int targetId) {
|
||||||
|
stringstream ss;
|
||||||
std::string texName;
|
std::string texName;
|
||||||
for (const auto &image : render_scene.images) {
|
for (const auto &image : render_scene.images) {
|
||||||
if (image.buffer_id == targetId) {
|
if (image.buffer_id == targetId) {
|
||||||
@@ -538,15 +560,16 @@ static std::string nameForTextureWithId(const RenderScene &render_scene, const i
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void assignTexture(
|
static void assignTexture(
|
||||||
const RenderScene &render_scene,
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
const RenderMaterial &,
|
const tinyusdz::tydra::RenderMaterial &material,
|
||||||
aiMaterial *mat,
|
aiMaterial *mat,
|
||||||
const int textureId,
|
const int textureId,
|
||||||
const int aiTextureType) {
|
const int aiTextureType) {
|
||||||
|
UNUSED(material);
|
||||||
std::string name = nameForTextureWithId(render_scene, textureId);
|
std::string name = nameForTextureWithId(render_scene, textureId);
|
||||||
aiString *texName = new aiString();
|
aiString *texName = new aiString();
|
||||||
texName->Set(name);
|
texName->Set(name);
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "assignTexture(): name: " << name;
|
ss << "assignTexture(): name: " << name;
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
@@ -558,8 +581,9 @@ void USDImporterImplTinyusdz::materials(
|
|||||||
const tinyusdz::tydra::RenderScene &render_scene,
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
aiScene *pScene,
|
aiScene *pScene,
|
||||||
const std::string &nameWExt) {
|
const std::string &nameWExt) {
|
||||||
const size_t numMaterials{ render_scene.materials.size() };
|
const size_t numMaterials{render_scene.materials.size()};
|
||||||
std::stringstream ss;
|
(void) numMaterials; // Ignore unused variable when -Werror enabled
|
||||||
|
stringstream ss;
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "materials(): model" << nameWExt << ", numMaterials: " << numMaterials;
|
ss << "materials(): model" << nameWExt << ", numMaterials: " << numMaterials;
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
@@ -567,7 +591,6 @@ void USDImporterImplTinyusdz::materials(
|
|||||||
if (render_scene.materials.empty()) {
|
if (render_scene.materials.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pScene->mMaterials = new aiMaterial *[render_scene.materials.size()];
|
pScene->mMaterials = new aiMaterial *[render_scene.materials.size()];
|
||||||
for (const auto &material : render_scene.materials) {
|
for (const auto &material : render_scene.materials) {
|
||||||
ss.str("");
|
ss.str("");
|
||||||
@@ -650,18 +673,22 @@ void USDImporterImplTinyusdz::materials(
|
|||||||
|
|
||||||
void USDImporterImplTinyusdz::textures(
|
void USDImporterImplTinyusdz::textures(
|
||||||
const tinyusdz::tydra::RenderScene &render_scene,
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
aiScene*,
|
aiScene *pScene,
|
||||||
const std::string &nameWExt) {
|
const std::string &nameWExt) {
|
||||||
const size_t numTextures{ render_scene.textures.size() };
|
UNUSED(pScene);
|
||||||
std::stringstream ss;
|
const size_t numTextures{render_scene.textures.size()};
|
||||||
|
UNUSED(numTextures); // Ignore unused variable when -Werror enabled
|
||||||
|
stringstream ss;
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "textures(): model" << nameWExt << ", numTextures: " << numTextures;
|
ss << "textures(): model" << nameWExt << ", numTextures: " << numTextures;
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
size_t i{ 0 };
|
size_t i{0};
|
||||||
|
UNUSED(i);
|
||||||
for (const auto &texture : render_scene.textures) {
|
for (const auto &texture : render_scene.textures) {
|
||||||
|
UNUSED(texture);
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " texture[" << i << "]: id: " << texture.texture_image_id << ", disp name: |" << texture.display_name << "|, varname_uv: " << texture.varname_uv << ", prim_name: |" << texture.prim_name << "|, abs_path: |" << texture.abs_path << "|";
|
ss << " texture[" << i << "]: id: " << texture.texture_image_id << ", disp name: |" << texture.display_name << "|, varname_uv: " <<
|
||||||
|
texture.varname_uv << ", prim_name: |" << texture.prim_name << "|, abs_path: |" << texture.abs_path << "|";
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@@ -675,12 +702,15 @@ void USDImporterImplTinyusdz::textures(
|
|||||||
* @param nameWExt filename w/ext (use to extract file type hint)
|
* @param nameWExt filename w/ext (use to extract file type hint)
|
||||||
* @return aiTexture ptr
|
* @return aiTexture ptr
|
||||||
*/
|
*/
|
||||||
static aiTexture *ownedEmbeddedTextureFor(const RenderScene &render_scene, const TextureImage &image,
|
static aiTexture *ownedEmbeddedTextureFor(
|
||||||
const std::string&) {
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
std::stringstream ss;
|
const tinyusdz::tydra::TextureImage &image,
|
||||||
|
const std::string &nameWExt) {
|
||||||
|
UNUSED(nameWExt);
|
||||||
|
stringstream ss;
|
||||||
aiTexture *tex = new aiTexture();
|
aiTexture *tex = new aiTexture();
|
||||||
size_t pos = image.asset_identifier.find_last_of('/');
|
size_t pos = image.asset_identifier.find_last_of('/');
|
||||||
std::string embTexName{ image.asset_identifier.substr(pos + 1) };
|
string embTexName{image.asset_identifier.substr(pos + 1)};
|
||||||
tex->mFilename.Set(image.asset_identifier.c_str());
|
tex->mFilename.Set(image.asset_identifier.c_str());
|
||||||
tex->mHeight = image.height;
|
tex->mHeight = image.height;
|
||||||
|
|
||||||
@@ -688,20 +718,20 @@ static aiTexture *ownedEmbeddedTextureFor(const RenderScene &render_scene, const
|
|||||||
if (tex->mHeight == 0) {
|
if (tex->mHeight == 0) {
|
||||||
pos = embTexName.find_last_of('.');
|
pos = embTexName.find_last_of('.');
|
||||||
strncpy(tex->achFormatHint, embTexName.substr(pos + 1).c_str(), 3);
|
strncpy(tex->achFormatHint, embTexName.substr(pos + 1).c_str(), 3);
|
||||||
const size_t imageBytesCount{ render_scene.buffers[image.buffer_id].data.size() };
|
const size_t imageBytesCount{render_scene.buffers[image.buffer_id].data.size()};
|
||||||
tex->pcData = (aiTexel *)new char[imageBytesCount];
|
tex->pcData = (aiTexel *) new char[imageBytesCount];
|
||||||
memcpy(tex->pcData, &render_scene.buffers[image.buffer_id].data[0], imageBytesCount);
|
memcpy(tex->pcData, &render_scene.buffers[image.buffer_id].data[0], imageBytesCount);
|
||||||
} else {
|
} else {
|
||||||
std::string formatHint{ "rgba8888" };
|
string formatHint{"rgba8888"};
|
||||||
strncpy(tex->achFormatHint, formatHint.c_str(), 8);
|
strncpy(tex->achFormatHint, formatHint.c_str(), 8);
|
||||||
const size_t imageTexelsCount{ tex->mWidth * tex->mHeight };
|
const size_t imageTexelsCount{tex->mWidth * tex->mHeight};
|
||||||
tex->pcData = (aiTexel *)new char[imageTexelsCount * image.channels];
|
tex->pcData = (aiTexel *) new char[imageTexelsCount * image.channels];
|
||||||
const float *floatPtr = reinterpret_cast<const float *>(&render_scene.buffers[image.buffer_id].data[0]);
|
const float *floatPtr = reinterpret_cast<const float *>(&render_scene.buffers[image.buffer_id].data[0]);
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "ownedEmbeddedTextureFor(): manual fill...";
|
ss << "ownedEmbeddedTextureFor(): manual fill...";
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
for (size_t i = 0, fpi = 0; i < imageTexelsCount; ++i, fpi += 4) {
|
for (size_t i = 0, fpi = 0; i < imageTexelsCount; ++i, fpi += 4) {
|
||||||
tex->pcData[i].b = static_cast<uint8_t>(floatPtr[fpi] * 255);
|
tex->pcData[i].b = static_cast<uint8_t>(floatPtr[fpi] * 255);
|
||||||
tex->pcData[i].g = static_cast<uint8_t>(floatPtr[fpi + 1] * 255);
|
tex->pcData[i].g = static_cast<uint8_t>(floatPtr[fpi + 1] * 255);
|
||||||
tex->pcData[i].r = static_cast<uint8_t>(floatPtr[fpi + 2] * 255);
|
tex->pcData[i].r = static_cast<uint8_t>(floatPtr[fpi + 2] * 255);
|
||||||
tex->pcData[i].a = static_cast<uint8_t>(floatPtr[fpi + 3] * 255);
|
tex->pcData[i].a = static_cast<uint8_t>(floatPtr[fpi + 3] * 255);
|
||||||
@@ -713,9 +743,13 @@ static aiTexture *ownedEmbeddedTextureFor(const RenderScene &render_scene, const
|
|||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void USDImporterImplTinyusdz::textureImages(const RenderScene &render_scene, aiScene *pScene, const std::string &nameWExt) {
|
void USDImporterImplTinyusdz::textureImages(
|
||||||
std::stringstream ss;
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
const size_t numTextureImages{ render_scene.images.size() };
|
aiScene *pScene,
|
||||||
|
const std::string &nameWExt) {
|
||||||
|
stringstream ss;
|
||||||
|
const size_t numTextureImages{render_scene.images.size()};
|
||||||
|
UNUSED(numTextureImages); // Ignore unused variable when -Werror enabled
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "textureImages(): model" << nameWExt << ", numTextureImages: " << numTextureImages;
|
ss << "textureImages(): model" << nameWExt << ", numTextureImages: " << numTextureImages;
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
@@ -723,15 +757,13 @@ void USDImporterImplTinyusdz::textureImages(const RenderScene &render_scene, aiS
|
|||||||
pScene->mNumTextures = 0;
|
pScene->mNumTextures = 0;
|
||||||
for (const auto &image : render_scene.images) {
|
for (const auto &image : render_scene.images) {
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " image[" << pScene->mNumTextures << "]: |" << image.asset_identifier << "| w: "
|
ss << " image[" << pScene->mNumTextures << "]: |" << image.asset_identifier << "| w: " << image.width << ", h: " << image.height <<
|
||||||
<< image.width << ", h: " << image.height << ", channels: " << image.channels << ", miplevel: "
|
", channels: " << image.channels << ", miplevel: " << image.miplevel << ", buffer id: " << image.buffer_id << "\n" <<
|
||||||
<< image.miplevel << ", buffer id: " << image.buffer_id << "\n"
|
" buffers.size(): " << render_scene.buffers.size() << ", data empty? " << render_scene.buffers[image.buffer_id].data.empty();
|
||||||
<< " buffers.size(): " << render_scene.buffers.size() << ", data empty? "
|
|
||||||
<< render_scene.buffers[image.buffer_id].data.empty();
|
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
if (image.buffer_id > -1 &&
|
if (image.buffer_id > -1 &&
|
||||||
image.buffer_id < static_cast<long int>(render_scene.buffers.size()) &&
|
image.buffer_id < static_cast<long int>(render_scene.buffers.size()) &&
|
||||||
!render_scene.buffers[image.buffer_id].data.empty()) {
|
!render_scene.buffers[image.buffer_id].data.empty()) {
|
||||||
aiTexture *tex = ownedEmbeddedTextureFor(
|
aiTexture *tex = ownedEmbeddedTextureFor(
|
||||||
render_scene,
|
render_scene,
|
||||||
image,
|
image,
|
||||||
@@ -743,8 +775,8 @@ void USDImporterImplTinyusdz::textureImages(const RenderScene &render_scene, aiS
|
|||||||
pScene->mTextures = new aiTexture *[render_scene.images.size()];
|
pScene->mTextures = new aiTexture *[render_scene.images.size()];
|
||||||
}
|
}
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " pScene->mTextures[" << pScene->mNumTextures << "] name: |" << tex->mFilename.C_Str()
|
ss << " pScene->mTextures[" << pScene->mNumTextures << "] name: |" << tex->mFilename.C_Str() <<
|
||||||
<< "|, w: " << tex->mWidth << ", h: " << tex->mHeight << ", hint: " << tex->achFormatHint;
|
"|, w: " << tex->mWidth << ", h: " << tex->mHeight << ", hint: " << tex->achFormatHint;
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
pScene->mTextures[pScene->mNumTextures++] = tex;
|
pScene->mTextures[pScene->mNumTextures++] = tex;
|
||||||
}
|
}
|
||||||
@@ -752,9 +784,12 @@ void USDImporterImplTinyusdz::textureImages(const RenderScene &render_scene, aiS
|
|||||||
}
|
}
|
||||||
|
|
||||||
void USDImporterImplTinyusdz::buffers(
|
void USDImporterImplTinyusdz::buffers(
|
||||||
const RenderScene &render_scene, aiScene*, const std::string &nameWExt) {
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
const size_t numBuffers{ render_scene.buffers.size() };
|
aiScene *pScene,
|
||||||
std::stringstream ss;
|
const std::string &nameWExt) {
|
||||||
|
const size_t numBuffers{render_scene.buffers.size()};
|
||||||
|
UNUSED(pScene); UNUSED(numBuffers); // Ignore unused variable when -Werror enabled
|
||||||
|
stringstream ss;
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "buffers(): model" << nameWExt << ", numBuffers: " << numBuffers;
|
ss << "buffers(): model" << nameWExt << ", numBuffers: " << numBuffers;
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
@@ -767,9 +802,53 @@ void USDImporterImplTinyusdz::buffers(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aiNode *USDImporterImplTinyusdz::nodesRecursive(aiNode *pNodeParent, const tinyusdz::tydra::Node &node,
|
void USDImporterImplTinyusdz::setupNodes(
|
||||||
const std::vector<SkelHierarchy> &skeletons) {
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
std::stringstream ss;
|
aiScene *pScene,
|
||||||
|
const tinyusdz::Stage &usdStage,
|
||||||
|
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
|
||||||
|
const std::string &nameWExt) {
|
||||||
|
stringstream ss;
|
||||||
|
|
||||||
|
pScene->mRootNode = nodes(render_scene, usdStage, meshNodes, nameWExt);
|
||||||
|
pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
|
||||||
|
pScene->mRootNode->mMeshes = new unsigned int[pScene->mRootNode->mNumMeshes];
|
||||||
|
ss.str("");
|
||||||
|
ss << "setupNodes(): pScene->mNumMeshes: " << pScene->mNumMeshes;
|
||||||
|
if (pScene->mRootNode != nullptr) {
|
||||||
|
ss << ", mRootNode->mNumMeshes: " << pScene->mRootNode->mNumMeshes;
|
||||||
|
}
|
||||||
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
|
|
||||||
|
for (unsigned int meshIdx = 0; meshIdx < pScene->mNumMeshes; meshIdx++) {
|
||||||
|
pScene->mRootNode->mMeshes[meshIdx] = meshIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
aiNode *USDImporterImplTinyusdz::nodes(
|
||||||
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
|
const tinyusdz::Stage &usdStage,
|
||||||
|
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
|
||||||
|
const std::string &nameWExt) {
|
||||||
|
const size_t numNodes{render_scene.nodes.size()};
|
||||||
|
(void) numNodes; // Ignore unused variable when -Werror enabled
|
||||||
|
stringstream ss;
|
||||||
|
ss.str("");
|
||||||
|
ss << "nodes(): model" << nameWExt << ", numNodes: " << numNodes;
|
||||||
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
|
return nodesRecursive(nullptr, usdStage.root_prims()[0], render_scene.nodes[0], meshNodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
using Assimp::tinyusdzNodeTypeFor;
|
||||||
|
using Assimp::tinyUsdzMat4ToAiMat4;
|
||||||
|
using tinyusdz::tydra::NodeType;
|
||||||
|
aiNode *USDImporterImplTinyusdz::nodesRecursive(
|
||||||
|
aiNode *pNodeParent,
|
||||||
|
const tinyusdz::Prim& prim,
|
||||||
|
const tinyusdz::tydra::Node &node,
|
||||||
|
const std::vector<tinyusdz::tydra::SkelHierarchy> &skeletons) {
|
||||||
|
stringstream ss;
|
||||||
aiNode *cNode = new aiNode();
|
aiNode *cNode = new aiNode();
|
||||||
cNode->mParent = pNodeParent;
|
cNode->mParent = pNodeParent;
|
||||||
cNode->mName.Set(node.prim_name);
|
cNode->mName.Set(node.prim_name);
|
||||||
@@ -782,9 +861,9 @@ aiNode *USDImporterImplTinyusdz::nodesRecursive(aiNode *pNodeParent, const tinyu
|
|||||||
}
|
}
|
||||||
|
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "nodesRecursive(): node " << cNode->mName.C_Str() << " type: |"
|
ss << "nodesRecursive(): node " << cNode->mName.C_Str() <<
|
||||||
<< tinyusdzNodeTypeFor(node.nodeType)
|
" type: |" << tinyusdzNodeTypeFor(node.nodeType) <<
|
||||||
<< "|, disp " << node.display_name << ", abs " << node.abs_path;
|
"|, disp " << node.display_name << ", abs " << node.abs_path;
|
||||||
if (cNode->mParent != nullptr) {
|
if (cNode->mParent != nullptr) {
|
||||||
ss << " (parent " << cNode->mParent->mName.C_Str() << ")";
|
ss << " (parent " << cNode->mParent->mName.C_Str() << ")";
|
||||||
}
|
}
|
||||||
@@ -808,6 +887,22 @@ aiNode *USDImporterImplTinyusdz::nodesRecursive(aiNode *pNodeParent, const tinyu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Composition: references
|
||||||
|
if (prim.metas().references.has_value())
|
||||||
|
{
|
||||||
|
const tinyusdz::ListEditQual referenceQual = prim.metas().references->first;
|
||||||
|
const std::vector<tinyusdz::Reference> references = prim.metas().references->second;
|
||||||
|
|
||||||
|
for (const auto &reference : references)
|
||||||
|
{
|
||||||
|
cNode->mMetaData = aiMetadata::Alloc(1);
|
||||||
|
cNode->mMetaData->Add("ref", aiString(reference.asset_path.GetAssetPath()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t i{0};
|
||||||
|
for (const auto &childNode: node.children) {
|
||||||
|
cNode->mChildren[i] = nodesRecursive(cNode, prim.children()[i], childNode, meshNodes);
|
||||||
cNode->mNumChildren = numChildren;
|
cNode->mNumChildren = numChildren;
|
||||||
|
|
||||||
// Done. No more children.
|
// Done. No more children.
|
||||||
@@ -825,15 +920,15 @@ aiNode *USDImporterImplTinyusdz::nodesRecursive(aiNode *pNodeParent, const tinyu
|
|||||||
|
|
||||||
if (skelNode != nullptr) {
|
if (skelNode != nullptr) {
|
||||||
// Convert USD skeleton into an Assimp node and make it the last child
|
// Convert USD skeleton into an Assimp node and make it the last child
|
||||||
cNode->mChildren[cNode->mNumChildren - 1] = skeletonNodesRecursive(cNode, *skelNode);
|
cNode->mChildren[cNode->mNumChildren-1] = skeletonNodesRecursive(cNode, *skelNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cNode;
|
return cNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
aiNode *USDImporterImplTinyusdz::skeletonNodesRecursive(
|
aiNode *USDImporterImplTinyusdz::skeletonNodesRecursive(
|
||||||
aiNode *pNodeParent,
|
aiNode* pNodeParent,
|
||||||
const SkelNode &joint) {
|
const tinyusdz::tydra::SkelNode& joint) {
|
||||||
auto *cNode = new aiNode(joint.joint_path);
|
auto *cNode = new aiNode(joint.joint_path);
|
||||||
cNode->mParent = pNodeParent;
|
cNode->mParent = pNodeParent;
|
||||||
cNode->mNumMeshes = 0; // not a mesh node
|
cNode->mNumMeshes = 0; // not a mesh node
|
||||||
@@ -848,7 +943,7 @@ aiNode *USDImporterImplTinyusdz::skeletonNodesRecursive(
|
|||||||
cNode->mChildren = new aiNode *[cNode->mNumChildren];
|
cNode->mChildren = new aiNode *[cNode->mNumChildren];
|
||||||
|
|
||||||
for (unsigned i = 0; i < cNode->mNumChildren; ++i) {
|
for (unsigned i = 0; i < cNode->mNumChildren; ++i) {
|
||||||
const SkelNode &childJoint = joint.children[i];
|
const tinyusdz::tydra::SkelNode &childJoint = joint.children[i];
|
||||||
cNode->mChildren[i] = skeletonNodesRecursive(cNode, childJoint);
|
cNode->mChildren[i] = skeletonNodesRecursive(cNode, childJoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,7 +952,7 @@ aiNode *USDImporterImplTinyusdz::skeletonNodesRecursive(
|
|||||||
|
|
||||||
void USDImporterImplTinyusdz::sanityCheckNodesRecursive(
|
void USDImporterImplTinyusdz::sanityCheckNodesRecursive(
|
||||||
aiNode *cNode) {
|
aiNode *cNode) {
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "sanityCheckNodesRecursive(): node " << cNode->mName.C_Str();
|
ss << "sanityCheckNodesRecursive(): node " << cNode->mName.C_Str();
|
||||||
if (cNode->mParent != nullptr) {
|
if (cNode->mParent != nullptr) {
|
||||||
@@ -870,14 +965,16 @@ void USDImporterImplTinyusdz::sanityCheckNodesRecursive(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void USDImporterImplTinyusdz::setupBlendShapes(const RenderScene &render_scene, aiScene *pScene,
|
void USDImporterImplTinyusdz::setupBlendShapes(
|
||||||
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
|
aiScene *pScene,
|
||||||
const std::string &nameWExt) {
|
const std::string &nameWExt) {
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "setupBlendShapes(): iterating over " << pScene->mNumMeshes << " meshes for model" << nameWExt;
|
ss << "setupBlendShapes(): iterating over " << pScene->mNumMeshes << " meshes for model" << nameWExt;
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
for (size_t meshIdx = 0; meshIdx < pScene->mNumMeshes; meshIdx++) {
|
for (size_t meshIdx = 0; meshIdx < pScene->mNumMeshes; meshIdx++) {
|
||||||
blendShapesForMesh(render_scene, pScene, meshIdx, nameWExt);
|
blendShapesForMesh(render_scene, pScene, meshIdx, nameWExt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -885,9 +982,10 @@ void USDImporterImplTinyusdz::blendShapesForMesh(
|
|||||||
const tinyusdz::tydra::RenderScene &render_scene,
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
aiScene *pScene,
|
aiScene *pScene,
|
||||||
size_t meshIdx,
|
size_t meshIdx,
|
||||||
const std::string &) {
|
const std::string &nameWExt) {
|
||||||
std::stringstream ss;
|
UNUSED(nameWExt);
|
||||||
const unsigned int numBlendShapeTargets{ static_cast<unsigned int>(render_scene.meshes[meshIdx].targets.size()) };
|
stringstream ss;
|
||||||
|
const unsigned int numBlendShapeTargets{static_cast<unsigned int>(render_scene.meshes[meshIdx].targets.size())};
|
||||||
UNUSED(numBlendShapeTargets); // Ignore unused variable when -Werror enabled
|
UNUSED(numBlendShapeTargets); // Ignore unused variable when -Werror enabled
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " blendShapesForMesh(): mesh[" << meshIdx << "], numBlendShapeTargets: " << numBlendShapeTargets;
|
ss << " blendShapesForMesh(): mesh[" << meshIdx << "], numBlendShapeTargets: " << numBlendShapeTargets;
|
||||||
@@ -897,13 +995,15 @@ void USDImporterImplTinyusdz::blendShapesForMesh(
|
|||||||
pScene->mMeshes[meshIdx]->mAnimMeshes = new aiAnimMesh *[pScene->mMeshes[meshIdx]->mNumAnimMeshes];
|
pScene->mMeshes[meshIdx]->mAnimMeshes = new aiAnimMesh *[pScene->mMeshes[meshIdx]->mNumAnimMeshes];
|
||||||
}
|
}
|
||||||
auto mapIter = render_scene.meshes[meshIdx].targets.begin();
|
auto mapIter = render_scene.meshes[meshIdx].targets.begin();
|
||||||
size_t animMeshIdx{ 0 };
|
size_t animMeshIdx{0};
|
||||||
for (; mapIter != render_scene.meshes[meshIdx].targets.end(); ++mapIter) {
|
for (; mapIter != render_scene.meshes[meshIdx].targets.end(); ++mapIter) {
|
||||||
const std::string name{ mapIter->first };
|
const std::string name{mapIter->first};
|
||||||
const tinyusdz::tydra::ShapeTarget shapeTarget{ mapIter->second };
|
const tinyusdz::tydra::ShapeTarget shapeTarget{mapIter->second};
|
||||||
pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx] = aiCreateAnimMesh(pScene->mMeshes[meshIdx]);
|
pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx] = aiCreateAnimMesh(pScene->mMeshes[meshIdx]);
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " mAnimMeshes[" << animMeshIdx << "]: mNumVertices: " << pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx]->mNumVertices << ", target: " << shapeTarget.pointIndices.size() << " pointIndices, " << shapeTarget.pointOffsets.size() << " pointOffsets, " << shapeTarget.normalOffsets.size() << " normalOffsets";
|
ss << " mAnimMeshes[" << animMeshIdx << "]: mNumVertices: " << pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx]->mNumVertices <<
|
||||||
|
", target: " << shapeTarget.pointIndices.size() << " pointIndices, " << shapeTarget.pointOffsets.size() <<
|
||||||
|
" pointOffsets, " << shapeTarget.normalOffsets.size() << " normalOffsets";
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
for (size_t iVert = 0; iVert < shapeTarget.pointOffsets.size(); ++iVert) {
|
for (size_t iVert = 0; iVert < shapeTarget.pointOffsets.size(); ++iVert) {
|
||||||
pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx]->mVertices[shapeTarget.pointIndices[iVert]] +=
|
pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx]->mVertices[shapeTarget.pointIndices[iVert]] +=
|
||||||
@@ -914,7 +1014,12 @@ void USDImporterImplTinyusdz::blendShapesForMesh(
|
|||||||
tinyUsdzScaleOrPosToAssimp(shapeTarget.normalOffsets[iVert]);
|
tinyUsdzScaleOrPosToAssimp(shapeTarget.normalOffsets[iVert]);
|
||||||
}
|
}
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " target[" << animMeshIdx << "]: name: " << name << ", prim_name: " << shapeTarget.prim_name << ", abs_path: " << shapeTarget.abs_path << ", display_name: " << shapeTarget.display_name << ", " << shapeTarget.pointIndices.size() << " pointIndices, " << shapeTarget.pointOffsets.size() << " pointOffsets, " << shapeTarget.normalOffsets.size() << " normalOffsets, " << shapeTarget.inbetweens.size() << " inbetweens";
|
ss << " target[" << animMeshIdx << "]: name: " << name << ", prim_name: " <<
|
||||||
|
shapeTarget.prim_name << ", abs_path: " << shapeTarget.abs_path <<
|
||||||
|
", display_name: " << shapeTarget.display_name << ", " << shapeTarget.pointIndices.size() <<
|
||||||
|
" pointIndices, " << shapeTarget.pointOffsets.size() << " pointOffsets, " <<
|
||||||
|
shapeTarget.normalOffsets.size() << " normalOffsets, " << shapeTarget.inbetweens.size() <<
|
||||||
|
" inbetweens";
|
||||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||||
++animMeshIdx;
|
++animMeshIdx;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,29 +43,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
* @brief Declaration of the USD importer class.
|
* @brief Declaration of the USD importer class.
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED
|
#ifndef AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED
|
||||||
#define AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED
|
#define AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED
|
||||||
|
|
||||||
#include "tinyusdz.hh"
|
|
||||||
#include "tydra/render-data.hh"
|
|
||||||
#include <assimp/BaseImporter.h>
|
#include <assimp/BaseImporter.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/types.h>
|
#include <assimp/types.h>
|
||||||
#include <cstdint>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <cstdint>
|
||||||
|
#include "tinyusdz.hh"
|
||||||
|
#include "tydra/render-data.hh"
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief USD Importer implementation using tinyusdz.
|
|
||||||
*/
|
|
||||||
class USDImporterImplTinyusdz {
|
class USDImporterImplTinyusdz {
|
||||||
public:
|
public:
|
||||||
/// @brief The class constructor.
|
|
||||||
USDImporterImplTinyusdz() = default;
|
USDImporterImplTinyusdz() = default;
|
||||||
|
|
||||||
/// @brief The class destructor.
|
|
||||||
~USDImporterImplTinyusdz() = default;
|
~USDImporterImplTinyusdz() = default;
|
||||||
|
|
||||||
void InternReadFile(
|
void InternReadFile(
|
||||||
@@ -132,8 +124,23 @@ public:
|
|||||||
aiScene *pScene,
|
aiScene *pScene,
|
||||||
const std::string &nameWExt);
|
const std::string &nameWExt);
|
||||||
|
|
||||||
|
void setupNodes(
|
||||||
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
|
aiScene *pScene,
|
||||||
|
const tinyusdz::Stage &usdStage,
|
||||||
|
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
|
||||||
|
const std::string &nameWExt
|
||||||
|
);
|
||||||
|
|
||||||
|
aiNode *nodes(
|
||||||
|
const tinyusdz::tydra::RenderScene &render_scene,
|
||||||
|
const tinyusdz::Stage &usdStage,
|
||||||
|
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
|
||||||
|
const std::string &nameWExt);
|
||||||
|
|
||||||
aiNode *nodesRecursive(
|
aiNode *nodesRecursive(
|
||||||
aiNode *pNodeParent,
|
aiNode *pNodeParent,
|
||||||
|
const tinyusdz::Prim &prim,
|
||||||
const tinyusdz::tydra::Node &node,
|
const tinyusdz::tydra::Node &node,
|
||||||
const std::vector<tinyusdz::tydra::SkelHierarchy> &skeletons);
|
const std::vector<tinyusdz::tydra::SkelHierarchy> &skeletons);
|
||||||
|
|
||||||
@@ -155,7 +162,5 @@ public:
|
|||||||
size_t meshIdx,
|
size_t meshIdx,
|
||||||
const std::string &nameWExt);
|
const std::string &nameWExt);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Assimp
|
} // namespace Assimp
|
||||||
|
|
||||||
#endif // AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED
|
#endif // AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED
|
||||||
|
|||||||
@@ -364,8 +364,11 @@ struct CustomExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CustomExtension() = default;
|
CustomExtension() = default;
|
||||||
|
|
||||||
~CustomExtension() = default;
|
~CustomExtension() = default;
|
||||||
|
|
||||||
CustomExtension(const CustomExtension &other) = default;
|
CustomExtension(const CustomExtension &other) = default;
|
||||||
|
|
||||||
CustomExtension& operator=(const CustomExtension&) = default;
|
CustomExtension& operator=(const CustomExtension&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -420,6 +423,7 @@ public:
|
|||||||
Type_text
|
Type_text
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// \struct SEncodedRegion
|
||||||
/// Descriptor of encoded region in "bufferView".
|
/// Descriptor of encoded region in "bufferView".
|
||||||
struct SEncodedRegion {
|
struct SEncodedRegion {
|
||||||
const size_t Offset; ///< Offset from begin of "bufferView" to encoded region, in bytes.
|
const size_t Offset; ///< Offset from begin of "bufferView" to encoded region, in bytes.
|
||||||
@@ -428,6 +432,7 @@ public:
|
|||||||
const size_t DecodedData_Length; ///< Size of decoded region, in bytes.
|
const size_t DecodedData_Length; ///< Size of decoded region, in bytes.
|
||||||
const std::string ID; ///< ID of the region.
|
const std::string ID; ///< ID of the region.
|
||||||
|
|
||||||
|
/// \fn SEncodedRegion(const size_t pOffset, const size_t pEncodedData_Length, uint8_t* pDecodedData, const size_t pDecodedData_Length, const std::string pID)
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \param [in] pOffset - offset from begin of "bufferView" to encoded region, in bytes.
|
/// \param [in] pOffset - offset from begin of "bufferView" to encoded region, in bytes.
|
||||||
/// \param [in] pEncodedData_Length - size of encoded region, in bytes.
|
/// \param [in] pEncodedData_Length - size of encoded region, in bytes.
|
||||||
@@ -441,6 +446,7 @@ public:
|
|||||||
DecodedData_Length(pDecodedData_Length),
|
DecodedData_Length(pDecodedData_Length),
|
||||||
ID(pID) {}
|
ID(pID) {}
|
||||||
|
|
||||||
|
/// \fn ~SEncodedRegion()
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
~SEncodedRegion() { delete[] DecodedData; }
|
~SEncodedRegion() { delete[] DecodedData; }
|
||||||
};
|
};
|
||||||
@@ -454,6 +460,7 @@ public:
|
|||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
|
|
||||||
|
/// \var EncodedRegion_Current
|
||||||
/// Pointer to currently active encoded region.
|
/// Pointer to currently active encoded region.
|
||||||
/// Why not decoding all regions at once and not to set one buffer with decoded data?
|
/// Why not decoding all regions at once and not to set one buffer with decoded data?
|
||||||
/// Yes, why not? Even "accessor" point to decoded data. I mean that fields "byteOffset", "byteStride" and "count" has values which describes decoded
|
/// Yes, why not? Even "accessor" point to decoded data. I mean that fields "byteOffset", "byteStride" and "count" has values which describes decoded
|
||||||
@@ -493,6 +500,7 @@ public:
|
|||||||
|
|
||||||
bool LoadFromStream(IOStream &stream, size_t length = 0, size_t baseOffset = 0);
|
bool LoadFromStream(IOStream &stream, size_t length = 0, size_t baseOffset = 0);
|
||||||
|
|
||||||
|
/// \fn void EncodedRegion_Mark(const size_t pOffset, const size_t pEncodedData_Length, uint8_t* pDecodedData, const size_t pDecodedData_Length, const std::string& pID)
|
||||||
/// Mark region of "bufferView" as encoded. When data is request from such region then "bufferView" use decoded data.
|
/// Mark region of "bufferView" as encoded. When data is request from such region then "bufferView" use decoded data.
|
||||||
/// \param [in] pOffset - offset from begin of "bufferView" to encoded region, in bytes.
|
/// \param [in] pOffset - offset from begin of "bufferView" to encoded region, in bytes.
|
||||||
/// \param [in] pEncodedData_Length - size of encoded region, in bytes.
|
/// \param [in] pEncodedData_Length - size of encoded region, in bytes.
|
||||||
@@ -501,10 +509,12 @@ public:
|
|||||||
/// \param [in] pID - ID of the region.
|
/// \param [in] pID - ID of the region.
|
||||||
void EncodedRegion_Mark(const size_t pOffset, const size_t pEncodedData_Length, uint8_t *pDecodedData, const size_t pDecodedData_Length, const std::string &pID);
|
void EncodedRegion_Mark(const size_t pOffset, const size_t pEncodedData_Length, uint8_t *pDecodedData, const size_t pDecodedData_Length, const std::string &pID);
|
||||||
|
|
||||||
|
/// \fn void EncodedRegion_SetCurrent(const std::string& pID)
|
||||||
/// Select current encoded region by ID. \sa EncodedRegion_Current.
|
/// Select current encoded region by ID. \sa EncodedRegion_Current.
|
||||||
/// \param [in] pID - ID of the region.
|
/// \param [in] pID - ID of the region.
|
||||||
void EncodedRegion_SetCurrent(const std::string &pID);
|
void EncodedRegion_SetCurrent(const std::string &pID);
|
||||||
|
|
||||||
|
/// \fn bool ReplaceData(const size_t pBufferData_Offset, const size_t pBufferData_Count, const uint8_t* pReplace_Data, const size_t pReplace_Count)
|
||||||
/// Replace part of buffer data. Pay attention that function work with original array of data (\ref mData) not with encoded regions.
|
/// Replace part of buffer data. Pay attention that function work with original array of data (\ref mData) not with encoded regions.
|
||||||
/// \param [in] pBufferData_Offset - index of first element in buffer from which new data will be placed.
|
/// \param [in] pBufferData_Offset - index of first element in buffer from which new data will be placed.
|
||||||
/// \param [in] pBufferData_Count - count of bytes in buffer which will be replaced.
|
/// \param [in] pBufferData_Count - count of bytes in buffer which will be replaced.
|
||||||
@@ -992,24 +1002,27 @@ struct Texture : public Object {
|
|||||||
|
|
||||||
struct Animation : public Object {
|
struct Animation : public Object {
|
||||||
struct Sampler {
|
struct Sampler {
|
||||||
Sampler() = default;
|
Sampler() :
|
||||||
|
interpolation(Interpolation_LINEAR) {}
|
||||||
|
|
||||||
Ref<Accessor> input; //!< Accessor reference to the buffer storing the key-frame times.
|
Ref<Accessor> input; //!< Accessor reference to the buffer storing the key-frame times.
|
||||||
Ref<Accessor> output; //!< Accessor reference to the buffer storing the key-frame values.
|
Ref<Accessor> output; //!< Accessor reference to the buffer storing the key-frame values.
|
||||||
Interpolation interpolation{Interpolation_LINEAR}; //!< Type of interpolation algorithm to use between key-frames.
|
Interpolation interpolation; //!< Type of interpolation algorithm to use between key-frames.
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Target {
|
struct Target {
|
||||||
Target() = default;
|
Target() :
|
||||||
|
path(AnimationPath_TRANSLATION) {}
|
||||||
|
|
||||||
Ref<Node> node; //!< The node to animate.
|
Ref<Node> node; //!< The node to animate.
|
||||||
AnimationPath path{AnimationPath_TRANSLATION}; //!< The property of the node to animate.
|
AnimationPath path; //!< The property of the node to animate.
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Channel {
|
struct Channel {
|
||||||
Channel() = default;
|
Channel() :
|
||||||
|
sampler(-1) {}
|
||||||
|
|
||||||
int sampler{-1}; //!< The sampler index containing the animation data.
|
int sampler; //!< The sampler index containing the animation data.
|
||||||
Target target; //!< The node and property to animate.
|
Target target; //!< The node and property to animate.
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1122,34 +1135,50 @@ class Asset {
|
|||||||
public:
|
public:
|
||||||
//! Keeps info about the enabled extensions
|
//! Keeps info about the enabled extensions
|
||||||
struct Extensions {
|
struct Extensions {
|
||||||
bool KHR_materials_pbrSpecularGlossiness{false};
|
bool KHR_materials_pbrSpecularGlossiness;
|
||||||
bool KHR_materials_specular{false};
|
bool KHR_materials_specular;
|
||||||
bool KHR_materials_unlit{false};
|
bool KHR_materials_unlit;
|
||||||
bool KHR_lights_punctual{false};
|
bool KHR_lights_punctual;
|
||||||
bool KHR_texture_transform{false};
|
bool KHR_texture_transform;
|
||||||
bool KHR_materials_sheen{false};
|
bool KHR_materials_sheen;
|
||||||
bool KHR_materials_clearcoat{false};
|
bool KHR_materials_clearcoat;
|
||||||
bool KHR_materials_transmission{false};
|
bool KHR_materials_transmission;
|
||||||
bool KHR_materials_volume{false};
|
bool KHR_materials_volume;
|
||||||
bool KHR_materials_ior{false};
|
bool KHR_materials_ior;
|
||||||
bool KHR_materials_emissive_strength{false};
|
bool KHR_materials_emissive_strength;
|
||||||
bool KHR_materials_anisotropy{false};
|
bool KHR_materials_anisotropy;
|
||||||
bool KHR_draco_mesh_compression{false};
|
bool KHR_draco_mesh_compression;
|
||||||
bool FB_ngon_encoding{false};
|
bool FB_ngon_encoding;
|
||||||
bool KHR_texture_basisu{false};
|
bool KHR_texture_basisu;
|
||||||
bool EXT_texture_webp{false};
|
|
||||||
|
|
||||||
Extensions() = default;
|
Extensions() :
|
||||||
~Extensions() = default;
|
KHR_materials_pbrSpecularGlossiness(false),
|
||||||
|
KHR_materials_specular(false),
|
||||||
|
KHR_materials_unlit(false),
|
||||||
|
KHR_lights_punctual(false),
|
||||||
|
KHR_texture_transform(false),
|
||||||
|
KHR_materials_sheen(false),
|
||||||
|
KHR_materials_clearcoat(false),
|
||||||
|
KHR_materials_transmission(false),
|
||||||
|
KHR_materials_volume(false),
|
||||||
|
KHR_materials_ior(false),
|
||||||
|
KHR_materials_emissive_strength(false),
|
||||||
|
KHR_materials_anisotropy(false),
|
||||||
|
KHR_draco_mesh_compression(false),
|
||||||
|
FB_ngon_encoding(false),
|
||||||
|
KHR_texture_basisu(false) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
} extensionsUsed;
|
} extensionsUsed;
|
||||||
|
|
||||||
//! Keeps info about the required extensions
|
//! Keeps info about the required extensions
|
||||||
struct RequiredExtensions {
|
struct RequiredExtensions {
|
||||||
bool KHR_draco_mesh_compression{false};
|
bool KHR_draco_mesh_compression;
|
||||||
bool KHR_texture_basisu{false};
|
bool KHR_texture_basisu;
|
||||||
bool EXT_texture_webp{false};
|
|
||||||
|
|
||||||
RequiredExtensions() = default;
|
RequiredExtensions() : KHR_draco_mesh_compression(false), KHR_texture_basisu(false) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
} extensionsRequired;
|
} extensionsRequired;
|
||||||
|
|
||||||
AssetMetadata asset;
|
AssetMetadata asset;
|
||||||
|
|||||||
@@ -1217,13 +1217,6 @@ inline void Texture::Read(Value &obj, Asset &r) {
|
|||||||
if (r.extensionsUsed.KHR_texture_basisu) {
|
if (r.extensionsUsed.KHR_texture_basisu) {
|
||||||
if (Value *curBasisU = FindObject(*extensions, "KHR_texture_basisu")) {
|
if (Value *curBasisU = FindObject(*extensions, "KHR_texture_basisu")) {
|
||||||
|
|
||||||
if (Value *sourceVal = FindUInt(*curBasisU, "source")) {
|
|
||||||
source = r.images.Retrieve(sourceVal->GetUint());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if(r.extensionsUsed.EXT_texture_webp) {
|
|
||||||
if (Value *curBasisU = FindObject(*extensions, "EXT_texture_webp")) {
|
|
||||||
|
|
||||||
if (Value *sourceVal = FindUInt(*curBasisU, "source")) {
|
if (Value *sourceVal = FindUInt(*curBasisU, "source")) {
|
||||||
source = r.images.Retrieve(sourceVal->GetUint());
|
source = r.images.Retrieve(sourceVal->GetUint());
|
||||||
}
|
}
|
||||||
@@ -2156,7 +2149,6 @@ inline void Asset::ReadExtensionsRequired(Document &doc) {
|
|||||||
|
|
||||||
CHECK_REQUIRED_EXT(KHR_draco_mesh_compression);
|
CHECK_REQUIRED_EXT(KHR_draco_mesh_compression);
|
||||||
CHECK_REQUIRED_EXT(KHR_texture_basisu);
|
CHECK_REQUIRED_EXT(KHR_texture_basisu);
|
||||||
CHECK_REQUIRED_EXT(EXT_texture_webp);
|
|
||||||
|
|
||||||
#undef CHECK_REQUIRED_EXT
|
#undef CHECK_REQUIRED_EXT
|
||||||
}
|
}
|
||||||
@@ -2187,7 +2179,6 @@ inline void Asset::ReadExtensionsUsed(Document &doc) {
|
|||||||
CHECK_EXT(KHR_materials_anisotropy);
|
CHECK_EXT(KHR_materials_anisotropy);
|
||||||
CHECK_EXT(KHR_draco_mesh_compression);
|
CHECK_EXT(KHR_draco_mesh_compression);
|
||||||
CHECK_EXT(KHR_texture_basisu);
|
CHECK_EXT(KHR_texture_basisu);
|
||||||
CHECK_EXT(EXT_texture_webp);
|
|
||||||
|
|
||||||
#undef CHECK_EXT
|
#undef CHECK_EXT
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1663,7 +1663,7 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) {
|
|||||||
ext = "kx2";
|
ext = "kx2";
|
||||||
} else if (strcmp(ext, "basis") == 0) { // basisu
|
} else if (strcmp(ext, "basis") == 0) { // basisu
|
||||||
ext = "bu";
|
ext = "bu";
|
||||||
} // webp requires no transformation
|
}
|
||||||
|
|
||||||
size_t len = strlen(ext);
|
size_t len = strlen(ext);
|
||||||
if (len > 3) len = 3;
|
if (len > 3) len = 3;
|
||||||
|
|||||||
@@ -457,7 +457,6 @@ ADD_ASSIMP_IMPORTER( MDL
|
|||||||
AssetLib/MDL/MDLLoader.h
|
AssetLib/MDL/MDLLoader.h
|
||||||
AssetLib/MDL/MDLMaterialLoader.cpp
|
AssetLib/MDL/MDLMaterialLoader.cpp
|
||||||
AssetLib/MDL/HalfLife/HalfLifeMDLBaseHeader.h
|
AssetLib/MDL/HalfLife/HalfLifeMDLBaseHeader.h
|
||||||
AssetLib/MDL/HalfLife/HL1DataBuffer.h
|
|
||||||
AssetLib/MDL/HalfLife/HL1FileData.h
|
AssetLib/MDL/HalfLife/HL1FileData.h
|
||||||
AssetLib/MDL/HalfLife/HL1MDLLoader.cpp
|
AssetLib/MDL/HalfLife/HL1MDLLoader.cpp
|
||||||
AssetLib/MDL/HalfLife/HL1MDLLoader.h
|
AssetLib/MDL/HalfLife/HL1MDLLoader.h
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* stb_image - v2.30 - public domain image loader - http://nothings.org/stb
|
/* stb_image - v2.29 - public domain image loader - http://nothings.org/stb
|
||||||
no warranty implied; use at your own risk
|
no warranty implied; use at your own risk
|
||||||
|
|
||||||
Do this:
|
Do this:
|
||||||
@@ -48,7 +48,6 @@ LICENSE
|
|||||||
|
|
||||||
RECENT REVISION HISTORY:
|
RECENT REVISION HISTORY:
|
||||||
|
|
||||||
2.30 (2024-05-31) avoid erroneous gcc warning
|
|
||||||
2.29 (2023-05-xx) optimizations
|
2.29 (2023-05-xx) optimizations
|
||||||
2.28 (2023-01-29) many error fixes, security errors, just tons of stuff
|
2.28 (2023-01-29) many error fixes, security errors, just tons of stuff
|
||||||
2.27 (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes
|
2.27 (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes
|
||||||
@@ -5160,11 +5159,9 @@ static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
|
|||||||
// non-paletted with tRNS = constant alpha. if header-scanning, we can stop now.
|
// non-paletted with tRNS = constant alpha. if header-scanning, we can stop now.
|
||||||
if (scan == STBI__SCAN_header) { ++s->img_n; return 1; }
|
if (scan == STBI__SCAN_header) { ++s->img_n; return 1; }
|
||||||
if (z->depth == 16) {
|
if (z->depth == 16) {
|
||||||
for (k = 0; k < s->img_n && k < 3; ++k) // extra loop test to suppress false GCC warning
|
for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
|
||||||
tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
|
|
||||||
} else {
|
} else {
|
||||||
for (k = 0; k < s->img_n && k < 3; ++k)
|
for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
|
||||||
tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
+4
-4
@@ -32,19 +32,19 @@ DOXYFILE_ENCODING = UTF-8
|
|||||||
# title of most generated pages and in a few other places.
|
# title of most generated pages and in a few other places.
|
||||||
# The default value is: My Project.
|
# The default value is: My Project.
|
||||||
|
|
||||||
PROJECT_NAME = "The Open Asset Importer Lib"
|
PROJECT_NAME = "My Project"
|
||||||
|
|
||||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = "6.0.2"
|
PROJECT_NUMBER =
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
# quick idea about the purpose of the project. Keep the description short.
|
# quick idea about the purpose of the project. Keep the description short.
|
||||||
|
|
||||||
PROJECT_BRIEF = The official Open-Asset-Importer-Library Repository. Loads 40+ 3D-file-formats into one unified and clean data structure.
|
PROJECT_BRIEF =
|
||||||
|
|
||||||
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
|
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
|
||||||
# in the documentation. The maximum height of the logo should not exceed 55
|
# in the documentation. The maximum height of the logo should not exceed 55
|
||||||
@@ -58,7 +58,7 @@ PROJECT_LOGO =
|
|||||||
# entered, it will be relative to the location where doxygen was started. If
|
# entered, it will be relative to the location where doxygen was started. If
|
||||||
# left blank the current directory will be used.
|
# left blank the current directory will be used.
|
||||||
|
|
||||||
OUTPUT_DIRECTORY = out
|
OUTPUT_DIRECTORY =
|
||||||
|
|
||||||
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
|
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
|
||||||
# directories (in 2 levels) under the output directory of each output format and
|
# directories (in 2 levels) under the output directory of each output format and
|
||||||
|
|||||||
@@ -47,11 +47,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
|
||||||
// Limit input size to 1MB to prevent OOMs and timeouts
|
|
||||||
if (dataSize > 1024 * 1024) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
aiLogStream stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT, nullptr);
|
aiLogStream stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT, nullptr);
|
||||||
aiAttachLogStream(&stream);
|
aiAttachLogStream(&stream);
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
# OBJ
|
|
||||||
"v "
|
|
||||||
"vn "
|
|
||||||
"vt "
|
|
||||||
"f "
|
|
||||||
"mtllib "
|
|
||||||
"usemtl "
|
|
||||||
|
|
||||||
# GLTF (JSON)
|
|
||||||
"asset"
|
|
||||||
"scene"
|
|
||||||
"scenes"
|
|
||||||
"nodes"
|
|
||||||
"meshes"
|
|
||||||
"accessors"
|
|
||||||
"bufferViews"
|
|
||||||
"buffers"
|
|
||||||
|
|
||||||
# PLY
|
|
||||||
"ply"
|
|
||||||
"format"
|
|
||||||
"element"
|
|
||||||
"property"
|
|
||||||
"vertex"
|
|
||||||
"face"
|
|
||||||
|
|
||||||
# STL
|
|
||||||
"solid"
|
|
||||||
"facet"
|
|
||||||
"normal"
|
|
||||||
"outer loop"
|
|
||||||
"vertex"
|
|
||||||
"endloop"
|
|
||||||
"endfacet"
|
|
||||||
"endsolid"
|
|
||||||
|
|
||||||
# Collada (XML)
|
|
||||||
"COLLADA"
|
|
||||||
"library_geometries"
|
|
||||||
"library_visual_scenes"
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
Open Asset Import Library (assimp)
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2006-2025, assimp team
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
|
||||||
with or without modification, are permitted provided that the following
|
|
||||||
conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
|
||||||
contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior
|
|
||||||
written permission of the assimp team.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
#include "fuzzer_common.h"
|
|
||||||
#include <assimp/cimport.h>
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/postprocess.h>
|
|
||||||
|
|
||||||
using namespace Assimp;
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
|
|
||||||
if (dataSize > 1024 * 1024) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Importer importer;
|
|
||||||
// Force Collada format (dae)
|
|
||||||
if (!AssimpFuzz::ForceFormat(importer, "dae")) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int flags = aiProcessPreset_TargetRealtime_Quality | aiProcess_ValidateDataStructure;
|
|
||||||
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize, flags, "dae");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
Open Asset Import Library (assimp)
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2006-2025, assimp team
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
|
||||||
with or without modification, are permitted provided that the following
|
|
||||||
conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
|
||||||
contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior
|
|
||||||
written permission of the assimp team.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
#include "fuzzer_common.h"
|
|
||||||
#include <assimp/cimport.h>
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/postprocess.h>
|
|
||||||
|
|
||||||
using namespace Assimp;
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
|
|
||||||
if (dataSize > 1024 * 1024) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Importer importer;
|
|
||||||
// Force GLB binary format only (see assimp_fuzzer_gltf.cc for text glTF)
|
|
||||||
if (!AssimpFuzz::ForceFormat(importer, "glb")) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int flags = aiProcessPreset_TargetRealtime_Quality | aiProcess_ValidateDataStructure;
|
|
||||||
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize, flags, "glb");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
Open Asset Import Library (assimp)
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2006-2025, assimp team
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
|
||||||
with or without modification, are permitted provided that the following
|
|
||||||
conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
|
||||||
contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior
|
|
||||||
written permission of the assimp team.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
#include "fuzzer_common.h"
|
|
||||||
#include <assimp/cimport.h>
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/postprocess.h>
|
|
||||||
|
|
||||||
using namespace Assimp;
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
|
|
||||||
if (dataSize > 1024 * 1024) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Importer importer;
|
|
||||||
// Force glTF text format only (see assimp_fuzzer_glb.cc for binary GLB)
|
|
||||||
if (!AssimpFuzz::ForceFormat(importer, "gltf")) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int flags = aiProcessPreset_TargetRealtime_Quality | aiProcess_ValidateDataStructure;
|
|
||||||
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize, flags, "gltf");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
Open Asset Import Library (assimp)
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2006-2025, assimp team
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
|
||||||
with or without modification, are permitted provided that the following
|
|
||||||
conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
|
||||||
contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior
|
|
||||||
written permission of the assimp team.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
#include "fuzzer_common.h"
|
|
||||||
#include <assimp/cimport.h>
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/postprocess.h>
|
|
||||||
|
|
||||||
using namespace Assimp;
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
|
|
||||||
// Limit input size to 1MB
|
|
||||||
if (dataSize > 1024 * 1024) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Importer importer;
|
|
||||||
// Force OBJ format
|
|
||||||
if (!AssimpFuzz::ForceFormat(importer, "obj")) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int flags = aiProcessPreset_TargetRealtime_Quality | aiProcess_ValidateDataStructure;
|
|
||||||
// We pass "obj" hint as well, though only OBJ loader is registered now.
|
|
||||||
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize, flags, "obj");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
Open Asset Import Library (assimp)
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2006-2025, assimp team
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
|
||||||
with or without modification, are permitted provided that the following
|
|
||||||
conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
|
||||||
contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior
|
|
||||||
written permission of the assimp team.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
#include "fuzzer_common.h"
|
|
||||||
#include <assimp/cimport.h>
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/postprocess.h>
|
|
||||||
|
|
||||||
using namespace Assimp;
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
|
|
||||||
if (dataSize > 1024 * 1024) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Importer importer;
|
|
||||||
// Force STL format
|
|
||||||
if (!AssimpFuzz::ForceFormat(importer, "stl")) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int flags = aiProcessPreset_TargetRealtime_Quality | aiProcess_ValidateDataStructure;
|
|
||||||
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize, flags, "stl");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
/*
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
Open Asset Import Library (assimp)
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2006-2025, assimp team
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
|
||||||
with or without modification, are permitted provided that the following
|
|
||||||
conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
|
||||||
contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior
|
|
||||||
written permission of the assimp team.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/BaseImporter.h>
|
|
||||||
#include <assimp/importerdesc.h>
|
|
||||||
#include <cstring>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace AssimpFuzz {
|
|
||||||
|
|
||||||
// Unregisters all loaders except the ones matching the given extension.
|
|
||||||
// Returns true if at least one loader was kept.
|
|
||||||
inline bool ForceFormat(Assimp::Importer& importer, const char* targetExtension) {
|
|
||||||
size_t count = importer.GetImporterCount();
|
|
||||||
std::vector<Assimp::BaseImporter*> toRemove;
|
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < count; ++i) {
|
|
||||||
const aiImporterDesc* desc = importer.GetImporterInfo(i);
|
|
||||||
Assimp::BaseImporter* imp = importer.GetImporter(i);
|
|
||||||
|
|
||||||
if (!desc || !imp) continue;
|
|
||||||
|
|
||||||
// Check if the importer supports the target extension
|
|
||||||
// mFileExtensions is a space-separated list (e.g., "obj mod")
|
|
||||||
// We wrap target in spaces or check bounds to be precise,
|
|
||||||
// but for fuzzing, a simple strstr is usually sufficient
|
|
||||||
// if the target string is unique enough (e.g. "gltf", "obj").
|
|
||||||
// A more robust check:
|
|
||||||
|
|
||||||
bool isTarget = false;
|
|
||||||
const char* extList = desc->mFileExtensions;
|
|
||||||
if (!extList) {
|
|
||||||
toRemove.push_back(imp);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const size_t targetLen = strlen(targetExtension);
|
|
||||||
|
|
||||||
const char* p = extList;
|
|
||||||
while ((p = strstr(p, targetExtension)) != nullptr) {
|
|
||||||
// Check boundaries
|
|
||||||
const char prev = (p == extList) ? ' ' : *(p - 1);
|
|
||||||
const char next = *(p + targetLen);
|
|
||||||
|
|
||||||
if (prev == ' ' && (next == ' ' || next == '\0')) {
|
|
||||||
isTarget = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isTarget) {
|
|
||||||
found = true;
|
|
||||||
} else {
|
|
||||||
toRemove.push_back(imp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto* imp : toRemove) {
|
|
||||||
importer.UnregisterLoader(imp);
|
|
||||||
delete imp; // Free the unregistered importer to prevent memory leaks
|
|
||||||
}
|
|
||||||
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
# Copyright 2021 Google LLC
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
FROM gcr.io/oss-fuzz-base/base-builder
|
|
||||||
RUN apt-get update && apt-get install -y make autoconf automake libtool ninja-build cmake zip
|
|
||||||
|
|
||||||
RUN git clone --depth 1 https://github.com/assimp/assimp.git assimp
|
|
||||||
WORKDIR assimp
|
|
||||||
COPY build.sh $SRC/
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
#!/bin/bash -eu
|
|
||||||
|
|
||||||
# Build directory
|
|
||||||
mkdir -p build
|
|
||||||
cd build
|
|
||||||
|
|
||||||
# Configure
|
|
||||||
cmake .. \
|
|
||||||
-G Ninja \
|
|
||||||
-DCMAKE_C_COMPILER="${CC}" \
|
|
||||||
-DCMAKE_CXX_COMPILER="${CXX}" \
|
|
||||||
-DCMAKE_C_FLAGS="${CFLAGS}" \
|
|
||||||
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
|
|
||||||
-DASSIMP_BUILD_ZLIB=ON \
|
|
||||||
-DASSIMP_BUILD_TESTS=OFF \
|
|
||||||
-DASSIMP_BUILD_ASSIMP_TOOLS=OFF \
|
|
||||||
-DBUILD_SHARED_LIBS=OFF \
|
|
||||||
-DASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=ON \
|
|
||||||
-DASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT=ON
|
|
||||||
|
|
||||||
# Build the library
|
|
||||||
ninja
|
|
||||||
|
|
||||||
# Helper function to build fuzzers
|
|
||||||
build_fuzzer() {
|
|
||||||
local fuzzer_name=$1
|
|
||||||
local source_file=$2
|
|
||||||
|
|
||||||
echo "Building $fuzzer_name..."
|
|
||||||
$CXX $CXXFLAGS -I../include -I../build/include -c "$source_file" -o "${fuzzer_name}.o"
|
|
||||||
|
|
||||||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE "${fuzzer_name}.o" -o "$OUT/${fuzzer_name}" \
|
|
||||||
./lib/libassimp.a \
|
|
||||||
./contrib/zlib/libzlibstatic.a \
|
|
||||||
-lpthread -ldl
|
|
||||||
}
|
|
||||||
|
|
||||||
# 1. Generic Fuzzer
|
|
||||||
build_fuzzer "assimp_fuzzer" "../fuzz/assimp_fuzzer.cc"
|
|
||||||
# Corpus for generic fuzzer (all models)
|
|
||||||
(cd ../test/models && zip -q -r $OUT/assimp_fuzzer_seed_corpus.zip .)
|
|
||||||
# Dictionary
|
|
||||||
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer.dict || true
|
|
||||||
|
|
||||||
|
|
||||||
# 2. OBJ Fuzzer
|
|
||||||
build_fuzzer "assimp_fuzzer_obj" "../fuzz/assimp_fuzzer_obj.cc"
|
|
||||||
if [ -d "../test/models/OBJ" ]; then
|
|
||||||
(cd ../test/models/OBJ && zip -q -r $OUT/assimp_fuzzer_obj_seed_corpus.zip .)
|
|
||||||
fi
|
|
||||||
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer_obj.dict || true
|
|
||||||
|
|
||||||
|
|
||||||
# 3. GLTF Fuzzer (text format only, glTF and glTF2 versions)
|
|
||||||
build_fuzzer "assimp_fuzzer_gltf" "../fuzz/assimp_fuzzer_gltf.cc"
|
|
||||||
mkdir -p gltf_corpus
|
|
||||||
[ -d "../test/models/glTF" ] && cp -r ../test/models/glTF/* gltf_corpus/
|
|
||||||
[ -d "../test/models/glTF2" ] && cp -r ../test/models/glTF2/* gltf_corpus/
|
|
||||||
if [ -d "gltf_corpus" ] && [ "$(ls -A gltf_corpus)" ]; then
|
|
||||||
(cd gltf_corpus && zip -q -r $OUT/assimp_fuzzer_gltf_seed_corpus.zip .)
|
|
||||||
fi
|
|
||||||
rm -rf gltf_corpus
|
|
||||||
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer_gltf.dict || true
|
|
||||||
|
|
||||||
|
|
||||||
# 4. GLB Fuzzer (binary glTF format)
|
|
||||||
build_fuzzer "assimp_fuzzer_glb" "../fuzz/assimp_fuzzer_glb.cc"
|
|
||||||
mkdir -p glb_corpus
|
|
||||||
# GLB files can be found in glTF and glTF2 directories
|
|
||||||
[ -d "../test/models/glTF" ] && find ../test/models/glTF -name "*.glb" -exec cp {} glb_corpus/ \; 2>/dev/null || true
|
|
||||||
[ -d "../test/models/glTF2" ] && find ../test/models/glTF2 -name "*.glb" -exec cp {} glb_corpus/ \; 2>/dev/null || true
|
|
||||||
if [ -d "glb_corpus" ] && [ "$(ls -A glb_corpus)" ]; then
|
|
||||||
(cd glb_corpus && zip -q -r $OUT/assimp_fuzzer_glb_seed_corpus.zip .)
|
|
||||||
fi
|
|
||||||
rm -rf glb_corpus
|
|
||||||
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer_glb.dict || true
|
|
||||||
|
|
||||||
|
|
||||||
# 5. FBX Fuzzer
|
|
||||||
build_fuzzer "assimp_fuzzer_fbx" "../fuzz/assimp_fuzzer_fbx.cc"
|
|
||||||
if [ -d "../test/models/FBX" ]; then
|
|
||||||
(cd ../test/models/FBX && zip -q -r $OUT/assimp_fuzzer_fbx_seed_corpus.zip .)
|
|
||||||
fi
|
|
||||||
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer_fbx.dict || true
|
|
||||||
|
|
||||||
|
|
||||||
# 6. Collada Fuzzer
|
|
||||||
build_fuzzer "assimp_fuzzer_collada" "../fuzz/assimp_fuzzer_collada.cc"
|
|
||||||
if [ -d "../test/models/Collada" ]; then
|
|
||||||
(cd ../test/models/Collada && zip -q -r $OUT/assimp_fuzzer_collada_seed_corpus.zip .)
|
|
||||||
fi
|
|
||||||
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer_collada.dict || true
|
|
||||||
|
|
||||||
|
|
||||||
# 7. STL Fuzzer
|
|
||||||
build_fuzzer "assimp_fuzzer_stl" "../fuzz/assimp_fuzzer_stl.cc"
|
|
||||||
if [ -d "../test/models/STL" ]; then
|
|
||||||
(cd ../test/models/STL && zip -q -r $OUT/assimp_fuzzer_stl_seed_corpus.zip .)
|
|
||||||
fi
|
|
||||||
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer_stl.dict || true
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
homepage: "https://github.com/assimp/assimp"
|
|
||||||
main_repo: "https://github.com/assimp/assimp"
|
|
||||||
language: c++
|
|
||||||
primary_contact: "kim.kulling@assimp.org"
|
|
||||||
auto_ccs:
|
|
||||||
- "kim.kulling@googlemail.com"
|
|
||||||
sanitizers:
|
|
||||||
- address
|
|
||||||
- undefined
|
|
||||||
- memory
|
|
||||||
fuzzing_engines:
|
|
||||||
- libfuzzer
|
|
||||||
- afl
|
|
||||||
- honggfuzz
|
|
||||||
+2
-12
@@ -147,6 +147,8 @@ SET( IMPORTERS
|
|||||||
unit/utBlendImportMaterials.cpp
|
unit/utBlendImportMaterials.cpp
|
||||||
unit/utBlenderWork.cpp
|
unit/utBlenderWork.cpp
|
||||||
unit/utBVHImportExport.cpp
|
unit/utBVHImportExport.cpp
|
||||||
|
unit/utColladaExport.cpp
|
||||||
|
unit/utColladaImportExport.cpp
|
||||||
unit/utCSMImportExport.cpp
|
unit/utCSMImportExport.cpp
|
||||||
unit/utB3DImportExport.cpp
|
unit/utB3DImportExport.cpp
|
||||||
#unit/utM3DImportExport.cpp
|
#unit/utM3DImportExport.cpp
|
||||||
@@ -178,18 +180,6 @@ if(ASSIMP_BUILD_USD_IMPORTER)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ASSIMP_BUILD_COLLADA_EXPORTER)
|
|
||||||
list( APPEND IMPORTERS
|
|
||||||
unit/utColladaExport.cpp
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(ASSIMP_BUILD_COLLADA_IMPORTER)
|
|
||||||
list( APPEND IMPORTERS
|
|
||||||
unit/utColladaImportExport.cpp
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
SET( MATERIAL
|
SET( MATERIAL
|
||||||
unit/utMaterialSystem.cpp
|
unit/utMaterialSystem.cpp
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2025, assimp team
|
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the
|
||||||
conditions are met:
|
following conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
@@ -36,28 +34,7 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "fuzzer_common.h"
|
//
|
||||||
#include <assimp/cimport.h>
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/postprocess.h>
|
|
||||||
|
|
||||||
using namespace Assimp;
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
|
|
||||||
if (dataSize > 1024 * 1024) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Importer importer;
|
|
||||||
// Force FBX format
|
|
||||||
if (!AssimpFuzz::ForceFormat(importer, "fbx")) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int flags = aiProcessPreset_TargetRealtime_Quality | aiProcess_ValidateDataStructure;
|
|
||||||
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize, flags, "fbx");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user