Compare commits
114
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
676ef9637b | ||
|
|
70459b4d1f | ||
|
|
45898eee55 | ||
|
|
f52fcb6052 | ||
|
|
2bce77f909 | ||
|
|
5d716b8fe0 | ||
|
|
b58afb7b83 | ||
|
|
7945359a5c | ||
|
|
9bb6f2e1b8 | ||
|
|
7efb98db27 | ||
|
|
f967e76493 | ||
|
|
d41511bf8a | ||
|
|
53b5dba4df | ||
|
|
9f3cd51a87 | ||
|
|
bc47836a8f | ||
|
|
2aac984fa3 | ||
|
|
31f0dcb4d1 | ||
|
|
f13197921b | ||
|
|
d91e0e4f42 | ||
|
|
ba4455c9c0 | ||
|
|
79d451bf4b | ||
|
|
2a0969d4d9 | ||
|
|
1e44036c36 | ||
|
|
2f6dcdfd72 | ||
|
|
e722420907 | ||
|
|
8e44b40df4 | ||
|
|
5aa38fe3cd | ||
|
|
0834fed661 | ||
|
|
f2c6aa15ed | ||
|
|
5fa7b8ceb9 | ||
|
|
d386309af9 | ||
|
|
2f40a77ae1 | ||
|
|
a4d8a5fec3 | ||
|
|
bbeb515421 | ||
|
|
437b484070 | ||
|
|
d70606bfb6 | ||
|
|
69558d8889 | ||
|
|
5e091572d5 | ||
|
|
ab5b32ecc7 | ||
|
|
7bd54e3604 | ||
|
|
258cdfd2bc | ||
|
|
016be03c3d | ||
|
|
1ce3164bc2 | ||
|
|
9f3a7e95ab | ||
|
|
ecc8a1c869 | ||
|
|
2090508c34 | ||
|
|
2b773f0f5a | ||
|
|
7a114059cd | ||
|
|
862abe410b | ||
|
|
76d22e5fbe | ||
|
|
f12e521986 | ||
|
|
28ebc8452b | ||
|
|
46c26eda5a | ||
|
|
bddc374b5a | ||
|
|
164a5ae8cf | ||
|
|
ff61095928 | ||
|
|
ca17cdc1f9 | ||
|
|
739ebfd207 | ||
|
|
72c51a9997 | ||
|
|
2493deff37 | ||
|
|
12f3309996 | ||
|
|
02d3887e9a | ||
|
|
09f6a5e136 | ||
|
|
5f100a0984 | ||
|
|
795d4897db | ||
|
|
6fad13c82b | ||
|
|
48bd7c3e22 | ||
|
|
c867ddbc04 | ||
|
|
41cc2f66a4 | ||
|
|
f5fb8ff842 | ||
|
|
c9bbbcf633 | ||
|
|
e7a6d33365 | ||
|
|
9723b3554b | ||
|
|
f7bb1bc170 | ||
|
|
9694f7e8e4 | ||
|
|
6520354a58 | ||
|
|
e06b80f6b0 | ||
|
|
401279e2f9 | ||
|
|
7634cf84ca | ||
|
|
ec563823b6 | ||
|
|
287d7ec213 | ||
|
|
8d5cc3c5d5 | ||
|
|
e699d23559 | ||
|
|
53d4663f29 | ||
|
|
f6c62605c7 | ||
|
|
720eae1396 | ||
|
|
e4ef89182d | ||
|
|
fffce70fce | ||
|
|
a383cb1ff7 | ||
|
|
4b9ac76815 | ||
|
|
2591d0e490 | ||
|
|
ce0a50ec21 | ||
|
|
811bf2df15 | ||
|
|
cb4e663138 | ||
|
|
9934a8d1cc | ||
|
|
56ea25f9eb | ||
|
|
ecdf8d24b8 | ||
|
|
1d99895e91 | ||
|
|
97257a3bcc | ||
|
|
17399d198f | ||
|
|
f63625256c | ||
|
|
f4c7606faf | ||
|
|
66187a77cf | ||
|
|
5c7acc968b | ||
|
|
f81ea6986c | ||
|
|
ab12e8d8ba | ||
|
|
3bd98611d7 | ||
|
|
d468e633b1 | ||
|
|
4024726eca | ||
|
|
cd0ef869e3 | ||
|
|
ed3fccd5db | ||
|
|
ff2dc2fb2e | ||
|
|
f69e55058d | ||
|
|
c1ffbfec06 |
@@ -0,0 +1,52 @@
|
||||
name: Build and Publish Prebuilt Binaries
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: windows-x64
|
||||
os: windows-latest
|
||||
arch: x64
|
||||
- name: windows-x86
|
||||
os: windows-latest
|
||||
arch: x86
|
||||
cmake_args: -A Win32
|
||||
- name: macos-x64
|
||||
os: macos-13
|
||||
- name: macos-arm64
|
||||
os: macos-latest
|
||||
- name: linux-x64
|
||||
os: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
|
||||
- uses: lukka/get-cmake@latest
|
||||
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: ${{ matrix.arch }}
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake -B build -S . ${{ matrix.cmake_args }} -DCMAKE_BUILD_TYPE=Release -DASSIMP_BUILD_TESTS=OFF
|
||||
cmake --build build --config Release
|
||||
|
||||
- uses: TheDoctor0/zip-release@0.7.6
|
||||
with:
|
||||
filename: ${{ matrix.name }}-${{ github.event.release.tag_name }}.zip
|
||||
directory: build/bin/
|
||||
|
||||
- uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: build/bin/${{ matrix.name }}-${{ github.event.release.tag_name }}.zip
|
||||
append_body: true
|
||||
fail_on_unmatched_files: true
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
buildDirectory: '${{ github.workspace }}/build/'
|
||||
|
||||
- name: Compile .ISS to .EXE Installer
|
||||
uses: Minionguyjpro/Inno-Setup-Action@v1.2.2
|
||||
uses: Minionguyjpro/Inno-Setup-Action@v1.2.5
|
||||
with:
|
||||
path: packaging/windows-innosetup/script_x64.iss
|
||||
options: /O+
|
||||
|
||||
@@ -122,5 +122,7 @@ tools/assimp_qt_viewer/ui_mainwindow.h
|
||||
generated/*
|
||||
|
||||
# 3rd party cloned repos/tarballs etc
|
||||
# meshlab repo, automatically cloned via CMake (to gain 2 source files for VRML file format conversion)
|
||||
contrib/meshlab/autoclone
|
||||
# tinyusdz repo, automatically cloned via CMake
|
||||
contrib/tinyusdz/autoclone
|
||||
|
||||
@@ -1,36 +1,10 @@
|
||||
# Build / Install Instructions
|
||||
|
||||
## Install on all platforms using vcpkg
|
||||
You can download and install assimp using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
|
||||
```bash
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.sh
|
||||
./vcpkg integrate install
|
||||
./vcpkg install assimp
|
||||
```
|
||||
The assimp port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||
|
||||
## Install on Ubuntu
|
||||
You can install the Asset-Importer-Lib via apt:
|
||||
```
|
||||
sudo apt-get update
|
||||
sudo apt-get install libassimp-dev
|
||||
```
|
||||
|
||||
## Install pyassimp
|
||||
You need to have pip installed:
|
||||
```
|
||||
pip install pyassimp
|
||||
```
|
||||
|
||||
## Manual build instructions
|
||||
|
||||
### Install CMake
|
||||
Asset-Importer-Lib can be built for a lot of different platforms. We are using cmake to generate the build environment for these via cmake. So you have to make sure that you have a working cmake-installation on your system. You can download it at https://cmake.org/ or for linux install it via
|
||||
```bash
|
||||
sudo apt-get install cmake
|
||||
```
|
||||
### Install prerequisites
|
||||
You need to install
|
||||
* cmake
|
||||
* Your compiler
|
||||
|
||||
### Get the source
|
||||
Make sure you have a working git-installation. Open a command prompt and clone the Asset-Importer-Lib via:
|
||||
@@ -38,15 +12,22 @@ Make sure you have a working git-installation. Open a command prompt and clone t
|
||||
git clone https://github.com/assimp/assimp.git
|
||||
```
|
||||
### Build from source:
|
||||
* For *assimp.lib* without any tools:
|
||||
```bash
|
||||
cd assimp
|
||||
cmake CMakeLists.txt
|
||||
cmake CMakeLists.txt
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
* For assimp with the common tools like *assimp-cmd*
|
||||
```bash
|
||||
cd assimp
|
||||
cmake CMakeLists.txt -DASSIMP_BUILD_ASSIMP_TOOLS=ON
|
||||
cmake --build .
|
||||
```
|
||||
Note that by default this builds a shared library into the `bin` directory. If you want to build it as a static library see the build options at the bottom of this file.
|
||||
|
||||
### Build instructions for Windows with Visual-Studio
|
||||
|
||||
First, you have to install Visual-Studio on your windows-system. You can get the Community-Version for free here: https://visualstudio.microsoft.com/de/downloads/
|
||||
To generate the build environment for your IDE open a command prompt, navigate to your repo and type:
|
||||
```bash
|
||||
@@ -57,17 +38,6 @@ This will generate the project files for the visual studio. All dependencies use
|
||||
### Build instructions for Windows with UWP
|
||||
See <https://stackoverflow.com/questions/40803170/cmake-uwp-using-cmake-to-build-universal-windows-app>
|
||||
|
||||
### Build instructions for Linux / Unix
|
||||
Open a terminal and got to your repository. You can generate the makefiles and build the library via:
|
||||
|
||||
```bash
|
||||
cmake CMakeLists.txt
|
||||
make -j4
|
||||
```
|
||||
The option -j describes the number of parallel processes for the build. In this case make will try to use 4 cores for the build.
|
||||
|
||||
If you want to use an IDE for linux you can try QTCreator for instance.
|
||||
|
||||
### Build instructions for MinGW
|
||||
Older versions of MinGW's compiler (e.g. 5.1.0) do not support the -mbig_obj flag
|
||||
required to compile some of assimp's files, especially for debug builds.
|
||||
@@ -111,3 +81,31 @@ The cmake-build-environment provides options to configure the build. The followi
|
||||
- **USE_STATIC_CRT (default OFF)**: Link against the static MSVC runtime libraries.
|
||||
- **ASSIMP_BUILD_DRACO (default OFF)**: Build Draco libraries. Primarily for glTF.
|
||||
- **ASSIMP_BUILD_ASSIMP_VIEW (default ON, if DirectX found, OFF otherwise)**: Build Assimp view tool (requires DirectX).
|
||||
|
||||
### Install prebuild binaries
|
||||
## Install on all platforms using vcpkg
|
||||
You can download and install assimp using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
|
||||
```bash
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.sh
|
||||
./vcpkg integrate install
|
||||
./vcpkg install assimp
|
||||
```
|
||||
The assimp port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||
|
||||
### Install on Ubuntu
|
||||
You can install the Asset-Importer-Lib via apt:
|
||||
```
|
||||
sudo apt-get update
|
||||
sudo apt-get install libassimp-dev
|
||||
```
|
||||
|
||||
### Install pyassimp
|
||||
You need to have pip installed:
|
||||
```
|
||||
pip install pyassimp
|
||||
```
|
||||
|
||||
### Get the SDK from itchi.io
|
||||
Just check [itchi.io](https://kimkulling.itch.io/the-asset-importer-lib)
|
||||
|
||||
+56
-24
@@ -1,6 +1,6 @@
|
||||
# Open Asset Import Library (assimp)
|
||||
# ----------------------------------------------------------------------
|
||||
# Copyright (c) 2006-2024, assimp team
|
||||
# Copyright (c) 2006-2025, assimp team
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
@@ -40,12 +40,47 @@ SET(CMAKE_POLICY_DEFAULT_CMP0092 NEW)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED( VERSION 3.22 )
|
||||
|
||||
#================================================================================#
|
||||
# Model formats not enabled by default
|
||||
#
|
||||
# 3rd party projects may not adhere to strict standards enforced by assimp,
|
||||
# in which case those formats must be opt-in; otherwise the 3rd party code
|
||||
# would fail assimp CI checks
|
||||
#================================================================================#
|
||||
# M3D format import support (assimp integration no longer supported by M3D format author)
|
||||
# User may override these in their CMake script to provide M3D import/export support
|
||||
# (M3D importer/exporter was disabled for assimp release 5.1 or later)
|
||||
option(ASSIMP_BUILD_M3D_IMPORTER "Enable M3D file import" off)
|
||||
option(ASSIMP_BUILD_M3D_EXPORTER "Enable M3D file export" off)
|
||||
|
||||
# Experimental USD importer: disabled, need to opt-in
|
||||
# Note: assimp github PR automatic checks will fail the PR due to compiler warnings in
|
||||
# the external, 3rd party tinyusdz code which isn't technically part of the PR since it's
|
||||
# auto-cloned during build; so MUST disable the feature or the PR will be rejected
|
||||
option(ASSIMP_BUILD_USD_IMPORTER "Enable USD file import" off)
|
||||
option(ASSIMP_BUILD_USD_VERBOSE_LOGS "Enable verbose USD import debug logging" off)
|
||||
|
||||
# VRML (.wrl/.x3dv) file import support by leveraging X3D importer and 3rd party file
|
||||
# format converter to convert .wrl/.x3dv files to X3D-compatible .xml
|
||||
# (Need to make this opt-in because 3rd party code triggers lots of CI code quality warnings)
|
||||
option(ASSIMP_BUILD_VRML_IMPORTER "Enable VRML (.wrl/.x3dv) file import" off)
|
||||
#--------------------------------------------------------------------------------#
|
||||
# Internal impl for optional model formats
|
||||
#--------------------------------------------------------------------------------#
|
||||
# Internal/private M3D logic
|
||||
if (NOT ASSIMP_BUILD_M3D_IMPORTER)
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_M3D_IMPORTER)
|
||||
endif () # if (not ASSIMP_BUILD_M3D_IMPORTER)
|
||||
if (NOT ASSIMP_BUILD_M3D_EXPORTER)
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||
endif () # if (not ASSIMP_BUILD_M3D_EXPORTER)
|
||||
|
||||
# Internal/private VRML logic
|
||||
if (NOT ASSIMP_BUILD_VRML_IMPORTER)
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_VRML_IMPORTER)
|
||||
endif () # if (not ASSIMP_BUILD_VRML_IMPORTER)
|
||||
#================================================================================#
|
||||
|
||||
option(ASSIMP_BUILD_USE_CCACHE "Use ccache to speed up compilation." on)
|
||||
|
||||
if(ASSIMP_BUILD_USE_CCACHE)
|
||||
@@ -56,17 +91,14 @@ if(ASSIMP_BUILD_USE_CCACHE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Disabled importers: m3d for 5.1 or later
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_M3D_IMPORTER)
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||
# Toggles the use of the hunter package manager
|
||||
option(ASSIMP_HUNTER_ENABLED "Enable Hunter package manager support" OFF)
|
||||
|
||||
IF(ASSIMP_HUNTER_ENABLED)
|
||||
include("cmake-modules/HunterGate.cmake")
|
||||
HunterGate(
|
||||
URL "https://github.com/cpp-pm/hunter/archive/v0.25.5.tar.gz"
|
||||
SHA1 "a20151e4c0740ee7d0f9994476856d813cdead29"
|
||||
URL "https://github.com/cpp-pm/hunter/archive/v0.25.8.tar.gz"
|
||||
SHA1 "26c79d587883ec910bce168e25f6ac4595f97033"
|
||||
)
|
||||
add_definitions(-DASSIMP_USE_HUNTER)
|
||||
ENDIF()
|
||||
@@ -279,7 +311,7 @@ IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT MINGW AND NOT HAIKU)
|
||||
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
ENDIF()
|
||||
|
||||
IF(CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 13)
|
||||
IF(CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 13 AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
MESSAGE(STATUS "GCC13 detected disabling \"-Wdangling-reference\" in Cpp files as it appears to be a false positive")
|
||||
ADD_COMPILE_OPTIONS("$<$<COMPILE_LANGUAGE:CXX>:-Wno-dangling-reference>")
|
||||
ENDIF()
|
||||
@@ -873,24 +905,24 @@ if(WIN32)
|
||||
IF(MSVC12 OR MSVC14 OR MSVC15 )
|
||||
ADD_CUSTOM_TARGET(UpdateAssimpLibsDebugSymbolsAndDLLs COMMENT "Copying Assimp Libraries ..." VERBATIM)
|
||||
IF(CMAKE_GENERATOR MATCHES "^Visual Studio")
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
|
||||
ELSE()
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mt.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mt.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mt.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mt.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF ()
|
||||
|
||||
+7
-12
@@ -1,22 +1,17 @@
|
||||
FROM ubuntu:22.04
|
||||
FROM gcc:latest
|
||||
|
||||
RUN apt-get update && apt-get install --no-install-recommends -y ninja-build \
|
||||
git cmake build-essential software-properties-common
|
||||
RUN apt-get update && apt-get install --no-install-recommends -y ninja-build cmake
|
||||
|
||||
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get update
|
||||
|
||||
WORKDIR /opt
|
||||
WORKDIR /app
|
||||
RUN apt install zlib1g-dev
|
||||
|
||||
# Build Assimp
|
||||
RUN git clone https://github.com/assimp/assimp.git /opt/assimp
|
||||
COPY . .
|
||||
|
||||
WORKDIR /opt/assimp
|
||||
|
||||
RUN git checkout master \
|
||||
&& mkdir build && cd build && \
|
||||
RUN mkdir build && cd build && \
|
||||
cmake -G 'Ninja' \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DASSIMP_BUILD_ASSIMP_TOOLS=ON \
|
||||
.. && \
|
||||
ninja -j4 && ninja install
|
||||
|
||||
CMD ["/app/build/bin/unit"]
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
Open Asset Import Library (assimp)
|
||||
==================================
|
||||
|
||||
Open Asset Import Library is a library to load various 3d file formats into a shared, in-memory format. It supports more than __40 file formats__ for import and a growing selection of file formats for export.
|
||||
Open Asset Import Library is a library that loads various 3D file formats into a shared, in-memory format. It supports more than __40 file formats__ for import and a growing selection of file formats for export.
|
||||
|
||||
### Current project status ###
|
||||
[](https://opencollective.com/assimp)
|
||||
### Current project status ###
|
||||

|
||||
[](https://www.codacy.com/gh/assimp/assimp/dashboard?utm_source=github.com&utm_medium=referral&utm_content=assimp/assimp&utm_campaign=Badge_Grade)
|
||||
[](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://sonarcloud.io/summary/new_code?id=assimp_assimp)
|
||||
[](http://isitmaintained.com/project/assimp/assimp "Average time to resolve an issue")
|
||||
[](http://isitmaintained.com/project/assimp/assimp "Percentage of issues still open")
|
||||
[](https://gurubase.io/g/assimp)
|
||||
[](https://opencollective.com/assimp)
|
||||
<br>
|
||||
|
||||
APIs are provided for C and C++. There are various bindings to other languages (C#, Java, Python, Delphi, D). Assimp also runs on Android and iOS.
|
||||
APIs are provided for C and C++. Various bindings exist to other languages (C#, Java, Python, Delphi, D). Assimp also runs on Android and iOS.
|
||||
Additionally, assimp features various __mesh post-processing tools__: normals and tangent space generation, triangulation, vertex cache locality optimization, removal of degenerate primitives and duplicate vertices, sorting by primitive type, merging of redundant materials and many more.
|
||||
|
||||
## Project activity ##
|
||||

|
||||
|
||||
### Documentation ###
|
||||
Read [our latest documentation](https://assimp-docs.readthedocs.io/en/latest/).
|
||||
|
||||
@@ -29,7 +33,7 @@ Clone [our model database](https://github.com/assimp/assimp-mdb).
|
||||
- Find us on [https://discord.gg/s9KJfaem](https://discord.gg/kKazXMXDy2)
|
||||
- Ask [the Assimp community on Reddit](https://www.reddit.com/r/Assimp/).
|
||||
- Ask on [StackOverflow with the assimp-tag](http://stackoverflow.com/questions/tagged/assimp?sort=newest).
|
||||
- Nothing has worked? File a question or an issue-report at [The Assimp-Issue Tracker](https://github.com/assimp/assimp/issues)
|
||||
- Nothing has worked? File a question or an issue report at [The Assimp-Issue Tracker](https://github.com/assimp/assimp/issues)
|
||||
|
||||
#### Supported file formats ####
|
||||
See [the complete list of supported formats](https://github.com/assimp/assimp/blob/master/doc/Fileformats.md).
|
||||
@@ -40,18 +44,18 @@ Start by reading [our build instructions](https://github.com/assimp/assimp/blob/
|
||||
### Ports ###
|
||||
* [Android](port/AndroidJNI/README.md)
|
||||
* [Python](port/PyAssimp/README.md)
|
||||
* [.NET](https://bitbucket.org/Starnick/assimpnet/src/master/)
|
||||
* [.NET](https://github.com/Saalvage/AssimpNetter)
|
||||
* [Pascal](port/AssimpPascal/Readme.md)
|
||||
* [Javascript (Alpha)](https://github.com/makc/assimp2json)
|
||||
* [Javascript/Node.js Interface](https://github.com/kovacsv/assimpjs)
|
||||
* [Unity 3d Plugin](https://ricardoreis.net/trilib-2/)
|
||||
* [Unreal Engine Plugin](https://github.com/irajsb/UE4_Assimp/)
|
||||
* [JVM](https://github.com/kotlin-graphics/assimp) Full jvm port (current [status](https://github.com/kotlin-graphics/assimp/wiki/Status))
|
||||
* [JVM](https://github.com/kotlin-graphics/assimp) Full JVM port (current [status](https://github.com/kotlin-graphics/assimp/wiki/Status))
|
||||
* [HAXE-Port](https://github.com/longde123/assimp-haxe) The Assimp-HAXE-port.
|
||||
* [Rust](https://github.com/jkvargas/russimp)
|
||||
|
||||
### Other tools ###
|
||||
[open3mod](https://github.com/acgessler/open3mod) is a powerful 3D model viewer based on Assimp's import and export abilities.
|
||||
[Qt5-ModelViewer](https://github.com/sharjith/ModelViewer-Qt5) is a powerful viewer based on Qt5 and Assimp's import and export abilities.<br>
|
||||
[Assimp-Viewer](https://github.com/assimp/assimp_view) is an experimental implementation for an Asset-Viewer based on ImGUI and Assimp (experimental).
|
||||
|
||||
#### Repository structure ####
|
||||
@@ -59,7 +63,7 @@ Open Asset Import Library is implemented in C++. The directory structure looks l
|
||||
|
||||
/code Source code
|
||||
/contrib Third-party libraries
|
||||
/doc Documentation (doxysource and pre-compiled docs)
|
||||
/doc Documentation (Doxygen source and pre-compiled docs)
|
||||
/fuzz Contains the test code for the Google Fuzzer project
|
||||
/include Public header C and C++ header files
|
||||
/scripts Scripts are used to generate the loading code for some formats
|
||||
@@ -79,7 +83,7 @@ The source code is organized in the following way:
|
||||
code/AssetLib/<FormatName> Implementation for import and export of the format
|
||||
|
||||
### Contributing ###
|
||||
Contributions to assimp are highly appreciated. The easiest way to get involved is to submit
|
||||
I would greatly appreciate contributing to assimp. The easiest way to get involved is to submit
|
||||
a pull request with your changes against the main repository's `master` branch.
|
||||
|
||||
## Contributors
|
||||
@@ -101,7 +105,7 @@ Become a financial contributor and help us sustain our community. [[Contribute](
|
||||
|
||||
#### Organizations
|
||||
|
||||
Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/assimp/contribute)]
|
||||
You can support the project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/assimp/contribute)]
|
||||
|
||||
<a href="https://opencollective.com/assimp/organization/0/website"><img src="https://opencollective.com/assimp/organization/0/avatar.svg"></a>
|
||||
|
||||
@@ -111,6 +115,3 @@ Our license is based on the modified, __3-clause BSD__-License.
|
||||
An _informal_ summary is: do whatever you want, but include Assimp's license text with your product -
|
||||
and don't sue us if our code doesn't work. Note that, unlike LGPLed code, you may link statically to Assimp.
|
||||
For the legal details, see the `LICENSE` file.
|
||||
|
||||
### Why this name ###
|
||||
Sorry, we're germans :-), no English native speakers ...
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# See <http://EditorConfig.org> for details
|
||||
|
||||
[*.{h,hpp,c,cpp}]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -643,11 +643,17 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene *pcSOut, aiNode *pcOut,
|
||||
}
|
||||
|
||||
// Allocate storage for children
|
||||
pcOut->mNumChildren = (unsigned int)pcIn->mChildren.size();
|
||||
const unsigned int size = static_cast<unsigned int>(pcIn->mChildren.size());
|
||||
|
||||
pcOut->mNumChildren = size;
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
pcOut->mChildren = new aiNode *[pcIn->mChildren.size()];
|
||||
|
||||
// Recursively process all children
|
||||
const unsigned int size = static_cast<unsigned int>(pcIn->mChildren.size());
|
||||
|
||||
for (unsigned int i = 0; i < size; ++i) {
|
||||
pcOut->mChildren[i] = new aiNode();
|
||||
pcOut->mChildren[i]->mParent = pcOut;
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -103,7 +102,7 @@ private:
|
||||
// preserves the mesh's given name if it has one. |index| is the index
|
||||
// of the mesh in |aiScene::mMeshes|.
|
||||
std::string GetMeshName(const aiMesh &mesh, unsigned int index, const aiNode &node) {
|
||||
static const char underscore = '_';
|
||||
static constexpr char underscore = '_';
|
||||
char postfix[10] = { 0 };
|
||||
ASSIMP_itoa10(postfix, index);
|
||||
|
||||
@@ -209,9 +208,6 @@ Discreet3DSExporter::Discreet3DSExporter(std::shared_ptr<IOStream> &outfile, con
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Discreet3DSExporter::~Discreet3DSExporter() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
int Discreet3DSExporter::WriteHierarchy(const aiNode &node, int seq, int sibling_level) {
|
||||
// 3DS scene hierarchy is serialized as in http://www.martinreddy.net/gfx/3d/3DS.spec
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -63,10 +63,10 @@ namespace Assimp {
|
||||
* @brief Helper class to export a given scene to a 3DS file.
|
||||
*/
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class Discreet3DSExporter {
|
||||
class Discreet3DSExporter final {
|
||||
public:
|
||||
Discreet3DSExporter(std::shared_ptr<IOStream> &outfile, const aiScene* pScene);
|
||||
~Discreet3DSExporter();
|
||||
~Discreet3DSExporter() = default;
|
||||
|
||||
private:
|
||||
void WriteMeshes();
|
||||
@@ -88,7 +88,6 @@ private:
|
||||
|
||||
using MeshesByNodeMap = std::multimap<const aiNode*, unsigned int>;
|
||||
MeshesByNodeMap meshes;
|
||||
|
||||
};
|
||||
|
||||
} // Namespace Assimp
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -64,7 +63,7 @@ using namespace D3DS;
|
||||
// ---------------------------------------------------------------------------------
|
||||
/** Importer class for 3D Studio r3 and r4 3DS files
|
||||
*/
|
||||
class Discreet3DSImporter : public BaseImporter {
|
||||
class Discreet3DSImporter final : public BaseImporter {
|
||||
public:
|
||||
Discreet3DSImporter();
|
||||
~Discreet3DSImporter() override = default;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -107,7 +107,7 @@ void D3MFImporter::InternReadFile(const std::string &filename, aiScene *pScene,
|
||||
|
||||
XmlParser xmlParser;
|
||||
if (xmlParser.parse(opcPackage.RootStream())) {
|
||||
XmlSerializer xmlSerializer(&xmlParser);
|
||||
XmlSerializer xmlSerializer(xmlParser);
|
||||
xmlSerializer.ImportXml(pScene);
|
||||
|
||||
const std::vector<aiTexture*> &tex = opcPackage.GetEmbeddedTextures();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -199,11 +199,11 @@ void assignDiffuseColor(XmlNode &node, aiMaterial *mat) {
|
||||
|
||||
} // namespace
|
||||
|
||||
XmlSerializer::XmlSerializer(XmlParser *xmlParser) :
|
||||
XmlSerializer::XmlSerializer(XmlParser &xmlParser) :
|
||||
mResourcesDictionnary(),
|
||||
mMeshCount(0),
|
||||
mXmlParser(xmlParser) {
|
||||
ai_assert(nullptr != xmlParser);
|
||||
// empty
|
||||
}
|
||||
|
||||
XmlSerializer::~XmlSerializer() {
|
||||
@@ -218,7 +218,7 @@ void XmlSerializer::ImportXml(aiScene *scene) {
|
||||
}
|
||||
|
||||
scene->mRootNode = new aiNode(XmlTag::RootTag);
|
||||
XmlNode node = mXmlParser->getRootNode().child(XmlTag::model);
|
||||
XmlNode node = mXmlParser.getRootNode().child(XmlTag::model);
|
||||
if (node.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -59,9 +59,9 @@ class Texture2DGroup;
|
||||
class EmbeddedTexture;
|
||||
class ColorGroup;
|
||||
|
||||
class XmlSerializer {
|
||||
class XmlSerializer final {
|
||||
public:
|
||||
XmlSerializer(XmlParser *xmlParser);
|
||||
XmlSerializer(XmlParser &xmlParser);
|
||||
~XmlSerializer();
|
||||
void ImportXml(aiScene *scene);
|
||||
|
||||
@@ -92,7 +92,7 @@ private:
|
||||
std::vector<aiMaterial *> mMaterials;
|
||||
std::map<unsigned int, Resource *> mResourcesDictionnary;
|
||||
unsigned int mMeshCount;
|
||||
XmlParser *mXmlParser;
|
||||
XmlParser &mXmlParser;
|
||||
};
|
||||
|
||||
} // namespace D3MF
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -144,10 +144,6 @@ AC3DImporter::AC3DImporter() :
|
||||
// nothing to be done here
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
AC3DImporter::~AC3DImporter() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool AC3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
||||
@@ -171,8 +167,9 @@ bool AC3DImporter::GetNextLine() {
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Parse an object section in an AC file
|
||||
bool AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
|
||||
if (!TokenMatch(mBuffer.data, "OBJECT", 6))
|
||||
if (!TokenMatch(mBuffer.data, "OBJECT", 6)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkipSpaces(&mBuffer.data, mBuffer.end);
|
||||
|
||||
@@ -192,7 +189,6 @@ bool AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
|
||||
light->mAttenuationConstant = 1.f;
|
||||
|
||||
// Generate a default name for both the light source and the node
|
||||
// FIXME - what's the right way to print a size_t? Is 'zu' universally available? stick with the safe version.
|
||||
light->mName.length = ::ai_snprintf(light->mName.data, AI_MAXLEN, "ACLight_%i", static_cast<unsigned int>(mLights->size()) - 1);
|
||||
obj.name = std::string(light->mName.data);
|
||||
|
||||
@@ -202,8 +198,10 @@ bool AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
|
||||
obj.type = Object::Group;
|
||||
} else if (!ASSIMP_strincmp(mBuffer.data, "world", 5)) {
|
||||
obj.type = Object::World;
|
||||
} else
|
||||
} else {
|
||||
obj.type = Object::Poly;
|
||||
}
|
||||
|
||||
while (GetNextLine()) {
|
||||
if (TokenMatch(mBuffer.data, "kids", 4)) {
|
||||
SkipSpaces(&mBuffer.data, mBuffer.end);
|
||||
@@ -344,6 +342,7 @@ bool AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
|
||||
}
|
||||
}
|
||||
ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: \'kids\' line was expected");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Assimp {
|
||||
class AC3DImporter : public BaseImporter {
|
||||
public:
|
||||
AC3DImporter();
|
||||
~AC3DImporter() override;
|
||||
~AC3DImporter() override = default;
|
||||
|
||||
// Represents an AC3D material
|
||||
struct Material {
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
|
||||
unsigned int mat, flags;
|
||||
|
||||
typedef std::pair<unsigned int, aiVector2D> SurfaceEntry;
|
||||
using SurfaceEntry = std::pair<unsigned int, aiVector2D>;
|
||||
std::vector<SurfaceEntry> entries;
|
||||
|
||||
// Type is low nibble of flags
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -474,7 +474,7 @@ void AMFImporter::ParseNode_Metadata(XmlNode &node) {
|
||||
|
||||
// read attribute
|
||||
ne = new AMFMetadata(mNodeElement_Cur);
|
||||
((AMFMetadata *)ne)->Type = type;
|
||||
((AMFMetadata *)ne)->MetaType = type;
|
||||
((AMFMetadata *)ne)->Value = value;
|
||||
mNodeElement_Cur->Child.push_back(ne); // Add element to child list of current element
|
||||
mNodeElement_List.push_back(ne); // and to node element list because its a new object in graph.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -202,7 +202,7 @@ void AMFImporter::ParseNode_Volume(XmlNode &node) {
|
||||
|
||||
((AMFVolume *)ne)->MaterialID = node.attribute("materialid").as_string();
|
||||
|
||||
((AMFVolume *)ne)->Type = type;
|
||||
((AMFVolume *)ne)->VolumeType = type;
|
||||
// Check for child nodes
|
||||
bool col_read = false;
|
||||
if (!node.empty()) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -263,22 +263,22 @@ void AMFImporter::ParseNode_TexMap(XmlNode &node, const bool pUseOldName) {
|
||||
const std::string &name = currentNode.name();
|
||||
if (name == "utex1") {
|
||||
read_flag[0] = true;
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[0].x);
|
||||
XmlParser::getValueAsReal(currentNode, als.TextureCoordinate[0].x);
|
||||
} else if (name == "utex2") {
|
||||
read_flag[1] = true;
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[1].x);
|
||||
XmlParser::getValueAsReal(currentNode, als.TextureCoordinate[1].x);
|
||||
} else if (name == "utex3") {
|
||||
read_flag[2] = true;
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[2].x);
|
||||
XmlParser::getValueAsReal(currentNode, als.TextureCoordinate[2].x);
|
||||
} else if (name == "vtex1") {
|
||||
read_flag[3] = true;
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[0].y);
|
||||
XmlParser::getValueAsReal(currentNode, als.TextureCoordinate[0].y);
|
||||
} else if (name == "vtex2") {
|
||||
read_flag[4] = true;
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[1].y);
|
||||
XmlParser::getValueAsReal(currentNode, als.TextureCoordinate[1].y);
|
||||
} else if (name == "vtex3") {
|
||||
read_flag[5] = true;
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[2].y);
|
||||
XmlParser::getValueAsReal(currentNode, als.TextureCoordinate[2].y);
|
||||
}
|
||||
}
|
||||
ParseHelper_Node_Exit();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -86,7 +86,8 @@ public:
|
||||
AMFNodeElementBase *Parent; ///< Parent element. If nullptr then this node is root.
|
||||
std::list<AMFNodeElementBase *> Child; ///< Child elements.
|
||||
|
||||
public: /// Destructor, virtual..
|
||||
public:
|
||||
/// Destructor, virtual..
|
||||
virtual ~AMFNodeElementBase() = default;
|
||||
|
||||
/// Disabled copy constructor and co.
|
||||
@@ -97,10 +98,10 @@ public: /// Destructor, virtual..
|
||||
|
||||
protected:
|
||||
/// In constructor inheritor must set element type.
|
||||
/// \param [in] pType - element type.
|
||||
/// \param [in] type - element type.
|
||||
/// \param [in] pParent - parent element.
|
||||
AMFNodeElementBase(const EType pType, AMFNodeElementBase *pParent) :
|
||||
Type(pType), Parent(pParent) {
|
||||
AMFNodeElementBase(EType type, AMFNodeElementBase *pParent) :
|
||||
Type(type), Parent(pParent) {
|
||||
// empty
|
||||
}
|
||||
}; // class IAMFImporter_NodeElement
|
||||
@@ -135,8 +136,8 @@ struct AMFInstance : public AMFNodeElementBase {
|
||||
/// Structure that define metadata node.
|
||||
struct AMFMetadata : public AMFNodeElementBase {
|
||||
|
||||
std::string Type; ///< Type of "Value".
|
||||
std::string Value; ///< Value.
|
||||
std::string MetaType; ///< Type of "Value".
|
||||
std::string Value; ///< Value.
|
||||
|
||||
/// Constructor.
|
||||
/// \param [in] pParent - pointer to parent node.
|
||||
@@ -225,7 +226,7 @@ struct AMFVertices : public AMFNodeElementBase {
|
||||
/// Structure that define volume node.
|
||||
struct AMFVolume : public AMFNodeElementBase {
|
||||
std::string MaterialID; ///< Which material to use.
|
||||
std::string Type; ///< What this volume describes can be "region" or "support". If none specified, "object" is assumed.
|
||||
std::string VolumeType; ///< What this volume describes can be "region" or "support". If none specified, "object" is assumed.
|
||||
|
||||
/// Constructor.
|
||||
/// \param [in] pParent - pointer to parent node.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -333,7 +333,7 @@ void AMFImporter::Postprocess_AddMetadata(const AMFMetaDataArray &metadataList,
|
||||
size_t meta_idx(0);
|
||||
|
||||
for (const AMFMetadata *metadata : metadataList) {
|
||||
sceneNode.mMetaData->Set(static_cast<unsigned int>(meta_idx++), metadata->Type, aiString(metadata->Value));
|
||||
sceneNode.mMetaData->Set(static_cast<unsigned int>(meta_idx++), metadata->MetaType, aiString(metadata->Value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -91,9 +91,13 @@ bool AssbinImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, boo
|
||||
}
|
||||
|
||||
char s[32];
|
||||
in->Read(s, sizeof(char), 32);
|
||||
const size_t read = in->Read(s, sizeof(char), 32);
|
||||
|
||||
pIOHandler->Close(in);
|
||||
|
||||
if (read < 19) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return strncmp(s, "ASSIMP.binary-dump.", 19) == 0;
|
||||
}
|
||||
@@ -684,6 +688,7 @@ void AssbinImporter::InternReadFile(const std::string &pFile, aiScene *pScene, I
|
||||
unsigned int versionMajor = Read<unsigned int>(stream);
|
||||
unsigned int versionMinor = Read<unsigned int>(stream);
|
||||
if (versionMinor != ASSBIN_VERSION_MINOR || versionMajor != ASSBIN_VERSION_MAJOR) {
|
||||
pIOHandler->Close(stream);
|
||||
throw DeadlyImportError("Invalid version, data format not compatible!");
|
||||
}
|
||||
|
||||
@@ -693,8 +698,10 @@ void AssbinImporter::InternReadFile(const std::string &pFile, aiScene *pScene, I
|
||||
shortened = Read<uint16_t>(stream) > 0;
|
||||
compressed = Read<uint16_t>(stream) > 0;
|
||||
|
||||
if (shortened)
|
||||
if (shortened) {
|
||||
pIOHandler->Close(stream);
|
||||
throw DeadlyImportError("Shortened binaries are not supported!");
|
||||
}
|
||||
|
||||
stream->Seek(256, aiOrigin_CUR); // original filename
|
||||
stream->Seek(128, aiOrigin_CUR); // options
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -36,7 +35,6 @@ 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -223,7 +221,7 @@ static void WriteDump(const char *pFile, const char *cmd, const aiScene *scene,
|
||||
const unsigned int majorVersion(aiGetVersionMajor());
|
||||
const unsigned int minorVersion(aiGetVersionMinor());
|
||||
const unsigned int rev(aiGetVersionRevision());
|
||||
const char *curtime(asctime(p));
|
||||
const char *curtime = asctime(p);
|
||||
ioprintf(io, header.c_str(), majorVersion, minorVersion, rev, pFile, c.c_str(), curtime, scene->mFlags, 0u);
|
||||
|
||||
// write the node graph
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -85,11 +83,9 @@ BVHLoader::BVHLoader() :
|
||||
mLine(),
|
||||
mAnimTickDuration(),
|
||||
mAnimNumFrames(),
|
||||
noSkeletonMesh() {}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
BVHLoader::~BVHLoader() = default;
|
||||
noSkeletonMesh() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
@@ -80,32 +80,27 @@ class BVHLoader : public BaseImporter {
|
||||
std::vector<ChannelType> mChannels;
|
||||
std::vector<float> mChannelValues; // motion data values for that node. Of size NumChannels * NumFrames
|
||||
|
||||
Node() :
|
||||
mNode(nullptr) {}
|
||||
|
||||
explicit Node(const aiNode *pNode) :
|
||||
mNode(pNode) {}
|
||||
Node() : mNode(nullptr) {}
|
||||
explicit Node(const aiNode *pNode) :mNode(pNode) {}
|
||||
};
|
||||
|
||||
public:
|
||||
BVHLoader();
|
||||
~BVHLoader();
|
||||
~BVHLoader() override = default;
|
||||
|
||||
public:
|
||||
/** Returns whether the class can handle the format of the given file.
|
||||
* See BaseImporter::CanRead() for details. */
|
||||
bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool cs) const;
|
||||
bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool cs) const override;
|
||||
|
||||
void SetupProperties(const Importer *pImp);
|
||||
const aiImporterDesc *GetInfo() const;
|
||||
void SetupProperties(const Importer *pImp) override;
|
||||
const aiImporterDesc *GetInfo() const override;
|
||||
|
||||
protected:
|
||||
/** Imports the given file into the given scene structure.
|
||||
* See BaseImporter::InternReadFile() for details
|
||||
*/
|
||||
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler);
|
||||
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
|
||||
|
||||
protected:
|
||||
/** Reads the file */
|
||||
void ReadStructure(aiScene *pScene);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -841,5 +841,7 @@ template <template <typename> class TOUT> template <typename T> void ObjectCache
|
||||
#endif
|
||||
}
|
||||
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
|
||||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -495,8 +493,9 @@ void BlenderImporter::BuildDefaultMaterial(Blender::ConversionData &conv_data) {
|
||||
if (index == static_cast<unsigned int>(-1)) {
|
||||
// Setup a default material.
|
||||
std::shared_ptr<Material> p(new Material());
|
||||
ai_assert(::strlen(AI_DEFAULT_MATERIAL_NAME) < sizeof(p->id.name) - 2);
|
||||
strcpy(p->id.name + 2, AI_DEFAULT_MATERIAL_NAME);
|
||||
const size_t len = ::strlen(AI_DEFAULT_MATERIAL_NAME);
|
||||
ai_assert(len < sizeof(p->id.name) - 2);
|
||||
memcpy(p->id.name + 2, AI_DEFAULT_MATERIAL_NAME, len);
|
||||
|
||||
// Note: MSVC11 does not zero-initialize Material here, although it should.
|
||||
// Thus all relevant fields should be explicitly initialized. We cannot add
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2021, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
@@ -86,7 +86,7 @@ namespace Assimp {
|
||||
}
|
||||
}
|
||||
|
||||
static const aiImporterDesc desc = {
|
||||
static constexpr aiImporterDesc desc = {
|
||||
"Cinema4D Importer",
|
||||
"",
|
||||
"",
|
||||
@@ -99,13 +99,6 @@ static const aiImporterDesc desc = {
|
||||
"c4d"
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
C4DImporter::C4DImporter() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
C4DImporter::~C4DImporter() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool C4DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
|
||||
const std::string& extension = GetExtension(pFile);
|
||||
@@ -196,7 +189,6 @@ void C4DImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
|
||||
std::copy(materials.begin(), materials.end(), pScene->mMaterials);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool C4DImporter::ReadShader(aiMaterial* out, BaseShader* shader) {
|
||||
// based on Cineware sample code (C4DImportExport.cpp)
|
||||
|
||||
@@ -78,8 +78,8 @@ namespace Assimp {
|
||||
// -------------------------------------------------------------------------------------------
|
||||
class C4DImporter : public BaseImporter, public LogFunctions<C4DImporter> {
|
||||
public:
|
||||
C4DImporter();
|
||||
~C4DImporter() override;
|
||||
C4DImporter() = default;
|
||||
~C4DImporter() override = default;
|
||||
bool CanRead( const std::string& pFile, IOSystem*, bool checkSig) const override;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -228,7 +228,7 @@ aiNode *COBImporter::BuildNodes(const Node &root, const Scene &scin, aiScene *fi
|
||||
const Mesh &ndmesh = (const Mesh &)(root);
|
||||
if (ndmesh.vertex_positions.size() && ndmesh.texture_coords.size()) {
|
||||
|
||||
typedef std::pair<const unsigned int, Mesh::FaceRefList> Entry;
|
||||
using Entry = std::pair<const unsigned int, Mesh::FaceRefList>;
|
||||
for (const Entry &reflist : ndmesh.temp_map) {
|
||||
{ // create mesh
|
||||
size_t n = 0;
|
||||
@@ -372,9 +372,11 @@ aiNode *COBImporter::BuildNodes(const Node &root, const Scene &scin, aiScene *fi
|
||||
}
|
||||
|
||||
// add children recursively
|
||||
nd->mChildren = new aiNode *[root.temp_children.size()]();
|
||||
for (const Node *n : root.temp_children) {
|
||||
(nd->mChildren[nd->mNumChildren++] = BuildNodes(*n, scin, fill))->mParent = nd;
|
||||
if (!root.temp_children.empty()) {
|
||||
nd->mChildren = new aiNode *[root.temp_children.size()]();
|
||||
for (const Node *n : root.temp_children) {
|
||||
(nd->mChildren[nd->mNumChildren++] = BuildNodes(*n, scin, fill))->mParent = nd;
|
||||
}
|
||||
}
|
||||
|
||||
return nd;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -73,10 +71,9 @@ static constexpr aiImporterDesc desc = {
|
||||
"csm"
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
CSMImporter::CSMImporter() : noSkeletonMesh(){
|
||||
CSMImporter::CSMImporter() : noSkeletonMesh() {
|
||||
// empty
|
||||
}
|
||||
|
||||
@@ -102,8 +99,7 @@ void CSMImporter::SetupProperties(const Importer* pImp) {
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
void CSMImporter::InternReadFile( const std::string& pFile,
|
||||
aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
aiScene* pScene, IOSystem* pIOHandler) {
|
||||
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
|
||||
|
||||
// Check whether we can read from the file
|
||||
@@ -127,11 +123,11 @@ void CSMImporter::InternReadFile( const std::string& pFile,
|
||||
|
||||
if ('$' == *buffer) {
|
||||
++buffer;
|
||||
if (TokenMatchI(buffer,"firstframe",10)) {
|
||||
if (TokenMatchI(buffer,"firstframe",10)) {
|
||||
SkipSpaces(&buffer, end);
|
||||
first = strtol10(buffer,&buffer);
|
||||
}
|
||||
else if (TokenMatchI(buffer,"lastframe",9)) {
|
||||
else if (TokenMatchI(buffer,"lastframe",9)) {
|
||||
SkipSpaces(&buffer, end);
|
||||
last = strtol10(buffer,&buffer);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -36,7 +35,6 @@ 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -64,6 +62,37 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
static const aiNode *findSkeletonRootNode(const aiScene *scene, const aiMesh *mesh) {
|
||||
std::set<const aiNode *> topParentBoneNodes;
|
||||
if (mesh && mesh->mNumBones > 0) {
|
||||
for (unsigned int i = 0; i < mesh->mNumBones; ++i) {
|
||||
aiBone *bone = mesh->mBones[i];
|
||||
|
||||
const aiNode *node = scene->mRootNode->findBoneNode(bone);
|
||||
if (node) {
|
||||
while (node->mParent && scene->findBone(node->mParent->mName) != nullptr) {
|
||||
node = node->mParent;
|
||||
}
|
||||
topParentBoneNodes.insert(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!topParentBoneNodes.empty()) {
|
||||
const aiNode *parentBoneNode = *topParentBoneNodes.begin();
|
||||
if (topParentBoneNodes.size() == 1) {
|
||||
return parentBoneNode;
|
||||
} else {
|
||||
for (auto it : topParentBoneNodes) {
|
||||
if (it->mParent) return it->mParent;
|
||||
}
|
||||
return parentBoneNode;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp
|
||||
void ExportSceneCollada(const char *pFile, IOSystem *pIOSystem, const aiScene *pScene, const ExportProperties * /*pProperties*/) {
|
||||
@@ -152,10 +181,6 @@ ColladaExporter::ColladaExporter(const aiScene *pScene, IOSystem *pIOSystem, con
|
||||
WriteFile();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor
|
||||
ColladaExporter::~ColladaExporter() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Starts writing the contents
|
||||
void ColladaExporter::WriteFile() {
|
||||
@@ -331,60 +356,68 @@ void ColladaExporter::WriteHeader() {
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Write the embedded textures
|
||||
void ColladaExporter::WriteTextures() {
|
||||
static const unsigned int buffer_size = 1024;
|
||||
char str[buffer_size];
|
||||
static constexpr unsigned int buffer_size = 1024;
|
||||
char str[buffer_size] = {'\0'};
|
||||
|
||||
if (mScene->HasTextures()) {
|
||||
for (unsigned int i = 0; i < mScene->mNumTextures; i++) {
|
||||
// It would be great to be able to create a directory in portable standard C++, but it's not the case,
|
||||
// so we just write the textures in the current directory.
|
||||
if (!mScene->HasTextures()) {
|
||||
return;
|
||||
}
|
||||
|
||||
aiTexture *texture = mScene->mTextures[i];
|
||||
if (nullptr == texture) {
|
||||
continue;
|
||||
}
|
||||
for (unsigned int i = 0; i < mScene->mNumTextures; i++) {
|
||||
// It would be great to be able to create a directory in portable standard C++, but it's not the case,
|
||||
// so we just write the textures in the current directory.
|
||||
|
||||
ASSIMP_itoa10(str, buffer_size, i + 1);
|
||||
|
||||
std::string name = mFile + "_texture_" + (i < 1000 ? "0" : "") + (i < 100 ? "0" : "") + (i < 10 ? "0" : "") + str + "." + ((const char *)texture->achFormatHint);
|
||||
|
||||
std::unique_ptr<IOStream> outfile(mIOSystem->Open(mPath + mIOSystem->getOsSeparator() + name, "wb"));
|
||||
if (outfile == nullptr) {
|
||||
throw DeadlyExportError("could not open output texture file: " + mPath + name);
|
||||
}
|
||||
|
||||
if (texture->mHeight == 0) {
|
||||
outfile->Write((void *)texture->pcData, texture->mWidth, 1);
|
||||
} else {
|
||||
Bitmap::Save(texture, outfile.get());
|
||||
}
|
||||
|
||||
outfile->Flush();
|
||||
|
||||
textures.insert(std::make_pair(i, name));
|
||||
aiTexture *texture = mScene->mTextures[i];
|
||||
if (nullptr == texture) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ASSIMP_itoa10(str, buffer_size, i + 1);
|
||||
|
||||
std::string name = mFile + "_texture_" + (i < 1000 ? "0" : "") + (i < 100 ? "0" : "") + (i < 10 ? "0" : "") + str + "." + ((const char *)texture->achFormatHint);
|
||||
|
||||
std::unique_ptr<IOStream> outfile(mIOSystem->Open(mPath + mIOSystem->getOsSeparator() + name, "wb"));
|
||||
if (outfile == nullptr) {
|
||||
throw DeadlyExportError("could not open output texture file: " + mPath + name);
|
||||
}
|
||||
|
||||
if (texture->mHeight == 0) {
|
||||
outfile->Write((void *)texture->pcData, texture->mWidth, 1);
|
||||
} else {
|
||||
Bitmap::Save(texture, outfile.get());
|
||||
}
|
||||
|
||||
outfile->Flush();
|
||||
|
||||
textures.insert(std::make_pair(i, name));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Write the embedded textures
|
||||
void ColladaExporter::WriteCamerasLibrary() {
|
||||
if (mScene->HasCameras()) {
|
||||
|
||||
mOutput << startstr << "<library_cameras>" << endstr;
|
||||
PushTag();
|
||||
|
||||
for (size_t a = 0; a < mScene->mNumCameras; ++a)
|
||||
WriteCamera(a);
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</library_cameras>" << endstr;
|
||||
if (!mScene->HasCameras()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mOutput << startstr << "<library_cameras>" << endstr;
|
||||
PushTag();
|
||||
|
||||
for (size_t a = 0; a < mScene->mNumCameras; ++a) {
|
||||
WriteCamera(a);
|
||||
}
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</library_cameras>" << endstr;
|
||||
}
|
||||
|
||||
void ColladaExporter::WriteCamera(size_t pIndex) {
|
||||
|
||||
const aiCamera *cam = mScene->mCameras[pIndex];
|
||||
if (cam == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string cameraId = GetObjectUniqueId(AiObjectType::Camera, pIndex);
|
||||
const std::string cameraName = GetObjectName(AiObjectType::Camera, pIndex);
|
||||
|
||||
@@ -422,22 +455,27 @@ void ColladaExporter::WriteCamera(size_t pIndex) {
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Write the embedded textures
|
||||
void ColladaExporter::WriteLightsLibrary() {
|
||||
if (mScene->HasLights()) {
|
||||
|
||||
mOutput << startstr << "<library_lights>" << endstr;
|
||||
PushTag();
|
||||
|
||||
for (size_t a = 0; a < mScene->mNumLights; ++a)
|
||||
WriteLight(a);
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</library_lights>" << endstr;
|
||||
if (!mScene->HasLights()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mOutput << startstr << "<library_lights>" << endstr;
|
||||
PushTag();
|
||||
|
||||
for (size_t a = 0; a < mScene->mNumLights; ++a) {
|
||||
WriteLight(a);
|
||||
}
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</library_lights>" << endstr;
|
||||
}
|
||||
|
||||
void ColladaExporter::WriteLight(size_t pIndex) {
|
||||
|
||||
const aiLight *light = mScene->mLights[pIndex];
|
||||
if (light == nullptr) {
|
||||
return;
|
||||
}
|
||||
const std::string lightId = GetObjectUniqueId(AiObjectType::Light, pIndex);
|
||||
const std::string lightName = GetObjectName(AiObjectType::Light, pIndex);
|
||||
|
||||
@@ -462,6 +500,7 @@ void ColladaExporter::WriteLight(size_t pIndex) {
|
||||
case aiLightSource_AREA:
|
||||
case aiLightSource_UNDEFINED:
|
||||
case _aiLightSource_Force32Bit:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
PopTag();
|
||||
@@ -521,10 +560,6 @@ void ColladaExporter::WriteSpotLight(const aiLight *const light) {
|
||||
mOutput << startstr << "<quadratic_attenuation>"
|
||||
<< light->mAttenuationQuadratic
|
||||
<< "</quadratic_attenuation>" << endstr;
|
||||
/*
|
||||
out->mAngleOuterCone = AI_DEG_TO_RAD (std::acos(std::pow(0.1f,1.f/srcLight->mFalloffExponent))+
|
||||
srcLight->mFalloffAngle);
|
||||
*/
|
||||
|
||||
const ai_real fallOffAngle = AI_RAD_TO_DEG(light->mAngleInnerCone);
|
||||
mOutput << startstr << "<falloff_angle sid=\"fall_off_angle\">"
|
||||
@@ -559,41 +594,43 @@ void ColladaExporter::WriteAmbientLight(const aiLight *const light) {
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads a single surface entry from the given material keys
|
||||
bool ColladaExporter::ReadMaterialSurface(Surface &poSurface, const aiMaterial &pSrcMat, aiTextureType pTexture, const char *pKey, size_t pType, size_t pIndex) {
|
||||
if (pSrcMat.GetTextureCount(pTexture) > 0) {
|
||||
aiString texfile;
|
||||
unsigned int uvChannel = 0;
|
||||
pSrcMat.GetTexture(pTexture, 0, &texfile, nullptr, &uvChannel);
|
||||
|
||||
std::string index_str(texfile.C_Str());
|
||||
|
||||
if (index_str.size() != 0 && index_str[0] == '*') {
|
||||
unsigned int index;
|
||||
|
||||
index_str = index_str.substr(1, std::string::npos);
|
||||
|
||||
try {
|
||||
index = (unsigned int)strtoul10_64<DeadlyExportError>(index_str.c_str());
|
||||
} catch (std::exception &error) {
|
||||
throw DeadlyExportError(error.what());
|
||||
}
|
||||
|
||||
std::map<unsigned int, std::string>::const_iterator name = textures.find(index);
|
||||
|
||||
if (name != textures.end()) {
|
||||
poSurface.texture = name->second;
|
||||
} else {
|
||||
throw DeadlyExportError("could not find embedded texture at index " + index_str);
|
||||
}
|
||||
} else {
|
||||
poSurface.texture = texfile.C_Str();
|
||||
}
|
||||
|
||||
poSurface.channel = uvChannel;
|
||||
poSurface.exist = true;
|
||||
} else {
|
||||
if (pSrcMat.GetTextureCount(pTexture) == 0) {
|
||||
if (pKey)
|
||||
poSurface.exist = pSrcMat.Get(pKey, static_cast<unsigned int>(pType), static_cast<unsigned int>(pIndex), poSurface.color) == aiReturn_SUCCESS;
|
||||
return poSurface.exist;
|
||||
}
|
||||
|
||||
aiString texfile;
|
||||
unsigned int uvChannel = 0;
|
||||
pSrcMat.GetTexture(pTexture, 0, &texfile, nullptr, &uvChannel);
|
||||
|
||||
std::string index_str(texfile.C_Str());
|
||||
|
||||
if (index_str.size() != 0 && index_str[0] == '*') {
|
||||
unsigned int index;
|
||||
|
||||
index_str = index_str.substr(1, std::string::npos);
|
||||
|
||||
try {
|
||||
index = (unsigned int)strtoul10_64<DeadlyExportError>(index_str.c_str());
|
||||
} catch (std::exception &error) {
|
||||
throw DeadlyExportError(error.what());
|
||||
}
|
||||
|
||||
std::map<unsigned int, std::string>::const_iterator name = textures.find(index);
|
||||
|
||||
if (name != textures.end()) {
|
||||
poSurface.texture = name->second;
|
||||
} else {
|
||||
throw DeadlyExportError("could not find embedded texture at index " + index_str);
|
||||
}
|
||||
} else {
|
||||
poSurface.texture = texfile.C_Str();
|
||||
}
|
||||
|
||||
poSurface.channel = uvChannel;
|
||||
poSurface.exist = true;
|
||||
|
||||
return poSurface.exist;
|
||||
}
|
||||
|
||||
@@ -606,79 +643,87 @@ static bool isalnum_C(char c) {
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Writes an image entry for the given surface
|
||||
void ColladaExporter::WriteImageEntry(const Surface &pSurface, const std::string &imageId) {
|
||||
if (!pSurface.texture.empty()) {
|
||||
mOutput << startstr << "<image id=\"" << imageId << "\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<init_from>";
|
||||
|
||||
// URL encode image file name first, then XML encode on top
|
||||
std::stringstream imageUrlEncoded;
|
||||
for (std::string::const_iterator it = pSurface.texture.begin(); it != pSurface.texture.end(); ++it) {
|
||||
if (isalnum_C((unsigned char)*it) || *it == ':' || *it == '_' || *it == '-' || *it == '.' || *it == '/' || *it == '\\')
|
||||
imageUrlEncoded << *it;
|
||||
else
|
||||
imageUrlEncoded << '%' << std::hex << size_t((unsigned char)*it) << std::dec;
|
||||
}
|
||||
mOutput << XMLEscape(imageUrlEncoded.str());
|
||||
mOutput << "</init_from>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</image>" << endstr;
|
||||
if (pSurface.texture.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mOutput << startstr << "<image id=\"" << imageId << "\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<init_from>";
|
||||
|
||||
// URL encode image file name first, then XML encode on top
|
||||
std::stringstream imageUrlEncoded;
|
||||
for (std::string::const_iterator it = pSurface.texture.begin(); it != pSurface.texture.end(); ++it) {
|
||||
if (isalnum_C((unsigned char)*it) || *it == ':' || *it == '_' || *it == '-' || *it == '.' || *it == '/' || *it == '\\')
|
||||
imageUrlEncoded << *it;
|
||||
else
|
||||
imageUrlEncoded << '%' << std::hex << size_t((unsigned char)*it) << std::dec;
|
||||
}
|
||||
mOutput << XMLEscape(imageUrlEncoded.str());
|
||||
mOutput << "</init_from>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</image>" << endstr;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Writes a color-or-texture entry into an effect definition
|
||||
void ColladaExporter::WriteTextureColorEntry(const Surface &pSurface, const std::string &pTypeName, const std::string &imageId) {
|
||||
if (pSurface.exist) {
|
||||
mOutput << startstr << "<" << pTypeName << ">" << endstr;
|
||||
PushTag();
|
||||
if (pSurface.texture.empty()) {
|
||||
mOutput << startstr << "<color sid=\"" << pTypeName << "\">" << pSurface.color.r << " " << pSurface.color.g << " " << pSurface.color.b << " " << pSurface.color.a << "</color>" << endstr;
|
||||
} else {
|
||||
mOutput << startstr << "<texture texture=\"" << imageId << "\" texcoord=\"CHANNEL" << pSurface.channel << "\" />" << endstr;
|
||||
}
|
||||
PopTag();
|
||||
mOutput << startstr << "</" << pTypeName << ">" << endstr;
|
||||
if (!pSurface.exist) {
|
||||
return;
|
||||
}
|
||||
|
||||
mOutput << startstr << "<" << pTypeName << ">" << endstr;
|
||||
PushTag();
|
||||
if (pSurface.texture.empty()) {
|
||||
mOutput << startstr << "<color sid=\"" << pTypeName << "\">" << pSurface.color.r << " " << pSurface.color.g << " " << pSurface.color.b << " " << pSurface.color.a << "</color>" << endstr;
|
||||
} else {
|
||||
mOutput << startstr << "<texture texture=\"" << imageId << "\" texcoord=\"CHANNEL" << pSurface.channel << "\" />" << endstr;
|
||||
}
|
||||
PopTag();
|
||||
mOutput << startstr << "</" << pTypeName << ">" << endstr;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Writes the two parameters necessary for referencing a texture in an effect entry
|
||||
void ColladaExporter::WriteTextureParamEntry(const Surface &pSurface, const std::string &pTypeName, const std::string &materialId) {
|
||||
// if surface is a texture, write out the sampler and the surface parameters necessary to reference the texture
|
||||
if (!pSurface.texture.empty()) {
|
||||
mOutput << startstr << "<newparam sid=\"" << materialId << "-" << pTypeName << "-surface\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<surface type=\"2D\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<init_from>" << materialId << "-" << pTypeName << "-image</init_from>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</surface>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</newparam>" << endstr;
|
||||
|
||||
mOutput << startstr << "<newparam sid=\"" << materialId << "-" << pTypeName << "-sampler\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<sampler2D>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<source>" << materialId << "-" << pTypeName << "-surface</source>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</sampler2D>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</newparam>" << endstr;
|
||||
if (pSurface.texture.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mOutput << startstr << "<newparam sid=\"" << materialId << "-" << pTypeName << "-surface\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<surface type=\"2D\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<init_from>" << materialId << "-" << pTypeName << "-image</init_from>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</surface>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</newparam>" << endstr;
|
||||
|
||||
mOutput << startstr << "<newparam sid=\"" << materialId << "-" << pTypeName << "-sampler\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<sampler2D>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<source>" << materialId << "-" << pTypeName << "-surface</source>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</sampler2D>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</newparam>" << endstr;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Writes a scalar property
|
||||
void ColladaExporter::WriteFloatEntry(const Property &pProperty, const std::string &pTypeName) {
|
||||
if (pProperty.exist) {
|
||||
mOutput << startstr << "<" << pTypeName << ">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<float sid=\"" << pTypeName << "\">" << pProperty.value << "</float>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</" << pTypeName << ">" << endstr;
|
||||
if (!pProperty.exist) {
|
||||
return;
|
||||
}
|
||||
|
||||
mOutput << startstr << "<" << pTypeName << ">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<float sid=\"" << pTypeName << "\">" << pProperty.value << "</float>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</" << pTypeName << ">" << endstr;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -832,8 +877,9 @@ void ColladaExporter::WriteControllerLibrary() {
|
||||
void ColladaExporter::WriteController(size_t pIndex) {
|
||||
const aiMesh *mesh = mScene->mMeshes[pIndex];
|
||||
// Is there a skin controller?
|
||||
if (mesh->mNumBones == 0 || mesh->mNumFaces == 0 || mesh->mNumVertices == 0)
|
||||
if (mesh->mNumBones == 0 || mesh->mNumFaces == 0 || mesh->mNumVertices == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string idstr = GetObjectUniqueId(AiObjectType::Mesh, pIndex);
|
||||
const std::string namestr = GetObjectName(AiObjectType::Mesh, pIndex);
|
||||
@@ -864,8 +910,9 @@ void ColladaExporter::WriteController(size_t pIndex) {
|
||||
|
||||
mOutput << startstr << "<Name_array id=\"" << idstr << "-skin-joints-array\" count=\"" << mesh->mNumBones << "\">";
|
||||
|
||||
for (size_t i = 0; i < mesh->mNumBones; ++i)
|
||||
for (size_t i = 0; i < mesh->mNumBones; ++i) {
|
||||
mOutput << GetBoneUniqueId(mesh->mBones[i]) << ' ';
|
||||
}
|
||||
|
||||
mOutput << "</Name_array>" << endstr;
|
||||
|
||||
@@ -888,9 +935,11 @@ void ColladaExporter::WriteController(size_t pIndex) {
|
||||
|
||||
std::vector<ai_real> bind_poses;
|
||||
bind_poses.reserve(mesh->mNumBones * 16);
|
||||
for (unsigned int i = 0; i < mesh->mNumBones; ++i)
|
||||
for (unsigned int j = 0; j < 4; ++j)
|
||||
for (unsigned int i = 0; i < mesh->mNumBones; ++i) {
|
||||
for (unsigned int j = 0; j < 4; ++j) {
|
||||
bind_poses.insert(bind_poses.end(), mesh->mBones[i]->mOffsetMatrix[j], mesh->mBones[i]->mOffsetMatrix[j] + 4);
|
||||
}
|
||||
}
|
||||
|
||||
WriteFloatArray(idstr + "-skin-bind_poses", FloatType_Mat4x4, (const ai_real *)bind_poses.data(), bind_poses.size() / 16);
|
||||
|
||||
@@ -898,9 +947,11 @@ void ColladaExporter::WriteController(size_t pIndex) {
|
||||
|
||||
std::vector<ai_real> skin_weights;
|
||||
skin_weights.reserve(mesh->mNumVertices * mesh->mNumBones);
|
||||
for (size_t i = 0; i < mesh->mNumBones; ++i)
|
||||
for (size_t j = 0; j < mesh->mBones[i]->mNumWeights; ++j)
|
||||
for (size_t i = 0; i < mesh->mNumBones; ++i) {
|
||||
for (size_t j = 0; j < mesh->mBones[i]->mNumWeights; ++j) {
|
||||
skin_weights.push_back(mesh->mBones[i]->mWeights[j].mWeight);
|
||||
}
|
||||
}
|
||||
|
||||
WriteFloatArray(idstr + "-skin-weights", FloatType_Weight, (const ai_real *)skin_weights.data(), skin_weights.size());
|
||||
|
||||
@@ -924,12 +975,15 @@ void ColladaExporter::WriteController(size_t pIndex) {
|
||||
mOutput << startstr << "<vcount>";
|
||||
|
||||
std::vector<ai_uint> num_influences(mesh->mNumVertices, (ai_uint)0);
|
||||
for (size_t i = 0; i < mesh->mNumBones; ++i)
|
||||
for (size_t j = 0; j < mesh->mBones[i]->mNumWeights; ++j)
|
||||
for (size_t i = 0; i < mesh->mNumBones; ++i) {
|
||||
for (size_t j = 0; j < mesh->mBones[i]->mNumWeights; ++j) {
|
||||
++num_influences[mesh->mBones[i]->mWeights[j].mVertexId];
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < mesh->mNumVertices; ++i)
|
||||
for (size_t i = 0; i < mesh->mNumVertices; ++i) {
|
||||
mOutput << num_influences[i] << " ";
|
||||
}
|
||||
|
||||
mOutput << "</vcount>" << endstr;
|
||||
|
||||
@@ -945,7 +999,7 @@ void ColladaExporter::WriteController(size_t pIndex) {
|
||||
|
||||
ai_uint weight_index = 0;
|
||||
std::vector<ai_int> joint_weight_indices(2 * joint_weight_indices_length, (ai_int)-1);
|
||||
for (unsigned int i = 0; i < mesh->mNumBones; ++i)
|
||||
for (unsigned int i = 0; i < mesh->mNumBones; ++i) {
|
||||
for (unsigned j = 0; j < mesh->mBones[i]->mNumWeights; ++j) {
|
||||
unsigned int vId = mesh->mBones[i]->mWeights[j].mVertexId;
|
||||
for (ai_uint k = 0; k < num_influences[vId]; ++k) {
|
||||
@@ -957,9 +1011,11 @@ void ColladaExporter::WriteController(size_t pIndex) {
|
||||
}
|
||||
++weight_index;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < joint_weight_indices.size(); ++i)
|
||||
for (size_t i = 0; i < joint_weight_indices.size(); ++i) {
|
||||
mOutput << joint_weight_indices[i] << " ";
|
||||
}
|
||||
|
||||
num_influences.clear();
|
||||
accum_influences.clear();
|
||||
@@ -983,8 +1039,9 @@ void ColladaExporter::WriteGeometryLibrary() {
|
||||
mOutput << startstr << "<library_geometries>" << endstr;
|
||||
PushTag();
|
||||
|
||||
for (size_t a = 0; a < mScene->mNumMeshes; ++a)
|
||||
for (size_t a = 0; a < mScene->mNumMeshes; ++a) {
|
||||
WriteGeometry(a);
|
||||
}
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</library_geometries>" << endstr;
|
||||
@@ -997,8 +1054,9 @@ void ColladaExporter::WriteGeometry(size_t pIndex) {
|
||||
const std::string geometryId = GetObjectUniqueId(AiObjectType::Mesh, pIndex);
|
||||
const std::string geometryName = GetObjectName(AiObjectType::Mesh, pIndex);
|
||||
|
||||
if (mesh->mNumFaces == 0 || mesh->mNumVertices == 0)
|
||||
if (mesh->mNumFaces == 0 || mesh->mNumVertices == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// opening tag
|
||||
mOutput << startstr << "<geometry id=\"" << geometryId << "\" name=\"" << geometryName << "\" >" << endstr;
|
||||
@@ -1010,8 +1068,9 @@ void ColladaExporter::WriteGeometry(size_t pIndex) {
|
||||
// Positions
|
||||
WriteFloatArray(geometryId + "-positions", FloatType_Vector, (ai_real *)mesh->mVertices, mesh->mNumVertices);
|
||||
// Normals, if any
|
||||
if (mesh->HasNormals())
|
||||
if (mesh->HasNormals()) {
|
||||
WriteFloatArray(geometryId + "-normals", FloatType_Vector, (ai_real *)mesh->mNormals, mesh->mNumVertices);
|
||||
}
|
||||
|
||||
// texture coords
|
||||
for (size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
|
||||
@@ -1040,10 +1099,11 @@ void ColladaExporter::WriteGeometry(size_t pIndex) {
|
||||
int countLines = 0;
|
||||
int countPoly = 0;
|
||||
for (size_t a = 0; a < mesh->mNumFaces; ++a) {
|
||||
if (mesh->mFaces[a].mNumIndices == 2)
|
||||
if (mesh->mFaces[a].mNumIndices == 2) {
|
||||
countLines++;
|
||||
else if (mesh->mFaces[a].mNumIndices >= 3)
|
||||
} else if (mesh->mFaces[a].mNumIndices >= 3) {
|
||||
countPoly++;
|
||||
}
|
||||
}
|
||||
|
||||
// lines
|
||||
@@ -1051,13 +1111,18 @@ void ColladaExporter::WriteGeometry(size_t pIndex) {
|
||||
mOutput << startstr << "<lines count=\"" << countLines << "\" material=\"defaultMaterial\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << geometryId << "-vertices\" />" << endstr;
|
||||
if (mesh->HasNormals())
|
||||
if (mesh->HasNormals()) {
|
||||
mOutput << startstr << "<input semantic=\"NORMAL\" source=\"#" << geometryId << "-normals\" />" << endstr;
|
||||
}
|
||||
for (size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
|
||||
if (mesh->HasTextureCoords(static_cast<unsigned int>(a)))
|
||||
mOutput << startstr << "<input semantic=\"TEXCOORD\" source=\"#" << geometryId << "-tex" << a << "\" "
|
||||
if (mesh->HasTextureCoords(static_cast<unsigned int>(a))) {
|
||||
mOutput << startstr
|
||||
<< "<input semantic=\"TEXCOORD\" source=\"#"
|
||||
<< geometryId
|
||||
<< "-tex" << a << "\" "
|
||||
<< "set=\"" << a << "\""
|
||||
<< " />" << endstr;
|
||||
}
|
||||
}
|
||||
for (size_t a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a) {
|
||||
if (mesh->HasVertexColors(static_cast<unsigned int>(a)))
|
||||
@@ -1070,8 +1135,9 @@ void ColladaExporter::WriteGeometry(size_t pIndex) {
|
||||
for (size_t a = 0; a < mesh->mNumFaces; ++a) {
|
||||
const aiFace &face = mesh->mFaces[a];
|
||||
if (face.mNumIndices != 2) continue;
|
||||
for (size_t b = 0; b < face.mNumIndices; ++b)
|
||||
for (size_t b = 0; b < face.mNumIndices; ++b) {
|
||||
mOutput << face.mIndices[b] << " ";
|
||||
}
|
||||
}
|
||||
mOutput << "</p>" << endstr;
|
||||
PopTag();
|
||||
@@ -1085,8 +1151,9 @@ void ColladaExporter::WriteGeometry(size_t pIndex) {
|
||||
mOutput << startstr << "<polylist count=\"" << countPoly << "\" material=\"defaultMaterial\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << geometryId << "-vertices\" />" << endstr;
|
||||
if (mesh->HasNormals())
|
||||
if (mesh->HasNormals()) {
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"NORMAL\" source=\"#" << geometryId << "-normals\" />" << endstr;
|
||||
}
|
||||
for (size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
|
||||
if (mesh->HasTextureCoords(static_cast<unsigned int>(a)))
|
||||
mOutput << startstr << "<input offset=\"0\" semantic=\"TEXCOORD\" source=\"#" << geometryId << "-tex" << a << "\" "
|
||||
@@ -1111,8 +1178,9 @@ void ColladaExporter::WriteGeometry(size_t pIndex) {
|
||||
for (size_t a = 0; a < mesh->mNumFaces; ++a) {
|
||||
const aiFace &face = mesh->mFaces[a];
|
||||
if (face.mNumIndices < 3) continue;
|
||||
for (size_t b = 0; b < face.mNumIndices; ++b)
|
||||
for (size_t b = 0; b < face.mNumIndices; ++b) {
|
||||
mOutput << face.mIndices[b] << " ";
|
||||
}
|
||||
}
|
||||
mOutput << "</p>" << endstr;
|
||||
PopTag();
|
||||
@@ -1131,13 +1199,27 @@ void ColladaExporter::WriteGeometry(size_t pIndex) {
|
||||
void ColladaExporter::WriteFloatArray(const std::string &pIdString, FloatDataType pType, const ai_real *pData, size_t pElementCount) {
|
||||
size_t floatsPerElement = 0;
|
||||
switch (pType) {
|
||||
case FloatType_Vector: floatsPerElement = 3; break;
|
||||
case FloatType_TexCoord2: floatsPerElement = 2; break;
|
||||
case FloatType_TexCoord3: floatsPerElement = 3; break;
|
||||
case FloatType_Color: floatsPerElement = 3; break;
|
||||
case FloatType_Mat4x4: floatsPerElement = 16; break;
|
||||
case FloatType_Weight: floatsPerElement = 1; break;
|
||||
case FloatType_Time: floatsPerElement = 1; break;
|
||||
case FloatType_Vector:
|
||||
floatsPerElement = 3;
|
||||
break;
|
||||
case FloatType_TexCoord2:
|
||||
floatsPerElement = 2;
|
||||
break;
|
||||
case FloatType_TexCoord3:
|
||||
floatsPerElement = 3;
|
||||
break;
|
||||
case FloatType_Color:
|
||||
floatsPerElement = 3;
|
||||
break;
|
||||
case FloatType_Mat4x4:
|
||||
floatsPerElement = 16;
|
||||
break;
|
||||
case FloatType_Weight:
|
||||
floatsPerElement = 1;
|
||||
break;
|
||||
case FloatType_Time:
|
||||
floatsPerElement = 1;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -1163,8 +1245,9 @@ void ColladaExporter::WriteFloatArray(const std::string &pIdString, FloatDataTyp
|
||||
mOutput << pData[a * 4 + 2] << " ";
|
||||
}
|
||||
} else {
|
||||
for (size_t a = 0; a < pElementCount * floatsPerElement; ++a)
|
||||
for (size_t a = 0; a < pElementCount * floatsPerElement; ++a) {
|
||||
mOutput << pData[a] << " ";
|
||||
}
|
||||
}
|
||||
mOutput << "</float_array>" << endstr;
|
||||
PopTag();
|
||||
@@ -1256,9 +1339,13 @@ void ColladaExporter::WriteSceneLibrary() {
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ColladaExporter::WriteAnimationLibrary(size_t pIndex) {
|
||||
const aiAnimation *anim = mScene->mAnimations[pIndex];
|
||||
|
||||
if (anim->mNumChannels == 0 && anim->mNumMeshChannels == 0 && anim->mNumMorphMeshChannels == 0)
|
||||
if (anim == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (anim->mNumChannels == 0 && anim->mNumMeshChannels == 0 && anim->mNumMorphMeshChannels == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string animationNameEscaped = GetObjectName(AiObjectType::Animation, pIndex);
|
||||
const std::string idstrEscaped = GetObjectUniqueId(AiObjectType::Animation, pIndex);
|
||||
@@ -1269,8 +1356,11 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex) {
|
||||
std::string cur_node_idstr;
|
||||
for (size_t a = 0; a < anim->mNumChannels; ++a) {
|
||||
const aiNodeAnim *nodeAnim = anim->mChannels[a];
|
||||
if (nodeAnim == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// sanity check
|
||||
// sanity checks
|
||||
if (nodeAnim->mNumPositionKeys != nodeAnim->mNumScalingKeys || nodeAnim->mNumPositionKeys != nodeAnim->mNumRotationKeys) {
|
||||
continue;
|
||||
}
|
||||
@@ -1369,6 +1459,9 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex) {
|
||||
|
||||
for (size_t a = 0; a < anim->mNumChannels; ++a) {
|
||||
const aiNodeAnim *nodeAnim = anim->mChannels[a];
|
||||
if (nodeAnim == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
{
|
||||
// samplers
|
||||
@@ -1387,97 +1480,42 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex) {
|
||||
|
||||
for (size_t a = 0; a < anim->mNumChannels; ++a) {
|
||||
const aiNodeAnim *nodeAnim = anim->mChannels[a];
|
||||
if (nodeAnim == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
{
|
||||
// channels
|
||||
mOutput << startstr << "<channel source=\"#" << XMLIDEncode(nodeAnim->mNodeName.data + std::string("_matrix-sampler")) << "\" target=\"" << XMLIDEncode(nodeAnim->mNodeName.data) << "/matrix\"/>" << endstr;
|
||||
mOutput << startstr
|
||||
<< "<channel source=\"#"
|
||||
<< XMLIDEncode(nodeAnim->mNodeName.data + std::string("_matrix-sampler"))
|
||||
<< "\" target=\""
|
||||
<< XMLIDEncode(nodeAnim->mNodeName.data)
|
||||
<< "/matrix\"/>"
|
||||
<< endstr;
|
||||
}
|
||||
}
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</animation>" << endstr;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ColladaExporter::WriteAnimationsLibrary() {
|
||||
if (mScene->mNumAnimations > 0) {
|
||||
mOutput << startstr << "<library_animations>" << endstr;
|
||||
PushTag();
|
||||
|
||||
// start recursive write at the root node
|
||||
for (size_t a = 0; a < mScene->mNumAnimations; ++a)
|
||||
WriteAnimationLibrary(a);
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</library_animations>" << endstr;
|
||||
if (mScene->mNumAnimations == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Helper to find a bone by name in the scene
|
||||
aiBone *findBone(const aiScene *scene, const aiString &name) {
|
||||
for (size_t m = 0; m < scene->mNumMeshes; m++) {
|
||||
aiMesh *mesh = scene->mMeshes[m];
|
||||
for (size_t b = 0; b < mesh->mNumBones; b++) {
|
||||
aiBone *bone = mesh->mBones[b];
|
||||
if (name == bone->mName) {
|
||||
return bone;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mOutput << startstr << "<library_animations>" << endstr;
|
||||
PushTag();
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Helper to find the node associated with a bone in the scene
|
||||
const aiNode *findBoneNode(const aiNode *aNode, const aiBone *bone) {
|
||||
if (aNode && bone && aNode->mName == bone->mName) {
|
||||
return aNode;
|
||||
// start recursive write at the root node
|
||||
for (size_t a = 0; a < mScene->mNumAnimations; ++a) {
|
||||
WriteAnimationLibrary(a);
|
||||
}
|
||||
|
||||
if (aNode && bone) {
|
||||
for (unsigned int i = 0; i < aNode->mNumChildren; ++i) {
|
||||
aiNode *aChild = aNode->mChildren[i];
|
||||
const aiNode *foundFromChild = nullptr;
|
||||
if (aChild) {
|
||||
foundFromChild = findBoneNode(aChild, bone);
|
||||
if (foundFromChild) {
|
||||
return foundFromChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const aiNode *findSkeletonRootNode(const aiScene *scene, const aiMesh *mesh) {
|
||||
std::set<const aiNode *> topParentBoneNodes;
|
||||
if (mesh && mesh->mNumBones > 0) {
|
||||
for (unsigned int i = 0; i < mesh->mNumBones; ++i) {
|
||||
aiBone *bone = mesh->mBones[i];
|
||||
|
||||
const aiNode *node = findBoneNode(scene->mRootNode, bone);
|
||||
if (node) {
|
||||
while (node->mParent && findBone(scene, node->mParent->mName) != nullptr) {
|
||||
node = node->mParent;
|
||||
}
|
||||
topParentBoneNodes.insert(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!topParentBoneNodes.empty()) {
|
||||
const aiNode *parentBoneNode = *topParentBoneNodes.begin();
|
||||
if (topParentBoneNodes.size() == 1) {
|
||||
return parentBoneNode;
|
||||
} else {
|
||||
for (auto it : topParentBoneNodes) {
|
||||
if (it->mParent) return it->mParent;
|
||||
}
|
||||
return parentBoneNode;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</library_animations>" << endstr;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -1488,13 +1526,13 @@ void ColladaExporter::WriteNode(const aiNode *pNode) {
|
||||
// Assimp-specific: nodes with no name cannot be associated with bones
|
||||
const char *node_type;
|
||||
bool is_joint, is_skeleton_root = false;
|
||||
if (pNode->mName.length == 0 || nullptr == findBone(mScene, pNode->mName)) {
|
||||
if (pNode->mName.length == 0 || nullptr == mScene->findBone(pNode->mName)) {
|
||||
node_type = "NODE";
|
||||
is_joint = false;
|
||||
} else {
|
||||
node_type = "JOINT";
|
||||
is_joint = true;
|
||||
if (!pNode->mParent || nullptr == findBone(mScene, pNode->mParent->mName)) {
|
||||
if (!pNode->mParent || nullptr == mScene->findBone(pNode->mParent->mName)) {
|
||||
is_skeleton_root = true;
|
||||
}
|
||||
}
|
||||
@@ -1532,7 +1570,6 @@ void ColladaExporter::WriteNode(const aiNode *pNode) {
|
||||
}
|
||||
|
||||
// customized, sid should be 'matrix' to match with loader code.
|
||||
//mOutput << startstr << "<matrix sid=\"transform\">";
|
||||
mOutput << startstr << "<matrix sid=\"matrix\">";
|
||||
|
||||
mOutput << mat.a1 << " " << mat.a2 << " " << mat.a3 << " " << mat.a4 << " ";
|
||||
@@ -1556,7 +1593,6 @@ void ColladaExporter::WriteNode(const aiNode *pNode) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
// instance every geometry
|
||||
for (size_t a = 0; a < pNode->mNumMeshes; ++a) {
|
||||
@@ -1612,8 +1648,9 @@ void ColladaExporter::WriteNode(const aiNode *pNode) {
|
||||
}
|
||||
|
||||
// recurse into subnodes
|
||||
for (size_t a = 0; a < pNode->mNumChildren; ++a)
|
||||
for (size_t a = 0; a < pNode->mNumChildren; ++a) {
|
||||
WriteNode(pNode->mChildren[a]);
|
||||
}
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</node>" << endstr;
|
||||
@@ -1628,8 +1665,9 @@ void ColladaExporter::CreateNodeIds(const aiNode *node) {
|
||||
std::string ColladaExporter::GetNodeUniqueId(const aiNode *node) {
|
||||
// Use the pointer as the key. This is safe because the scene is immutable.
|
||||
auto idIt = mNodeIdMap.find(node);
|
||||
if (idIt != mNodeIdMap.cend())
|
||||
if (idIt != mNodeIdMap.cend()) {
|
||||
return idIt->second;
|
||||
}
|
||||
|
||||
// Prefer the requested Collada Id if extant
|
||||
std::string idStr;
|
||||
@@ -1640,36 +1678,42 @@ std::string ColladaExporter::GetNodeUniqueId(const aiNode *node) {
|
||||
idStr = node->mName.C_Str();
|
||||
}
|
||||
// Make sure the requested id is valid
|
||||
if (idStr.empty())
|
||||
if (idStr.empty()) {
|
||||
idStr = "node";
|
||||
else
|
||||
} else {
|
||||
idStr = XMLIDEncode(idStr);
|
||||
}
|
||||
|
||||
// Ensure it's unique
|
||||
idStr = MakeUniqueId(mUniqueIds, idStr, std::string());
|
||||
mUniqueIds.insert(idStr);
|
||||
mNodeIdMap.insert(std::make_pair(node, idStr));
|
||||
|
||||
return idStr;
|
||||
}
|
||||
|
||||
std::string ColladaExporter::GetNodeName(const aiNode *node) {
|
||||
|
||||
if (node == nullptr) {
|
||||
return std::string();
|
||||
}
|
||||
return XMLEscape(node->mName.C_Str());
|
||||
}
|
||||
|
||||
std::string ColladaExporter::GetBoneUniqueId(const aiBone *bone) {
|
||||
// Find the Node that is this Bone
|
||||
const aiNode *boneNode = findBoneNode(mScene->mRootNode, bone);
|
||||
if (boneNode == nullptr)
|
||||
const aiNode *boneNode = mScene->mRootNode->findBoneNode(bone);
|
||||
if (boneNode == nullptr) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
return GetNodeUniqueId(boneNode);
|
||||
}
|
||||
|
||||
std::string ColladaExporter::GetObjectUniqueId(AiObjectType type, size_t pIndex) {
|
||||
auto idIt = GetObjectIdMap(type).find(pIndex);
|
||||
if (idIt != GetObjectIdMap(type).cend())
|
||||
if (idIt != GetObjectIdMap(type).cend()) {
|
||||
return idIt->second;
|
||||
}
|
||||
|
||||
// Not seen this object before, create and add
|
||||
NameIdPair result = AddObjectIndexToMaps(type, pIndex);
|
||||
@@ -1678,8 +1722,9 @@ std::string ColladaExporter::GetObjectUniqueId(AiObjectType type, size_t pIndex)
|
||||
|
||||
std::string ColladaExporter::GetObjectName(AiObjectType type, size_t pIndex) {
|
||||
auto objectName = GetObjectNameMap(type).find(pIndex);
|
||||
if (objectName != GetObjectNameMap(type).cend())
|
||||
if (objectName != GetObjectNameMap(type).cend()) {
|
||||
return objectName->second;
|
||||
}
|
||||
|
||||
// Not seen this object before, create and add
|
||||
NameIdPair result = AddObjectIndexToMaps(type, pIndex);
|
||||
@@ -1699,9 +1744,15 @@ ColladaExporter::NameIdPair ColladaExporter::AddObjectIndexToMaps(AiObjectType t
|
||||
|
||||
// Get the name and id postfix
|
||||
switch (type) {
|
||||
case AiObjectType::Mesh: name = mScene->mMeshes[index]->mName.C_Str(); break;
|
||||
case AiObjectType::Material: name = mScene->mMaterials[index]->GetName().C_Str(); break;
|
||||
case AiObjectType::Animation: name = mScene->mAnimations[index]->mName.C_Str(); break;
|
||||
case AiObjectType::Mesh:
|
||||
name = mScene->mMeshes[index]->mName.C_Str();
|
||||
break;
|
||||
case AiObjectType::Material:
|
||||
name = mScene->mMaterials[index]->GetName().C_Str();
|
||||
break;
|
||||
case AiObjectType::Animation:
|
||||
name = mScene->mAnimations[index]->mName.C_Str();
|
||||
break;
|
||||
case AiObjectType::Light:
|
||||
name = mScene->mLights[index]->mName.C_Str();
|
||||
idPostfix = "-light";
|
||||
@@ -1710,7 +1761,8 @@ ColladaExporter::NameIdPair ColladaExporter::AddObjectIndexToMaps(AiObjectType t
|
||||
name = mScene->mCameras[index]->mName.C_Str();
|
||||
idPostfix = "-camera";
|
||||
break;
|
||||
case AiObjectType::Count: throw std::logic_error("ColladaExporter::AiObjectType::Count is not an object type");
|
||||
case AiObjectType::Count:
|
||||
throw std::logic_error("ColladaExporter::AiObjectType::Count is not an object type");
|
||||
}
|
||||
|
||||
if (name.empty()) {
|
||||
@@ -1728,8 +1780,9 @@ ColladaExporter::NameIdPair ColladaExporter::AddObjectIndexToMaps(AiObjectType t
|
||||
idStr = XMLIDEncode(name);
|
||||
}
|
||||
|
||||
if (!name.empty())
|
||||
if (!name.empty()) {
|
||||
name = XMLEscape(name);
|
||||
}
|
||||
|
||||
idStr = MakeUniqueId(mUniqueIds, idStr, idPostfix);
|
||||
|
||||
@@ -1743,5 +1796,5 @@ ColladaExporter::NameIdPair ColladaExporter::AddObjectIndexToMaps(AiObjectType t
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif // ASSIMP_BUILD_NO_COLLADA_EXPORTER
|
||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -72,7 +71,7 @@ public:
|
||||
ColladaExporter(const aiScene *pScene, IOSystem *pIOSystem, const std::string &path, const std::string &file);
|
||||
|
||||
/// Destructor
|
||||
virtual ~ColladaExporter();
|
||||
virtual ~ColladaExporter() = default;
|
||||
|
||||
protected:
|
||||
/// Starts writing the contents
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -1077,6 +1077,7 @@ static float getWeightAtKey(const std::vector<MorphTimeValues> &values, int key,
|
||||
return mKey.mWeight;
|
||||
}
|
||||
}
|
||||
|
||||
// no value at key found, try to interpolate if present at other keys. if not, return zero
|
||||
// TODO: interpolation
|
||||
return 0.0f;
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -77,8 +76,11 @@ struct ColladaMeshIndex {
|
||||
}
|
||||
};
|
||||
|
||||
/** Loader class to read Collada scenes. Collada is over-engineered to death, with every new iteration bringing
|
||||
* more useless stuff, so I limited the data to what I think is useful for games.
|
||||
/**
|
||||
* @brief Loader class to read Collada scenes.
|
||||
*
|
||||
* Collada is over-engineered to death, with every new iteration bringing more useless stuff,
|
||||
* so I limited the data to what I think is useful for games.
|
||||
*/
|
||||
class ColladaLoader : public BaseImporter {
|
||||
public:
|
||||
@@ -102,50 +104,51 @@ protected:
|
||||
/// See #BaseImporter::InternReadFile for the details
|
||||
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
|
||||
|
||||
/** Recursively constructs a scene node for the given parser node and returns it. */
|
||||
/// Recursively constructs a scene node for the given parser node and returns it.
|
||||
aiNode *BuildHierarchy(const ColladaParser &pParser, const Collada::Node *pNode);
|
||||
|
||||
/** Resolve node instances */
|
||||
/// Resolve node instances
|
||||
void ResolveNodeInstances(const ColladaParser &pParser, const Collada::Node *pNode,
|
||||
std::vector<const Collada::Node *> &resolved);
|
||||
|
||||
/** Builds meshes for the given node and references them */
|
||||
/// Builds meshes for the given node and references them
|
||||
void BuildMeshesForNode(const ColladaParser &pParser, const Collada::Node *pNode,
|
||||
aiNode *pTarget);
|
||||
|
||||
/// Lookup for meshes by their name
|
||||
aiMesh *findMesh(const std::string &meshid);
|
||||
|
||||
/** Creates a mesh for the given ColladaMesh face subset and returns the newly created mesh */
|
||||
/// Creates a mesh for the given ColladaMesh face subset and returns the newly created mesh
|
||||
aiMesh *CreateMesh(const ColladaParser &pParser, const Collada::Mesh *pSrcMesh, const Collada::SubMesh &pSubMesh,
|
||||
const Collada::Controller *pSrcController, size_t pStartVertex, size_t pStartFace);
|
||||
|
||||
/** Builds cameras for the given node and references them */
|
||||
/// Builds cameras for the given node and references them
|
||||
void BuildCamerasForNode(const ColladaParser &pParser, const Collada::Node *pNode,
|
||||
aiNode *pTarget);
|
||||
|
||||
/** Builds lights for the given node and references them */
|
||||
/// Builds lights for the given node and references them
|
||||
void BuildLightsForNode(const ColladaParser &pParser, const Collada::Node *pNode,
|
||||
aiNode *pTarget);
|
||||
|
||||
/** Stores all meshes in the given scene */
|
||||
/// Stores all meshes in the given scene
|
||||
void StoreSceneMeshes(aiScene *pScene);
|
||||
|
||||
/** Stores all materials in the given scene */
|
||||
/// Stores all materials in the given scene
|
||||
void StoreSceneMaterials(aiScene *pScene);
|
||||
|
||||
/** Stores all lights in the given scene */
|
||||
/// Stores all lights in the given scene
|
||||
void StoreSceneLights(aiScene *pScene);
|
||||
|
||||
/** Stores all cameras in the given scene */
|
||||
/// Stores all cameras in the given scene
|
||||
void StoreSceneCameras(aiScene *pScene);
|
||||
|
||||
/** Stores all textures in the given scene */
|
||||
/// Stores all textures in the given scene
|
||||
void StoreSceneTextures(aiScene *pScene);
|
||||
|
||||
/** Stores all animations
|
||||
* @param pScene target scene to store the anims
|
||||
*/
|
||||
void StoreAnimations(aiScene *pScene, const ColladaParser &pParser);
|
||||
/// Stores all animations
|
||||
/// @param pScene Target scene to store the anims
|
||||
/// @param parser The collada parser
|
||||
void StoreAnimations(aiScene *pScene, const ColladaParser &parser);
|
||||
|
||||
/** Stores all animations for the given source anim and its nested child animations
|
||||
* @param pScene target scene to store the anims
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -62,10 +61,7 @@ namespace DXF {
|
||||
// do NOT skip empty lines. In DXF files, they count as valid data.
|
||||
class LineReader {
|
||||
public:
|
||||
LineReader(StreamReaderLE& reader)
|
||||
: splitter(reader,false,true)
|
||||
, groupcode( 0 )
|
||||
, end() {
|
||||
LineReader(StreamReaderLE& reader) : splitter(reader,false,true), groupcode( 0 ), end() {
|
||||
// empty
|
||||
}
|
||||
|
||||
@@ -165,8 +161,7 @@ private:
|
||||
|
||||
// represents a POLYLINE or a LWPOLYLINE. or even a 3DFACE The data is converted as needed.
|
||||
struct PolyLine {
|
||||
PolyLine()
|
||||
: flags() {
|
||||
PolyLine() : flags() {
|
||||
// empty
|
||||
}
|
||||
|
||||
@@ -182,10 +177,7 @@ struct PolyLine {
|
||||
|
||||
// reference to a BLOCK. Specifies its own coordinate system.
|
||||
struct InsertBlock {
|
||||
InsertBlock()
|
||||
: pos()
|
||||
, scale(1.f,1.f,1.f)
|
||||
, angle() {
|
||||
InsertBlock() : pos(0.f, 0.f, 0.f), scale(1.f,1.f,1.f), angle(0.0f) {
|
||||
// empty
|
||||
}
|
||||
|
||||
@@ -198,8 +190,7 @@ struct InsertBlock {
|
||||
|
||||
|
||||
// keeps track of all geometry in a single BLOCK.
|
||||
struct Block
|
||||
{
|
||||
struct Block {
|
||||
std::vector< std::shared_ptr<PolyLine> > lines;
|
||||
std::vector<InsertBlock> insertions;
|
||||
|
||||
@@ -207,14 +198,12 @@ struct Block
|
||||
aiVector3D base;
|
||||
};
|
||||
|
||||
|
||||
struct FileData
|
||||
{
|
||||
struct FileData {
|
||||
// note: the LAST block always contains the stuff from ENTITIES.
|
||||
std::vector<Block> blocks;
|
||||
};
|
||||
|
||||
}
|
||||
} // Namespace Assimp
|
||||
} // namespace DXF
|
||||
} // namespace Assimp
|
||||
|
||||
#endif
|
||||
#endif // INCLUDED_DXFHELPER_H
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -143,31 +143,33 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element &element, cons
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const AnimationCurveMap &AnimationCurveNode::Curves() const {
|
||||
if (curves.empty()) {
|
||||
// resolve attached animation curves
|
||||
const std::vector<const Connection *> &conns = doc.GetConnectionsByDestinationSequenced(ID(), "AnimationCurve");
|
||||
if (!curves.empty()) {
|
||||
return curves;
|
||||
}
|
||||
|
||||
// resolve attached animation curves
|
||||
const std::vector<const Connection *> &conns = doc.GetConnectionsByDestinationSequenced(ID(), "AnimationCurve");
|
||||
|
||||
for (const Connection *con : conns) {
|
||||
for (const Connection *con : conns) {
|
||||
|
||||
// link should go for a property
|
||||
if (!con->PropertyName().length()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const Object *const ob = con->SourceObject();
|
||||
if (nullptr == ob) {
|
||||
DOMWarning("failed to read source object for AnimationCurve->AnimationCurveNode link, ignoring", &element);
|
||||
continue;
|
||||
}
|
||||
|
||||
const AnimationCurve *const anim = dynamic_cast<const AnimationCurve *>(ob);
|
||||
if (nullptr == anim) {
|
||||
DOMWarning("source object for ->AnimationCurveNode link is not an AnimationCurve", &element);
|
||||
continue;
|
||||
}
|
||||
|
||||
curves[con->PropertyName()] = anim;
|
||||
// link should go for a property
|
||||
if (!con->PropertyName().length()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const Object *const ob = con->SourceObject();
|
||||
if (nullptr == ob) {
|
||||
DOMWarning("failed to read source object for AnimationCurve->AnimationCurveNode link, ignoring", &element);
|
||||
continue;
|
||||
}
|
||||
|
||||
const AnimationCurve *const anim = dynamic_cast<const AnimationCurve *>(ob);
|
||||
if (nullptr == anim) {
|
||||
DOMWarning("source object for ->AnimationCurveNode link is not an AnimationCurve", &element);
|
||||
continue;
|
||||
}
|
||||
|
||||
curves[con->PropertyName()] = anim;
|
||||
}
|
||||
|
||||
return curves;
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -60,58 +59,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
namespace Assimp {
|
||||
namespace FBX {
|
||||
|
||||
//enum Flag
|
||||
//{
|
||||
// e_unknown_0 = 1 << 0,
|
||||
// e_unknown_1 = 1 << 1,
|
||||
// e_unknown_2 = 1 << 2,
|
||||
// e_unknown_3 = 1 << 3,
|
||||
// e_unknown_4 = 1 << 4,
|
||||
// e_unknown_5 = 1 << 5,
|
||||
// e_unknown_6 = 1 << 6,
|
||||
// e_unknown_7 = 1 << 7,
|
||||
// e_unknown_8 = 1 << 8,
|
||||
// e_unknown_9 = 1 << 9,
|
||||
// e_unknown_10 = 1 << 10,
|
||||
// e_unknown_11 = 1 << 11,
|
||||
// e_unknown_12 = 1 << 12,
|
||||
// e_unknown_13 = 1 << 13,
|
||||
// e_unknown_14 = 1 << 14,
|
||||
// e_unknown_15 = 1 << 15,
|
||||
// e_unknown_16 = 1 << 16,
|
||||
// e_unknown_17 = 1 << 17,
|
||||
// e_unknown_18 = 1 << 18,
|
||||
// e_unknown_19 = 1 << 19,
|
||||
// e_unknown_20 = 1 << 20,
|
||||
// e_unknown_21 = 1 << 21,
|
||||
// e_unknown_22 = 1 << 22,
|
||||
// e_unknown_23 = 1 << 23,
|
||||
// e_flag_field_size_64_bit = 1 << 24, // Not sure what is
|
||||
// e_unknown_25 = 1 << 25,
|
||||
// e_unknown_26 = 1 << 26,
|
||||
// e_unknown_27 = 1 << 27,
|
||||
// e_unknown_28 = 1 << 28,
|
||||
// e_unknown_29 = 1 << 29,
|
||||
// e_unknown_30 = 1 << 30,
|
||||
// e_unknown_31 = 1 << 31
|
||||
//};
|
||||
//
|
||||
//bool check_flag(uint32_t flags, Flag to_check)
|
||||
//{
|
||||
// return (flags & to_check) != 0;
|
||||
//}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Token::Token(const char* sbegin, const char* send, TokenType type, size_t offset)
|
||||
:
|
||||
#ifdef DEBUG
|
||||
contents(sbegin, static_cast<size_t>(send-sbegin)),
|
||||
#endif
|
||||
sbegin(sbegin)
|
||||
, send(send)
|
||||
, type(type)
|
||||
, line(offset)
|
||||
, column(BINARY_MARKER)
|
||||
{
|
||||
Token::Token(const char* sbegin, const char* send, TokenType type, size_t offset) :
|
||||
#ifdef DEBUG
|
||||
contents(sbegin, static_cast<size_t>(send-sbegin)),
|
||||
#endif
|
||||
sbegin(sbegin),
|
||||
send(send),
|
||||
type(type),
|
||||
line(offset),
|
||||
column(BINARY_MARKER) {
|
||||
ai_assert(sbegin);
|
||||
ai_assert(send);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -51,7 +51,8 @@ namespace Assimp {
|
||||
namespace FBX {
|
||||
|
||||
static constexpr size_t NumNullRecords = 25;
|
||||
const char NULL_RECORD[NumNullRecords] = { // 25 null bytes in 64-bit and 13 null bytes in 32-bit
|
||||
|
||||
constexpr char NULL_RECORD[NumNullRecords] = { // 25 null bytes in 64-bit and 13 null bytes in 32-bit
|
||||
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
|
||||
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'
|
||||
}; // who knows why, it looks like two integers 32/64 bit (compressed and uncompressed sizes?) + 1 byte (might be compression type?)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -181,7 +181,9 @@ FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBo
|
||||
if (out->mNumMeshes == 0) {
|
||||
out->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
|
||||
} else {
|
||||
correctRootTransform(mSceneOut);
|
||||
// Apply the FBX axis metadata unless requested not to
|
||||
if (!doc.Settings().ignoreUpDirection)
|
||||
correctRootTransform(mSceneOut);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +247,7 @@ struct FBXConverter::PotentialNode {
|
||||
/// todo: get bone from stack
|
||||
/// todo: make map of aiBone* to aiNode*
|
||||
/// then update convert clusters to the new format
|
||||
void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node) {
|
||||
void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node, const aiMatrix4x4& parent_transform) {
|
||||
const std::vector<const Connection *> &conns = doc.GetConnectionsByDestinationSequenced(id, "Model");
|
||||
|
||||
std::vector<PotentialNode> nodes;
|
||||
@@ -276,7 +278,7 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node)
|
||||
if (nullptr != model) {
|
||||
nodes_chain.clear();
|
||||
post_nodes_chain.clear();
|
||||
aiMatrix4x4 new_abs_transform = parent->mTransformation;
|
||||
aiMatrix4x4 new_abs_transform = parent_transform;
|
||||
std::string node_name = FixNodeName(model->Name());
|
||||
// even though there is only a single input node, the design of
|
||||
// assimp (or rather: the complicated transformation chain that
|
||||
@@ -310,6 +312,8 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node)
|
||||
|
||||
child->mParent = last_parent;
|
||||
last_parent = child.mNode;
|
||||
|
||||
new_abs_transform *= child->mTransformation;
|
||||
}
|
||||
|
||||
// attach geometry
|
||||
@@ -332,6 +336,8 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node)
|
||||
|
||||
postnode->mParent = last_parent;
|
||||
last_parent = postnode.mNode;
|
||||
|
||||
new_abs_transform *= postnode->mTransformation;
|
||||
}
|
||||
} else {
|
||||
// free the nodes we allocated as we don't need them
|
||||
@@ -339,7 +345,7 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node)
|
||||
}
|
||||
|
||||
// recursion call - child nodes
|
||||
ConvertNodes(model->ID(), last_parent, root_node);
|
||||
ConvertNodes(model->ID(), last_parent, root_node, new_abs_transform);
|
||||
|
||||
if (doc.Settings().readLights) {
|
||||
ConvertLights(*model, node_name);
|
||||
@@ -357,12 +363,12 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node)
|
||||
if (nodes.empty()) {
|
||||
parent->mNumChildren = 0;
|
||||
parent->mChildren = nullptr;
|
||||
}
|
||||
|
||||
parent->mChildren = new aiNode *[nodes.size()]();
|
||||
parent->mNumChildren = static_cast<unsigned int>(nodes.size());
|
||||
for (unsigned int i = 0; i < nodes.size(); ++i) {
|
||||
parent->mChildren[i] = nodes[i].mOwnership.release();
|
||||
} else {
|
||||
parent->mChildren = new aiNode *[nodes.size()]();
|
||||
parent->mNumChildren = static_cast<unsigned int>(nodes.size());
|
||||
for (unsigned int i = 0; i < nodes.size(); ++i) {
|
||||
parent->mChildren[i] = nodes[i].mOwnership.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,7 +438,8 @@ void FBXConverter::ConvertLight(const Light &light, const std::string &orig_name
|
||||
out_light->mType = aiLightSource_UNDEFINED;
|
||||
break;
|
||||
default:
|
||||
ai_assert(false);
|
||||
FBXImporter::LogError("Not handled light type: ", light.LightType());
|
||||
break;
|
||||
}
|
||||
|
||||
float decay = light.DecayStart();
|
||||
@@ -457,7 +464,7 @@ void FBXConverter::ConvertLight(const Light &light, const std::string &orig_name
|
||||
out_light->mAttenuationQuadratic = 1.0f;
|
||||
break;
|
||||
default:
|
||||
ai_assert(false);
|
||||
FBXImporter::LogError("Not handled light decay type: ", light.DecayType());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -595,7 +602,7 @@ const char *FBXConverter::NameTransformationCompProperty(TransformationComp comp
|
||||
return "GeometricRotationInverse";
|
||||
case TransformationComp_GeometricTranslationInverse:
|
||||
return "GeometricTranslationInverse";
|
||||
case TransformationComp_MAXIMUM: // this is to silence compiler warnings
|
||||
case TransformationComp_MAXIMUM:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -711,8 +718,7 @@ bool FBXConverter::NeedsComplexTransformationChain(const Model &model) {
|
||||
for (size_t i = 0; i < TransformationComp_MAXIMUM; ++i) {
|
||||
const TransformationComp comp = static_cast<TransformationComp>(i);
|
||||
|
||||
if (comp == TransformationComp_Rotation || comp == TransformationComp_Scaling || comp == TransformationComp_Translation ||
|
||||
comp == TransformationComp_PreRotation || comp == TransformationComp_PostRotation) {
|
||||
if (comp == TransformationComp_Rotation || comp == TransformationComp_Scaling || comp == TransformationComp_Translation) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1248,9 +1254,9 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, c
|
||||
for (const BlendShapeChannel *blendShapeChannel : blendShape->BlendShapeChannels()) {
|
||||
const auto& shapeGeometries = blendShapeChannel->GetShapeGeometries();
|
||||
for (const ShapeGeometry *shapeGeometry : shapeGeometries) {
|
||||
aiAnimMesh *animMesh = aiCreateAnimMesh(out_mesh);
|
||||
const auto &curVertices = shapeGeometry->GetVertices();
|
||||
const auto &curNormals = shapeGeometry->GetNormals();
|
||||
aiAnimMesh *animMesh = aiCreateAnimMesh(out_mesh, true, !curNormals.empty());
|
||||
const auto &curVertices = shapeGeometry->GetVertices();
|
||||
const auto &curIndices = shapeGeometry->GetIndices();
|
||||
//losing channel name if using shapeGeometry->Name()
|
||||
// if blendShapeChannel Name is empty or doesn't have a ".", add geoMetryName;
|
||||
@@ -1266,7 +1272,7 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, c
|
||||
for (size_t j = 0; j < curIndices.size(); j++) {
|
||||
const unsigned int curIndex = curIndices.at(j);
|
||||
aiVector3D vertex = curVertices.at(j);
|
||||
aiVector3D normal = curNormals.at(j);
|
||||
aiVector3D normal = curNormals.empty() ? aiVector3D() : curNormals.at(j);
|
||||
unsigned int count = 0;
|
||||
const unsigned int *outIndices = mesh.ToOutputVertexIndex(curIndex, count);
|
||||
for (unsigned int k = 0; k < count; k++) {
|
||||
@@ -1486,15 +1492,15 @@ unsigned int FBXConverter::ConvertMeshMultiMaterial(const MeshGeometry &mesh, co
|
||||
for (const BlendShapeChannel *blendShapeChannel : blendShape->BlendShapeChannels()) {
|
||||
const auto& shapeGeometries = blendShapeChannel->GetShapeGeometries();
|
||||
for (const ShapeGeometry *shapeGeometry : shapeGeometries) {
|
||||
aiAnimMesh *animMesh = aiCreateAnimMesh(out_mesh);
|
||||
const auto& curVertices = shapeGeometry->GetVertices();
|
||||
const auto& curNormals = shapeGeometry->GetNormals();
|
||||
aiAnimMesh *animMesh = aiCreateAnimMesh(out_mesh, true, !curNormals.empty());
|
||||
const auto& curVertices = shapeGeometry->GetVertices();
|
||||
const auto& curIndices = shapeGeometry->GetIndices();
|
||||
animMesh->mName.Set(FixAnimMeshName(shapeGeometry->Name()));
|
||||
for (size_t j = 0; j < curIndices.size(); j++) {
|
||||
unsigned int curIndex = curIndices.at(j);
|
||||
aiVector3D vertex = curVertices.at(j);
|
||||
aiVector3D normal = curNormals.at(j);
|
||||
aiVector3D normal = curNormals.empty() ? aiVector3D() : curNormals.at(j);
|
||||
unsigned int count = 0;
|
||||
const unsigned int *outIndices = mesh.ToOutputVertexIndex(curIndex, count);
|
||||
for (unsigned int k = 0; k < count; k++) {
|
||||
@@ -1670,14 +1676,14 @@ void FBXConverter::ConvertCluster(std::vector<aiBone*> &local_mesh_bones, const
|
||||
|
||||
//bone->mOffsetMatrix = cluster->Transform();
|
||||
// store local transform link for post processing
|
||||
|
||||
|
||||
bone->mOffsetMatrix = cluster->TransformLink();
|
||||
bone->mOffsetMatrix.Inverse();
|
||||
|
||||
const aiMatrix4x4 matrix = (aiMatrix4x4)absolute_transform;
|
||||
|
||||
bone->mOffsetMatrix = bone->mOffsetMatrix * matrix; // * mesh_offset
|
||||
|
||||
|
||||
//
|
||||
// Now calculate the aiVertexWeights
|
||||
//
|
||||
@@ -3410,7 +3416,7 @@ FBXConverter::KeyFrameListList FBXConverter::GetRotationKeyframeList(const std::
|
||||
KeyFrameListList inputs;
|
||||
inputs.reserve(nodes.size() * 3);
|
||||
|
||||
//give some breathing room for rounding errors
|
||||
// give some breathing room for rounding errors
|
||||
const int64_t adj_start = start - 10000;
|
||||
const int64_t adj_stop = stop + 10000;
|
||||
|
||||
@@ -3436,7 +3442,7 @@ FBXConverter::KeyFrameListList FBXConverter::GetRotationKeyframeList(const std::
|
||||
ai_assert(curve->GetKeys().size() == curve->GetValues().size());
|
||||
ai_assert(curve->GetKeys().size());
|
||||
|
||||
//get values within the start/stop time window
|
||||
// get values within the start/stop time window
|
||||
std::shared_ptr<KeyTimeList> Keys(new KeyTimeList());
|
||||
std::shared_ptr<KeyValueList> Values(new KeyValueList());
|
||||
const size_t count = curve->GetKeys().size();
|
||||
@@ -3456,8 +3462,7 @@ FBXConverter::KeyFrameListList FBXConverter::GetRotationKeyframeList(const std::
|
||||
if (tnew >= adj_start && tnew <= adj_stop) {
|
||||
Keys->push_back(tnew);
|
||||
Values->push_back(vnew);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Something broke
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -70,7 +69,7 @@ struct morphKeyData {
|
||||
std::vector<unsigned int> values;
|
||||
std::vector<float> weights;
|
||||
};
|
||||
typedef std::map<int64_t, morphKeyData*> morphAnimData;
|
||||
using morphAnimData = std::map<int64_t, morphKeyData*> ;
|
||||
|
||||
namespace Assimp {
|
||||
namespace FBX {
|
||||
@@ -134,7 +133,7 @@ private:
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// collect and assign child nodes
|
||||
void ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node);
|
||||
void ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node, const aiMatrix4x4& parent_transform = aiMatrix4x4());
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ConvertLights(const Model& model, const std::string &orig_name );
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -65,9 +65,6 @@ Deformer::Deformer(uint64_t id, const Element& element, const Document& doc, con
|
||||
props = GetPropertyTable(doc,"Deformer.Fbx" + classname,element,sc,true);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Deformer::~Deformer() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Cluster::Cluster(uint64_t id, const Element& element, const Document& doc, const std::string& name)
|
||||
: Deformer(id,element,doc,name)
|
||||
@@ -113,10 +110,6 @@ Cluster::Cluster(uint64_t id, const Element& element, const Document& doc, const
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Cluster::~Cluster() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Skin::Skin(uint64_t id, const Element& element, const Document& doc, const std::string& name)
|
||||
: Deformer(id,element,doc,name)
|
||||
@@ -142,9 +135,6 @@ Skin::Skin(uint64_t id, const Element& element, const Document& doc, const std::
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Skin::~Skin() = default;
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
BlendShape::BlendShape(uint64_t id, const Element& element, const Document& doc, const std::string& name)
|
||||
: Deformer(id, element, doc, name)
|
||||
@@ -161,8 +151,7 @@ BlendShape::BlendShape(uint64_t id, const Element& element, const Document& doc,
|
||||
}
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
BlendShape::~BlendShape() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
BlendShapeChannel::BlendShapeChannel(uint64_t id, const Element& element, const Document& doc, const std::string& name)
|
||||
: Deformer(id, element, doc, name)
|
||||
@@ -188,10 +177,8 @@ BlendShapeChannel::BlendShapeChannel(uint64_t id, const Element& element, const
|
||||
}
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
BlendShapeChannel::~BlendShapeChannel() = default;
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace FBX
|
||||
} // Namespace Assimp
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_FBX_IMPORTER
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -663,6 +663,10 @@ LazyObject& Connection::LazyDestinationObject() const {
|
||||
const Object* Connection::SourceObject() const {
|
||||
LazyObject* const lazy = doc.GetObject(src);
|
||||
ai_assert(lazy);
|
||||
if (lazy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return lazy->Get();
|
||||
}
|
||||
|
||||
@@ -670,6 +674,10 @@ const Object* Connection::SourceObject() const {
|
||||
const Object* Connection::DestinationObject() const {
|
||||
LazyObject* const lazy = doc.GetObject(dest);
|
||||
ai_assert(lazy);
|
||||
if (lazy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return lazy->Get();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -657,11 +657,11 @@ private:
|
||||
};
|
||||
|
||||
/** DOM class for generic FBX materials */
|
||||
class Material : public Object {
|
||||
class Material final : public Object {
|
||||
public:
|
||||
Material(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
||||
|
||||
virtual ~Material();
|
||||
~Material() override = default;
|
||||
|
||||
const std::string& GetShadingModel() const {
|
||||
return shading;
|
||||
@@ -835,7 +835,7 @@ private:
|
||||
class Deformer : public Object {
|
||||
public:
|
||||
Deformer(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
||||
virtual ~Deformer();
|
||||
virtual ~Deformer() = default;
|
||||
|
||||
const PropertyTable& Props() const {
|
||||
ai_assert(props.get());
|
||||
@@ -855,7 +855,7 @@ class BlendShapeChannel : public Deformer {
|
||||
public:
|
||||
BlendShapeChannel(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
||||
|
||||
virtual ~BlendShapeChannel();
|
||||
virtual ~BlendShapeChannel() = default;
|
||||
|
||||
float DeformPercent() const {
|
||||
return percent;
|
||||
@@ -880,7 +880,7 @@ class BlendShape : public Deformer {
|
||||
public:
|
||||
BlendShape(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
||||
|
||||
virtual ~BlendShape();
|
||||
virtual ~BlendShape() = default;
|
||||
|
||||
const std::unordered_set<const BlendShapeChannel*>& BlendShapeChannels() const {
|
||||
return blendShapeChannels;
|
||||
@@ -895,7 +895,7 @@ class Cluster : public Deformer {
|
||||
public:
|
||||
Cluster(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
||||
|
||||
virtual ~Cluster();
|
||||
virtual ~Cluster() = default;
|
||||
|
||||
/** get the list of deformer weights associated with this cluster.
|
||||
* Use #GetIndices() to get the associated vertices. Both arrays
|
||||
@@ -939,7 +939,7 @@ class Skin : public Deformer {
|
||||
public:
|
||||
Skin(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
||||
|
||||
virtual ~Skin();
|
||||
virtual ~Skin() = default;
|
||||
|
||||
float DeformAccuracy() const {
|
||||
return accuracy;
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -36,7 +35,6 @@ 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -81,8 +79,7 @@ void DOMWarning(const std::string& message, const Token& token) {
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void DOMWarning(const std::string& message, const Element* element /*= nullptr*/)
|
||||
{
|
||||
void DOMWarning(const std::string& message, const Element* element /*= nullptr*/) {
|
||||
if(element) {
|
||||
DOMWarning(message,element->KeyToken());
|
||||
return;
|
||||
@@ -92,41 +89,39 @@ void DOMWarning(const std::string& message, const Element* element /*= nullptr*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// fetch a property table and the corresponding property template
|
||||
std::shared_ptr<const PropertyTable> GetPropertyTable(const Document& doc,
|
||||
const std::string& templateName,
|
||||
const Element &element,
|
||||
const Scope& sc,
|
||||
bool no_warn /*= false*/)
|
||||
{
|
||||
const std::string& templateName,
|
||||
const Element &element,
|
||||
const Scope& sc,
|
||||
bool no_warn /*= false*/) {
|
||||
const Element* const Properties70 = sc["Properties70"];
|
||||
std::shared_ptr<const PropertyTable> templateProps = std::shared_ptr<const PropertyTable>(
|
||||
static_cast<const PropertyTable *>(nullptr));
|
||||
|
||||
if(templateName.length()) {
|
||||
if (templateName.length()) {
|
||||
PropertyTemplateMap::const_iterator it = doc.Templates().find(templateName);
|
||||
if(it != doc.Templates().end()) {
|
||||
templateProps = (*it).second;
|
||||
}
|
||||
}
|
||||
|
||||
if(!Properties70 || !Properties70->Compound()) {
|
||||
if (!Properties70 || !Properties70->Compound()) {
|
||||
if(!no_warn) {
|
||||
DOMWarning("property table (Properties70) not found",&element);
|
||||
}
|
||||
if(templateProps) {
|
||||
return templateProps;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return std::make_shared<const PropertyTable>();
|
||||
}
|
||||
}
|
||||
return std::make_shared<const PropertyTable>(*Properties70,templateProps);
|
||||
}
|
||||
|
||||
} // !Util
|
||||
} // !FBX
|
||||
} // !Assimp
|
||||
|
||||
#endif
|
||||
#endif // ASSIMP_BUILD_NO_FBX_IMPORTER
|
||||
|
||||
@@ -114,4 +114,4 @@ inline const T* ProcessSimpleConnection(const Connection& con,
|
||||
} //!FBX
|
||||
} //!Assimp
|
||||
|
||||
#endif
|
||||
#endif // ASSIMP_BUILD_NO_FBX_IMPORTER
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -35,7 +35,6 @@ 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
@@ -55,37 +54,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <memory> // shared_ptr
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// AddP70<type> helpers... there's no usable pattern here,
|
||||
// so all are defined as separate functions.
|
||||
// Even "animatable" properties are often completely different
|
||||
// from the standard (nonanimated) property definition,
|
||||
// so they are specified with an 'A' suffix.
|
||||
|
||||
void FBX::Node::AddP70int(
|
||||
const std::string& cur_name, int32_t value
|
||||
) {
|
||||
void FBX::Node::AddP70int(const std::string& cur_name, int32_t value) {
|
||||
FBX::Node n("P");
|
||||
n.AddProperties(cur_name, "int", "Integer", "", value);
|
||||
AddChild(n);
|
||||
}
|
||||
|
||||
void FBX::Node::AddP70bool(
|
||||
const std::string& cur_name, bool value
|
||||
) {
|
||||
void FBX::Node::AddP70bool(const std::string& cur_name, bool value) {
|
||||
FBX::Node n("P");
|
||||
n.AddProperties(cur_name, "bool", "", "", int32_t(value));
|
||||
AddChild(n);
|
||||
}
|
||||
|
||||
void FBX::Node::AddP70double(
|
||||
const std::string &cur_name, double value) {
|
||||
FBX::Node n("P");
|
||||
void FBX::Node::AddP70double(const std::string &cur_name, double value) { FBX::Node n("P");
|
||||
n.AddProperties(cur_name, "double", "Number", "", value);
|
||||
AddChild(n);
|
||||
}
|
||||
|
||||
void FBX::Node::AddP70numberA(
|
||||
const std::string &cur_name, double value) {
|
||||
void FBX::Node::AddP70numberA(const std::string &cur_name, double value) {
|
||||
FBX::Node n("P");
|
||||
n.AddProperties(cur_name, "Number", "", "A", value);
|
||||
AddChild(n);
|
||||
@@ -405,8 +398,7 @@ void FBX::Node::DumpChildrenAscii(std::ostream& s, int indent)
|
||||
}
|
||||
}
|
||||
|
||||
void FBX::Node::EndAscii(std::ostream& s, int indent, bool has_children)
|
||||
{
|
||||
void FBX::Node::EndAscii(std::ostream& s, int indent, bool has_children) {
|
||||
if (!has_children) { return; } // nothing to do
|
||||
s << '\n';
|
||||
for (int i = 0; i < indent; ++i) { s << '\t'; }
|
||||
@@ -417,11 +409,10 @@ void FBX::Node::EndAscii(std::ostream& s, int indent, bool has_children)
|
||||
|
||||
// ascii property node from vector of doubles
|
||||
void FBX::Node::WritePropertyNodeAscii(
|
||||
const std::string& name,
|
||||
const std::vector<double>& v,
|
||||
Assimp::StreamWriterLE& s,
|
||||
int indent
|
||||
){
|
||||
const std::string& name,
|
||||
const std::vector<double>& v,
|
||||
Assimp::StreamWriterLE& s,
|
||||
int indent){
|
||||
char buffer[32];
|
||||
FBX::Node node(name);
|
||||
node.Begin(s, false, indent);
|
||||
@@ -556,6 +547,8 @@ void FBX::Node::WritePropertyNode(
|
||||
FBX::Node::WritePropertyNodeAscii(name, v, s, indent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_FBX_EXPORTER
|
||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -35,7 +35,6 @@ 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -70,7 +69,6 @@ public:
|
||||
// some nodes always pretend they have children...
|
||||
bool force_has_children = false;
|
||||
|
||||
public: // constructors
|
||||
/// The default class constructor.
|
||||
Node() = default;
|
||||
|
||||
@@ -89,7 +87,6 @@ public: // constructors
|
||||
AddProperties(std::forward<More>(more)...);
|
||||
}
|
||||
|
||||
public: // functions to add properties or children
|
||||
// add a single property to the node
|
||||
template <typename T>
|
||||
void AddProperty(T&& value) {
|
||||
@@ -118,8 +115,6 @@ public: // functions to add properties or children
|
||||
children.push_back(std::move(c));
|
||||
}
|
||||
|
||||
public: // support specifically for dealing with Properties70 nodes
|
||||
|
||||
// it really is simpler to make these all separate functions.
|
||||
// the versions with 'A' suffixes are for animatable properties.
|
||||
// those often follow a completely different format internally in FBX.
|
||||
@@ -150,8 +145,6 @@ public: // support specifically for dealing with Properties70 nodes
|
||||
AddChild(n);
|
||||
}
|
||||
|
||||
public: // member functions for writing data to a file or stream
|
||||
|
||||
// write the full node to the given file or stream
|
||||
void Dump(
|
||||
const std::shared_ptr<Assimp::IOStream> &outfile,
|
||||
@@ -175,31 +168,6 @@ public: // member functions for writing data to a file or stream
|
||||
bool has_children
|
||||
);
|
||||
|
||||
private: // internal functions used for writing
|
||||
|
||||
void DumpBinary(Assimp::StreamWriterLE &s);
|
||||
void DumpAscii(Assimp::StreamWriterLE &s, int indent);
|
||||
void DumpAscii(std::ostream &s, int indent);
|
||||
|
||||
void BeginBinary(Assimp::StreamWriterLE &s);
|
||||
void DumpPropertiesBinary(Assimp::StreamWriterLE& s);
|
||||
void EndPropertiesBinary(Assimp::StreamWriterLE &s);
|
||||
void EndPropertiesBinary(Assimp::StreamWriterLE &s, size_t num_properties);
|
||||
void DumpChildrenBinary(Assimp::StreamWriterLE& s);
|
||||
void EndBinary(Assimp::StreamWriterLE &s, bool has_children);
|
||||
|
||||
void BeginAscii(std::ostream &s, int indent);
|
||||
void DumpPropertiesAscii(std::ostream &s, int indent);
|
||||
void BeginChildrenAscii(std::ostream &s, int indent);
|
||||
void DumpChildrenAscii(std::ostream &s, int indent);
|
||||
void EndAscii(std::ostream &s, int indent, bool has_children);
|
||||
|
||||
private: // data used for binary dumps
|
||||
size_t start_pos; // starting position in stream
|
||||
size_t end_pos; // ending position in stream
|
||||
size_t property_start; // starting position of property section
|
||||
|
||||
public: // static member functions
|
||||
|
||||
// convenience function to create a node with a single property,
|
||||
// and write it to the stream.
|
||||
@@ -235,7 +203,26 @@ public: // static member functions
|
||||
bool binary, int indent
|
||||
);
|
||||
|
||||
private: // static helper functions
|
||||
private: // internal functions used for writing
|
||||
|
||||
void DumpBinary(Assimp::StreamWriterLE &s);
|
||||
void DumpAscii(Assimp::StreamWriterLE &s, int indent);
|
||||
void DumpAscii(std::ostream &s, int indent);
|
||||
|
||||
void BeginBinary(Assimp::StreamWriterLE &s);
|
||||
void DumpPropertiesBinary(Assimp::StreamWriterLE& s);
|
||||
void EndPropertiesBinary(Assimp::StreamWriterLE &s);
|
||||
void EndPropertiesBinary(Assimp::StreamWriterLE &s, size_t num_properties);
|
||||
void DumpChildrenBinary(Assimp::StreamWriterLE& s);
|
||||
void EndBinary(Assimp::StreamWriterLE &s, bool has_children);
|
||||
|
||||
void BeginAscii(std::ostream &s, int indent);
|
||||
void DumpPropertiesAscii(std::ostream &s, int indent);
|
||||
void BeginChildrenAscii(std::ostream &s, int indent);
|
||||
void DumpChildrenAscii(std::ostream &s, int indent);
|
||||
void EndAscii(std::ostream &s, int indent, bool has_children);
|
||||
|
||||
// static helper functions
|
||||
static void WritePropertyNodeAscii(
|
||||
const std::string& name,
|
||||
const std::vector<double>& v,
|
||||
@@ -259,9 +246,13 @@ private: // static helper functions
|
||||
Assimp::StreamWriterLE& s
|
||||
);
|
||||
|
||||
private: // data used for binary dumps
|
||||
size_t start_pos; // starting position in stream
|
||||
size_t end_pos; // ending position in stream
|
||||
size_t property_start; // starting position of property section
|
||||
};
|
||||
}
|
||||
|
||||
} // Namespace Assimp
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_FBX_EXPORTER
|
||||
|
||||
#endif // AI_FBXEXPORTNODE_H_INC
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
+277
-305
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -370,12 +370,6 @@ void FBXExporter::WriteHeaderExtension ()
|
||||
"Creator", creator.str(), outstream, binary, indent
|
||||
);
|
||||
|
||||
//FBX::Node sceneinfo("SceneInfo");
|
||||
//sceneinfo.AddProperty("GlobalInfo" + FBX::SEPARATOR + "SceneInfo");
|
||||
// not sure if any of this is actually needed,
|
||||
// so just write an empty node for now.
|
||||
//sceneinfo.Dump(outstream, binary, indent);
|
||||
|
||||
indent = 0;
|
||||
|
||||
// finish node
|
||||
@@ -459,11 +453,7 @@ void WritePropString(const aiScene* scene, FBX::Node& p, const std::string& key,
|
||||
}
|
||||
}
|
||||
|
||||
void FBXExporter::WriteGlobalSettings ()
|
||||
{
|
||||
if (!binary) {
|
||||
// no title, follows directly from the header extension
|
||||
}
|
||||
void FBXExporter::WriteGlobalSettings () {
|
||||
FBX::Node gs("GlobalSettings");
|
||||
gs.AddChild("Version", int32_t(1000));
|
||||
|
||||
@@ -493,8 +483,7 @@ void FBXExporter::WriteGlobalSettings ()
|
||||
gs.Dump(outfile, binary, 0);
|
||||
}
|
||||
|
||||
void FBXExporter::WriteDocuments ()
|
||||
{
|
||||
void FBXExporter::WriteDocuments() {
|
||||
if (!binary) {
|
||||
WriteAsciiSectionHeader("Documents Description");
|
||||
}
|
||||
@@ -523,8 +512,7 @@ void FBXExporter::WriteDocuments ()
|
||||
docs.Dump(outfile, binary, 0);
|
||||
}
|
||||
|
||||
void FBXExporter::WriteReferences ()
|
||||
{
|
||||
void FBXExporter::WriteReferences() {
|
||||
if (!binary) {
|
||||
WriteAsciiSectionHeader("Document References");
|
||||
}
|
||||
@@ -540,7 +528,6 @@ void FBXExporter::WriteReferences ()
|
||||
// some internal helper functions used for writing the definitions
|
||||
// (before any actual data is written)
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
size_t count_nodes(const aiNode* n, const aiNode* root) {
|
||||
size_t count;
|
||||
if (n == root) {
|
||||
@@ -556,8 +543,7 @@ size_t count_nodes(const aiNode* n, const aiNode* root) {
|
||||
return count;
|
||||
}
|
||||
|
||||
bool has_phong_mat(const aiScene* scene)
|
||||
{
|
||||
static bool has_phong_mat(const aiScene* scene) {
|
||||
// just search for any material with a shininess exponent
|
||||
for (size_t i = 0; i < scene->mNumMaterials; ++i) {
|
||||
aiMaterial* mat = scene->mMaterials[i];
|
||||
@@ -570,16 +556,12 @@ bool has_phong_mat(const aiScene* scene)
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t count_images(const aiScene* scene) {
|
||||
static size_t count_images(const aiScene* scene) {
|
||||
std::unordered_set<std::string> images;
|
||||
aiString texpath;
|
||||
for (size_t i = 0; i < scene->mNumMaterials; ++i) {
|
||||
aiMaterial* mat = scene->mMaterials[i];
|
||||
for (
|
||||
size_t tt = aiTextureType_DIFFUSE;
|
||||
tt < aiTextureType_UNKNOWN;
|
||||
++tt
|
||||
){
|
||||
aiMaterial *mat = scene->mMaterials[i];
|
||||
for (size_t tt = aiTextureType_DIFFUSE; tt < aiTextureType_UNKNOWN; ++tt) {
|
||||
const aiTextureType textype = static_cast<aiTextureType>(tt);
|
||||
const size_t texcount = mat->GetTextureCount(textype);
|
||||
for (unsigned int j = 0; j < texcount; ++j) {
|
||||
@@ -588,10 +570,11 @@ size_t count_images(const aiScene* scene) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return images.size();
|
||||
}
|
||||
|
||||
size_t count_textures(const aiScene* scene) {
|
||||
static size_t count_textures(const aiScene* scene) {
|
||||
size_t count = 0;
|
||||
for (size_t i = 0; i < scene->mNumMaterials; ++i) {
|
||||
aiMaterial* mat = scene->mMaterials[i];
|
||||
@@ -609,7 +592,7 @@ size_t count_textures(const aiScene* scene) {
|
||||
return count;
|
||||
}
|
||||
|
||||
size_t count_deformers(const aiScene* scene) {
|
||||
static size_t count_deformers(const aiScene* scene) {
|
||||
size_t count = 0;
|
||||
for (size_t i = 0; i < scene->mNumMeshes; ++i) {
|
||||
const size_t n = scene->mMeshes[i]->mNumBones;
|
||||
@@ -621,8 +604,7 @@ size_t count_deformers(const aiScene* scene) {
|
||||
return count;
|
||||
}
|
||||
|
||||
void FBXExporter::WriteDefinitions ()
|
||||
{
|
||||
void FBXExporter::WriteDefinitions () {
|
||||
// basically this is just bookkeeping:
|
||||
// determining how many of each type of object there are
|
||||
// and specifying the base properties to use when otherwise unspecified.
|
||||
@@ -1033,9 +1015,7 @@ void FBXExporter::WriteDefinitions ()
|
||||
// some internal helper functions used for writing the objects section
|
||||
// (which holds the actual data)
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
aiNode* get_node_for_mesh(unsigned int meshIndex, aiNode* node)
|
||||
{
|
||||
static aiNode* get_node_for_mesh(unsigned int meshIndex, aiNode* node) {
|
||||
for (size_t i = 0; i < node->mNumMeshes; ++i) {
|
||||
if (node->mMeshes[i] == meshIndex) {
|
||||
return node;
|
||||
@@ -1048,8 +1028,7 @@ aiNode* get_node_for_mesh(unsigned int meshIndex, aiNode* node)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aiMatrix4x4 get_world_transform(const aiNode* node, const aiScene* scene)
|
||||
{
|
||||
aiMatrix4x4 get_world_transform(const aiNode* node, const aiScene* scene) {
|
||||
std::vector<const aiNode*> node_chain;
|
||||
while (node != scene->mRootNode && node != nullptr) {
|
||||
node_chain.push_back(node);
|
||||
@@ -1073,8 +1052,7 @@ inline int64_t to_ktime(double time) {
|
||||
return (static_cast<int64_t>(time * FBX::SECOND));
|
||||
}
|
||||
|
||||
void FBXExporter::WriteObjects ()
|
||||
{
|
||||
void FBXExporter::WriteObjects () {
|
||||
if (!binary) {
|
||||
WriteAsciiSectionHeader("Object properties");
|
||||
}
|
||||
@@ -1087,21 +1065,28 @@ void FBXExporter::WriteObjects ()
|
||||
object_node.BeginChildren(outstream, binary, indent);
|
||||
|
||||
bool bJoinIdenticalVertices = mProperties->GetPropertyBool("bJoinIdenticalVertices", true);
|
||||
std::vector<std::vector<int32_t>> vVertexIndice;//save vertex_indices as it is needed later
|
||||
// save vertex_indices as it is needed later
|
||||
std::vector<std::vector<int32_t>> vVertexIndice(mScene->mNumMeshes);
|
||||
|
||||
std::vector<uint32_t> uniq_v_before_mi;
|
||||
|
||||
const auto bTransparencyFactorReferencedToOpacity = mProperties->GetPropertyBool(AI_CONFIG_EXPORT_FBX_TRANSPARENCY_FACTOR_REFER_TO_OPACITY, false);
|
||||
|
||||
// geometry (aiMesh)
|
||||
mesh_uids.clear();
|
||||
indent = 1;
|
||||
for (size_t mi = 0; mi < mScene->mNumMeshes; ++mi) {
|
||||
// it's all about this mesh
|
||||
aiMesh* m = mScene->mMeshes[mi];
|
||||
std::function<void(const aiNode*)> visit_node_geo = [&](const aiNode *node) {
|
||||
if (node->mNumMeshes == 0) {
|
||||
for (uint32_t ni = 0; ni < node->mNumChildren; ni++) {
|
||||
visit_node_geo(node->mChildren[ni]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// start the node record
|
||||
FBX::Node n("Geometry");
|
||||
int64_t uid = generate_uid();
|
||||
mesh_uids.push_back(uid);
|
||||
mesh_uids[node] = uid;
|
||||
n.AddProperty(uid);
|
||||
n.AddProperty(FBX::SEPARATOR + "Geometry");
|
||||
n.AddProperty("Mesh");
|
||||
@@ -1109,158 +1094,112 @@ void FBXExporter::WriteObjects ()
|
||||
n.DumpProperties(outstream, binary, indent);
|
||||
n.EndProperties(outstream, binary, indent);
|
||||
n.BeginChildren(outstream, binary, indent);
|
||||
indent = 2;
|
||||
|
||||
// output vertex data - each vertex should be unique (probably)
|
||||
std::vector<double> flattened_vertices;
|
||||
// index of original vertex in vertex data vector
|
||||
std::vector<int32_t> vertex_indices;
|
||||
// map of vertex value to its index in the data vector
|
||||
std::map<aiVector3D,size_t> index_by_vertex_value;
|
||||
if(bJoinIdenticalVertices){
|
||||
int32_t index = 0;
|
||||
for (size_t vi = 0; vi < m->mNumVertices; ++vi) {
|
||||
aiVector3D vtx = m->mVertices[vi];
|
||||
auto elem = index_by_vertex_value.find(vtx);
|
||||
if (elem == index_by_vertex_value.end()) {
|
||||
vertex_indices.push_back(index);
|
||||
index_by_vertex_value[vtx] = index;
|
||||
flattened_vertices.push_back(vtx[0]);
|
||||
flattened_vertices.push_back(vtx[1]);
|
||||
flattened_vertices.push_back(vtx[2]);
|
||||
++index;
|
||||
} else {
|
||||
vertex_indices.push_back(int32_t(elem->second));
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // do not join vertex, respect the export flag
|
||||
vertex_indices.resize(m->mNumVertices);
|
||||
std::iota(vertex_indices.begin(), vertex_indices.end(), 0);
|
||||
for(unsigned int v = 0; v < m->mNumVertices; ++ v) {
|
||||
aiVector3D vtx = m->mVertices[v];
|
||||
flattened_vertices.push_back(vtx.x);
|
||||
flattened_vertices.push_back(vtx.y);
|
||||
flattened_vertices.push_back(vtx.z);
|
||||
}
|
||||
}
|
||||
vVertexIndice.push_back(vertex_indices);
|
||||
|
||||
FBX::Node::WritePropertyNode(
|
||||
"Vertices", flattened_vertices, outstream, binary, indent
|
||||
);
|
||||
std::vector<double> normal_data;
|
||||
std::vector<double> color_data;
|
||||
|
||||
std::vector<int32_t> polygon_data;
|
||||
|
||||
std::vector<std::vector<double>> uv_data;
|
||||
std::vector<std::vector<int32_t>> uv_indices;
|
||||
std::map<aiVector3D, int32_t> index_by_uv;
|
||||
|
||||
std::vector<int32_t> offsets = { 0 };
|
||||
|
||||
indent = 2;
|
||||
|
||||
for (uint32_t n_mi = 0; n_mi < node->mNumMeshes; n_mi++) {
|
||||
const auto mi = node->mMeshes[n_mi];
|
||||
const aiMesh *m = mScene->mMeshes[mi];
|
||||
|
||||
size_t v_offset = vertex_indices.size();
|
||||
size_t uniq_v_before = flattened_vertices.size() / 3;
|
||||
|
||||
// map of vertex value to its index in the data vector
|
||||
std::map<aiVector3D,size_t> index_by_vertex_value;
|
||||
if(bJoinIdenticalVertices){
|
||||
int32_t index = 0;
|
||||
for (size_t vi = 0; vi < m->mNumVertices; ++vi) {
|
||||
aiVector3D vtx = m->mVertices[vi];
|
||||
auto elem = index_by_vertex_value.find(vtx);
|
||||
if (elem == index_by_vertex_value.end()) {
|
||||
vertex_indices.push_back(index);
|
||||
index_by_vertex_value[vtx] = index;
|
||||
flattened_vertices.insert(flattened_vertices.end(), { vtx.x, vtx.y, vtx.z });
|
||||
++index;
|
||||
} else {
|
||||
vertex_indices.push_back(int32_t(elem->second));
|
||||
}
|
||||
}
|
||||
} else { // do not join vertex, respect the export flag
|
||||
vertex_indices.resize(v_offset + m->mNumVertices);
|
||||
std::iota(vertex_indices.begin() + v_offset, vertex_indices.end(), (int)v_offset);
|
||||
for(unsigned int v = 0; v < m->mNumVertices; ++ v) {
|
||||
aiVector3D vtx = m->mVertices[v];
|
||||
flattened_vertices.insert(flattened_vertices.end(), {vtx.x, vtx.y, vtx.z});
|
||||
}
|
||||
}
|
||||
vVertexIndice[mi].insert(
|
||||
// TODO test whether this can be end or not
|
||||
vVertexIndice[mi].begin(),
|
||||
vertex_indices.begin(),
|
||||
vertex_indices.end()
|
||||
);
|
||||
|
||||
// here could be edges but they're insane.
|
||||
// it's optional anyway, so let's ignore it.
|
||||
|
||||
// output polygon data as a flattened array of vertex indices.
|
||||
// the last vertex index of each polygon is negated and - 1
|
||||
std::vector<int32_t> polygon_data;
|
||||
for (size_t fi = 0; fi < m->mNumFaces; ++fi) {
|
||||
for (size_t fi = 0; fi < m->mNumFaces; fi++) {
|
||||
const aiFace &f = m->mFaces[fi];
|
||||
for (size_t pvi = 0; pvi < f.mNumIndices - 1; ++pvi) {
|
||||
polygon_data.push_back(vertex_indices[f.mIndices[pvi]]);
|
||||
size_t pvi = 0;
|
||||
for (; pvi < f.mNumIndices - 1; pvi++) {
|
||||
polygon_data.push_back(
|
||||
static_cast<int32_t>(uniq_v_before + vertex_indices[v_offset + f.mIndices[pvi]])
|
||||
);
|
||||
}
|
||||
polygon_data.push_back(
|
||||
-1 - vertex_indices[f.mIndices[f.mNumIndices-1]]
|
||||
static_cast<int32_t>(-1 - (uniq_v_before + vertex_indices[v_offset+f.mIndices[pvi]]))
|
||||
);
|
||||
}
|
||||
FBX::Node::WritePropertyNode(
|
||||
"PolygonVertexIndex", polygon_data, outstream, binary, indent
|
||||
);
|
||||
}
|
||||
|
||||
// here could be edges but they're insane.
|
||||
// it's optional anyway, so let's ignore it.
|
||||
uniq_v_before_mi.push_back(static_cast<uint32_t>(uniq_v_before));
|
||||
|
||||
FBX::Node::WritePropertyNode(
|
||||
"GeometryVersion", int32_t(124), outstream, binary, indent
|
||||
);
|
||||
|
||||
// normals, if any
|
||||
if (m->HasNormals()) {
|
||||
FBX::Node normals("LayerElementNormal", int32_t(0));
|
||||
normals.Begin(outstream, binary, indent);
|
||||
normals.DumpProperties(outstream, binary, indent);
|
||||
normals.EndProperties(outstream, binary, indent);
|
||||
normals.BeginChildren(outstream, binary, indent);
|
||||
indent = 3;
|
||||
FBX::Node::WritePropertyNode(
|
||||
"Version", int32_t(101), outstream, binary, indent
|
||||
);
|
||||
FBX::Node::WritePropertyNode(
|
||||
"Name", "", outstream, binary, indent
|
||||
);
|
||||
FBX::Node::WritePropertyNode(
|
||||
"MappingInformationType", "ByPolygonVertex",
|
||||
outstream, binary, indent
|
||||
);
|
||||
// TODO: vertex-normals or indexed normals when appropriate
|
||||
FBX::Node::WritePropertyNode(
|
||||
"ReferenceInformationType", "Direct",
|
||||
outstream, binary, indent
|
||||
);
|
||||
std::vector<double> normal_data;
|
||||
if (m->HasNormals()) {
|
||||
normal_data.reserve(3 * polygon_data.size());
|
||||
for (size_t fi = 0; fi < m->mNumFaces; ++fi) {
|
||||
const aiFace &f = m->mFaces[fi];
|
||||
for (size_t pvi = 0; pvi < f.mNumIndices; ++pvi) {
|
||||
const aiVector3D &curN = m->mNormals[f.mIndices[pvi]];
|
||||
normal_data.push_back(curN.x);
|
||||
normal_data.push_back(curN.y);
|
||||
normal_data.push_back(curN.z);
|
||||
}
|
||||
for (size_t fi = 0; fi < m->mNumFaces; fi++) {
|
||||
const aiFace & f = m->mFaces[fi];
|
||||
for (size_t pvi = 0; pvi < f.mNumIndices; pvi++) {
|
||||
const aiVector3D &curN = m->mNormals[f.mIndices[pvi]];
|
||||
normal_data.insert(normal_data.end(), { curN.x, curN.y, curN.z });
|
||||
}
|
||||
}
|
||||
FBX::Node::WritePropertyNode(
|
||||
"Normals", normal_data, outstream, binary, indent
|
||||
);
|
||||
// note: version 102 has a NormalsW also... not sure what it is,
|
||||
// so we can stick with version 101 for now.
|
||||
indent = 2;
|
||||
normals.End(outstream, binary, indent, true);
|
||||
}
|
||||
}
|
||||
|
||||
// colors, if any
|
||||
for (size_t ci = 0; ci < m->GetNumColorChannels(); ++ci) {
|
||||
FBX::Node vertexcolors("LayerElementColor", int32_t(ci));
|
||||
vertexcolors.Begin(outstream, binary, indent);
|
||||
vertexcolors.DumpProperties(outstream, binary, indent);
|
||||
vertexcolors.EndProperties(outstream, binary, indent);
|
||||
vertexcolors.BeginChildren(outstream, binary, indent);
|
||||
indent = 3;
|
||||
FBX::Node::WritePropertyNode(
|
||||
"Version", int32_t(101), outstream, binary, indent
|
||||
);
|
||||
char layerName[8];
|
||||
snprintf(layerName, sizeof(layerName), "COLOR_%d", int32_t(ci));
|
||||
FBX::Node::WritePropertyNode(
|
||||
"Name", (const char*)layerName, outstream, binary, indent
|
||||
);
|
||||
FBX::Node::WritePropertyNode(
|
||||
"MappingInformationType", "ByPolygonVertex",
|
||||
outstream, binary, indent
|
||||
);
|
||||
FBX::Node::WritePropertyNode(
|
||||
"ReferenceInformationType", "Direct",
|
||||
outstream, binary, indent
|
||||
);
|
||||
std::vector<double> color_data;
|
||||
const int32_t colorChannelIndex = 0;
|
||||
if (m->HasVertexColors(colorChannelIndex)) {
|
||||
color_data.reserve(4 * polygon_data.size());
|
||||
for (size_t fi = 0; fi < m->mNumFaces; ++fi) {
|
||||
const aiFace &f = m->mFaces[fi];
|
||||
for (size_t pvi = 0; pvi < f.mNumIndices; ++pvi) {
|
||||
const aiColor4D &c = m->mColors[ci][f.mIndices[pvi]];
|
||||
color_data.push_back(c.r);
|
||||
color_data.push_back(c.g);
|
||||
color_data.push_back(c.b);
|
||||
color_data.push_back(c.a);
|
||||
}
|
||||
for (size_t fi = 0; fi < m->mNumFaces; fi++) {
|
||||
const aiFace &f = m->mFaces[fi];
|
||||
for (size_t pvi = 0; pvi < f.mNumIndices; pvi++) {
|
||||
const aiColor4D &c = m->mColors[colorChannelIndex][f.mIndices[pvi]];
|
||||
color_data.insert(color_data.end(), { c.r, c.g, c.b, c.a });
|
||||
}
|
||||
}
|
||||
FBX::Node::WritePropertyNode(
|
||||
"Colors", color_data, outstream, binary, indent
|
||||
);
|
||||
indent = 2;
|
||||
vertexcolors.End(outstream, binary, indent, true);
|
||||
}
|
||||
}
|
||||
|
||||
// uvs, if any
|
||||
for (size_t uvi = 0; uvi < m->GetNumUVChannels(); ++uvi) {
|
||||
const auto num_uv = static_cast<size_t>(m->GetNumUVChannels());
|
||||
uv_indices.resize(std::max(num_uv, uv_indices.size()));
|
||||
uv_data.resize(std::max(num_uv, uv_data.size()));
|
||||
|
||||
// uvs, if any
|
||||
for (size_t uvi = 0; uvi < m->GetNumUVChannels(); uvi++) {
|
||||
if (m->mNumUVComponents[uvi] > 2) {
|
||||
// FBX only supports 2-channel UV maps...
|
||||
// or at least i'm not sure how to indicate a different number
|
||||
@@ -1276,71 +1215,111 @@ void FBXExporter::WriteObjects ()
|
||||
err << " but may be incorrectly interpreted on load.";
|
||||
ASSIMP_LOG_WARN(err.str());
|
||||
}
|
||||
FBX::Node uv("LayerElementUV", int32_t(uvi));
|
||||
uv.Begin(outstream, binary, indent);
|
||||
uv.DumpProperties(outstream, binary, indent);
|
||||
uv.EndProperties(outstream, binary, indent);
|
||||
uv.BeginChildren(outstream, binary, indent);
|
||||
indent = 3;
|
||||
FBX::Node::WritePropertyNode(
|
||||
"Version", int32_t(101), outstream, binary, indent
|
||||
);
|
||||
// it doesn't seem like assimp keeps the uv map name,
|
||||
// so just leave it blank.
|
||||
FBX::Node::WritePropertyNode(
|
||||
"Name", "", outstream, binary, indent
|
||||
);
|
||||
FBX::Node::WritePropertyNode(
|
||||
"MappingInformationType", "ByPolygonVertex",
|
||||
outstream, binary, indent
|
||||
);
|
||||
FBX::Node::WritePropertyNode(
|
||||
"ReferenceInformationType", "IndexToDirect",
|
||||
outstream, binary, indent
|
||||
);
|
||||
|
||||
std::vector<double> uv_data;
|
||||
std::vector<int32_t> uv_indices;
|
||||
std::map<aiVector3D,int32_t> index_by_uv;
|
||||
int32_t index = 0;
|
||||
for (size_t fi = 0; fi < m->mNumFaces; ++fi) {
|
||||
const aiFace &f = m->mFaces[fi];
|
||||
for (size_t pvi = 0; pvi < f.mNumIndices; ++pvi) {
|
||||
const aiVector3D &curUv =
|
||||
m->mTextureCoords[uvi][f.mIndices[pvi]];
|
||||
auto elem = index_by_uv.find(curUv);
|
||||
if (elem == index_by_uv.end()) {
|
||||
index_by_uv[curUv] = index;
|
||||
uv_indices.push_back(index);
|
||||
for (unsigned int x = 0; x < m->mNumUVComponents[uvi]; ++x) {
|
||||
uv_data.push_back(curUv[x]);
|
||||
}
|
||||
++index;
|
||||
} else {
|
||||
uv_indices.push_back(elem->second);
|
||||
}
|
||||
for (size_t fi = 0; fi < m->mNumFaces; fi++) {
|
||||
const aiFace &f = m->mFaces[fi];
|
||||
for (size_t pvi = 0; pvi < f.mNumIndices; pvi++) {
|
||||
const aiVector3D &curUv = m->mTextureCoords[uvi][f.mIndices[pvi]];
|
||||
auto elem = index_by_uv.find(curUv);
|
||||
if (elem == index_by_uv.end()) {
|
||||
index_by_uv[curUv] = index;
|
||||
uv_indices[uvi].push_back(index);
|
||||
for (uint32_t x = 0; x < m->mNumUVComponents[uvi]; ++x) {
|
||||
uv_data[uvi].push_back(curUv[x]);
|
||||
}
|
||||
++index;
|
||||
} else {
|
||||
uv_indices[uvi].push_back(elem->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
FBX::Node::WritePropertyNode(
|
||||
"UV", uv_data, outstream, binary, indent
|
||||
);
|
||||
FBX::Node::WritePropertyNode(
|
||||
"UVIndex", uv_indices, outstream, binary, indent
|
||||
);
|
||||
indent = 2;
|
||||
uv.End(outstream, binary, indent, true);
|
||||
}
|
||||
|
||||
offsets.push_back((int32_t)polygon_data.size());
|
||||
}
|
||||
|
||||
// i'm not really sure why this material section exists,
|
||||
// as the material is linked via "Connections".
|
||||
// it seems to always have the same "0" value.
|
||||
|
||||
FBX::Node::WritePropertyNode("Vertices", flattened_vertices, outstream, binary, indent);
|
||||
FBX::Node::WritePropertyNode("PolygonVertexIndex", polygon_data, outstream, binary, indent);
|
||||
FBX::Node::WritePropertyNode("GeometryVersion", int32_t(124), outstream, binary, indent);
|
||||
|
||||
FBX::Node normals("LayerElementNormal", int32_t(0));
|
||||
normals.Begin(outstream, binary, indent);
|
||||
normals.DumpProperties(outstream, binary, indent);
|
||||
normals.EndProperties(outstream, binary, indent);
|
||||
normals.BeginChildren(outstream, binary, indent);
|
||||
indent = 3;
|
||||
FBX::Node::WritePropertyNode("Version", int32_t(101),outstream,binary,indent);
|
||||
FBX::Node::WritePropertyNode("Name", "",outstream,binary,indent);
|
||||
FBX::Node::WritePropertyNode("MappingInformationType", "ByPolygonVertex",outstream,binary,indent);
|
||||
FBX::Node::WritePropertyNode("ReferenceInformationType", "Direct",outstream,binary,indent);
|
||||
FBX::Node::WritePropertyNode("Normals", normal_data,outstream,binary,indent);
|
||||
// note: version 102 has a NormalsW also... not sure what it is,
|
||||
// so stick with version 101 for now.
|
||||
indent = 2;
|
||||
normals.End(outstream,binary,indent,true);
|
||||
|
||||
const auto colorChannelIndex = 0;
|
||||
FBX::Node vertexcolors("LayerElementColor", int32_t(colorChannelIndex));
|
||||
vertexcolors.Begin(outstream, binary, indent);
|
||||
vertexcolors.DumpProperties(outstream, binary, indent);
|
||||
vertexcolors.EndProperties(outstream, binary, indent);
|
||||
vertexcolors.BeginChildren(outstream, binary, indent);
|
||||
indent = 3;
|
||||
FBX::Node::WritePropertyNode("Version", int32_t(101), outstream, binary, indent);
|
||||
char layerName[8];
|
||||
snprintf(layerName, sizeof(layerName), "COLOR_%d", colorChannelIndex);
|
||||
FBX::Node::WritePropertyNode("Name", (const char *)layerName, outstream, binary, indent);
|
||||
FBX::Node::WritePropertyNode("MappingInformationType", "ByPolygonVertex", outstream, binary, indent);
|
||||
FBX::Node::WritePropertyNode("ReferenceInformationType", "Direct", outstream, binary, indent);
|
||||
FBX::Node::WritePropertyNode("Colors", color_data, outstream, binary, indent);
|
||||
indent = 2;
|
||||
vertexcolors.End(outstream, binary, indent, true);
|
||||
|
||||
for (uint32_t uvi = 0; uvi < uv_data.size(); uvi++) {
|
||||
FBX::Node uv("LayerElementUV", int32_t(uvi));
|
||||
uv.Begin(outstream, binary, indent);
|
||||
uv.DumpProperties(outstream, binary, indent);
|
||||
uv.EndProperties(outstream, binary, indent);
|
||||
uv.BeginChildren(outstream, binary, indent);
|
||||
indent = 3;
|
||||
FBX::Node::WritePropertyNode("Version", int32_t(101), outstream, binary, indent);
|
||||
FBX::Node::WritePropertyNode("Name", "", outstream, binary, indent);
|
||||
FBX::Node::WritePropertyNode("MappingInformationType", "ByPolgonVertex", outstream, binary, indent);
|
||||
FBX::Node::WritePropertyNode("ReferenceInformationType", "IndexToDirect", outstream, binary, indent);
|
||||
FBX::Node::WritePropertyNode("UV", uv_data[uvi], outstream, binary, indent);
|
||||
FBX::Node::WritePropertyNode("UVIndex", uv_indices[uvi], outstream, binary, indent);
|
||||
indent = 2;
|
||||
uv.End(outstream, binary, indent, true);
|
||||
}
|
||||
|
||||
|
||||
// When merging multiple meshes, we instead use by polygon so the correct material is
|
||||
// assigned to each face. Previously, this LayerElementMaterial always had 0 since it
|
||||
// assumed there was 1 material for each node for all meshes.
|
||||
FBX::Node mat("LayerElementMaterial", int32_t(0));
|
||||
mat.AddChild("Version", int32_t(101));
|
||||
mat.AddChild("Name", "");
|
||||
mat.AddChild("MappingInformationType", "AllSame");
|
||||
mat.AddChild("ReferenceInformationType", "IndexToDirect");
|
||||
std::vector<int32_t> mat_indices = {0};
|
||||
mat.AddChild("Materials", mat_indices);
|
||||
if (node->mNumMeshes == 1) {
|
||||
mat.AddChild("MappingInformationType", "AllSame");
|
||||
mat.AddChild("ReferenceInformationType", "IndexToDirect");
|
||||
std::vector<int32_t> mat_indices = {0};
|
||||
mat.AddChild("Materials", mat_indices);
|
||||
} else {
|
||||
mat.AddChild("MappingInformationType", "ByPolygon");
|
||||
mat.AddChild("ReferenceInformationType", "IndexToDirect");
|
||||
std::vector<int32_t> mat_indices(polygon_data.size());
|
||||
uint32_t curr_offset = 0;
|
||||
for (uint32_t mi = 0; mi < node->mNumMeshes; mi++) {
|
||||
uint32_t num_faces = mScene->mMeshes[node->mMeshes[mi]]->mNumFaces;
|
||||
for (uint32_t fi = 0; fi < num_faces; fi++) {
|
||||
mat_indices[curr_offset + fi] = mi;
|
||||
}
|
||||
curr_offset += num_faces;
|
||||
}
|
||||
mat.AddChild("Materials", mat_indices);
|
||||
}
|
||||
mat.Dump(outstream, binary, indent);
|
||||
|
||||
// finally we have the layer specifications,
|
||||
@@ -1353,12 +1332,10 @@ void FBXExporter::WriteObjects ()
|
||||
le.AddChild("TypedIndex", int32_t(0));
|
||||
layer.AddChild(le);
|
||||
|
||||
for (size_t ci = 0; ci < m->GetNumColorChannels(); ++ci) {
|
||||
le = FBX::Node("LayerElement");
|
||||
le.AddChild("Type", "LayerElementColor");
|
||||
le.AddChild("TypedIndex", int32_t(ci));
|
||||
layer.AddChild(le);
|
||||
}
|
||||
le = FBX::Node("LayerElement");
|
||||
le.AddChild("Type", "LayerElementColor");
|
||||
le.AddChild("TypedIndex", int32_t(0));
|
||||
layer.AddChild(le);
|
||||
|
||||
le = FBX::Node("LayerElement");
|
||||
le.AddChild("Type", "LayerElementMaterial");
|
||||
@@ -1370,8 +1347,7 @@ void FBXExporter::WriteObjects ()
|
||||
layer.AddChild(le);
|
||||
layer.Dump(outstream, binary, indent);
|
||||
|
||||
for(unsigned int lr = 1; lr < m->GetNumUVChannels(); ++ lr)
|
||||
{
|
||||
for(unsigned int lr = 1; lr < uv_data.size(); ++ lr) {
|
||||
FBX::Node layerExtra("Layer", int32_t(lr));
|
||||
layerExtra.AddChild("Version", int32_t(100));
|
||||
FBX::Node leExtra("LayerElement");
|
||||
@@ -1383,7 +1359,14 @@ void FBXExporter::WriteObjects ()
|
||||
// finish the node record
|
||||
indent = 1;
|
||||
n.End(outstream, binary, indent, true);
|
||||
}
|
||||
|
||||
for (uint32_t ni = 0; ni < node->mNumChildren; ni++) {
|
||||
visit_node_geo(node->mChildren[ni]);
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
visit_node_geo(mScene->mRootNode);
|
||||
|
||||
|
||||
// aiMaterial
|
||||
@@ -1748,7 +1731,8 @@ void FBXExporter::WriteObjects ()
|
||||
dnode.AddChild("Version", int32_t(101));
|
||||
dnode.Dump(outstream, binary, indent);
|
||||
// connect it
|
||||
connections.emplace_back("C", "OO", deformer_uid, mesh_uids[mi]);
|
||||
const auto node = get_node_for_mesh((unsigned int)mi, mScene->mRootNode);
|
||||
connections.emplace_back("C", "OO", deformer_uid, mesh_uids[node]);
|
||||
std::vector<int32_t> vertex_indices = vVertexIndice[mi];
|
||||
|
||||
for (unsigned int am = 0; am < m->mNumAnimMeshes; ++am) {
|
||||
@@ -1758,7 +1742,7 @@ void FBXExporter::WriteObjects ()
|
||||
// start the node record
|
||||
FBX::Node bsnode("Geometry");
|
||||
int64_t blendshape_uid = generate_uid();
|
||||
mesh_uids.push_back(blendshape_uid);
|
||||
blendshape_uids.push_back(blendshape_uid);
|
||||
bsnode.AddProperty(blendshape_uid);
|
||||
bsnode.AddProperty(blendshape_name + FBX::SEPARATOR + "Geometry");
|
||||
bsnode.AddProperty("Shape");
|
||||
@@ -1770,23 +1754,25 @@ void FBXExporter::WriteObjects ()
|
||||
indent++;
|
||||
if (pAnimMesh->HasPositions()) {
|
||||
std::vector<int32_t>shape_indices;
|
||||
std::vector<double>pPositionDiff;
|
||||
std::vector<double>pNormalDiff;
|
||||
std::vector<float>pPositionDiff;
|
||||
std::vector<float>pNormalDiff;
|
||||
|
||||
for (unsigned int vt = 0; vt < vertex_indices.size(); ++vt) {
|
||||
aiVector3D pDiff = (pAnimMesh->mVertices[vertex_indices[vt]] - m->mVertices[vertex_indices[vt]]);
|
||||
if(pDiff.Length()>1e-8){
|
||||
shape_indices.push_back(vertex_indices[vt]);
|
||||
pPositionDiff.push_back(pDiff[0]);
|
||||
pPositionDiff.push_back(pDiff[1]);
|
||||
pPositionDiff.push_back(pDiff[2]);
|
||||
shape_indices.push_back(vertex_indices[vt]);
|
||||
pPositionDiff.push_back(pDiff[0]);
|
||||
pPositionDiff.push_back(pDiff[1]);
|
||||
pPositionDiff.push_back(pDiff[2]);
|
||||
|
||||
if (pAnimMesh->HasNormals()) {
|
||||
aiVector3D nDiff = (pAnimMesh->mNormals[vertex_indices[vt]] - m->mNormals[vertex_indices[vt]]);
|
||||
pNormalDiff.push_back(nDiff[0]);
|
||||
pNormalDiff.push_back(nDiff[1]);
|
||||
pNormalDiff.push_back(nDiff[2]);
|
||||
}
|
||||
if (pAnimMesh->HasNormals()) {
|
||||
aiVector3D nDiff = (pAnimMesh->mNormals[vertex_indices[vt]] - m->mNormals[vertex_indices[vt]]);
|
||||
pNormalDiff.push_back(nDiff[0]);
|
||||
pNormalDiff.push_back(nDiff[1]);
|
||||
pNormalDiff.push_back(nDiff[2]);
|
||||
} else {
|
||||
pNormalDiff.push_back(0.0);
|
||||
pNormalDiff.push_back(0.0);
|
||||
pNormalDiff.push_back(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1943,22 +1929,15 @@ void FBXExporter::WriteObjects ()
|
||||
// otherwise check if this is the root of the skeleton
|
||||
bool end = false;
|
||||
// is the mesh part of this node?
|
||||
for (size_t i = 0; i < parent->mNumMeshes; ++i) {
|
||||
if (parent->mMeshes[i] == mi) {
|
||||
end = true;
|
||||
break;
|
||||
}
|
||||
for (size_t i = 0; i < parent->mNumMeshes && !end; ++i) {
|
||||
end |= parent->mMeshes[i] == mi;
|
||||
}
|
||||
// is the mesh in one of the children of this node?
|
||||
for (size_t j = 0; j < parent->mNumChildren; ++j) {
|
||||
for (size_t j = 0; j < parent->mNumChildren && !end; ++j) {
|
||||
aiNode* child = parent->mChildren[j];
|
||||
for (size_t i = 0; i < child->mNumMeshes; ++i) {
|
||||
if (child->mMeshes[i] == mi) {
|
||||
end = true;
|
||||
break;
|
||||
}
|
||||
for (size_t i = 0; i < child->mNumMeshes && !end; ++i) {
|
||||
end |= child->mMeshes[i] == mi;
|
||||
}
|
||||
if (end) { break; }
|
||||
}
|
||||
|
||||
// if it was the skeleton root we can finish here
|
||||
@@ -1972,8 +1951,7 @@ void FBXExporter::WriteObjects ()
|
||||
for (size_t i = 0; i < mScene->mNumMeshes; ++i) {
|
||||
auto &s = skeleton_by_mesh[i];
|
||||
for (const aiNode* n : s) {
|
||||
auto elem = node_uids.find(n);
|
||||
if (elem == node_uids.end()) {
|
||||
if (node_uids.find(n) == node_uids.end()) {
|
||||
node_uids[n] = generate_uid();
|
||||
}
|
||||
}
|
||||
@@ -1989,6 +1967,8 @@ void FBXExporter::WriteObjects ()
|
||||
if (!m->HasBones()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const aiNode *mesh_node = get_node_for_mesh((uint32_t)mi, mScene->mRootNode);
|
||||
// make a deformer for this mesh
|
||||
int64_t deformer_uid = generate_uid();
|
||||
FBX::Node dnode("Deformer");
|
||||
@@ -2000,10 +1980,7 @@ void FBXExporter::WriteObjects ()
|
||||
dnode.Dump(outstream, binary, indent);
|
||||
|
||||
// connect it
|
||||
connections.emplace_back("C", "OO", deformer_uid, mesh_uids[mi]);
|
||||
|
||||
//computed before
|
||||
std::vector<int32_t>& vertex_indices = vVertexIndice[mi];
|
||||
connections.emplace_back("C", "OO", deformer_uid, mesh_uids[mesh_node]);
|
||||
|
||||
// TODO, FIXME: this won't work if anything is not in the bind pose.
|
||||
// for now if such a situation is detected, we throw an exception.
|
||||
@@ -2017,7 +1994,6 @@ void FBXExporter::WriteObjects ()
|
||||
// as it can be instanced to many nodes.
|
||||
// All we can do is assume no instancing,
|
||||
// and take the first node we find that contains the mesh.
|
||||
aiNode* mesh_node = get_node_for_mesh((unsigned int)mi, mScene->mRootNode);
|
||||
aiMatrix4x4 mesh_xform = get_world_transform(mesh_node, mScene);
|
||||
|
||||
// now make a subdeformer for each bone in the skeleton
|
||||
@@ -2046,14 +2022,15 @@ void FBXExporter::WriteObjects ()
|
||||
sdnode.AddChild("Version", int32_t(100));
|
||||
sdnode.AddChild("UserData", "", "");
|
||||
|
||||
std::set<int32_t> setWeightedVertex;
|
||||
// add indices and weights, if any
|
||||
if (b) {
|
||||
std::set<int32_t> setWeightedVertex;
|
||||
std::vector<int32_t> subdef_indices;
|
||||
std::vector<double> subdef_weights;
|
||||
int32_t last_index = -1;
|
||||
for (size_t wi = 0; wi < b->mNumWeights; ++wi) {
|
||||
int32_t vi = vertex_indices[b->mWeights[wi].mVertexId];
|
||||
int32_t vi = vVertexIndice[mi][b->mWeights[wi].mVertexId] \
|
||||
+ uniq_v_before_mi[mi];
|
||||
bool bIsWeightedAlready = (setWeightedVertex.find(vi) != setWeightedVertex.end());
|
||||
if (vi == last_index || bIsWeightedAlready) {
|
||||
// only for vertices we exported to fbx
|
||||
@@ -2700,9 +2677,8 @@ void FBXExporter::WriteModelNodes(
|
||||
// handled later
|
||||
} else if (node->mNumMeshes == 1) {
|
||||
// connect to child mesh, which should have been written previously
|
||||
connections.emplace_back(
|
||||
"C", "OO", mesh_uids[node->mMeshes[0]], node_uid
|
||||
);
|
||||
// TODO double check this line
|
||||
connections.emplace_back("C", "OO", mesh_uids[node], node_uid);
|
||||
// also connect to the material for the child mesh
|
||||
connections.emplace_back(
|
||||
"C", "OO",
|
||||
@@ -2727,6 +2703,16 @@ void FBXExporter::WriteModelNodes(
|
||||
na.Dump(outstream, binary, 1);
|
||||
// and connect them
|
||||
connections.emplace_back("C", "OO", node_attribute_uid, node_uid);
|
||||
} else if (node->mNumMeshes >= 1) {
|
||||
connections.emplace_back("C", "OO", mesh_uids[node], node_uid);
|
||||
for (size_t i = 0; i < node->mNumMeshes; i++) {
|
||||
connections.emplace_back(
|
||||
"C", "OO",
|
||||
material_uids[mScene->mMeshes[node->mMeshes[i]]->mMaterialIndex],
|
||||
node_uid
|
||||
);
|
||||
}
|
||||
WriteModelNode(outstream, binary, node, node_uid, "Mesh", transform_chain);
|
||||
} else {
|
||||
const auto& lightIt = lights_uids.find(node->mName.C_Str());
|
||||
if(lightIt != lights_uids.end()) {
|
||||
@@ -2743,34 +2729,20 @@ void FBXExporter::WriteModelNodes(
|
||||
}
|
||||
}
|
||||
|
||||
// if more than one child mesh, make nodes for each mesh
|
||||
if (node->mNumMeshes > 1 || node == mScene->mRootNode) {
|
||||
for (size_t i = 0; i < node->mNumMeshes; ++i) {
|
||||
// make a new model node
|
||||
int64_t new_node_uid = generate_uid();
|
||||
// connect to parent node
|
||||
connections.emplace_back("C", "OO", new_node_uid, node_uid);
|
||||
// connect to child mesh, which should have been written previously
|
||||
connections.emplace_back(
|
||||
"C", "OO", mesh_uids[node->mMeshes[i]], new_node_uid
|
||||
);
|
||||
// also connect to the material for the child mesh
|
||||
connections.emplace_back(
|
||||
"C", "OO",
|
||||
material_uids[
|
||||
mScene->mMeshes[node->mMeshes[i]]->mMaterialIndex
|
||||
],
|
||||
new_node_uid
|
||||
);
|
||||
|
||||
aiNode new_node;
|
||||
// take name from mesh name, if it exists
|
||||
new_node.mName = mScene->mMeshes[node->mMeshes[i]]->mName;
|
||||
// write model node
|
||||
WriteModelNode(
|
||||
outstream, binary, &new_node, new_node_uid, "Mesh", std::vector<std::pair<std::string,aiVector3D>>()
|
||||
);
|
||||
}
|
||||
if (node == mScene->mRootNode && node->mNumMeshes > 0) {
|
||||
int64_t new_node_uid = generate_uid();
|
||||
connections.emplace_back("C", "OO", new_node_uid, node_uid);
|
||||
connections.emplace_back("C", "OO", mesh_uids[node], new_node_uid);
|
||||
for (size_t i = 0; i < node->mNumMeshes; ++i) {
|
||||
connections.emplace_back(
|
||||
"C", "OO",
|
||||
material_uids[mScene->mMeshes[node->mMeshes[i]]->mMaterialIndex],
|
||||
new_node_uid
|
||||
);
|
||||
}
|
||||
aiNode new_node;
|
||||
new_node.mName = mScene->mMeshes[0]->mName;
|
||||
WriteModelNode(outstream, binary, &new_node, new_node_uid, "Mesh", {});
|
||||
}
|
||||
|
||||
// now recurse into children
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -51,7 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "FBXCommon.h" // FBX::TransformInheritance
|
||||
|
||||
#include <assimp/types.h>
|
||||
//#include <assimp/material.h>
|
||||
#include <assimp/StreamWriter.h> // StreamWriterLE
|
||||
#include <assimp/Exceptional.h> // DeadlyExportError
|
||||
|
||||
@@ -91,7 +90,8 @@ namespace Assimp {
|
||||
|
||||
std::vector<FBX::Node> connections; // connection storage
|
||||
|
||||
std::vector<int64_t> mesh_uids;
|
||||
std::map<const aiNode*, int64_t> mesh_uids;
|
||||
std::vector<int64_t> blendshape_uids;
|
||||
std::vector<int64_t> material_uids;
|
||||
std::map<const aiNode*,int64_t> node_uids;
|
||||
std::map<std::string,int64_t> lights_uids;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -156,6 +156,9 @@ struct ImportSettings {
|
||||
/** Set to true to perform a conversion from cm to meter after the import
|
||||
*/
|
||||
bool convertToMeters;
|
||||
|
||||
// Set to true to ignore the axis configuration in the file
|
||||
bool ignoreUpDirection = false;
|
||||
};
|
||||
|
||||
} // namespace FBX
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
Copyright (c) 2006-2025, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -117,6 +117,7 @@ void FBXImporter::SetupProperties(const Importer *pImp) {
|
||||
mSettings.useLegacyEmbeddedTextureNaming = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING, false);
|
||||
mSettings.removeEmptyBones = pImp->GetPropertyBool(AI_CONFIG_IMPORT_REMOVE_EMPTY_BONES, true);
|
||||
mSettings.convertToMeters = pImp->GetPropertyBool(AI_CONFIG_FBX_CONVERT_TO_M, false);
|
||||
mSettings.ignoreUpDirection = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_IGNORE_UP_DIRECTION, false);
|
||||
mSettings.useSkeleton = pImp->GetPropertyBool(AI_CONFIG_FBX_USE_SKELETON_BONE_CONTAINER, false);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user