Compare commits

..

47 Commits

Author SHA1 Message Date
Kim Kulling
bb1eaad91c Add prototypes for jt 2025-12-14 21:27:21 +01:00
Kim Kulling
81fad0f20c Prepare jt importer 2025-12-14 10:39:21 +01:00
Kim Kulling
5245511f1d Add new CMake preset for static build with double precision (#6414)
- Add static build preset
- Add build all preset
2025-12-13 09:58:49 +01:00
Matt Penny
e3b13a48a9 Fix incorrect FBX connection order (#6421)
PR #6120 fixed a macro which previously prevented std::unordered_multimap
from being used during FBX import when compiled with GCC.

This caused FBX::Element properties to be stored in arbitrary order,
but the order of connections ("C" properties) in FBX files matters.
The main issue I saw was incorrect materials.

This changes the type of FBX::ElementMap to always use std::multimap
(i.e., ordered). This was the behavior for years under GCC while the
broken macro was in use. Unordered containers are still used elsewhere
in the FBX importer to benefit from their performance.

Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
2025-12-11 21:42:45 +01:00
Kim Kulling
9481ce8db9 Delete tools/coverity/assimp_modeling.cpp (#6422) 2025-12-10 16:38:09 +01:00
Kim Kulling
3761ee65c2 Update project details in Doxyfile (#6420) 2025-12-10 08:52:46 +01:00
Kim Kulling
75386282c1 Delete cmake-modules/FindDevIL.cmake (#6418) 2025-12-10 00:03:00 +01:00
Kim Kulling
c087c20e8b Update stb_image.h to version 2.30 (#6419) 2025-12-09 23:52:34 +01:00
Kim Kulling
7d1fa60aa3 Implement overflow check in Q3DLoader (#6417)
* Implement overflow check in Q3DLoader
2025-12-09 23:28:44 +01:00
Kim Kulling
6ef6d84a7e Revert buggy PR (#6415)
Co-authored-by: Kim Kulling <kim.kulling@draeger.com>
2025-12-09 20:57:36 +01:00
Kim Kulling
354cf46b51 Merge 2998ad82a1 into 5b8cfa920b 2023-10-07 12:36:19 +00:00
Kim Kulling
2998ad82a1 Fix verbose string + refactorings 2023-10-07 14:21:59 +02:00
Kim Kulling
3ce8af18e2 Revert "Fix verbose string + refactorings"
This reverts commit 824db16a68.
2023-10-07 14:20:55 +02:00
Kim Kulling
824db16a68 Fix verbose string + refactorings 2023-10-07 14:17:39 +02:00
Kim Kulling
3dd83275c9 Merge branch 'master' of https://github.com/assimp/assimp 2023-10-07 08:43:44 +02:00
Kim Kulling
d65049a657 Merge branch 'master' of https://github.com/assimp/assimp 2023-09-09 20:28:25 +02:00
Kim Kulling
e2fa181aa6 Merge branch 'master' of https://github.com/assimp/assimp 2023-02-14 21:10:12 +01:00
Kim Kulling
6332f8a5bc Merge branch 'master' of https://github.com/assimp/assimp 2023-02-08 19:17:17 +01:00
Kim Kulling
b58bec39d9 Merge branch 'NeosSharedProject-fix-artifact' 2023-02-05 13:01:47 +01:00
Kim Kulling
ce7b2e571a Merge branch 'fix-artifact' of https://github.com/NeosSharedProject/assimp into NeosSharedProject-fix-artifact 2023-02-05 13:00:52 +01:00
Kazuki Y
6c95fe19d0 Merge branch 'master' into fix-artifact 2022-12-29 23:46:13 +09:00
Kazuki Y
26e4ab2a23 Merge branch 'assimp:master' into master 2022-12-29 23:44:30 +09:00
Kazuki Y
a84bf34cbb Update ccpp.yml 2022-12-29 23:43:07 +09:00
Kazuki Y
cd0bbe15af Merge branch 'master' into fix-artifact 2022-12-28 22:07:07 +09:00
Kazuki Y
d04dd1af9b Merge branch 'master' into fix-artifact 2022-12-21 22:35:35 +09:00
Kazuki Y
b406ce6707 Merge branch 'assimp:master' into master 2022-12-20 19:24:15 +09:00
Kazuki Y
2c87088079 Update ccpp.yml 2022-12-17 21:49:28 +09:00
Kazuki Y
2ec097b862 Update ccpp.yml 2022-12-17 21:06:36 +09:00
Kazuki Y
dd313da24f Update ccpp.yml 2022-12-17 21:04:11 +09:00
Kazuki Y
5925dcd0e2 Update ccpp.yml 2022-12-17 15:08:25 +09:00
Kazuki Y
9b644494ed Merge branch 'assimp:master' into master 2022-12-17 15:00:20 +09:00
Kazuki Y
b1a700dbbc Merge pull request #1 from NeosSharedProject/TestPatch
Update ccpp.yml
2022-12-12 12:43:51 +09:00
Kazuki Y
f77db867b5 Update ccpp.yml 2022-12-12 12:43:34 +09:00
kazu0617
4b523e99c4 fix ccpp.yml - build both hunter or not 2022-12-12 12:13:37 +09:00
kazu0617
53f0d5dcbd fix ccpp.yml -- fix matrix.name check for artifact 2022-12-12 10:55:13 +09:00
Kazuki Y
bbfc9f4658 upload/release対象のartifactを修正
追加当時のIssueを参考に修正(当時はHunterなかったっぽい)
a9a0c30932
2022-12-12 10:34:45 +09:00
Kazuki Y
fde8bf1071 buildする方についてwindows-msvcのついている方にした
この二つ、何の違いがあるかいまいち理解してない…
clでビルドするかhunterでビルドするかの違い?
2022-12-10 17:37:49 +09:00
Kazuki Y
cf3be00fd3 Update ccpp.yml 2022-12-09 17:42:45 +09:00
Kazuki Y
1f8f4da97c Merge branch 'assimp:master' into master 2022-12-09 16:21:11 +09:00
Kazuki Y
b9cf35ea3a Update ccpp.yml 2022-12-09 16:20:49 +09:00
Kazuki Y
09375a386a Update ccpp.yml 2022-12-09 10:28:32 +09:00
Kazuki Y
a09a4d0518 Update ccpp.yml 2022-12-09 01:49:22 +09:00
Kazuki Y
8b73b85628 Update ccpp.yml 2022-12-09 01:34:19 +09:00
Kazuki Y
b0515a0dd0 Update ccpp.yml 2022-12-08 20:50:48 +09:00
Kazuki Y
05b9940ce3 Merge branch 'assimp:master' into master 2022-12-08 20:19:58 +09:00
Kazuki Y
e8393116d4 Update ccpp.yml 2022-12-08 02:09:09 +09:00
Kazuki Y
49fa7fcc44 upload contains "windows" in GH Actions 2022-12-08 02:07:19 +09:00
22 changed files with 306 additions and 504 deletions

View File

@@ -197,4 +197,13 @@ jobs:
with:
files: |
*.zip
upload_url: '${{ steps.upload-url.outputs.url }}'
- name: Upload EXE files
if: contains(matrix.name, 'windows-msvc-hunter')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: '${{secrets.GITHUB_TOKEN}}'
with:
files: |
build/bin/assimp*.exe
upload_url: '${{ steps.upload-url.outputs.url }}'

View File

@@ -14,6 +14,16 @@
"ASSIMP_BUILD_ASSIMP_TOOLS": "OFF"
}
},
{
"name": "assimp_static",
"binaryDir": "${sourceDir}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_SHARED_LIBS": "OFF",
"ASSIMP_BUILD_ASSIMP_TOOLS": "OFF",
"ASSIMP_DOUBLE_PRECISION": "ON"
}
},
{
"name": "assimp_double_precision",
"binaryDir": "${sourceDir}",
@@ -29,6 +39,13 @@
"cacheVariables": {
"ASSIMP_BUILD_ASSIMP_TOOLS": "ON"
}
},
{
"name": "assimp_all",
"binaryDir": "${sourceDir}",
"cacheVariables": {
"ASSIMP_BUILD_ASSIMP_TOOLS": "ON",
"ASSIMP_BUILD_SAMPLES": "ON",
"ASSIMP_BUILD_DOCS": "ON"
}
}
]
}

View File

@@ -1,72 +0,0 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.rst:
# FindDevIL
# ---------
#
#
#
# This module locates the developer's image library.
# http://openil.sourceforge.net/
#
# This module sets:
#
# ::
#
# IL_LIBRARIES - the name of the IL library. These include the full path to
# the core DevIL library. This one has to be linked into the
# application.
# ILU_LIBRARIES - the name of the ILU library. Again, the full path. This
# library is for filters and effects, not actual loading. It
# doesn't have to be linked if the functionality it provides
# is not used.
# ILUT_LIBRARIES - the name of the ILUT library. Full path. This part of the
# library interfaces with OpenGL. It is not strictly needed
# in applications.
# IL_INCLUDE_DIR - where to find the il.h, ilu.h and ilut.h files.
# IL_FOUND - this is set to TRUE if all the above variables were set.
# This will be set to false if ILU or ILUT are not found,
# even if they are not needed. In most systems, if one
# library is found all the others are as well. That's the
# way the DevIL developers release it.
# TODO: Add version support.
# Tested under Linux and Windows (MSVC)
#include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
include(FindPackageHandleStandardArgs)
find_path(IL_INCLUDE_DIR il.h
PATH_SUFFIXES include IL
DOC "The path to the directory that contains il.h"
)
#message("IL_INCLUDE_DIR is ${IL_INCLUDE_DIR}")
find_library(IL_LIBRARIES
NAMES IL DEVIL
PATH_SUFFIXES lib64 lib lib32
DOC "The file that corresponds to the base il library."
)
#message("IL_LIBRARIES is ${IL_LIBRARIES}")
find_library(ILUT_LIBRARIES
NAMES ILUT
PATH_SUFFIXES lib64 lib lib32
DOC "The file that corresponds to the il (system?) utility library."
)
#message("ILUT_LIBRARIES is ${ILUT_LIBRARIES}")
find_library(ILU_LIBRARIES
NAMES ILU
PATH_SUFFIXES lib64 lib lib32
DOC "The file that corresponds to the il utility library."
)
#message("ILU_LIBRARIES is ${ILU_LIBRARIES}")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(IL DEFAULT_MSG
IL_LIBRARIES IL_INCLUDE_DIR)

View File

@@ -64,7 +64,7 @@ class Parser;
class Element;
using ScopeList = std::vector<Scope*>;
using ElementMap = std::fbx_unordered_multimap< std::string, Element*>;
using ElementMap = std::multimap< std::string, Element*>;
using ElementCollection = std::pair<ElementMap::const_iterator,ElementMap::const_iterator>;
#define new_Scope new (allocator.Allocate(sizeof(Scope))) Scope

View File

@@ -0,0 +1,83 @@
//
#include "JT/JTImporter.h"
#include <assimp/StreamReader.h>
#include <cstddef>
namespace Assimp::JT {
enum class SegmentType {
Invalid = -1, //< Predefined class: Invalid
LOGICAL_SCENE_GRAPH,//< Predefined class: Logical_Scene_Graph
JT_BREP,//< Predefined class: JT_BRep
PMI_DATA, //<Predefined class: PMI_Data
META_DATA, //< Predefined class: Meta_Data
SHAPE, //< Predefined class: Shape
SHAPE_LOD0, //< Predefined class: Shape_LOD0
SHAPE_LOD1, //< Predefined class: Logical_Scene_Graph
SHAPE_LOD2, //< Predefined class: Shape_LOD2
SHAPE_LOD3, //< Predefined class: Shape_LOD3
SHAPE_LOD4, //< Predefined class: Shape_LOD4
SHAPE_LOD5, //< Predefined class: Shape_LOD5
SHAPE_LOD6, //< Predefined class: Shape_LOD6
SHAPE_LOD7, //< Predefined class: Shape_LOD7
SHAPE_LOD8, //< Predefined class: Shape_LOD8
SHAPE_LOD9, ///< Predefined class: Shape_LOD9
XT_BREP, //< Predefined class: XT_BRep
Count //< Number of segment types
};
struct Guid {
uint32_t Data0{};
uint32_t Data1{};
uint32_t Data2{}
uint32_t Data3{};
};
struct Version {
constexpr static size_t VersionSize = 80;
uint8_t Version[VersionSize]{};
int32_t Empty{0};
uint64_t TOCOffset{0};
}
struct SegmentHeader {
Guid SegmentGuid{};
SegmentType Type{SegmentType::Invalid};
};
namespace {
void readVersion(StreamReaderLE& reader, Version& version) {
reader.ReadBytes(version.Version, Version::VersionSize);
version.Empty = reader.Read<int32_t>();
version.TOCOffset = reader.Read<uint64_t>();
}
} // Anonymous namespace
JTImporter::JTImporter() : BaseImporter() {
}
JTImporter::~JTImporter() {
}
bool JTImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
}
void JTImporter::setupProperties(const Importer* pImp) {
}
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
auto stream = std::shared_ptr<IOStream>(pIOHandler->Open(pFile, "rb"));
if (!stream) {
throw DeadlyImportError("Failed to open JT file " + pFile + " for reading.");
}
StreamReaderLE reader(stream);
Version version;
readVersion(reader, version);
}
} // Namespace Assimp

View File

@@ -0,0 +1,17 @@
#pragma once
#include <assimp/BaseImporter.h>
namespace Assimp::JT {
class JTImporter : public BaseImporter {
public:
JTImporter();
~JTImporter() override;
bool CanRead(const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const override;
void setupProperties(const Importer* pImp) override;
protected:
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) override;
}

View File

@@ -379,7 +379,12 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
light->mColorSpecular = light->mColorDiffuse;
// We don't need the rest, but we need to know where this chunk ends.
unsigned int temp = (unsigned int)(stream.GetI4() * stream.GetI4());
const auto t1 = stream.GetI4();
const auto t2 = stream.GetI4();
if (t1 < 0 || t2 < 0) {
throw DeadlyImportError("Quick3D: Overflow detected.");
}
const unsigned int temp = static_cast<unsigned int>(t1*t2);
// skip the background file name
while (stream.GetI1())

View File

@@ -77,7 +77,6 @@ static constexpr aiImporterDesc desc = {
};
namespace Assimp {
using namespace std;
// Constructor to be privately used by Importer
USDImporter::USDImporter() :

View File

@@ -53,9 +53,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "USDLoaderImplTinyusdz.h"
namespace Assimp {
class USDImporter : public BaseImporter {
/// @brief USD Importer class
class USDImporter final : public BaseImporter {
public:
/// @brief Constructor
USDImporter();
/// @brief Destructor
~USDImporter() override = default;
/// \brief Returns whether the class can handle the format of the given file.

View File

@@ -44,32 +44,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ASSIMP_BUILD_NO_USD_IMPORTER
#include "USDLoaderImplTinyusdz.h"
#include "USDLoaderImplTinyusdzHelper.h"
#include "USDLoaderUtil.h"
#include "USDPreprocessor.h"
#include "io-util.hh" // namespace tinyusdz::io
#include "tydra/scene-access.hh"
#include "tydra/shader-network.hh"
#include <memory>
#include <sstream>
// internal headers
#include <assimp/ai_assert.h>
#include <assimp/anim.h>
#include "assimp/MemoryIOWrapper.h"
#include <assimp/CreateAnimMesh.h>
#include <assimp/DefaultIOSystem.h>
#include <assimp/DefaultLogger.hpp>
#include <assimp/fast_atof.h>
#include <assimp/Importer.hpp>
#include <assimp/importerdesc.h>
#include <assimp/IOStreamBuffer.h>
#include <assimp/IOSystem.hpp>
#include "assimp/MemoryIOWrapper.h"
#include <assimp/StringUtils.h>
#include <assimp/StreamReader.h>
#include <assimp/metadata.h>
#include <assimp/StringUtils.h>
#include <assimp/ai_assert.h>
#include <assimp/anim.h>
#include <assimp/fast_atof.h>
#include <assimp/importerdesc.h>
#include <assimp/DefaultLogger.hpp>
#include <assimp/IOSystem.hpp>
#include <assimp/Importer.hpp>
#include "io-util.hh" // namespace tinyusdz::io
#include "tydra/scene-access.hh"
#include "tydra/shader-network.hh"
#include "USDLoaderImplTinyusdzHelper.h"
#include "USDLoaderImplTinyusdz.h"
#include "USDLoaderUtil.h"
#include "USDPreprocessor.h"
#include "../../../contrib/tinyusdz/assimp_tinyusdz_logging.inc"
@@ -78,17 +79,18 @@ namespace {
}
namespace Assimp {
using namespace std;
void USDImporterImplTinyusdz::InternReadFile(
const std::string &pFile,
aiScene *pScene,
IOSystem *pIOHandler) {
using Assimp::tinyUsdzMat4ToAiMat4;
using Assimp::tinyusdzNodeTypeFor;
using tinyusdz::tydra::NodeType;
using namespace tinyusdz::tydra;
void USDImporterImplTinyusdz::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
// Grab filename for logging purposes
size_t pos = pFile.find_last_of('/');
string basePath = pFile.substr(0, pos);
string nameWExt = pFile.substr(pos + 1);
stringstream ss;
std::string basePath = pFile.substr(0, pos);
std::string nameWExt = pFile.substr(pos + 1);
std::stringstream ss;
ss.str("");
ss << "InternReadFile(): model" << nameWExt;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
@@ -161,9 +163,10 @@ void USDImporterImplTinyusdz::InternReadFile(
TINYUSDZLOGE(TAG, "%s", ss.str().c_str());
return;
}
tinyusdz::tydra::RenderScene render_scene;
tinyusdz::tydra::RenderSceneConverter converter;
tinyusdz::tydra::RenderSceneConverterEnv env(stage);
RenderScene render_scene;
RenderSceneConverter converter;
RenderSceneConverterEnv env(stage);
std::string usd_basedir = tinyusdz::io::GetBaseDir(pFile);
env.set_search_paths({ usd_basedir }); // {} needed to convert to vector of char
@@ -220,16 +223,12 @@ void USDImporterImplTinyusdz::InternReadFile(
textures(render_scene, pScene, nameWExt);
textureImages(render_scene, pScene, nameWExt);
buffers(render_scene, pScene, nameWExt);
std::map<size_t, tinyusdz::tydra::Node> meshNodes;
setupNodes(render_scene, pScene, stage, meshNodes, nameWExt);
pScene->mRootNode = nodesRecursive(nullptr, render_scene.nodes[0], render_scene.skeletons);
setupBlendShapes(render_scene, pScene, nameWExt);
}
void USDImporterImplTinyusdz::animations(
const tinyusdz::tydra::RenderScene& render_scene,
aiScene* pScene) {
void USDImporterImplTinyusdz::animations(const tinyusdz::tydra::RenderScene &render_scene, aiScene *pScene) {
if (render_scene.animations.empty()) {
return;
}
@@ -269,7 +268,7 @@ void USDImporterImplTinyusdz::animations(
for (const auto &[channelType, animChannel] : animationChannelMap) {
switch (channelType) {
case tinyusdz::tydra::AnimationChannel::ChannelType::Rotation:
case AnimationChannel::ChannelType::Rotation:
if (animChannel.rotations.static_value.has_value()) {
rotationKeys.emplace_back(0, tinyUsdzQuatToAiQuat(animChannel.rotations.static_value.value()));
}
@@ -281,7 +280,7 @@ void USDImporterImplTinyusdz::animations(
rotationKeys.emplace_back(rotationAnimSampler.t, tinyUsdzQuatToAiQuat(rotationAnimSampler.value));
}
break;
case tinyusdz::tydra::AnimationChannel::ChannelType::Scale:
case AnimationChannel::ChannelType::Scale:
if (animChannel.scales.static_value.has_value()) {
scalingKeys.emplace_back(0, tinyUsdzScaleOrPosToAssimp(animChannel.scales.static_value.value()));
}
@@ -292,7 +291,7 @@ void USDImporterImplTinyusdz::animations(
scalingKeys.emplace_back(scaleAnimSampler.t, tinyUsdzScaleOrPosToAssimp(scaleAnimSampler.value));
}
break;
case tinyusdz::tydra::AnimationChannel::ChannelType::Transform:
case AnimationChannel::ChannelType::Transform:
if (animChannel.transforms.static_value.has_value()) {
aiVector3D position;
aiVector3D scale;
@@ -318,7 +317,7 @@ void USDImporterImplTinyusdz::animations(
rotationKeys.emplace_back(transformAnimSampler.t, rotation);
}
break;
case tinyusdz::tydra::AnimationChannel::ChannelType::Translation:
case AnimationChannel::ChannelType::Translation:
if (animChannel.translations.static_value.has_value()) {
positionKeys.emplace_back(0, tinyUsdzScaleOrPosToAssimp(animChannel.translations.static_value.value()));
}
@@ -356,7 +355,7 @@ void USDImporterImplTinyusdz::meshes(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
const std::string &nameWExt) {
stringstream ss;
std::stringstream ss;
pScene->mNumMeshes = static_cast<unsigned int>(render_scene.meshes.size());
pScene->mMeshes = new aiMesh *[pScene->mNumMeshes]();
ss.str("");
@@ -368,10 +367,7 @@ void USDImporterImplTinyusdz::meshes(
pScene->mMeshes[meshIdx] = new aiMesh();
pScene->mMeshes[meshIdx]->mName.Set(render_scene.meshes[meshIdx].prim_name);
ss.str("");
ss << " mesh[" << meshIdx << "]: " <<
render_scene.meshes[meshIdx].joint_and_weights.jointIndices.size() << " jointIndices, " <<
render_scene.meshes[meshIdx].joint_and_weights.jointWeights.size() << " jointWeights, elementSize: " <<
render_scene.meshes[meshIdx].joint_and_weights.elementSize;
ss << " mesh[" << meshIdx << "]: " << render_scene.meshes[meshIdx].joint_and_weights.jointIndices.size() << " jointIndices, " << render_scene.meshes[meshIdx].joint_and_weights.jointWeights.size() << " jointWeights, elementSize: " << render_scene.meshes[meshIdx].joint_and_weights.elementSize;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
ss.str("");
ss << " skel_id: " << render_scene.meshes[meshIdx].skel_id;
@@ -390,12 +386,8 @@ void USDImporterImplTinyusdz::meshes(
}
}
void USDImporterImplTinyusdz::verticesForMesh(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
size_t meshIdx,
const std::string &nameWExt) {
UNUSED(nameWExt);
void USDImporterImplTinyusdz::verticesForMesh(const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene, size_t meshIdx, const std::string &) {
const auto numVertices = static_cast<unsigned int>(render_scene.meshes[meshIdx].points.size());
pScene->mMeshes[meshIdx]->mNumVertices = numVertices;
pScene->mMeshes[meshIdx]->mVertices = new aiVector3D[pScene->mMeshes[meshIdx]->mNumVertices];
@@ -454,7 +446,7 @@ void USDImporterImplTinyusdz::verticesForMesh(
std::swap_ranges(aiBonesVertexWeights[boneIndex].begin(), aiBonesVertexWeights[boneIndex].end(), pScene->mMeshes[meshIdx]->mBones[boneIndex]->mWeights);
}
} // Skinned mesh end
} // Skinned mesh end
for (size_t j = 0; j < pScene->mMeshes[meshIdx]->mNumVertices; ++j) {
pScene->mMeshes[meshIdx]->mVertices[j].x = render_scene.meshes[meshIdx].points[j][0];
@@ -463,12 +455,8 @@ void USDImporterImplTinyusdz::verticesForMesh(
}
}
void USDImporterImplTinyusdz::facesForMesh(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
size_t meshIdx,
const std::string &nameWExt) {
UNUSED(nameWExt);
void USDImporterImplTinyusdz::facesForMesh(const RenderScene &render_scene, aiScene *pScene,
size_t meshIdx, const std::string &) {
pScene->mMeshes[meshIdx]->mNumFaces = static_cast<unsigned int>(render_scene.meshes[meshIdx].faceVertexCounts().size());
pScene->mMeshes[meshIdx]->mFaces = new aiFace[pScene->mMeshes[meshIdx]->mNumFaces]();
size_t faceVertIdxOffset = 0;
@@ -483,12 +471,8 @@ void USDImporterImplTinyusdz::facesForMesh(
}
}
void USDImporterImplTinyusdz::normalsForMesh(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
size_t meshIdx,
const std::string &nameWExt) {
UNUSED(nameWExt);
void USDImporterImplTinyusdz::normalsForMesh(const RenderScene &render_scene, aiScene *pScene,
size_t meshIdx, const std::string &) {
pScene->mMeshes[meshIdx]->mNormals = new aiVector3D[pScene->mMeshes[meshIdx]->mNumVertices];
const float *floatPtr = reinterpret_cast<const float *>(render_scene.meshes[meshIdx].normals.get_data().data());
for (size_t vertIdx = 0, fpj = 0; vertIdx < pScene->mMeshes[meshIdx]->mNumVertices; ++vertIdx, fpj += 3) {
@@ -498,20 +482,16 @@ void USDImporterImplTinyusdz::normalsForMesh(
}
}
void USDImporterImplTinyusdz::materialsForMesh(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
size_t meshIdx,
const std::string &nameWExt) {
UNUSED(render_scene); UNUSED(pScene); UNUSED(meshIdx); UNUSED(nameWExt);
void USDImporterImplTinyusdz::materialsForMesh(const RenderScene&, aiScene*,
size_t, const std::string&) {
// todo
}
void USDImporterImplTinyusdz::uvsForMesh(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
size_t meshIdx,
const std::string &nameWExt) {
UNUSED(nameWExt);
const std::string&) {
const size_t uvSlotsCount = render_scene.meshes[meshIdx].texcoords.size();
if (uvSlotsCount < 1) {
return;
@@ -539,10 +519,8 @@ static aiColor3D *ownedColorPtrFor(const std::array<float, 3> &color) {
return colorPtr;
}
static std::string nameForTextureWithId(
const tinyusdz::tydra::RenderScene &render_scene,
const int targetId) {
stringstream ss;
static std::string nameForTextureWithId(const RenderScene &render_scene, const int targetId) {
std::stringstream ss;
std::string texName;
for (const auto &image : render_scene.images) {
if (image.buffer_id == targetId) {
@@ -560,16 +538,15 @@ static std::string nameForTextureWithId(
}
static void assignTexture(
const tinyusdz::tydra::RenderScene &render_scene,
const tinyusdz::tydra::RenderMaterial &material,
const RenderScene &render_scene,
const RenderMaterial &,
aiMaterial *mat,
const int textureId,
const int aiTextureType) {
UNUSED(material);
std::string name = nameForTextureWithId(render_scene, textureId);
aiString *texName = new aiString();
texName->Set(name);
stringstream ss;
std::stringstream ss;
ss.str("");
ss << "assignTexture(): name: " << name;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
@@ -581,9 +558,8 @@ void USDImporterImplTinyusdz::materials(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
const std::string &nameWExt) {
const size_t numMaterials{render_scene.materials.size()};
(void) numMaterials; // Ignore unused variable when -Werror enabled
stringstream ss;
const size_t numMaterials{ render_scene.materials.size() };
std::stringstream ss;
ss.str("");
ss << "materials(): model" << nameWExt << ", numMaterials: " << numMaterials;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
@@ -591,6 +567,7 @@ void USDImporterImplTinyusdz::materials(
if (render_scene.materials.empty()) {
return;
}
pScene->mMaterials = new aiMaterial *[render_scene.materials.size()];
for (const auto &material : render_scene.materials) {
ss.str("");
@@ -673,22 +650,18 @@ void USDImporterImplTinyusdz::materials(
void USDImporterImplTinyusdz::textures(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
aiScene*,
const std::string &nameWExt) {
UNUSED(pScene);
const size_t numTextures{render_scene.textures.size()};
UNUSED(numTextures); // Ignore unused variable when -Werror enabled
stringstream ss;
const size_t numTextures{ render_scene.textures.size() };
std::stringstream ss;
ss.str("");
ss << "textures(): model" << nameWExt << ", numTextures: " << numTextures;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
size_t i{0};
UNUSED(i);
size_t i{ 0 };
for (const auto &texture : render_scene.textures) {
UNUSED(texture);
ss.str("");
ss << " texture[" << i << "]: id: " << texture.texture_image_id << ", disp name: |" << texture.display_name << "|, varname_uv: " <<
texture.varname_uv << ", prim_name: |" << texture.prim_name << "|, abs_path: |" << texture.abs_path << "|";
ss << " texture[" << i << "]: id: " << texture.texture_image_id << ", disp name: |" << texture.display_name << "|, varname_uv: " << texture.varname_uv << ", prim_name: |" << texture.prim_name << "|, abs_path: |" << texture.abs_path << "|";
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
++i;
}
@@ -702,15 +675,12 @@ void USDImporterImplTinyusdz::textures(
* @param nameWExt filename w/ext (use to extract file type hint)
* @return aiTexture ptr
*/
static aiTexture *ownedEmbeddedTextureFor(
const tinyusdz::tydra::RenderScene &render_scene,
const tinyusdz::tydra::TextureImage &image,
const std::string &nameWExt) {
UNUSED(nameWExt);
stringstream ss;
static aiTexture *ownedEmbeddedTextureFor(const RenderScene &render_scene, const TextureImage &image,
const std::string&) {
std::stringstream ss;
aiTexture *tex = new aiTexture();
size_t pos = image.asset_identifier.find_last_of('/');
string embTexName{image.asset_identifier.substr(pos + 1)};
std::string embTexName{ image.asset_identifier.substr(pos + 1) };
tex->mFilename.Set(image.asset_identifier.c_str());
tex->mHeight = image.height;
@@ -718,20 +688,20 @@ static aiTexture *ownedEmbeddedTextureFor(
if (tex->mHeight == 0) {
pos = embTexName.find_last_of('.');
strncpy(tex->achFormatHint, embTexName.substr(pos + 1).c_str(), 3);
const size_t imageBytesCount{render_scene.buffers[image.buffer_id].data.size()};
tex->pcData = (aiTexel *) new char[imageBytesCount];
const size_t imageBytesCount{ render_scene.buffers[image.buffer_id].data.size() };
tex->pcData = (aiTexel *)new char[imageBytesCount];
memcpy(tex->pcData, &render_scene.buffers[image.buffer_id].data[0], imageBytesCount);
} else {
string formatHint{"rgba8888"};
std::string formatHint{ "rgba8888" };
strncpy(tex->achFormatHint, formatHint.c_str(), 8);
const size_t imageTexelsCount{tex->mWidth * tex->mHeight};
tex->pcData = (aiTexel *) new char[imageTexelsCount * image.channels];
const size_t imageTexelsCount{ tex->mWidth * tex->mHeight };
tex->pcData = (aiTexel *)new char[imageTexelsCount * image.channels];
const float *floatPtr = reinterpret_cast<const float *>(&render_scene.buffers[image.buffer_id].data[0]);
ss.str("");
ss << "ownedEmbeddedTextureFor(): manual fill...";
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
for (size_t i = 0, fpi = 0; i < imageTexelsCount; ++i, fpi += 4) {
tex->pcData[i].b = static_cast<uint8_t>(floatPtr[fpi] * 255);
tex->pcData[i].b = static_cast<uint8_t>(floatPtr[fpi] * 255);
tex->pcData[i].g = static_cast<uint8_t>(floatPtr[fpi + 1] * 255);
tex->pcData[i].r = static_cast<uint8_t>(floatPtr[fpi + 2] * 255);
tex->pcData[i].a = static_cast<uint8_t>(floatPtr[fpi + 3] * 255);
@@ -743,13 +713,9 @@ static aiTexture *ownedEmbeddedTextureFor(
return tex;
}
void USDImporterImplTinyusdz::textureImages(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
const std::string &nameWExt) {
stringstream ss;
const size_t numTextureImages{render_scene.images.size()};
UNUSED(numTextureImages); // Ignore unused variable when -Werror enabled
void USDImporterImplTinyusdz::textureImages(const RenderScene &render_scene, aiScene *pScene, const std::string &nameWExt) {
std::stringstream ss;
const size_t numTextureImages{ render_scene.images.size() };
ss.str("");
ss << "textureImages(): model" << nameWExt << ", numTextureImages: " << numTextureImages;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
@@ -757,13 +723,15 @@ void USDImporterImplTinyusdz::textureImages(
pScene->mNumTextures = 0;
for (const auto &image : render_scene.images) {
ss.str("");
ss << " image[" << pScene->mNumTextures << "]: |" << image.asset_identifier << "| w: " << image.width << ", h: " << image.height <<
", channels: " << image.channels << ", miplevel: " << image.miplevel << ", buffer id: " << image.buffer_id << "\n" <<
" buffers.size(): " << render_scene.buffers.size() << ", data empty? " << render_scene.buffers[image.buffer_id].data.empty();
ss << " image[" << pScene->mNumTextures << "]: |" << image.asset_identifier << "| w: "
<< image.width << ", h: " << image.height << ", channels: " << image.channels << ", miplevel: "
<< image.miplevel << ", buffer id: " << image.buffer_id << "\n"
<< " buffers.size(): " << render_scene.buffers.size() << ", data empty? "
<< render_scene.buffers[image.buffer_id].data.empty();
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
if (image.buffer_id > -1 &&
image.buffer_id < static_cast<long int>(render_scene.buffers.size()) &&
!render_scene.buffers[image.buffer_id].data.empty()) {
image.buffer_id < static_cast<long int>(render_scene.buffers.size()) &&
!render_scene.buffers[image.buffer_id].data.empty()) {
aiTexture *tex = ownedEmbeddedTextureFor(
render_scene,
image,
@@ -775,8 +743,8 @@ void USDImporterImplTinyusdz::textureImages(
pScene->mTextures = new aiTexture *[render_scene.images.size()];
}
ss.str("");
ss << " pScene->mTextures[" << pScene->mNumTextures << "] name: |" << tex->mFilename.C_Str() <<
"|, w: " << tex->mWidth << ", h: " << tex->mHeight << ", hint: " << tex->achFormatHint;
ss << " pScene->mTextures[" << pScene->mNumTextures << "] name: |" << tex->mFilename.C_Str()
<< "|, w: " << tex->mWidth << ", h: " << tex->mHeight << ", hint: " << tex->achFormatHint;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
pScene->mTextures[pScene->mNumTextures++] = tex;
}
@@ -784,12 +752,9 @@ void USDImporterImplTinyusdz::textureImages(
}
void USDImporterImplTinyusdz::buffers(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
const std::string &nameWExt) {
const size_t numBuffers{render_scene.buffers.size()};
UNUSED(pScene); UNUSED(numBuffers); // Ignore unused variable when -Werror enabled
stringstream ss;
const RenderScene &render_scene, aiScene*, const std::string &nameWExt) {
const size_t numBuffers{ render_scene.buffers.size() };
std::stringstream ss;
ss.str("");
ss << "buffers(): model" << nameWExt << ", numBuffers: " << numBuffers;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
@@ -802,53 +767,9 @@ void USDImporterImplTinyusdz::buffers(
}
}
void USDImporterImplTinyusdz::setupNodes(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
const tinyusdz::Stage &usdStage,
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
const std::string &nameWExt) {
stringstream ss;
pScene->mRootNode = nodes(render_scene, usdStage, meshNodes, nameWExt);
pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
pScene->mRootNode->mMeshes = new unsigned int[pScene->mRootNode->mNumMeshes];
ss.str("");
ss << "setupNodes(): pScene->mNumMeshes: " << pScene->mNumMeshes;
if (pScene->mRootNode != nullptr) {
ss << ", mRootNode->mNumMeshes: " << pScene->mRootNode->mNumMeshes;
}
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
for (unsigned int meshIdx = 0; meshIdx < pScene->mNumMeshes; meshIdx++) {
pScene->mRootNode->mMeshes[meshIdx] = meshIdx;
}
}
aiNode *USDImporterImplTinyusdz::nodes(
const tinyusdz::tydra::RenderScene &render_scene,
const tinyusdz::Stage &usdStage,
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
const std::string &nameWExt) {
const size_t numNodes{render_scene.nodes.size()};
(void) numNodes; // Ignore unused variable when -Werror enabled
stringstream ss;
ss.str("");
ss << "nodes(): model" << nameWExt << ", numNodes: " << numNodes;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
return nodesRecursive(nullptr, usdStage.root_prims()[0], render_scene.nodes[0], meshNodes);
}
using Assimp::tinyusdzNodeTypeFor;
using Assimp::tinyUsdzMat4ToAiMat4;
using tinyusdz::tydra::NodeType;
aiNode *USDImporterImplTinyusdz::nodesRecursive(
aiNode *pNodeParent,
const tinyusdz::Prim& prim,
const tinyusdz::tydra::Node &node,
const std::vector<tinyusdz::tydra::SkelHierarchy> &skeletons) {
stringstream ss;
aiNode *USDImporterImplTinyusdz::nodesRecursive(aiNode *pNodeParent, const tinyusdz::tydra::Node &node,
const std::vector<SkelHierarchy> &skeletons) {
std::stringstream ss;
aiNode *cNode = new aiNode();
cNode->mParent = pNodeParent;
cNode->mName.Set(node.prim_name);
@@ -861,9 +782,9 @@ aiNode *USDImporterImplTinyusdz::nodesRecursive(
}
ss.str("");
ss << "nodesRecursive(): node " << cNode->mName.C_Str() <<
" type: |" << tinyusdzNodeTypeFor(node.nodeType) <<
"|, disp " << node.display_name << ", abs " << node.abs_path;
ss << "nodesRecursive(): node " << cNode->mName.C_Str() << " type: |"
<< tinyusdzNodeTypeFor(node.nodeType)
<< "|, disp " << node.display_name << ", abs " << node.abs_path;
if (cNode->mParent != nullptr) {
ss << " (parent " << cNode->mParent->mName.C_Str() << ")";
}
@@ -887,22 +808,6 @@ aiNode *USDImporterImplTinyusdz::nodesRecursive(
}
}
// Composition: references
if (prim.metas().references.has_value())
{
const tinyusdz::ListEditQual referenceQual = prim.metas().references->first;
const std::vector<tinyusdz::Reference> references = prim.metas().references->second;
for (const auto &reference : references)
{
cNode->mMetaData = aiMetadata::Alloc(1);
cNode->mMetaData->Add("ref", aiString(reference.asset_path.GetAssetPath()));
}
}
size_t i{0};
for (const auto &childNode: node.children) {
cNode->mChildren[i] = nodesRecursive(cNode, prim.children()[i], childNode, meshNodes);
cNode->mNumChildren = numChildren;
// Done. No more children.
@@ -920,15 +825,15 @@ aiNode *USDImporterImplTinyusdz::nodesRecursive(
if (skelNode != nullptr) {
// Convert USD skeleton into an Assimp node and make it the last child
cNode->mChildren[cNode->mNumChildren-1] = skeletonNodesRecursive(cNode, *skelNode);
cNode->mChildren[cNode->mNumChildren - 1] = skeletonNodesRecursive(cNode, *skelNode);
}
return cNode;
}
aiNode *USDImporterImplTinyusdz::skeletonNodesRecursive(
aiNode* pNodeParent,
const tinyusdz::tydra::SkelNode& joint) {
aiNode *pNodeParent,
const SkelNode &joint) {
auto *cNode = new aiNode(joint.joint_path);
cNode->mParent = pNodeParent;
cNode->mNumMeshes = 0; // not a mesh node
@@ -943,7 +848,7 @@ aiNode *USDImporterImplTinyusdz::skeletonNodesRecursive(
cNode->mChildren = new aiNode *[cNode->mNumChildren];
for (unsigned i = 0; i < cNode->mNumChildren; ++i) {
const tinyusdz::tydra::SkelNode &childJoint = joint.children[i];
const SkelNode &childJoint = joint.children[i];
cNode->mChildren[i] = skeletonNodesRecursive(cNode, childJoint);
}
@@ -952,7 +857,7 @@ aiNode *USDImporterImplTinyusdz::skeletonNodesRecursive(
void USDImporterImplTinyusdz::sanityCheckNodesRecursive(
aiNode *cNode) {
stringstream ss;
std::stringstream ss;
ss.str("");
ss << "sanityCheckNodesRecursive(): node " << cNode->mName.C_Str();
if (cNode->mParent != nullptr) {
@@ -965,16 +870,14 @@ void USDImporterImplTinyusdz::sanityCheckNodesRecursive(
}
}
void USDImporterImplTinyusdz::setupBlendShapes(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
void USDImporterImplTinyusdz::setupBlendShapes(const RenderScene &render_scene, aiScene *pScene,
const std::string &nameWExt) {
stringstream ss;
std::stringstream ss;
ss.str("");
ss << "setupBlendShapes(): iterating over " << pScene->mNumMeshes << " meshes for model" << nameWExt;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
for (size_t meshIdx = 0; meshIdx < pScene->mNumMeshes; meshIdx++) {
blendShapesForMesh(render_scene, pScene, meshIdx, nameWExt);
blendShapesForMesh(render_scene, pScene, meshIdx, nameWExt);
}
}
@@ -982,10 +885,9 @@ void USDImporterImplTinyusdz::blendShapesForMesh(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
size_t meshIdx,
const std::string &nameWExt) {
UNUSED(nameWExt);
stringstream ss;
const unsigned int numBlendShapeTargets{static_cast<unsigned int>(render_scene.meshes[meshIdx].targets.size())};
const std::string &) {
std::stringstream ss;
const unsigned int numBlendShapeTargets{ static_cast<unsigned int>(render_scene.meshes[meshIdx].targets.size()) };
UNUSED(numBlendShapeTargets); // Ignore unused variable when -Werror enabled
ss.str("");
ss << " blendShapesForMesh(): mesh[" << meshIdx << "], numBlendShapeTargets: " << numBlendShapeTargets;
@@ -995,15 +897,13 @@ void USDImporterImplTinyusdz::blendShapesForMesh(
pScene->mMeshes[meshIdx]->mAnimMeshes = new aiAnimMesh *[pScene->mMeshes[meshIdx]->mNumAnimMeshes];
}
auto mapIter = render_scene.meshes[meshIdx].targets.begin();
size_t animMeshIdx{0};
size_t animMeshIdx{ 0 };
for (; mapIter != render_scene.meshes[meshIdx].targets.end(); ++mapIter) {
const std::string name{mapIter->first};
const tinyusdz::tydra::ShapeTarget shapeTarget{mapIter->second};
const std::string name{ mapIter->first };
const tinyusdz::tydra::ShapeTarget shapeTarget{ mapIter->second };
pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx] = aiCreateAnimMesh(pScene->mMeshes[meshIdx]);
ss.str("");
ss << " mAnimMeshes[" << animMeshIdx << "]: mNumVertices: " << pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx]->mNumVertices <<
", target: " << shapeTarget.pointIndices.size() << " pointIndices, " << shapeTarget.pointOffsets.size() <<
" pointOffsets, " << shapeTarget.normalOffsets.size() << " normalOffsets";
ss << " mAnimMeshes[" << animMeshIdx << "]: mNumVertices: " << pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx]->mNumVertices << ", target: " << shapeTarget.pointIndices.size() << " pointIndices, " << shapeTarget.pointOffsets.size() << " pointOffsets, " << shapeTarget.normalOffsets.size() << " normalOffsets";
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
for (size_t iVert = 0; iVert < shapeTarget.pointOffsets.size(); ++iVert) {
pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx]->mVertices[shapeTarget.pointIndices[iVert]] +=
@@ -1014,12 +914,7 @@ void USDImporterImplTinyusdz::blendShapesForMesh(
tinyUsdzScaleOrPosToAssimp(shapeTarget.normalOffsets[iVert]);
}
ss.str("");
ss << " target[" << animMeshIdx << "]: name: " << name << ", prim_name: " <<
shapeTarget.prim_name << ", abs_path: " << shapeTarget.abs_path <<
", display_name: " << shapeTarget.display_name << ", " << shapeTarget.pointIndices.size() <<
" pointIndices, " << shapeTarget.pointOffsets.size() << " pointOffsets, " <<
shapeTarget.normalOffsets.size() << " normalOffsets, " << shapeTarget.inbetweens.size() <<
" inbetweens";
ss << " target[" << animMeshIdx << "]: name: " << name << ", prim_name: " << shapeTarget.prim_name << ", abs_path: " << shapeTarget.abs_path << ", display_name: " << shapeTarget.display_name << ", " << shapeTarget.pointIndices.size() << " pointIndices, " << shapeTarget.pointOffsets.size() << " pointOffsets, " << shapeTarget.normalOffsets.size() << " normalOffsets, " << shapeTarget.inbetweens.size() << " inbetweens";
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
++animMeshIdx;
}

View File

@@ -43,21 +43,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @brief Declaration of the USD importer class.
*/
#pragma once
#ifndef AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED
#define AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED
#include "tinyusdz.hh"
#include "tydra/render-data.hh"
#include <assimp/BaseImporter.h>
#include <assimp/scene.h>
#include <assimp/types.h>
#include <vector>
#include <cstdint>
#include "tinyusdz.hh"
#include "tydra/render-data.hh"
#include <vector>
namespace Assimp {
/**
* @brief USD Importer implementation using tinyusdz.
*/
class USDImporterImplTinyusdz {
public:
/// @brief The class constructor.
USDImporterImplTinyusdz() = default;
/// @brief The class destructor.
~USDImporterImplTinyusdz() = default;
void InternReadFile(
@@ -124,23 +132,8 @@ public:
aiScene *pScene,
const std::string &nameWExt);
void setupNodes(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
const tinyusdz::Stage &usdStage,
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
const std::string &nameWExt
);
aiNode *nodes(
const tinyusdz::tydra::RenderScene &render_scene,
const tinyusdz::Stage &usdStage,
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
const std::string &nameWExt);
aiNode *nodesRecursive(
aiNode *pNodeParent,
const tinyusdz::Prim &prim,
const tinyusdz::tydra::Node &node,
const std::vector<tinyusdz::tydra::SkelHierarchy> &skeletons);
@@ -162,5 +155,7 @@ public:
size_t meshIdx,
const std::string &nameWExt);
};
} // namespace Assimp
#endif // AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED

View File

@@ -914,29 +914,16 @@ class Asset {
friend struct Buffer; // To access OpenFile
friend class AssetWriter;
private:
IOSystem *mIOSystem;
std::string mCurrentAssetDir;
size_t mSceneLength;
size_t mBodyOffset, mBodyLength;
std::vector<LazyDictBase *> mDicts;
IdMap mUsedIds;
Ref<Buffer> mBodyBuffer;
Asset(Asset &);
Asset &operator=(const Asset &);
public:
// Copy policies
Asset(Asset &) = delete;
Asset &operator=(const Asset &) = delete;
//! Keeps info about the enabled extensions
struct Extensions {
bool KHR_binary_glTF;
bool KHR_materials_common;
bool KHR_binary_glTF{ false };
bool KHR_materials_common{ false };
} extensionsUsed;
AssetMetadata asset;
@@ -961,8 +948,7 @@ public:
Ref<Scene> scene;
public:
Asset(IOSystem *io = nullptr) :
explicit Asset(IOSystem *io = nullptr) :
mIOSystem(io),
asset(),
accessors(*this, "accessors"),
@@ -979,7 +965,7 @@ public:
skins(*this, "skins"),
textures(*this, "textures"),
lights(*this, "lights", "KHR_materials_common") {
memset(&extensionsUsed, 0, sizeof(extensionsUsed));
// empty
}
//! Main function
@@ -995,10 +981,17 @@ public:
private:
void ReadBinaryHeader(IOStream &stream);
void ReadExtensionsUsed(Document &doc);
IOStream *OpenFile(const std::string &path, const char *mode, bool absolute = false);
private:
IOSystem *mIOSystem;
std::string mCurrentAssetDir;
size_t mSceneLength;
size_t mBodyOffset, mBodyLength;
std::vector<LazyDictBase *> mDicts;
IdMap mUsedIds;
Ref<Buffer> mBodyBuffer;
};
} // namespace glTF

View File

@@ -49,7 +49,6 @@ struct aiNode;
namespace glTF {
class Asset;
}
namespace Assimp {
@@ -58,7 +57,7 @@ namespace Assimp {
* Load the glTF format.
* https://github.com/KhronosGroup/glTF/tree/master/specification
*/
class glTFImporter : public BaseImporter {
class glTFImporter final : public BaseImporter {
public:
glTFImporter();
~glTFImporter() override = default;

View File

@@ -58,7 +58,6 @@ SET( COMPILER_HEADERS
SOURCE_GROUP( Compiler FILES ${COMPILER_HEADERS})
SET( PUBLIC_HEADERS
${HEADER_PATH}/allocator.h
${HEADER_PATH}/anim.h
${HEADER_PATH}/aabb.h
${HEADER_PATH}/ai_assert.h
@@ -168,7 +167,6 @@ SET( Logging_SRCS
SOURCE_GROUP(Logging FILES ${Logging_SRCS})
SET( Common_SRCS
Common/allocator.cpp
Common/StbCommon.h
Common/Compression.cpp
Common/Compression.h
@@ -403,6 +401,11 @@ ADD_ASSIMP_IMPORTER( IRR
AssetLib/Irr/IRRShared.h
)
ADD_ASSIMP_IMPORTER(JT
AssetLib/JT/JTImporter.cpp
AssetLib/JT/JTImporter.h
)
ADD_ASSIMP_IMPORTER( LWO
AssetLib/LWO/LWOAnimation.cpp
AssetLib/LWO/LWOAnimation.h

View File

@@ -69,7 +69,7 @@ using namespace Assimp;
namespace Assimp {
// underlying structure for aiPropertyStore
using PropertyMap = BatchLoader::PropertyMap ;
using PropertyMap = BatchLoader::PropertyMap ;
#if defined(__has_warning)
# if __has_warning("-Wordered-compare-function-pointers")

View File

@@ -1,12 +0,0 @@
#include <assimp/allocator.h>
aiAllocator gAllocatoMod;
void *aiAlloc(size_t size) {
return aiAllocator::allocFunc(size);
}
void aiFree(void *ptr) {
aiAllocator::freeFunc(ptr);
}

View File

@@ -1,4 +1,4 @@
/* stb_image - v2.29 - public domain image loader - http://nothings.org/stb
/* stb_image - v2.30 - public domain image loader - http://nothings.org/stb
no warranty implied; use at your own risk
Do this:
@@ -48,6 +48,7 @@ LICENSE
RECENT REVISION HISTORY:
2.30 (2024-05-31) avoid erroneous gcc warning
2.29 (2023-05-xx) optimizations
2.28 (2023-01-29) many error fixes, security errors, just tons of stuff
2.27 (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes
@@ -5159,9 +5160,11 @@ static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
// non-paletted with tRNS = constant alpha. if header-scanning, we can stop now.
if (scan == STBI__SCAN_header) { ++s->img_n; return 1; }
if (z->depth == 16) {
for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
for (k = 0; k < s->img_n && k < 3; ++k) // extra loop test to suppress false GCC warning
tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
} else {
for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
for (k = 0; k < s->img_n && k < 3; ++k)
tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
}
}
break;

View File

@@ -32,19 +32,19 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
PROJECT_NAME = "My Project"
PROJECT_NAME = "The Open Asset Importer Lib"
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER =
PROJECT_NUMBER = "6.0.2"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.
PROJECT_BRIEF =
PROJECT_BRIEF = The official Open-Asset-Importer-Library Repository. Loads 40+ 3D-file-formats into one unified and clean data structure.
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
@@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.
OUTPUT_DIRECTORY =
OUTPUT_DIRECTORY = out
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and

View File

@@ -156,8 +156,8 @@ private:
std::string mCur{};
const char *mEnd{nullptr};
StreamReaderLE &mStream;
bool mSwallow{false};
bool mSkip_empty_lines{ false };
bool mSwallow{ false };
bool mSkip_empty_lines{ false };1
bool mTrim{ false };
};

View File

@@ -331,11 +331,11 @@ private:
// --------------------------------------------------------------------------------------------
// `static` StreamReaders. Their byte order is fixed and they might be a little bit faster.
#ifdef AI_BUILD_BIG_ENDIAN
typedef StreamReader<true> StreamReaderLE;
typedef StreamReader<false> StreamReaderBE;
using StreamReaderLE = StreamReader<true> ;
using StreamReaderBE = StreamReader<false> ;
#else
typedef StreamReader<true> StreamReaderBE;
typedef StreamReader<false> StreamReaderLE;
using StreamReaderBE = StreamReader<true> ;
using StreamReaderLE = StreamReader<false> ;
#endif
// `dynamic` StreamReader. The byte order of the input data is specified in the

View File

@@ -1,97 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2025, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#ifndef AI_ALLOCATOR_H_INC
#define AI_ALLOCATOR_H_INC
#include <assimp/types.h>
#include <stddef.h>
#include <stdlib.h>
#include <memory.h>
typedef void* (*alloc_func)(size_t size);
typedef void (*free_func)(void* ptr);
static void *aiDefaultAlloc(size_t size) {
return malloc(size);
}
static void aiDefaultFree(void *ptr) {
free(ptr);
}
struct aiAllocator {
static alloc_func allocFunc;
static free_func freeFunc;
static void DefaultInit() {
allocFunc = aiDefaultAlloc;
freeFunc = aiDefaultFree;
}
static void init(alloc_func alloc_fn, free_func free_fn) {
allocFunc = alloc_fn;
freeFunc = free_fn;
}
} gAllocatoMod;
static void aiRegisterAllocator(alloc_func alloc_fn, free_func free_fn) {
aiAllocator::init(alloc_fn, free_fn);
}
ASSIMP_API void *aiAlloc(size_t size);
ASSIMP_API void aiFree(void *ptr);
#ifdef __cplusplus
extern "C" {
#endif
#define AI_NEW(ai_type, ...) new ai_type(__VA_ARGS__)
#define AI_NEW_ARRAY(ai_type, count) new ai_type[count]()
#define AI_DELETE(ptr) delete ptr
#define AI_DELETE_ARRAY(ptr) delete[] ptr
#ifdef __cplusplus
}
#endif
#endif // AI_ALLOCATOR_H_INC

View File

@@ -1,40 +0,0 @@
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2020, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
//