Merge branch 'master' into updatedpoli2tri
commit
be5961a259
|
@ -0,0 +1,51 @@
|
|||
name: Build Windows Installer
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
jobs:
|
||||
build:
|
||||
name: Build the Inno Setup Installer
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: lukka/get-cmake@latest
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
|
||||
- name: Cache DX SDK
|
||||
id: dxcache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: '${{ github.workspace }}/DX_SDK'
|
||||
key: ${{ runner.os }}-DX_SDK
|
||||
restore-keys: |
|
||||
${{ runner.os }}-DX_SDK
|
||||
|
||||
- name: Download DXSetup
|
||||
run: |
|
||||
curl -s -o DXSDK_Jun10.exe --location https://download.microsoft.com/download/A/E/7/AE743F1F-632B-4809-87A9-AA1BB3458E31/DXSDK_Jun10.exe
|
||||
cmd.exe /c start /wait .\DXSDK_Jun10.exe /U /O /F /S /P "${{ github.workspace }}\DX_SDK"
|
||||
|
||||
- name: Set Windows specific CMake arguments
|
||||
id: windows_extra_cmake_args
|
||||
run: echo "::set-output name=args::-DASSIMP_BUILD_ASSIMP_TOOLS=1 -DASSIMP_BUILD_ASSIMP_VIEW=1 -DASSIMP_BUILD_ZLIB=1"
|
||||
|
||||
- name: configure and build
|
||||
uses: lukka/run-cmake@v3
|
||||
env:
|
||||
DXSDK_DIR: '${{ github.workspace }}/DX_SDK'
|
||||
|
||||
with:
|
||||
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
||||
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
|
||||
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release ${{ steps.windows_extra_cmake_args.outputs.args }} ${{ steps.hunter_extra_cmake_args.outputs.args }}'
|
||||
buildWithCMakeArgs: '--parallel 24 -v'
|
||||
buildDirectory: '${{ github.workspace }}/build/'
|
||||
|
||||
- name: Compile .ISS to .EXE Installer
|
||||
uses: Minionguyjpro/Inno-Setup-Action@v1.2.2
|
||||
with:
|
||||
path: packaging/windows-innosetup/script_x64.iss
|
||||
options: /O+
|
|
@ -120,3 +120,7 @@ tools/assimp_qt_viewer/ui_mainwindow.h
|
|||
|
||||
#Generated directory
|
||||
generated/*
|
||||
|
||||
# 3rd party cloned repos/tarballs etc
|
||||
# tinyusdz repo, automatically cloned via CMake
|
||||
contrib/tinyusdz/autoclone
|
||||
|
|
|
@ -40,6 +40,13 @@ SET(CMAKE_POLICY_DEFAULT_CMP0092 NEW)
|
|||
|
||||
CMAKE_MINIMUM_REQUIRED( VERSION 3.22 )
|
||||
|
||||
# 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)
|
||||
|
||||
# Disabled importers: m3d for 5.1 or later
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_M3D_IMPORTER)
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||
|
@ -262,7 +269,7 @@ IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT MINGW AND NOT HAIKU)
|
|||
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
ENDIF()
|
||||
|
||||
|
||||
IF(CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 13)
|
||||
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>")
|
||||
|
@ -284,13 +291,13 @@ ELSEIF(MSVC)
|
|||
ELSE() # msvc
|
||||
ADD_COMPILE_OPTIONS(/MP /bigobj)
|
||||
ENDIF()
|
||||
|
||||
|
||||
# disable "elements of array '' will be default initialized" warning on MSVC2013
|
||||
IF(MSVC12)
|
||||
ADD_COMPILE_OPTIONS(/wd4351)
|
||||
ADD_COMPILE_OPTIONS(/wd4351)
|
||||
ENDIF()
|
||||
# supress warning for double to float conversion if Double precision is activated
|
||||
ADD_COMPILE_OPTIONS(/wd4244)
|
||||
ADD_COMPILE_OPTIONS(/wd4244)
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG:FULL /PDBALTPATH:%_PDB% /OPT:REF /OPT:ICF")
|
||||
|
@ -330,7 +337,7 @@ ENDIF()
|
|||
|
||||
IF (ASSIMP_COVERALLS)
|
||||
MESSAGE(STATUS "Coveralls enabled")
|
||||
|
||||
|
||||
INCLUDE(Coveralls)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
||||
|
@ -338,7 +345,7 @@ ENDIF()
|
|||
|
||||
IF (ASSIMP_ASAN)
|
||||
MESSAGE(STATUS "AddressSanitizer enabled")
|
||||
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
|
||||
ENDIF()
|
||||
|
@ -761,8 +768,8 @@ IF ( ASSIMP_INSTALL )
|
|||
ENDIF()
|
||||
|
||||
CONFIGURE_FILE(
|
||||
${CMAKE_CURRENT_LIST_DIR}/revision.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/revision.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/assimp/revision.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/assimp/revision.h
|
||||
)
|
||||
|
||||
CONFIGURE_FILE(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
FROM ubuntu:22.04
|
||||
|
||||
RUN apt-get update && apt-get install -y ninja-build \
|
||||
RUN apt-get update && apt-get install --no-install-recommends -y ninja-build \
|
||||
git cmake build-essential software-properties-common
|
||||
|
||||
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get update
|
||||
|
|
|
@ -26,12 +26,11 @@ Clone [our model database](https://github.com/assimp/assimp-mdb).
|
|||
|
||||
### Communities ###
|
||||
- Ask questions at [the Assimp Discussion Board](https://github.com/assimp/assimp/discussions).
|
||||
- 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)
|
||||
|
||||
And we also have a Gitter-channel:Gitter [](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)<br>
|
||||
|
||||
#### Supported file formats ####
|
||||
See [the complete list of supported formats](https://github.com/assimp/assimp/blob/master/doc/Fileformats.md).
|
||||
|
||||
|
|
|
@ -22,38 +22,9 @@
|
|||
# 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.
|
||||
|
||||
# This is a gate file to Hunter package manager.
|
||||
# Include this file using `include` command and add package you need, example:
|
||||
#
|
||||
# cmake_minimum_required(VERSION 3.2)
|
||||
#
|
||||
# include("cmake/HunterGate.cmake")
|
||||
# HunterGate(
|
||||
# URL "https://github.com/path/to/hunter/archive.tar.gz"
|
||||
# SHA1 "798501e983f14b28b10cda16afa4de69eee1da1d"
|
||||
# )
|
||||
#
|
||||
# project(MyProject)
|
||||
#
|
||||
# hunter_add_package(Foo)
|
||||
# hunter_add_package(Boo COMPONENTS Bar Baz)
|
||||
#
|
||||
# Projects:
|
||||
# * https://github.com/hunter-packages/gate/
|
||||
# * https://github.com/ruslo/hunter
|
||||
|
||||
option(HUNTER_ENABLED "Enable Hunter package manager support" ON)
|
||||
|
||||
if(HUNTER_ENABLED)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.2")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"At least CMake version 3.2 required for Hunter dependency management."
|
||||
" Update CMake or set HUNTER_ENABLED to OFF."
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(CMakeParseArguments) # cmake_parse_arguments
|
||||
|
||||
option(HUNTER_STATUS_PRINT "Print working status" ON)
|
||||
|
|
|
@ -709,7 +709,7 @@ void Discreet3DSImporter::GenerateNodeGraph(aiScene *pcOut) {
|
|||
pcNode->mNumMeshes = 1;
|
||||
|
||||
// Build a name for the node
|
||||
pcNode->mName.length = ai_snprintf(pcNode->mName.data, MAXLEN, "3DSMesh_%u", i);
|
||||
pcNode->mName.length = ai_snprintf(pcNode->mName.data, AI_MAXLEN, "3DSMesh_%u", i);
|
||||
}
|
||||
|
||||
// Build dummy nodes for all cameras
|
||||
|
|
|
@ -365,14 +365,13 @@ struct Texture {
|
|||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif // _MSC_VER
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Helper structure representing a 3ds material */
|
||||
struct Material {
|
||||
//! Default constructor has been deleted
|
||||
Material() :
|
||||
mName(),
|
||||
mDiffuse(ai_real(0.6), ai_real(0.6), ai_real(0.6)),
|
||||
mDiffuse(0.6f, 0.6f, 0.6f),
|
||||
mSpecularExponent(ai_real(0.0)),
|
||||
mShininessStrength(ai_real(1.0)),
|
||||
mShading(Discreet3DS::Gouraud),
|
||||
|
@ -385,7 +384,7 @@ struct Material {
|
|||
//! Constructor with explicit name
|
||||
explicit Material(const std::string &name) :
|
||||
mName(name),
|
||||
mDiffuse(ai_real(0.6), ai_real(0.6), ai_real(0.6)),
|
||||
mDiffuse(0.6f, 0.6f, 0.6f),
|
||||
mSpecularExponent(ai_real(0.0)),
|
||||
mShininessStrength(ai_real(1.0)),
|
||||
mShading(Discreet3DS::Gouraud),
|
||||
|
|
|
@ -57,8 +57,8 @@ static constexpr size_t ColRGBA_Len = 9;
|
|||
static constexpr size_t ColRGB_Len = 7;
|
||||
|
||||
// format of the color string: #RRGGBBAA or #RRGGBB (3MF Core chapter 5.1.1)
|
||||
bool validateColorString(const char *color) {
|
||||
const size_t len = strlen(color);
|
||||
bool validateColorString(const std::string color) {
|
||||
const size_t len = color.size();
|
||||
if (ColRGBA_Len != len && ColRGB_Len != len) {
|
||||
return false;
|
||||
}
|
||||
|
@ -157,8 +157,8 @@ aiMatrix4x4 parseTransformMatrix(const std::string& matrixStr) {
|
|||
return transformMatrix;
|
||||
}
|
||||
|
||||
bool parseColor(const char *color, aiColor4D &diffuse) {
|
||||
if (nullptr == color) {
|
||||
bool parseColor(const std::string &color, aiColor4D &diffuse) {
|
||||
if (color.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ bool parseColor(const char *color, aiColor4D &diffuse) {
|
|||
|
||||
char b[3] = { color[5], color[6], '\0' };
|
||||
diffuse.b = static_cast<ai_real>(strtol(b, nullptr, 16)) / ai_real(255.0);
|
||||
const size_t len = strlen(color);
|
||||
const size_t len = color.size();
|
||||
if (ColRGB_Len == len) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ bool AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
|
|||
|
||||
// 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, MAXLEN, "ACLight_%i", static_cast<unsigned int>(mLights->size()) - 1);
|
||||
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);
|
||||
|
||||
ASSIMP_LOG_VERBOSE_DEBUG("AC3D: Light source encountered");
|
||||
|
@ -696,18 +696,18 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
|
|||
// generate a name depending on the type of the node
|
||||
switch (object.type) {
|
||||
case Object::Group:
|
||||
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACGroup_%i", mGroupsCounter++);
|
||||
node->mName.length = ::ai_snprintf(node->mName.data, AI_MAXLEN, "ACGroup_%i", mGroupsCounter++);
|
||||
break;
|
||||
case Object::Poly:
|
||||
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACPoly_%i", mPolysCounter++);
|
||||
node->mName.length = ::ai_snprintf(node->mName.data, AI_MAXLEN, "ACPoly_%i", mPolysCounter++);
|
||||
break;
|
||||
case Object::Light:
|
||||
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACLight_%i", mLightsCounter++);
|
||||
node->mName.length = ::ai_snprintf(node->mName.data, AI_MAXLEN, "ACLight_%i", mLightsCounter++);
|
||||
break;
|
||||
|
||||
// there shouldn't be more than one world, but we don't care
|
||||
case Object::World:
|
||||
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACWorld_%i", mWorldsCounter++);
|
||||
node->mName.length = ::ai_snprintf(node->mName.data, AI_MAXLEN, "ACWorld_%i", mWorldsCounter++);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,28 +178,6 @@ bool AMFImporter::XML_SearchNode(const std::string &nodeName) {
|
|||
return nullptr != mXmlParser->findNode(nodeName);
|
||||
}
|
||||
|
||||
void AMFImporter::ParseHelper_FixTruncatedFloatString(const char *pInStr, std::string &pOutString) {
|
||||
size_t instr_len;
|
||||
|
||||
pOutString.clear();
|
||||
instr_len = strlen(pInStr);
|
||||
if (!instr_len) return;
|
||||
|
||||
pOutString.reserve(instr_len * 3 / 2);
|
||||
// check and correct floats in format ".x". Must be "x.y".
|
||||
if (pInStr[0] == '.') pOutString.push_back('0');
|
||||
|
||||
pOutString.push_back(pInStr[0]);
|
||||
for (size_t ci = 1; ci < instr_len; ci++) {
|
||||
if ((pInStr[ci] == '.') && ((pInStr[ci - 1] == ' ') || (pInStr[ci - 1] == '-') || (pInStr[ci - 1] == '+') || (pInStr[ci - 1] == '\t'))) {
|
||||
pOutString.push_back('0');
|
||||
pOutString.push_back('.');
|
||||
} else {
|
||||
pOutString.push_back(pInStr[ci]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool ParseHelper_Decode_Base64_IsBase64(const char pChar) {
|
||||
return (isalnum((unsigned char)pChar) || (pChar == '+') || (pChar == '/'));
|
||||
}
|
||||
|
@ -213,7 +191,10 @@ void AMFImporter::ParseHelper_Decode_Base64(const std::string &pInputBase64, std
|
|||
uint8_t arr4[4], arr3[3];
|
||||
|
||||
// check input data
|
||||
if (pInputBase64.size() % 4) throw DeadlyImportError("Base64-encoded data must have size multiply of four.");
|
||||
if (pInputBase64.size() % 4) {
|
||||
throw DeadlyImportError("Base64-encoded data must have size multiply of four.");
|
||||
}
|
||||
|
||||
// prepare output place
|
||||
pOutputData.clear();
|
||||
pOutputData.reserve(pInputBase64.size() / 4 * 3);
|
||||
|
@ -403,17 +384,17 @@ void AMFImporter::ParseNode_Instance(XmlNode &node) {
|
|||
for (auto ¤tNode : node.children()) {
|
||||
const std::string ¤tName = currentNode.name();
|
||||
if (currentName == "deltax") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Delta.x);
|
||||
XmlParser::getValueAsReal(currentNode, als.Delta.x);
|
||||
} else if (currentName == "deltay") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Delta.y);
|
||||
XmlParser::getValueAsReal(currentNode, als.Delta.y);
|
||||
} else if (currentName == "deltaz") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Delta.z);
|
||||
XmlParser::getValueAsReal(currentNode, als.Delta.z);
|
||||
} else if (currentName == "rx") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Delta.x);
|
||||
XmlParser::getValueAsReal(currentNode, als.Delta.x);
|
||||
} else if (currentName == "ry") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Delta.y);
|
||||
XmlParser::getValueAsReal(currentNode, als.Delta.y);
|
||||
} else if (currentName == "rz") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Delta.z);
|
||||
XmlParser::getValueAsReal(currentNode, als.Delta.z);
|
||||
}
|
||||
}
|
||||
ParseHelper_Node_Exit();
|
||||
|
|
|
@ -168,7 +168,6 @@ public:
|
|||
AI_WONT_RETURN void Throw_ID_NotFound(const std::string &pID) const AI_WONT_RETURN_SUFFIX;
|
||||
void XML_CheckNode_MustHaveChildren(pugi::xml_node &node);
|
||||
bool XML_SearchNode(const std::string &nodeName);
|
||||
void ParseHelper_FixTruncatedFloatString(const char *pInStr, std::string &pOutString);
|
||||
AMFImporter(const AMFImporter &pScene) = delete;
|
||||
AMFImporter &operator=(const AMFImporter &pScene) = delete;
|
||||
|
||||
|
|
|
@ -167,11 +167,11 @@ void AMFImporter::ParseNode_Coordinates(XmlNode &node) {
|
|||
AMFCoordinates &als = *((AMFCoordinates *)ne); // alias for convenience
|
||||
const std::string ¤tName = ai_tolower(currentNode.name());
|
||||
if (currentName == "x") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Coordinate.x);
|
||||
XmlParser::getValueAsReal(currentNode, als.Coordinate.x);
|
||||
} else if (currentName == "y") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Coordinate.y);
|
||||
XmlParser::getValueAsReal(currentNode, als.Coordinate.y);
|
||||
} else if (currentName == "z") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Coordinate.z);
|
||||
XmlParser::getValueAsReal(currentNode, als.Coordinate.z);
|
||||
}
|
||||
}
|
||||
ParseHelper_Node_Exit();
|
||||
|
|
|
@ -263,26 +263,25 @@ void AMFImporter::ParseNode_TexMap(XmlNode &node, const bool pUseOldName) {
|
|||
const std::string &name = currentNode.name();
|
||||
if (name == "utex1") {
|
||||
read_flag[0] = true;
|
||||
XmlParser::getValueAsFloat(node, als.TextureCoordinate[0].x);
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[0].x);
|
||||
} else if (name == "utex2") {
|
||||
read_flag[1] = true;
|
||||
XmlParser::getValueAsFloat(node, als.TextureCoordinate[1].x);
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[1].x);
|
||||
} else if (name == "utex3") {
|
||||
read_flag[2] = true;
|
||||
XmlParser::getValueAsFloat(node, als.TextureCoordinate[2].x);
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[2].x);
|
||||
} else if (name == "vtex1") {
|
||||
read_flag[3] = true;
|
||||
XmlParser::getValueAsFloat(node, als.TextureCoordinate[0].y);
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[0].y);
|
||||
} else if (name == "vtex2") {
|
||||
read_flag[4] = true;
|
||||
XmlParser::getValueAsFloat(node, als.TextureCoordinate[1].y);
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[1].y);
|
||||
} else if (name == "vtex3") {
|
||||
read_flag[5] = true;
|
||||
XmlParser::getValueAsFloat(node, als.TextureCoordinate[2].y);
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[2].y);
|
||||
}
|
||||
}
|
||||
ParseHelper_Node_Exit();
|
||||
|
||||
} else {
|
||||
for (pugi::xml_attribute &attr : node.attributes()) {
|
||||
const std::string name = attr.name();
|
||||
|
|
|
@ -56,7 +56,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/// \class CAMFImporter_NodeElement
|
||||
/// Base class for elements of nodes.
|
||||
class AMFNodeElementBase {
|
||||
public:
|
||||
|
@ -106,7 +105,6 @@ protected:
|
|||
}
|
||||
}; // class IAMFImporter_NodeElement
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_Constellation
|
||||
/// A collection of objects or constellations with specific relative locations.
|
||||
struct AMFConstellation : public AMFNodeElementBase {
|
||||
/// Constructor.
|
||||
|
@ -116,7 +114,6 @@ struct AMFConstellation : public AMFNodeElementBase {
|
|||
|
||||
}; // struct CAMFImporter_NodeElement_Constellation
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_Instance
|
||||
/// Part of constellation.
|
||||
struct AMFInstance : public AMFNodeElementBase {
|
||||
|
||||
|
@ -135,7 +132,6 @@ struct AMFInstance : public AMFNodeElementBase {
|
|||
AMFNodeElementBase(ENET_Instance, pParent) {}
|
||||
};
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_Metadata
|
||||
/// Structure that define metadata node.
|
||||
struct AMFMetadata : public AMFNodeElementBase {
|
||||
|
||||
|
@ -148,7 +144,6 @@ struct AMFMetadata : public AMFNodeElementBase {
|
|||
AMFNodeElementBase(ENET_Metadata, pParent) {}
|
||||
};
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_Root
|
||||
/// Structure that define root node.
|
||||
struct AMFRoot : public AMFNodeElementBase {
|
||||
|
||||
|
@ -161,7 +156,6 @@ struct AMFRoot : public AMFNodeElementBase {
|
|||
AMFNodeElementBase(ENET_Root, pParent) {}
|
||||
};
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_Color
|
||||
/// Structure that define object node.
|
||||
struct AMFColor : public AMFNodeElementBase {
|
||||
bool Composed; ///< Type of color stored: if true then look for formula in \ref Color_Composed[4], else - in \ref Color.
|
||||
|
@ -177,7 +171,6 @@ struct AMFColor : public AMFNodeElementBase {
|
|||
}
|
||||
};
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_Material
|
||||
/// Structure that define material node.
|
||||
struct AMFMaterial : public AMFNodeElementBase {
|
||||
|
||||
|
@ -187,7 +180,6 @@ struct AMFMaterial : public AMFNodeElementBase {
|
|||
AMFNodeElementBase(ENET_Material, pParent) {}
|
||||
};
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_Object
|
||||
/// Structure that define object node.
|
||||
struct AMFObject : public AMFNodeElementBase {
|
||||
|
||||
|
@ -206,7 +198,6 @@ struct AMFMesh : public AMFNodeElementBase {
|
|||
AMFNodeElementBase(ENET_Mesh, pParent) {}
|
||||
};
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_Vertex
|
||||
/// Structure that define vertex node.
|
||||
struct AMFVertex : public AMFNodeElementBase {
|
||||
/// Constructor.
|
||||
|
@ -215,7 +206,6 @@ struct AMFVertex : public AMFNodeElementBase {
|
|||
AMFNodeElementBase(ENET_Vertex, pParent) {}
|
||||
};
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_Edge
|
||||
/// Structure that define edge node.
|
||||
struct AMFEdge : public AMFNodeElementBase {
|
||||
/// Constructor.
|
||||
|
@ -224,7 +214,6 @@ struct AMFEdge : public AMFNodeElementBase {
|
|||
AMFNodeElementBase(ENET_Edge, pParent) {}
|
||||
};
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_Vertices
|
||||
/// Structure that define vertices node.
|
||||
struct AMFVertices : public AMFNodeElementBase {
|
||||
/// Constructor.
|
||||
|
@ -233,7 +222,6 @@ struct AMFVertices : public AMFNodeElementBase {
|
|||
AMFNodeElementBase(ENET_Vertices, pParent) {}
|
||||
};
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_Volume
|
||||
/// Structure that define volume node.
|
||||
struct AMFVolume : public AMFNodeElementBase {
|
||||
std::string MaterialID; ///< Which material to use.
|
||||
|
@ -245,7 +233,6 @@ struct AMFVolume : public AMFNodeElementBase {
|
|||
AMFNodeElementBase(ENET_Volume, pParent) {}
|
||||
};
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_Coordinates
|
||||
/// Structure that define coordinates node.
|
||||
struct AMFCoordinates : public AMFNodeElementBase {
|
||||
aiVector3D Coordinate; ///< Coordinate.
|
||||
|
@ -256,7 +243,6 @@ struct AMFCoordinates : public AMFNodeElementBase {
|
|||
AMFNodeElementBase(ENET_Coordinates, pParent) {}
|
||||
};
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_TexMap
|
||||
/// Structure that define texture coordinates node.
|
||||
struct AMFTexMap : public AMFNodeElementBase {
|
||||
aiVector3D TextureCoordinate[3]; ///< Texture coordinates.
|
||||
|
@ -273,7 +259,6 @@ struct AMFTexMap : public AMFNodeElementBase {
|
|||
}
|
||||
};
|
||||
|
||||
/// \struct CAMFImporter_NodeElement_Triangle
|
||||
/// Structure that define triangle node.
|
||||
struct AMFTriangle : public AMFNodeElementBase {
|
||||
size_t V[3]; ///< Triangle vertices.
|
||||
|
|
|
@ -224,7 +224,8 @@ size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string &
|
|||
}
|
||||
|
||||
// Create format hint.
|
||||
strcpy(converted_texture.FormatHint, "rgba0000"); // copy initial string.
|
||||
constexpr char templateColor[] = "rgba0000";
|
||||
memcpy(converted_texture.FormatHint, templateColor, 8);
|
||||
if (!r.empty()) converted_texture.FormatHint[4] = '8';
|
||||
if (!g.empty()) converted_texture.FormatHint[5] = '8';
|
||||
if (!b.empty()) converted_texture.FormatHint[6] = '8';
|
||||
|
@ -867,7 +868,7 @@ nl_clean_loop:
|
|||
pScene->mTextures[idx]->mHeight = static_cast<unsigned int>(tex_convd.Height);
|
||||
pScene->mTextures[idx]->pcData = (aiTexel *)tex_convd.Data;
|
||||
// texture format description.
|
||||
strcpy(pScene->mTextures[idx]->achFormatHint, tex_convd.FormatHint);
|
||||
strncpy(pScene->mTextures[idx]->achFormatHint, tex_convd.FormatHint, HINTMAXTEXTURELEN);
|
||||
idx++;
|
||||
} // for(const SPP_Texture& tex_convd: mTexture_Converted)
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ void ASEImporter::InternReadFile(const std::string &pFile,
|
|||
// Allocate storage and copy the contents of the file to a memory buffer
|
||||
std::vector<char> mBuffer2;
|
||||
TextFileToBuffer(file.get(), mBuffer2);
|
||||
|
||||
const size_t fileSize = mBuffer2.size();
|
||||
this->mBuffer = &mBuffer2[0];
|
||||
this->pcScene = pScene;
|
||||
|
||||
|
@ -146,7 +146,7 @@ void ASEImporter::InternReadFile(const std::string &pFile,
|
|||
};
|
||||
|
||||
// Construct an ASE parser and parse the file
|
||||
ASE::Parser parser(mBuffer, defaultFormat);
|
||||
ASE::Parser parser(mBuffer, fileSize, defaultFormat);
|
||||
mParser = &parser;
|
||||
mParser->Parse();
|
||||
|
||||
|
@ -446,10 +446,9 @@ void ASEImporter::BuildLights() {
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ASEImporter::AddNodes(const std::vector<BaseNode *> &nodes,
|
||||
aiNode *pcParent, const char *szName) {
|
||||
void ASEImporter::AddNodes(const std::vector<BaseNode *> &nodes, aiNode *pcParent, const std::string &name) {
|
||||
aiMatrix4x4 m;
|
||||
AddNodes(nodes, pcParent, szName, m);
|
||||
AddNodes(nodes, pcParent, name, m);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -506,10 +505,9 @@ void ASEImporter::AddMeshes(const ASE::BaseNode *snode, aiNode *node) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Add child nodes to a given parent node
|
||||
void ASEImporter::AddNodes(const std::vector<BaseNode *> &nodes,
|
||||
aiNode *pcParent, const char *szName,
|
||||
void ASEImporter::AddNodes(const std::vector<BaseNode *> &nodes, aiNode *pcParent, const std::string &name,
|
||||
const aiMatrix4x4 &mat) {
|
||||
const size_t len = szName ? ::strlen(szName) : 0;
|
||||
const size_t len = name.size();
|
||||
ai_assert(4 <= AI_MAX_NUMBER_OF_COLOR_SETS);
|
||||
|
||||
// Receives child nodes for the pcParent node
|
||||
|
@ -519,16 +517,18 @@ void ASEImporter::AddNodes(const std::vector<BaseNode *> &nodes,
|
|||
// which has *us* as parent.
|
||||
for (std::vector<BaseNode *>::const_iterator it = nodes.begin(), end = nodes.end(); it != end; ++it) {
|
||||
const BaseNode *snode = *it;
|
||||
if (szName) {
|
||||
if (len != snode->mParent.length() || ::strcmp(szName, snode->mParent.c_str()))
|
||||
if (!name.empty()) {
|
||||
if (len != snode->mParent.length() || name != snode->mParent.c_str()) {
|
||||
continue;
|
||||
} else if (snode->mParent.length())
|
||||
}
|
||||
} else if (snode->mParent.length()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
(*it)->mProcessed = true;
|
||||
|
||||
// Allocate a new node and add it to the output data structure
|
||||
apcNodes.push_back(new aiNode());
|
||||
apcNodes.push_back(new aiNode);
|
||||
aiNode *node = apcNodes.back();
|
||||
|
||||
node->mName.Set((snode->mName.length() ? snode->mName.c_str() : "Unnamed_Node"));
|
||||
|
@ -541,7 +541,7 @@ void ASEImporter::AddNodes(const std::vector<BaseNode *> &nodes,
|
|||
|
||||
// Add sub nodes - prevent stack overflow due to recursive parenting
|
||||
if (node->mName != node->mParent->mName && node->mName != node->mParent->mParent->mName) {
|
||||
AddNodes(nodes, node, node->mName.data, snode->mTransform);
|
||||
AddNodes(nodes, node, node->mName.C_Str(), snode->mTransform);
|
||||
}
|
||||
|
||||
// Further processing depends on the type of the node
|
||||
|
@ -619,7 +619,8 @@ void ASEImporter::BuildNodes(std::vector<BaseNode *> &nodes) {
|
|||
}
|
||||
|
||||
// add all nodes
|
||||
AddNodes(nodes, ch, nullptr);
|
||||
static const std::string none = "";
|
||||
AddNodes(nodes, ch, none);
|
||||
|
||||
// now iterate through al nodes and find those that have not yet
|
||||
// been added to the nodegraph (= their parent could not be recognized)
|
||||
|
|
|
@ -153,13 +153,13 @@ private:
|
|||
* \param matrix Current transform
|
||||
*/
|
||||
void AddNodes(const std::vector<ASE::BaseNode*>& nodes,
|
||||
aiNode* pcParent,const char* szName);
|
||||
aiNode* pcParent, const std::string &name);
|
||||
|
||||
void AddNodes(const std::vector<ASE::BaseNode*>& nodes,
|
||||
aiNode* pcParent,const char* szName,
|
||||
aiNode* pcParent, const std::string &name,
|
||||
const aiMatrix4x4& matrix);
|
||||
|
||||
void AddMeshes(const ASE::BaseNode* snode,aiNode* node);
|
||||
void AddMeshes(const ASE::BaseNode* snode, aiNode* node);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Generate a default material and add it to the parser's list
|
||||
|
@ -188,5 +188,4 @@ protected:
|
|||
|
||||
} // end of namespace Assimp
|
||||
|
||||
|
||||
#endif // AI_3DSIMPORTER_H_INC
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -391,11 +391,11 @@ public:
|
|||
// -------------------------------------------------------------------
|
||||
//! Construct a parser from a given input file which is
|
||||
//! guaranteed to be terminated with zero.
|
||||
//! @param szFile Input file
|
||||
//! @param file The name of the input file.
|
||||
//! @param fileFormatDefault Assumed file format version. If the
|
||||
//! file format is specified in the file the new value replaces
|
||||
//! the default value.
|
||||
Parser(const char *szFile, unsigned int fileFormatDefault);
|
||||
Parser(const char *file, size_t fileLen, unsigned int fileFormatDefault);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parses the file into the parsers internal representation
|
||||
|
@ -553,13 +553,15 @@ private:
|
|||
//! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL ...)
|
||||
//! \param apOut Output buffer (3 floats)
|
||||
//! \param rIndexOut Output index
|
||||
void ParseLV4MeshFloatTriple(ai_real *apOut, unsigned int &rIndexOut);
|
||||
void ParseLV4MeshRealTriple(ai_real *apOut, unsigned int &rIndexOut);
|
||||
void ParseLV4MeshFloatTriple(float *apOut, unsigned int &rIndexOut);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse a *MESH_VERT block in a file
|
||||
//! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL ...)
|
||||
//! \param apOut Output buffer (3 floats)
|
||||
void ParseLV4MeshFloatTriple(ai_real *apOut);
|
||||
void ParseLV4MeshRealTriple(ai_real *apOut);
|
||||
void ParseLV4MeshFloatTriple(float *apOut);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse a *MESH_TFACE block in a file
|
||||
|
@ -577,7 +579,8 @@ private:
|
|||
// -------------------------------------------------------------------
|
||||
//! Parse a single float element
|
||||
//! \param fOut Output float
|
||||
void ParseLV4MeshFloat(ai_real &fOut);
|
||||
void ParseLV4MeshReal(ai_real &fOut);
|
||||
void ParseLV4MeshFloat(float &fOut);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse a single int element
|
||||
|
@ -617,11 +620,8 @@ private:
|
|||
bool ParseString(std::string &out, const char *szName);
|
||||
|
||||
public:
|
||||
//! Pointer to current data
|
||||
const char *filePtr;
|
||||
|
||||
/// The end pointer of the file data
|
||||
const char *mEnd;
|
||||
const char *mFilePtr; ////< Pointer to current data
|
||||
const char *mEnd; ///< The end pointer of the file data
|
||||
|
||||
//! background color to be passed to the viewer
|
||||
//! QNAN if none was found
|
||||
|
|
|
@ -359,7 +359,7 @@ void BlenderImporter::ResolveImage(aiMaterial *out, const Material *mat, const M
|
|||
// check if the file contents are bundled with the BLEND file
|
||||
if (img->packedfile) {
|
||||
name.data[0] = '*';
|
||||
name.length = 1 + ASSIMP_itoa10(name.data + 1, static_cast<unsigned int>(MAXLEN - 1), static_cast<int32_t>(conv_data.textures->size()));
|
||||
name.length = 1 + ASSIMP_itoa10(name.data + 1, static_cast<unsigned int>(AI_MAXLEN - 1), static_cast<int32_t>(conv_data.textures->size()));
|
||||
|
||||
conv_data.textures->push_back(new aiTexture());
|
||||
aiTexture *curTex = conv_data.textures->back();
|
||||
|
@ -433,7 +433,7 @@ void BlenderImporter::AddSentinelTexture(aiMaterial *out, const Material *mat, c
|
|||
(void)conv_data;
|
||||
|
||||
aiString name;
|
||||
name.length = ai_snprintf(name.data, MAXLEN, "Procedural,num=%i,type=%s", conv_data.sentinel_cnt++,
|
||||
name.length = ai_snprintf(name.data, AI_MAXLEN, "Procedural,num=%i,type=%s", conv_data.sentinel_cnt++,
|
||||
GetTextureTypeDisplayString(tex->tex->type));
|
||||
out->AddProperty(&name, AI_MATKEY_TEXTURE_DIFFUSE(
|
||||
conv_data.next_texture[aiTextureType_DIFFUSE]++));
|
||||
|
|
|
@ -625,16 +625,14 @@ aiMesh *ColladaLoader::CreateMesh(const ColladaParser &pParser, const Mesh *pSrc
|
|||
}
|
||||
|
||||
// same for texture coords, as many as we have
|
||||
// empty slots are not allowed, need to pack and adjust UV indexes accordingly
|
||||
for (size_t a = 0, real = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
|
||||
for (size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
|
||||
if (pSrcMesh->mTexCoords[a].size() >= pStartVertex + numVertices) {
|
||||
dstMesh->mTextureCoords[real] = new aiVector3D[numVertices];
|
||||
dstMesh->mTextureCoords[a] = new aiVector3D[numVertices];
|
||||
for (size_t b = 0; b < numVertices; ++b) {
|
||||
dstMesh->mTextureCoords[real][b] = pSrcMesh->mTexCoords[a][pStartVertex + b];
|
||||
dstMesh->mTextureCoords[a][b] = pSrcMesh->mTexCoords[a][pStartVertex + b];
|
||||
}
|
||||
|
||||
dstMesh->mNumUVComponents[real] = pSrcMesh->mNumUVComponents[a];
|
||||
++real;
|
||||
dstMesh->mNumUVComponents[a] = pSrcMesh->mNumUVComponents[a];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -968,34 +968,34 @@ void ColladaParser::ReadLight(XmlNode &node, Collada::Light &pLight) {
|
|||
content = fast_atoreal_move<ai_real>(content, (ai_real &)pLight.mColor.b);
|
||||
SkipSpacesAndLineEnd(&content, end);
|
||||
} else if (currentName == "constant_attenuation") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mAttConstant);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mAttConstant);
|
||||
} else if (currentName == "linear_attenuation") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mAttLinear);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mAttLinear);
|
||||
} else if (currentName == "quadratic_attenuation") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mAttQuadratic);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mAttQuadratic);
|
||||
} else if (currentName == "falloff_angle") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mFalloffAngle);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mFalloffAngle);
|
||||
} else if (currentName == "falloff_exponent") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mFalloffExponent);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mFalloffExponent);
|
||||
}
|
||||
// FCOLLADA extensions
|
||||
// -------------------------------------------------------
|
||||
else if (currentName == "outer_cone") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mOuterAngle);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mOuterAngle);
|
||||
} else if (currentName == "penumbra_angle") { // this one is deprecated, now calculated using outer_cone
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mPenumbraAngle);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mPenumbraAngle);
|
||||
} else if (currentName == "intensity") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mIntensity);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mIntensity);
|
||||
}
|
||||
else if (currentName == "falloff") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mOuterAngle);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mOuterAngle);
|
||||
} else if (currentName == "hotspot_beam") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mFalloffAngle);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mFalloffAngle);
|
||||
}
|
||||
// OpenCOLLADA extensions
|
||||
// -------------------------------------------------------
|
||||
else if (currentName == "decay_falloff") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mOuterAngle);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mOuterAngle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1010,15 +1010,15 @@ void ColladaParser::ReadCamera(XmlNode &node, Collada::Camera &camera) {
|
|||
if (currentName == "orthographic") {
|
||||
camera.mOrtho = true;
|
||||
} else if (currentName == "xfov" || currentName == "xmag") {
|
||||
XmlParser::getValueAsFloat(currentNode, camera.mHorFov);
|
||||
XmlParser::getValueAsReal(currentNode, camera.mHorFov);
|
||||
} else if (currentName == "yfov" || currentName == "ymag") {
|
||||
XmlParser::getValueAsFloat(currentNode, camera.mVerFov);
|
||||
XmlParser::getValueAsReal(currentNode, camera.mVerFov);
|
||||
} else if (currentName == "aspect_ratio") {
|
||||
XmlParser::getValueAsFloat(currentNode, camera.mAspect);
|
||||
XmlParser::getValueAsReal(currentNode, camera.mAspect);
|
||||
} else if (currentName == "znear") {
|
||||
XmlParser::getValueAsFloat(currentNode, camera.mZNear);
|
||||
XmlParser::getValueAsReal(currentNode, camera.mZNear);
|
||||
} else if (currentName == "zfar") {
|
||||
XmlParser::getValueAsFloat(currentNode, camera.mZFar);
|
||||
XmlParser::getValueAsReal(currentNode, camera.mZFar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1170,15 +1170,15 @@ void ColladaParser::ReadSamplerProperties(XmlNode &node, Sampler &out) {
|
|||
} else if (currentName == "mirrorV") {
|
||||
XmlParser::getValueAsBool(currentNode, out.mMirrorV);
|
||||
} else if (currentName == "repeatU") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mTransform.mScaling.x);
|
||||
XmlParser::getValueAsReal(currentNode, out.mTransform.mScaling.x);
|
||||
} else if (currentName == "repeatV") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mTransform.mScaling.y);
|
||||
XmlParser::getValueAsReal(currentNode, out.mTransform.mScaling.y);
|
||||
} else if (currentName == "offsetU") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mTransform.mTranslation.x);
|
||||
XmlParser::getValueAsReal(currentNode, out.mTransform.mTranslation.x);
|
||||
} else if (currentName == "offsetV") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mTransform.mTranslation.y);
|
||||
XmlParser::getValueAsReal(currentNode, out.mTransform.mTranslation.y);
|
||||
} else if (currentName == "rotateUV") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mTransform.mRotation);
|
||||
XmlParser::getValueAsReal(currentNode, out.mTransform.mRotation);
|
||||
} else if (currentName == "blend_mode") {
|
||||
std::string v;
|
||||
XmlParser::getValueAsString(currentNode, v);
|
||||
|
@ -1198,14 +1198,14 @@ void ColladaParser::ReadSamplerProperties(XmlNode &node, Sampler &out) {
|
|||
// OKINO extensions
|
||||
// -------------------------------------------------------
|
||||
else if (currentName == "weighting") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mWeighting);
|
||||
XmlParser::getValueAsReal(currentNode, out.mWeighting);
|
||||
} else if (currentName == "mix_with_previous_layer") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mMixWithPrevious);
|
||||
XmlParser::getValueAsReal(currentNode, out.mMixWithPrevious);
|
||||
}
|
||||
// MAX3D extensions
|
||||
// -------------------------------------------------------
|
||||
else if (currentName == "amount") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mWeighting);
|
||||
XmlParser::getValueAsReal(currentNode, out.mWeighting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1265,13 +1265,13 @@ void ColladaParser::ReadEffectColor(XmlNode &node, aiColor4D &pColor, Sampler &p
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads an effect entry containing a float
|
||||
void ColladaParser::ReadEffectFloat(XmlNode &node, ai_real &pFloat) {
|
||||
pFloat = 0.f;
|
||||
void ColladaParser::ReadEffectFloat(XmlNode &node, ai_real &pReal) {
|
||||
pReal = 0.f;
|
||||
XmlNode floatNode = node.child("float");
|
||||
if (floatNode.empty()) {
|
||||
return;
|
||||
}
|
||||
XmlParser::getValueAsFloat(floatNode, pFloat);
|
||||
XmlParser::getValueAsReal(floatNode, pReal);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -2293,9 +2293,9 @@ void ColladaParser::ReadNodeGeometry(XmlNode &node, Node *pNode) {
|
|||
urlMat++;
|
||||
|
||||
s.mMatName = urlMat;
|
||||
ReadMaterialVertexInputBinding(instanceMatNode, s);
|
||||
// store the association
|
||||
instance.mMaterials[group] = s;
|
||||
ReadMaterialVertexInputBinding(instanceMatNode, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1860,7 +1860,7 @@ aiString FBXConverter::GetTexturePath(const Texture *tex) {
|
|||
// We need to load all textures before referencing them, as FBX file format order may reference a texture before loading it
|
||||
// This may occur on this case too, it has to be studied
|
||||
path.data[0] = '*';
|
||||
path.length = 1 + ASSIMP_itoa10(path.data + 1, MAXLEN - 1, index);
|
||||
path.length = 1 + ASSIMP_itoa10(path.data + 1, AI_MAXLEN - 1, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2440,7 +2440,7 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTa
|
|||
|
||||
// setup texture reference string (copied from ColladaLoader::FindFilenameForEffectTexture)
|
||||
path.data[0] = '*';
|
||||
path.length = 1 + ASSIMP_itoa10(path.data + 1, MAXLEN - 1, index);
|
||||
path.length = 1 + ASSIMP_itoa10(path.data + 1, AI_MAXLEN - 1, index);
|
||||
}
|
||||
|
||||
out_mat->AddProperty(&path, (name + "|file").c_str(), aiTextureType_UNKNOWN, 0);
|
||||
|
@ -2806,7 +2806,7 @@ void FBXConverter::ProcessMorphAnimDatas(std::map<std::string, morphAnimData *>
|
|||
auto geoIt = std::find(model->GetGeometry().begin(), model->GetGeometry().end(), geo);
|
||||
auto geoIndex = static_cast<unsigned int>(std::distance(model->GetGeometry().begin(), geoIt));
|
||||
auto name = aiString(FixNodeName(model->Name() + "*"));
|
||||
name.length = 1 + ASSIMP_itoa10(name.data + name.length, MAXLEN - 1, geoIndex);
|
||||
name.length = 1 + ASSIMP_itoa10(name.data + name.length, AI_MAXLEN - 1, geoIndex);
|
||||
morphAnimData *animData;
|
||||
auto animIt = morphAnimDatas->find(name.C_Str());
|
||||
if (animIt == morphAnimDatas->end()) {
|
||||
|
|
|
@ -1051,7 +1051,7 @@ aiNode* get_node_for_mesh(unsigned int meshIndex, aiNode* node)
|
|||
aiMatrix4x4 get_world_transform(const aiNode* node, const aiScene* scene)
|
||||
{
|
||||
std::vector<const aiNode*> node_chain;
|
||||
while (node != scene->mRootNode) {
|
||||
while (node != scene->mRootNode && node != nullptr) {
|
||||
node_chain.push_back(node);
|
||||
node = node->mParent;
|
||||
}
|
||||
|
@ -1868,33 +1868,26 @@ void FBXExporter::WriteObjects ()
|
|||
// one sticky point is that the number of vertices may not match,
|
||||
// because assimp splits vertices by normal, uv, etc.
|
||||
|
||||
// functor for aiNode sorting
|
||||
struct SortNodeByName
|
||||
{
|
||||
bool operator()(const aiNode *lhs, const aiNode *rhs) const
|
||||
{
|
||||
return strcmp(lhs->mName.C_Str(), rhs->mName.C_Str()) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
// first we should mark the skeleton for each mesh.
|
||||
// the skeleton must include not only the aiBones,
|
||||
// but also all their parent nodes.
|
||||
// anything that affects the position of any bone node must be included.
|
||||
// Use SorNodeByName to make sure the exported result will be the same across all systems
|
||||
// Otherwise the aiNodes of the skeleton would be sorted based on the pointer address, which isn't consistent
|
||||
std::vector<std::set<const aiNode*, SortNodeByName>> skeleton_by_mesh(mScene->mNumMeshes);
|
||||
|
||||
// note that we want to preserve input order as much as possible here.
|
||||
// previously, sorting by name lead to consistent output across systems, but was not
|
||||
// suitable for downstream consumption by some applications.
|
||||
std::vector<std::vector<const aiNode*>> skeleton_by_mesh(mScene->mNumMeshes);
|
||||
// at the same time we can build a list of all the skeleton nodes,
|
||||
// which will be used later to mark them as type "limbNode".
|
||||
std::unordered_set<const aiNode*> limbnodes;
|
||||
|
||||
//actual bone nodes in fbx, without parenting-up
|
||||
std::unordered_set<std::string> setAllBoneNamesInScene;
|
||||
for(unsigned int m = 0; m < mScene->mNumMeshes; ++ m)
|
||||
{
|
||||
std::vector<std::string> allBoneNames;
|
||||
for(unsigned int m = 0; m < mScene->mNumMeshes; ++ m) {
|
||||
aiMesh* pMesh = mScene->mMeshes[m];
|
||||
for(unsigned int b = 0; b < pMesh->mNumBones; ++ b)
|
||||
setAllBoneNamesInScene.insert(pMesh->mBones[b]->mName.data);
|
||||
allBoneNames.push_back(pMesh->mBones[b]->mName.data);
|
||||
}
|
||||
aiMatrix4x4 mxTransIdentity;
|
||||
|
||||
|
@ -1902,7 +1895,7 @@ void FBXExporter::WriteObjects ()
|
|||
std::map<std::string,aiNode*> node_by_bone;
|
||||
for (size_t mi = 0; mi < mScene->mNumMeshes; ++mi) {
|
||||
const aiMesh* m = mScene->mMeshes[mi];
|
||||
std::set<const aiNode*, SortNodeByName> skeleton;
|
||||
std::vector<const aiNode*> skeleton;
|
||||
for (size_t bi =0; bi < m->mNumBones; ++bi) {
|
||||
const aiBone* b = m->mBones[bi];
|
||||
const std::string name(b->mName.C_Str());
|
||||
|
@ -1921,7 +1914,7 @@ void FBXExporter::WriteObjects ()
|
|||
node_by_bone[name] = n;
|
||||
limbnodes.insert(n);
|
||||
}
|
||||
skeleton.insert(n);
|
||||
skeleton.push_back(n);
|
||||
// mark all parent nodes as skeleton as well,
|
||||
// up until we find the root node,
|
||||
// or else the node containing the mesh,
|
||||
|
@ -1932,7 +1925,7 @@ void FBXExporter::WriteObjects ()
|
|||
parent = parent->mParent
|
||||
) {
|
||||
// if we've already done this node we can skip it all
|
||||
if (skeleton.count(parent)) {
|
||||
if (std::find(skeleton.begin(), skeleton.end(), parent) != skeleton.end()) {
|
||||
break;
|
||||
}
|
||||
// ignore fbx transform nodes as these will be collapsed later
|
||||
|
@ -1942,7 +1935,7 @@ void FBXExporter::WriteObjects ()
|
|||
continue;
|
||||
}
|
||||
//not a bone in scene && no effect in transform
|
||||
if(setAllBoneNamesInScene.find(node_name)==setAllBoneNamesInScene.end()
|
||||
if (std::find(allBoneNames.begin(), allBoneNames.end(), node_name) == allBoneNames.end()
|
||||
&& parent->mTransformation == mxTransIdentity) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2027,7 +2020,7 @@ void FBXExporter::WriteObjects ()
|
|||
aiMatrix4x4 mesh_xform = get_world_transform(mesh_node, mScene);
|
||||
|
||||
// now make a subdeformer for each bone in the skeleton
|
||||
const std::set<const aiNode*, SortNodeByName> skeleton= skeleton_by_mesh[mi];
|
||||
const auto & skeleton= skeleton_by_mesh[mi];
|
||||
for (const aiNode* bone_node : skeleton) {
|
||||
// if there's a bone for this node, find it
|
||||
const aiBone* b = nullptr;
|
||||
|
|
|
@ -644,10 +644,12 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, cons
|
|||
return;
|
||||
}
|
||||
|
||||
// materials are handled separately. First of all, they are assigned per-face
|
||||
// and not per polyvert. Secondly, ReferenceInformationType=IndexToDirect
|
||||
// has a slightly different meaning for materials.
|
||||
ParseVectorDataArray(materials_out,GetRequiredElement(source,"Materials"));
|
||||
if (source["Materials"]) {
|
||||
// materials are handled separately. First of all, they are assigned per-face
|
||||
// and not per polyvert. Secondly, ReferenceInformationType=IndexToDirect
|
||||
// has a slightly different meaning for materials.
|
||||
ParseVectorDataArray(materials_out, GetRequiredElement(source, "Materials"));
|
||||
}
|
||||
|
||||
if (MappingInformationType == "AllSame") {
|
||||
// easy - same material for all faces
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
const char* elementNameCStr = elementName.c_str();
|
||||
for (auto element = elements.begin(); element != elements.end(); ++element)
|
||||
{
|
||||
if (!ASSIMP_strincmp(element->first.c_str(), elementNameCStr, MAXLEN)) {
|
||||
if (!ASSIMP_strincmp(element->first.c_str(), elementNameCStr, AI_MAXLEN)) {
|
||||
return element->second;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ void IFCImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
std::unique_ptr<STEP::DB> db(STEP::ReadFileHeader(std::move(stream)));
|
||||
const STEP::HeaderInfo &head = static_cast<const STEP::DB &>(*db).GetHeader();
|
||||
|
||||
if (!head.fileSchema.size() || head.fileSchema.substr(0, 3) != "IFC") {
|
||||
if (!head.fileSchema.size() || head.fileSchema.substr(0, 4) != "IFC2") {
|
||||
ThrowException("Unrecognized file schema: " + head.fileSchema);
|
||||
}
|
||||
|
||||
|
@ -260,6 +260,8 @@ void IFCImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
ThrowException("missing IfcProject entity");
|
||||
}
|
||||
|
||||
|
||||
|
||||
ConversionData conv(*db, proj->To<Schema_2x3::IfcProject>(), pScene, settings);
|
||||
SetUnits(conv);
|
||||
SetCoordinateSpace(conv);
|
||||
|
@ -352,6 +354,11 @@ void ConvertUnit(const ::Assimp::STEP::EXPRESS::DataType &dt, ConversionData &co
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void SetUnits(ConversionData &conv) {
|
||||
if (conv.proj.UnitsInContext == nullptr) {
|
||||
IFCImporter::LogError("Skipping conversion data, nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
// see if we can determine the coordinate space used to express.
|
||||
for (size_t i = 0; i < conv.proj.UnitsInContext->Units.size(); ++i) {
|
||||
ConvertUnit(*conv.proj.UnitsInContext->Units[i], conv);
|
||||
|
|
|
@ -168,7 +168,7 @@ void IRRImporter::BuildSkybox(std::vector<aiMesh *> &meshes, std::vector<aiMater
|
|||
aiMaterial *out = (aiMaterial *)(*(materials.end() - (6 - i)));
|
||||
|
||||
aiString s;
|
||||
s.length = ::ai_snprintf(s.data, MAXLEN, "SkyboxSide_%u", i);
|
||||
s.length = ::ai_snprintf(s.data, AI_MAXLEN, "SkyboxSide_%u", i);
|
||||
out->AddProperty(&s, AI_MATKEY_NAME);
|
||||
|
||||
int shading = aiShadingMode_NoShading;
|
||||
|
@ -316,7 +316,7 @@ void IRRImporter::ComputeAnimations(Node *root, aiNode *real, std::vector<aiNode
|
|||
if (cur != total - 1) {
|
||||
// Build a new name - a prefix instead of a suffix because it is
|
||||
// easier to check against
|
||||
anim->mNodeName.length = ::ai_snprintf(anim->mNodeName.data, MAXLEN,
|
||||
anim->mNodeName.length = ::ai_snprintf(anim->mNodeName.data, AI_MAXLEN,
|
||||
"$INST_DUMMY_%i_%s", total - 1,
|
||||
(root->name.length() ? root->name.c_str() : ""));
|
||||
|
||||
|
|
|
@ -305,14 +305,14 @@ void LWSImporter::SetupNodeName(aiNode *nd, LWS::NodeDesc &src) {
|
|||
}
|
||||
std::string::size_type t = src.path.substr(s).find_last_of('.');
|
||||
|
||||
nd->mName.length = ::ai_snprintf(nd->mName.data, MAXLEN, "%s_(%08X)", src.path.substr(s).substr(0, t).c_str(), combined);
|
||||
if (nd->mName.length > MAXLEN) {
|
||||
nd->mName.length = MAXLEN;
|
||||
nd->mName.length = ::ai_snprintf(nd->mName.data, AI_MAXLEN, "%s_(%08X)", src.path.substr(s).substr(0, t).c_str(), combined);
|
||||
if (nd->mName.length > AI_MAXLEN) {
|
||||
nd->mName.length = AI_MAXLEN;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
nd->mName.length = ::ai_snprintf(nd->mName.data, MAXLEN, "%s_(%08X)", src.name, combined);
|
||||
nd->mName.length = ::ai_snprintf(nd->mName.data, AI_MAXLEN, "%s_(%08X)", src.name, combined);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -707,7 +707,7 @@ void MD5Importer::LoadMD5CameraFile() {
|
|||
for (std::vector<unsigned int>::const_iterator it = cuts.begin(); it != cuts.end() - 1; ++it) {
|
||||
|
||||
aiAnimation *anim = *tmp++ = new aiAnimation();
|
||||
anim->mName.length = ::ai_snprintf(anim->mName.data, MAXLEN, "anim%u_from_%u_to_%u", (unsigned int)(it - cuts.begin()), (*it), *(it + 1));
|
||||
anim->mName.length = ::ai_snprintf(anim->mName.data, AI_MAXLEN, "anim%u_from_%u_to_%u", (unsigned int)(it - cuts.begin()), (*it), *(it + 1));
|
||||
|
||||
anim->mTicksPerSecond = cameraParser.fFrameRate;
|
||||
anim->mChannels = new aiNodeAnim *[anim->mNumChannels = 1];
|
||||
|
|
|
@ -234,8 +234,12 @@ inline void AI_MD5_READ_TRIPLE(aiVector3D &vec, const char **sz, const char *buf
|
|||
AI_MD5_SKIP_SPACES(sz, bufferEnd, linenumber);
|
||||
if ('(' != **sz) {
|
||||
MD5Parser::ReportWarning("Unexpected token: ( was expected", linenumber);
|
||||
if (*sz == bufferEnd)
|
||||
return;
|
||||
++*sz;
|
||||
}
|
||||
if (*sz == bufferEnd)
|
||||
return;
|
||||
++*sz;
|
||||
AI_MD5_SKIP_SPACES(sz, bufferEnd, linenumber);
|
||||
*sz = fast_atoreal_move<float>(*sz, (float &)vec.x);
|
||||
|
@ -247,6 +251,8 @@ inline void AI_MD5_READ_TRIPLE(aiVector3D &vec, const char **sz, const char *buf
|
|||
if (')' != **sz) {
|
||||
MD5Parser::ReportWarning("Unexpected token: ) was expected", linenumber);
|
||||
}
|
||||
if (*sz == bufferEnd)
|
||||
return;
|
||||
++*sz;
|
||||
}
|
||||
|
||||
|
|
|
@ -962,7 +962,7 @@ void MDLImporter::CalcAbsBoneMatrices_3DGS_MDL7(MDL::IntBone_MDL7 **apcOutBones)
|
|||
|
||||
if (AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE == pcHeader->bone_stc_size) {
|
||||
// no real name for our poor bone is specified :-(
|
||||
pcOutBone->mName.length = ai_snprintf(pcOutBone->mName.data, MAXLEN,
|
||||
pcOutBone->mName.length = ai_snprintf(pcOutBone->mName.data, AI_MAXLEN,
|
||||
"UnnamedBone_%i", iBone);
|
||||
} else {
|
||||
// Make sure we won't run over the buffer's end if there is no
|
||||
|
@ -1567,7 +1567,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7() {
|
|||
} else {
|
||||
pcNode->mName.length = (ai_uint32)::strlen(szBuffer);
|
||||
}
|
||||
::strncpy(pcNode->mName.data, szBuffer, MAXLEN - 1);
|
||||
::strncpy(pcNode->mName.data, szBuffer, AI_MAXLEN - 1);
|
||||
++p;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -494,7 +494,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
|||
|
||||
aiString szFile;
|
||||
const size_t iLen = strlen((const char *)szCurrent);
|
||||
size_t iLen2 = iLen > (MAXLEN - 1) ? (MAXLEN - 1) : iLen;
|
||||
size_t iLen2 = iLen > (AI_MAXLEN - 1) ? (AI_MAXLEN - 1) : iLen;
|
||||
memcpy(szFile.data, (const char *)szCurrent, iLen2);
|
||||
szFile.data[iLen2] = '\0';
|
||||
szFile.length = static_cast<ai_uint32>(iLen2);
|
||||
|
@ -610,7 +610,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
|||
if (is_not_qnan(clrTexture.r)) {
|
||||
clrTemp.r *= clrTexture.a;
|
||||
}
|
||||
pcMatOut->AddProperty<ai_real>(&clrTemp.r, 1, AI_MATKEY_OPACITY);
|
||||
pcMatOut->AddProperty<float>(&clrTemp.r, 1, AI_MATKEY_OPACITY);
|
||||
|
||||
// read phong power
|
||||
int iShadingMode = (int)aiShadingMode_Gouraud;
|
||||
|
@ -730,9 +730,12 @@ void MDLImporter::SkipSkinLump_3DGS_MDL7(
|
|||
// if an ASCII effect description (HLSL?) is contained in the file,
|
||||
// we can simply ignore it ...
|
||||
if (iType & AI_MDL7_SKINTYPE_MATERIAL_ASCDEF) {
|
||||
int32_t iMe = *((int32_t *)szCurrent);
|
||||
VALIDATE_FILE_SIZE(szCurrent + sizeof(int32_t));
|
||||
int32_t iMe = 0;
|
||||
::memcpy(&iMe, szCurrent, sizeof(int32_t));
|
||||
AI_SWAP4(iMe);
|
||||
szCurrent += sizeof(char) * iMe + sizeof(int32_t);
|
||||
VALIDATE_FILE_SIZE(szCurrent);
|
||||
}
|
||||
*szCurrentOut = szCurrent;
|
||||
}
|
||||
|
|
|
@ -316,7 +316,7 @@ void OFFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials];
|
||||
aiMaterial *pcMat = new aiMaterial();
|
||||
|
||||
aiColor4D clr(ai_real(0.6), ai_real(0.6), ai_real(0.6), ai_real(1.0));
|
||||
aiColor4D clr(0.6f, 0.6f, 0.6f, 1.0f);
|
||||
pcMat->AddProperty(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
|
||||
pScene->mMaterials[0] = pcMat;
|
||||
|
||||
|
|
|
@ -199,12 +199,12 @@ struct Material {
|
|||
|
||||
//! Constructor
|
||||
Material() :
|
||||
diffuse(ai_real(0.6), ai_real(0.6), ai_real(0.6)),
|
||||
diffuse(0.6f, 0.6f, 0.6f),
|
||||
alpha(ai_real(1.0)),
|
||||
shineness(ai_real(0.0)),
|
||||
illumination_model(1),
|
||||
ior(ai_real(1.0)),
|
||||
transparent(ai_real(1.0), ai_real(1.0), ai_real(1.0)),
|
||||
transparent(1.0f, 1.0, 1.0),
|
||||
roughness(),
|
||||
metallic(),
|
||||
sheen(),
|
||||
|
|
|
@ -193,7 +193,7 @@ void ObjFileImporter::CreateDataFromImport(const ObjFile::Model *pModel, aiScene
|
|||
pScene->mRootNode->mChildren = new aiNode *[childCount];
|
||||
|
||||
// Create nodes for the whole scene
|
||||
std::vector<aiMesh *> MeshArray;
|
||||
std::vector<std::unique_ptr<aiMesh>> MeshArray;
|
||||
MeshArray.reserve(meshCount);
|
||||
for (size_t index = 0; index < pModel->mObjects.size(); ++index) {
|
||||
createNodes(pModel, pModel->mObjects[index], pScene->mRootNode, pScene, MeshArray);
|
||||
|
@ -205,7 +205,7 @@ void ObjFileImporter::CreateDataFromImport(const ObjFile::Model *pModel, aiScene
|
|||
if (pScene->mNumMeshes > 0) {
|
||||
pScene->mMeshes = new aiMesh *[MeshArray.size()];
|
||||
for (size_t index = 0; index < MeshArray.size(); ++index) {
|
||||
pScene->mMeshes[index] = MeshArray[index];
|
||||
pScene->mMeshes[index] = MeshArray[index].release();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ void ObjFileImporter::CreateDataFromImport(const ObjFile::Model *pModel, aiScene
|
|||
// Creates all nodes of the model
|
||||
aiNode *ObjFileImporter::createNodes(const ObjFile::Model *pModel, const ObjFile::Object *pObject,
|
||||
aiNode *pParent, aiScene *pScene,
|
||||
std::vector<aiMesh *> &MeshArray) {
|
||||
std::vector<std::unique_ptr<aiMesh>> &MeshArray) {
|
||||
ai_assert(nullptr != pModel);
|
||||
if (nullptr == pObject) {
|
||||
return nullptr;
|
||||
|
@ -275,12 +275,10 @@ aiNode *ObjFileImporter::createNodes(const ObjFile::Model *pModel, const ObjFile
|
|||
|
||||
for (size_t i = 0; i < pObject->m_Meshes.size(); ++i) {
|
||||
unsigned int meshId = pObject->m_Meshes[i];
|
||||
aiMesh *pMesh = createTopology(pModel, pObject, meshId);
|
||||
std::unique_ptr<aiMesh> pMesh = createTopology(pModel, pObject, meshId);
|
||||
if (pMesh != nullptr) {
|
||||
if (pMesh->mNumFaces > 0) {
|
||||
MeshArray.push_back(pMesh);
|
||||
} else {
|
||||
delete pMesh;
|
||||
MeshArray.push_back(std::move(pMesh));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -312,7 +310,7 @@ aiNode *ObjFileImporter::createNodes(const ObjFile::Model *pModel, const ObjFile
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Create topology data
|
||||
aiMesh *ObjFileImporter::createTopology(const ObjFile::Model *pModel, const ObjFile::Object *pData, unsigned int meshIndex) {
|
||||
std::unique_ptr<aiMesh> ObjFileImporter::createTopology(const ObjFile::Model *pModel, const ObjFile::Object *pData, unsigned int meshIndex) {
|
||||
// Checking preconditions
|
||||
ai_assert(nullptr != pModel);
|
||||
|
||||
|
@ -394,7 +392,7 @@ aiMesh *ObjFileImporter::createTopology(const ObjFile::Model *pModel, const ObjF
|
|||
// Create mesh vertices
|
||||
createVertexArray(pModel, pData, meshIndex, pMesh.get(), uiIdxCount);
|
||||
|
||||
return pMesh.release();
|
||||
return pMesh;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/material.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
struct aiMesh;
|
||||
|
@ -84,10 +85,10 @@ protected:
|
|||
|
||||
//! \brief Creates all nodes stored in imported content.
|
||||
aiNode *createNodes(const ObjFile::Model *pModel, const ObjFile::Object *pData,
|
||||
aiNode *pParent, aiScene *pScene, std::vector<aiMesh *> &MeshArray);
|
||||
aiNode *pParent, aiScene *pScene, std::vector<std::unique_ptr<aiMesh>> &MeshArray);
|
||||
|
||||
//! \brief Creates topology data like faces and meshes for the geometry.
|
||||
aiMesh *createTopology(const ObjFile::Model *pModel, const ObjFile::Object *pData,
|
||||
std::unique_ptr<aiMesh> createTopology(const ObjFile::Model *pModel, const ObjFile::Object *pData,
|
||||
unsigned int uiMeshIndex);
|
||||
|
||||
//! \brief Creates vertices from model.
|
||||
|
|
|
@ -343,7 +343,7 @@ void ObjFileMtlImporter::createMaterial() {
|
|||
}
|
||||
}
|
||||
|
||||
name = trim_whitespaces(name);
|
||||
name = ai_trim(name);
|
||||
|
||||
std::map<std::string, ObjFile::Material *>::iterator it = m_pModel->mMaterialMap.find(name);
|
||||
if (m_pModel->mMaterialMap.end() == it) {
|
||||
|
|
|
@ -577,7 +577,7 @@ void ObjFileParser::getMaterialDesc() {
|
|||
|
||||
// Get name
|
||||
std::string strName(pStart, &(*m_DataIt));
|
||||
strName = trim_whitespaces(strName);
|
||||
strName = ai_trim(strName);
|
||||
if (strName.empty()) {
|
||||
skip = true;
|
||||
}
|
||||
|
|
|
@ -247,22 +247,6 @@ inline char_t getFloat(char_t it, char_t end, ai_real &value) {
|
|||
return it;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Will remove white-spaces for a string.
|
||||
* @param[in] str The string to clean
|
||||
* @return The trimmed string.
|
||||
*/
|
||||
template <class string_type>
|
||||
inline string_type trim_whitespaces(string_type str) {
|
||||
while (!str.empty() && IsSpace(str[0])) {
|
||||
str.erase(0);
|
||||
}
|
||||
while (!str.empty() && IsSpace(str[str.length() - 1])) {
|
||||
str.erase(str.length() - 1);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks for a line-end.
|
||||
* @param[in] it Current iterator in string.
|
||||
|
|
|
@ -346,10 +346,22 @@ void PlyExporter::WriteMeshVertsBinary(const aiMesh* m, unsigned int components)
|
|||
|
||||
for (unsigned int n = PLY_EXPORT_HAS_COLORS, c = 0; (components & n) && c != AI_MAX_NUMBER_OF_COLOR_SETS; n <<= 1, ++c) {
|
||||
if (m->HasVertexColors(c)) {
|
||||
mOutput.write(reinterpret_cast<const char*>(&m->mColors[c][i].r), 16);
|
||||
unsigned char rgba[4] = {
|
||||
static_cast<unsigned char>(m->mColors[c][i].r * 255),
|
||||
static_cast<unsigned char>(m->mColors[c][i].g * 255),
|
||||
static_cast<unsigned char>(m->mColors[c][i].b * 255),
|
||||
static_cast<unsigned char>(m->mColors[c][i].a * 255)
|
||||
};
|
||||
mOutput.write(reinterpret_cast<const char*>(&rgba), 4);
|
||||
}
|
||||
else {
|
||||
mOutput.write(reinterpret_cast<const char*>(&defaultColor.r), 16);
|
||||
unsigned char rgba[4] = {
|
||||
static_cast<unsigned char>(defaultColor.r * 255),
|
||||
static_cast<unsigned char>(defaultColor.g * 255),
|
||||
static_cast<unsigned char>(defaultColor.b * 255),
|
||||
static_cast<unsigned char>(defaultColor.a * 255)
|
||||
};
|
||||
mOutput.write(reinterpret_cast<const char*>(&rgba), 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -564,6 +564,10 @@ void PLYImporter::LoadFace(const PLY::Element *pcElement, const PLY::ElementInst
|
|||
if (mGeneratedMesh->mFaces == nullptr) {
|
||||
mGeneratedMesh->mNumFaces = pcElement->NumOccur;
|
||||
mGeneratedMesh->mFaces = new aiFace[mGeneratedMesh->mNumFaces];
|
||||
} else {
|
||||
if (mGeneratedMesh->mNumFaces < pcElement->NumOccur) {
|
||||
throw DeadlyImportError("Invalid .ply file: Too many faces");
|
||||
}
|
||||
}
|
||||
|
||||
if (!bIsTriStrip) {
|
||||
|
|
|
@ -588,7 +588,7 @@ bool Q3BSPFileImporter::importTextureFromArchive(const Q3BSP::Q3BSPModel *model,
|
|||
|
||||
aiString name;
|
||||
name.data[0] = '*';
|
||||
name.length = 1 + ASSIMP_itoa10(name.data + 1, static_cast<unsigned int>(MAXLEN - 1), static_cast<int32_t>(mTextures.size()));
|
||||
name.length = 1 + ASSIMP_itoa10(name.data + 1, static_cast<unsigned int>(AI_MAXLEN - 1), static_cast<int32_t>(mTextures.size()));
|
||||
|
||||
archive->Close(pTextureStream);
|
||||
|
||||
|
@ -641,7 +641,7 @@ bool Q3BSPFileImporter::importLightmap(const Q3BSP::Q3BSPModel *pModel, aiScene
|
|||
|
||||
aiString name;
|
||||
name.data[0] = '*';
|
||||
name.length = 1 + ASSIMP_itoa10(name.data + 1, static_cast<unsigned int>(MAXLEN - 1), static_cast<int32_t>(mTextures.size()));
|
||||
name.length = 1 + ASSIMP_itoa10(name.data + 1, static_cast<unsigned int>(AI_MAXLEN - 1), static_cast<int32_t>(mTextures.size()));
|
||||
|
||||
pMatHelper->AddProperty(&name, AI_MATKEY_TEXTURE_LIGHTMAP(1));
|
||||
mTextures.push_back(pTexture);
|
||||
|
|
|
@ -250,7 +250,7 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
|
|||
c = stream.GetI1();
|
||||
while (c) {
|
||||
mat.name.data[mat.name.length++] = c;
|
||||
if (mat.name.length == MAXLEN) {
|
||||
if (mat.name.length == AI_MAXLEN) {
|
||||
ASSIMP_LOG_ERROR("String ouverflow detected, skipped material name parsing.");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -589,12 +589,12 @@ void SMDImporter::CreateOutputMaterials() {
|
|||
pScene->mMaterials[iMat] = pcMat;
|
||||
|
||||
aiString szName;
|
||||
szName.length = static_cast<ai_uint32>(ai_snprintf(szName.data,MAXLEN,"Texture_%u",iMat));
|
||||
szName.length = static_cast<ai_uint32>(ai_snprintf(szName.data, AI_MAXLEN, "Texture_%u", iMat));
|
||||
pcMat->AddProperty(&szName,AI_MATKEY_NAME);
|
||||
|
||||
if (aszTextures[iMat].length())
|
||||
{
|
||||
::strncpy(szName.data, aszTextures[iMat].c_str(),MAXLEN-1);
|
||||
::strncpy(szName.data, aszTextures[iMat].c_str(), AI_MAXLEN - 1);
|
||||
szName.length = static_cast<ai_uint32>( aszTextures[iMat].length() );
|
||||
pcMat->AddProperty(&szName,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ void STLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
mBuffer = &buffer2[0];
|
||||
|
||||
// the default vertex color is light gray.
|
||||
mClrColorDefault.r = mClrColorDefault.g = mClrColorDefault.b = mClrColorDefault.a = (ai_real)0.6;
|
||||
mClrColorDefault.r = mClrColorDefault.g = mClrColorDefault.b = mClrColorDefault.a = 0.6f;
|
||||
|
||||
// allocate a single node
|
||||
mScene->mRootNode = new aiNode();
|
||||
|
@ -209,7 +209,7 @@ void STLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
}
|
||||
pcMat->AddProperty(&clrDiffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
|
||||
pcMat->AddProperty(&clrDiffuse, 1, AI_MATKEY_COLOR_SPECULAR);
|
||||
clrDiffuse = aiColor4D(ai_real(0.05), ai_real(0.05), ai_real(0.05), ai_real(1.0));
|
||||
clrDiffuse = aiColor4D(0.05f, 0.05f, 0.05f, 1.0f);
|
||||
pcMat->AddProperty(&clrDiffuse, 1, AI_MATKEY_COLOR_AMBIENT);
|
||||
|
||||
mScene->mNumMaterials = 1;
|
||||
|
@ -257,7 +257,7 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
|
|||
size_t temp = (size_t)(sz - szMe);
|
||||
// setup the name of the node
|
||||
if (temp) {
|
||||
if (temp >= MAXLEN) {
|
||||
if (temp >= AI_MAXLEN) {
|
||||
throw DeadlyImportError("STL: Node name too long");
|
||||
}
|
||||
std::string name(szMe, temp);
|
||||
|
|
|
@ -82,8 +82,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
// this is intended as stress test - by default, entities are evaluated
|
||||
// lazily and therefore not unless needed.
|
||||
|
||||
//#define ASSIMP_IFC_TEST
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// ********************************************************************************
|
||||
|
@ -531,6 +529,7 @@ public:
|
|||
|
||||
template <typename T>
|
||||
const T &To() const {
|
||||
|
||||
return dynamic_cast<const T &>(**this);
|
||||
}
|
||||
|
||||
|
@ -581,12 +580,12 @@ private:
|
|||
};
|
||||
|
||||
template <typename T>
|
||||
inline bool operator==(const std::shared_ptr<LazyObject> &lo, T whatever) {
|
||||
inline bool operator == (const std::shared_ptr<LazyObject> &lo, T whatever) {
|
||||
return *lo == whatever; // XXX use std::forward if we have 0x
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool operator==(const std::pair<uint64_t, std::shared_ptr<LazyObject>> &lo, T whatever) {
|
||||
inline bool operator == (const std::pair<uint64_t, std::shared_ptr<LazyObject>> &lo, T whatever) {
|
||||
return *(lo.second) == whatever; // XXX use std::forward if we have 0x
|
||||
}
|
||||
|
||||
|
@ -599,18 +598,30 @@ struct Lazy {
|
|||
Lazy(const LazyObject *obj = nullptr) : obj(obj) {}
|
||||
|
||||
operator const T *() const {
|
||||
if (obj == nullptr) {
|
||||
throw TypeError("Obj type is nullptr.");
|
||||
}
|
||||
return obj->ToPtr<T>();
|
||||
}
|
||||
|
||||
operator const T &() const {
|
||||
if (obj == nullptr) {
|
||||
throw TypeError("Obj type is nullptr.");
|
||||
}
|
||||
return obj->To<T>();
|
||||
}
|
||||
|
||||
const T &operator*() const {
|
||||
if (obj == nullptr) {
|
||||
throw TypeError("Obj type is nullptr.");
|
||||
}
|
||||
return obj->To<T>();
|
||||
}
|
||||
|
||||
const T *operator->() const {
|
||||
if (obj == nullptr) {
|
||||
throw TypeError("Obj type is nullptr.");
|
||||
}
|
||||
return &obj->To<T>();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -37,11 +36,9 @@ 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.
|
||||
|
||||
@author: Richard Steffen, 2015
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO_STEP_EXPORTER
|
||||
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file USDLoader.cpp
|
||||
* @brief Implementation of the USD importer class
|
||||
*/
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_USD_IMPORTER
|
||||
#include <memory>
|
||||
|
||||
// internal headers
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <assimp/anim.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/scene.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/StreamReader.h>
|
||||
|
||||
#include "USDLoader.h"
|
||||
#include "USDLoaderUtil.h"
|
||||
#include "USDPreprocessor.h"
|
||||
|
||||
static constexpr aiImporterDesc desc = {
|
||||
"USD Object Importer",
|
||||
"",
|
||||
"",
|
||||
"https://en.wikipedia.org/wiki/Universal_Scene_Description/",
|
||||
aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportBinaryFlavour,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"usd usda usdc usdz"
|
||||
};
|
||||
|
||||
namespace Assimp {
|
||||
using namespace std;
|
||||
|
||||
// Constructor to be privately used by Importer
|
||||
USDImporter::USDImporter() :
|
||||
impl(USDImporterImplTinyusdz()) {
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
bool USDImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool) const {
|
||||
// Based on token
|
||||
static const uint32_t usdcTokens[] = { AI_MAKE_MAGIC("PXR-USDC") };
|
||||
bool canRead = CheckMagicToken(pIOHandler, pFile, usdcTokens, AI_COUNT_OF(usdcTokens));
|
||||
if (canRead) {
|
||||
return canRead;
|
||||
}
|
||||
|
||||
// Based on extension
|
||||
// TODO: confirm OK to replace this w/SimpleExtensionCheck() below
|
||||
canRead = isUsd(pFile) || isUsda(pFile) || isUsdc(pFile) || isUsdz(pFile);
|
||||
if (canRead) {
|
||||
return canRead;
|
||||
}
|
||||
canRead = SimpleExtensionCheck(pFile, "usd", "usda", "usdc", "usdz");
|
||||
return canRead;
|
||||
}
|
||||
|
||||
const aiImporterDesc *USDImporter::GetInfo() const {
|
||||
return &desc;
|
||||
}
|
||||
|
||||
void USDImporter::InternReadFile(
|
||||
const std::string &pFile,
|
||||
aiScene *pScene,
|
||||
IOSystem *pIOHandler) {
|
||||
impl.InternReadFile(
|
||||
pFile,
|
||||
pScene,
|
||||
pIOHandler);
|
||||
}
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_USD_IMPORTER
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file USDLoader.h
|
||||
* @brief Declaration of the USD importer class.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef AI_USDLOADER_H_INCLUDED
|
||||
#define AI_USDLOADER_H_INCLUDED
|
||||
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/types.h>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
#include "USDLoaderImplTinyusdz.h"
|
||||
|
||||
namespace Assimp {
|
||||
class USDImporter : public BaseImporter {
|
||||
public:
|
||||
USDImporter();
|
||||
~USDImporter() override = default;
|
||||
|
||||
/// \brief Returns whether the class can handle the format of the given file.
|
||||
/// \remark See BaseImporter::CanRead() for details.
|
||||
bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const override;
|
||||
|
||||
protected:
|
||||
//! \brief Appends the supported extension.
|
||||
const aiImporterDesc *GetInfo() const override;
|
||||
|
||||
void InternReadFile(
|
||||
const std::string &pFile,
|
||||
aiScene *pScene,
|
||||
IOSystem *pIOHandler) override;
|
||||
private:
|
||||
USDImporterImplTinyusdz impl;
|
||||
};
|
||||
|
||||
} // namespace Assimp
|
||||
#endif // AI_USDLOADER_H_INCLUDED
|
|
@ -0,0 +1,749 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file USDLoader.cpp
|
||||
* @brief Implementation of the USD importer class
|
||||
*/
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_USD_IMPORTER
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
// internal headers
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <assimp/anim.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/StringUtils.h>
|
||||
#include <assimp/StreamReader.h>
|
||||
|
||||
#include "io-util.hh" // namespace tinyusdz::io
|
||||
#include "tydra/scene-access.hh"
|
||||
#include "tydra/shader-network.hh"
|
||||
#include "USDLoaderImplTinyusdzHelper.h"
|
||||
#include "USDLoaderImplTinyusdz.h"
|
||||
#include "USDLoaderUtil.h"
|
||||
#include "USDPreprocessor.h"
|
||||
|
||||
#include "../../../contrib/tinyusdz/assimp_tinyusdz_logging.inc"
|
||||
|
||||
namespace {
|
||||
static constexpr char Tag[] = "tinyusdz loader";
|
||||
}
|
||||
|
||||
namespace Assimp {
|
||||
using namespace std;
|
||||
|
||||
void USDImporterImplTinyusdz::InternReadFile(
|
||||
const std::string &pFile,
|
||||
aiScene *pScene,
|
||||
IOSystem *) {
|
||||
// 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;
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): model" << nameWExt;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
|
||||
bool ret{ false };
|
||||
tinyusdz::USDLoadOptions options;
|
||||
tinyusdz::Stage stage;
|
||||
std::string warn, err;
|
||||
bool is_usdz{ false };
|
||||
if (isUsdc(pFile)) {
|
||||
ret = LoadUSDCFromFile(pFile, &stage, &warn, &err, options);
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): LoadUSDCFromFile() result: " << ret;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
} else if (isUsda(pFile)) {
|
||||
ret = LoadUSDAFromFile(pFile, &stage, &warn, &err, options);
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): LoadUSDAFromFile() result: " << ret;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
} else if (isUsdz(pFile)) {
|
||||
ret = LoadUSDZFromFile(pFile, &stage, &warn, &err, options);
|
||||
is_usdz = true;
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): LoadUSDZFromFile() result: " << ret;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
} else if (isUsd(pFile)) {
|
||||
ret = LoadUSDFromFile(pFile, &stage, &warn, &err, options);
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): LoadUSDFromFile() result: " << ret;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
}
|
||||
if (warn.empty() && err.empty()) {
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): load free of warnings/errors";
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
} else {
|
||||
if (!warn.empty()) {
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): WARNING reported: " << warn;
|
||||
TINYUSDZLOGW(TAG, "%s", ss.str().c_str());
|
||||
}
|
||||
if (!err.empty()) {
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): ERROR reported: " << err;
|
||||
TINYUSDZLOGE(TAG, "%s", ss.str().c_str());
|
||||
}
|
||||
}
|
||||
if (!ret) {
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): ERROR: load failed! ret: " << ret;
|
||||
TINYUSDZLOGE(TAG, "%s", ss.str().c_str());
|
||||
return;
|
||||
}
|
||||
tinyusdz::tydra::RenderScene render_scene;
|
||||
tinyusdz::tydra::RenderSceneConverter converter;
|
||||
tinyusdz::tydra::RenderSceneConverterEnv env(stage);
|
||||
std::string usd_basedir = tinyusdz::io::GetBaseDir(pFile);
|
||||
env.set_search_paths({ usd_basedir }); // {} needed to convert to vector of char
|
||||
|
||||
// NOTE: Pointer address of usdz_asset must be valid until the call of RenderSceneConverter::ConvertToRenderScene.
|
||||
tinyusdz::USDZAsset usdz_asset;
|
||||
if (is_usdz) {
|
||||
if (!tinyusdz::ReadUSDZAssetInfoFromFile(pFile, &usdz_asset, &warn, &err)) {
|
||||
if (!warn.empty()) {
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): ReadUSDZAssetInfoFromFile: WARNING reported: " << warn;
|
||||
TINYUSDZLOGW(TAG, "%s", ss.str().c_str());
|
||||
}
|
||||
if (!err.empty()) {
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): ReadUSDZAssetInfoFromFile: ERROR reported: " << err;
|
||||
TINYUSDZLOGE(TAG, "%s", ss.str().c_str());
|
||||
}
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): ReadUSDZAssetInfoFromFile: ERROR!";
|
||||
TINYUSDZLOGE(TAG, "%s", ss.str().c_str());
|
||||
} else {
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): ReadUSDZAssetInfoFromFile: OK";
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
}
|
||||
|
||||
tinyusdz::AssetResolutionResolver arr;
|
||||
if (!tinyusdz::SetupUSDZAssetResolution(arr, &usdz_asset)) {
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): SetupUSDZAssetResolution: ERROR: load failed! ret: " << ret;
|
||||
TINYUSDZLOGE(TAG, "%s", ss.str().c_str());
|
||||
} else {
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): SetupUSDZAssetResolution: OK";
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
env.asset_resolver = arr;
|
||||
}
|
||||
}
|
||||
|
||||
ret = converter.ConvertToRenderScene(env, &render_scene);
|
||||
if (!ret) {
|
||||
ss.str("");
|
||||
ss << "InternReadFile(): ConvertToRenderScene() failed!";
|
||||
TINYUSDZLOGE(TAG, "%s", ss.str().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
// sanityCheckNodesRecursive(pScene->mRootNode);
|
||||
meshes(render_scene, pScene, nameWExt);
|
||||
materials(render_scene, pScene, nameWExt);
|
||||
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, meshNodes, nameWExt);
|
||||
|
||||
setupBlendShapes(render_scene, pScene, nameWExt);
|
||||
}
|
||||
|
||||
void USDImporterImplTinyusdz::meshes(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
const std::string &nameWExt) {
|
||||
stringstream ss;
|
||||
pScene->mNumMeshes = static_cast<unsigned int>(render_scene.meshes.size());
|
||||
pScene->mMeshes = new aiMesh *[pScene->mNumMeshes]();
|
||||
ss.str("");
|
||||
ss << "meshes(): pScene->mNumMeshes: " << pScene->mNumMeshes;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
|
||||
// Export meshes
|
||||
for (size_t meshIdx = 0; meshIdx < pScene->mNumMeshes; meshIdx++) {
|
||||
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;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
ss.str("");
|
||||
ss << " skel_id: " << render_scene.meshes[meshIdx].skel_id;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
if (render_scene.meshes[meshIdx].material_id > -1) {
|
||||
pScene->mMeshes[meshIdx]->mMaterialIndex = render_scene.meshes[meshIdx].material_id;
|
||||
}
|
||||
verticesForMesh(render_scene, pScene, meshIdx, nameWExt);
|
||||
facesForMesh(render_scene, pScene, meshIdx, nameWExt);
|
||||
// Some models infer normals from faces, but others need them e.g.
|
||||
// - apple "toy car" canopy normals will be wrong
|
||||
// - human "untitled" model (tinyusdz issue #115) will be "splotchy"
|
||||
normalsForMesh(render_scene, pScene, meshIdx, nameWExt);
|
||||
materialsForMesh(render_scene, pScene, meshIdx, nameWExt);
|
||||
uvsForMesh(render_scene, pScene, meshIdx, nameWExt);
|
||||
}
|
||||
}
|
||||
|
||||
void USDImporterImplTinyusdz::verticesForMesh(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
size_t meshIdx,
|
||||
const std::string &nameWExt) {
|
||||
UNUSED(nameWExt);
|
||||
pScene->mMeshes[meshIdx]->mNumVertices = static_cast<unsigned int>(render_scene.meshes[meshIdx].points.size());
|
||||
pScene->mMeshes[meshIdx]->mVertices = new aiVector3D[pScene->mMeshes[meshIdx]->mNumVertices];
|
||||
for (size_t j = 0; j < pScene->mMeshes[meshIdx]->mNumVertices; ++j) {
|
||||
pScene->mMeshes[meshIdx]->mVertices[j].x = render_scene.meshes[meshIdx].points[j][0];
|
||||
pScene->mMeshes[meshIdx]->mVertices[j].y = render_scene.meshes[meshIdx].points[j][1];
|
||||
pScene->mMeshes[meshIdx]->mVertices[j].z = render_scene.meshes[meshIdx].points[j][2];
|
||||
}
|
||||
}
|
||||
|
||||
void USDImporterImplTinyusdz::facesForMesh(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
size_t meshIdx,
|
||||
const std::string &nameWExt) {
|
||||
UNUSED(nameWExt);
|
||||
pScene->mMeshes[meshIdx]->mNumFaces = static_cast<unsigned int>(render_scene.meshes[meshIdx].faceVertexCounts().size());
|
||||
pScene->mMeshes[meshIdx]->mFaces = new aiFace[pScene->mMeshes[meshIdx]->mNumFaces]();
|
||||
size_t faceVertIdxOffset = 0;
|
||||
for (size_t faceIdx = 0; faceIdx < pScene->mMeshes[meshIdx]->mNumFaces; ++faceIdx) {
|
||||
pScene->mMeshes[meshIdx]->mFaces[faceIdx].mNumIndices = render_scene.meshes[meshIdx].faceVertexCounts()[faceIdx];
|
||||
pScene->mMeshes[meshIdx]->mFaces[faceIdx].mIndices = new unsigned int[pScene->mMeshes[meshIdx]->mFaces[faceIdx].mNumIndices];
|
||||
for (size_t j = 0; j < pScene->mMeshes[meshIdx]->mFaces[faceIdx].mNumIndices; ++j) {
|
||||
pScene->mMeshes[meshIdx]->mFaces[faceIdx].mIndices[j] =
|
||||
render_scene.meshes[meshIdx].faceVertexIndices()[j + faceVertIdxOffset];
|
||||
}
|
||||
faceVertIdxOffset += pScene->mMeshes[meshIdx]->mFaces[faceIdx].mNumIndices;
|
||||
}
|
||||
}
|
||||
|
||||
void USDImporterImplTinyusdz::normalsForMesh(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
size_t meshIdx,
|
||||
const std::string &nameWExt) {
|
||||
UNUSED(nameWExt);
|
||||
pScene->mMeshes[meshIdx]->mNormals = new aiVector3D[pScene->mMeshes[meshIdx]->mNumVertices];
|
||||
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) {
|
||||
pScene->mMeshes[meshIdx]->mNormals[vertIdx].x = floatPtr[fpj];
|
||||
pScene->mMeshes[meshIdx]->mNormals[vertIdx].y = floatPtr[fpj + 1];
|
||||
pScene->mMeshes[meshIdx]->mNormals[vertIdx].z = floatPtr[fpj + 2];
|
||||
}
|
||||
}
|
||||
|
||||
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::uvsForMesh(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
size_t meshIdx,
|
||||
const std::string &nameWExt) {
|
||||
UNUSED(nameWExt);
|
||||
const size_t uvSlotsCount = render_scene.meshes[meshIdx].texcoords.size();
|
||||
if (uvSlotsCount < 1) {
|
||||
return;
|
||||
}
|
||||
pScene->mMeshes[meshIdx]->mTextureCoords[0] = new aiVector3D[pScene->mMeshes[meshIdx]->mNumVertices];
|
||||
pScene->mMeshes[meshIdx]->mNumUVComponents[0] = 2; // U and V stored in "x", "y" of aiVector3D.
|
||||
for (unsigned int uvSlotIdx = 0; uvSlotIdx < uvSlotsCount; ++uvSlotIdx) {
|
||||
const auto uvsForSlot = render_scene.meshes[meshIdx].texcoords.at(uvSlotIdx);
|
||||
if (uvsForSlot.get_data().size() == 0) {
|
||||
continue;
|
||||
}
|
||||
const float *floatPtr = reinterpret_cast<const float *>(uvsForSlot.get_data().data());
|
||||
for (size_t vertIdx = 0, fpj = 0; vertIdx < pScene->mMeshes[meshIdx]->mNumVertices; ++vertIdx, fpj += 2) {
|
||||
pScene->mMeshes[meshIdx]->mTextureCoords[uvSlotIdx][vertIdx].x = floatPtr[fpj];
|
||||
pScene->mMeshes[meshIdx]->mTextureCoords[uvSlotIdx][vertIdx].y = floatPtr[fpj + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static aiColor3D *ownedColorPtrFor(const std::array<float, 3> &color) {
|
||||
aiColor3D *colorPtr = new aiColor3D();
|
||||
colorPtr->r = color[0];
|
||||
colorPtr->g = color[1];
|
||||
colorPtr->b = color[2];
|
||||
return colorPtr;
|
||||
}
|
||||
|
||||
static std::string nameForTextureWithId(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
const int targetId) {
|
||||
stringstream ss;
|
||||
std::string texName;
|
||||
for (const auto &image : render_scene.images) {
|
||||
if (image.buffer_id == targetId) {
|
||||
texName = image.asset_identifier;
|
||||
ss.str("");
|
||||
ss << "nameForTextureWithId(): found texture " << texName << " with target id " << targetId;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
ss.str("");
|
||||
ss << "nameForTextureWithId(): ERROR! Failed to find texture with target id " << targetId;
|
||||
TINYUSDZLOGE(TAG, "%s", ss.str().c_str());
|
||||
return texName;
|
||||
}
|
||||
|
||||
static void assignTexture(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
const tinyusdz::tydra::RenderMaterial &material,
|
||||
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;
|
||||
ss.str("");
|
||||
ss << "assignTexture(): name: " << name;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
// TODO: verify hard-coded '0' index is correct
|
||||
mat->AddProperty(texName, _AI_MATKEY_TEXTURE_BASE, aiTextureType, 0);
|
||||
}
|
||||
|
||||
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;
|
||||
ss.str("");
|
||||
ss << "materials(): model" << nameWExt << ", numMaterials: " << numMaterials;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
pScene->mNumMaterials = 0;
|
||||
if (render_scene.materials.empty()) {
|
||||
return;
|
||||
}
|
||||
pScene->mMaterials = new aiMaterial *[render_scene.materials.size()];
|
||||
for (const auto &material : render_scene.materials) {
|
||||
ss.str("");
|
||||
ss << " material[" << pScene->mNumMaterials << "]: name: |" << material.name << "|, disp name: |" << material.display_name << "|";
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
aiMaterial *mat = new aiMaterial;
|
||||
|
||||
aiString *materialName = new aiString();
|
||||
materialName->Set(material.name);
|
||||
mat->AddProperty(materialName, AI_MATKEY_NAME);
|
||||
|
||||
mat->AddProperty(
|
||||
ownedColorPtrFor(material.surfaceShader.diffuseColor.value),
|
||||
1, AI_MATKEY_COLOR_DIFFUSE);
|
||||
mat->AddProperty(
|
||||
ownedColorPtrFor(material.surfaceShader.specularColor.value),
|
||||
1, AI_MATKEY_COLOR_SPECULAR);
|
||||
mat->AddProperty(
|
||||
ownedColorPtrFor(material.surfaceShader.emissiveColor.value),
|
||||
1, AI_MATKEY_COLOR_EMISSIVE);
|
||||
|
||||
ss.str("");
|
||||
if (material.surfaceShader.diffuseColor.is_texture()) {
|
||||
assignTexture(render_scene, material, mat, material.surfaceShader.diffuseColor.texture_id, aiTextureType_DIFFUSE);
|
||||
ss << " material[" << pScene->mNumMaterials << "]: diff tex id " << material.surfaceShader.diffuseColor.texture_id << "\n";
|
||||
}
|
||||
if (material.surfaceShader.specularColor.is_texture()) {
|
||||
assignTexture(render_scene, material, mat, material.surfaceShader.specularColor.texture_id, aiTextureType_SPECULAR);
|
||||
ss << " material[" << pScene->mNumMaterials << "]: spec tex id " << material.surfaceShader.specularColor.texture_id << "\n";
|
||||
}
|
||||
if (material.surfaceShader.normal.is_texture()) {
|
||||
assignTexture(render_scene, material, mat, material.surfaceShader.normal.texture_id, aiTextureType_NORMALS);
|
||||
ss << " material[" << pScene->mNumMaterials << "]: normal tex id " << material.surfaceShader.normal.texture_id << "\n";
|
||||
}
|
||||
if (material.surfaceShader.emissiveColor.is_texture()) {
|
||||
assignTexture(render_scene, material, mat, material.surfaceShader.emissiveColor.texture_id, aiTextureType_EMISSIVE);
|
||||
ss << " material[" << pScene->mNumMaterials << "]: emissive tex id " << material.surfaceShader.emissiveColor.texture_id << "\n";
|
||||
}
|
||||
if (material.surfaceShader.occlusion.is_texture()) {
|
||||
assignTexture(render_scene, material, mat, material.surfaceShader.occlusion.texture_id, aiTextureType_LIGHTMAP);
|
||||
ss << " material[" << pScene->mNumMaterials << "]: lightmap (occlusion) tex id " << material.surfaceShader.occlusion.texture_id << "\n";
|
||||
}
|
||||
if (material.surfaceShader.metallic.is_texture()) {
|
||||
assignTexture(render_scene, material, mat, material.surfaceShader.metallic.texture_id, aiTextureType_METALNESS);
|
||||
ss << " material[" << pScene->mNumMaterials << "]: metallic tex id " << material.surfaceShader.metallic.texture_id << "\n";
|
||||
}
|
||||
if (material.surfaceShader.roughness.is_texture()) {
|
||||
assignTexture(render_scene, material, mat, material.surfaceShader.roughness.texture_id, aiTextureType_DIFFUSE_ROUGHNESS);
|
||||
ss << " material[" << pScene->mNumMaterials << "]: roughness tex id " << material.surfaceShader.roughness.texture_id << "\n";
|
||||
}
|
||||
if (material.surfaceShader.clearcoat.is_texture()) {
|
||||
assignTexture(render_scene, material, mat, material.surfaceShader.clearcoat.texture_id, aiTextureType_CLEARCOAT);
|
||||
ss << " material[" << pScene->mNumMaterials << "]: clearcoat tex id " << material.surfaceShader.clearcoat.texture_id << "\n";
|
||||
}
|
||||
if (material.surfaceShader.opacity.is_texture()) {
|
||||
assignTexture(render_scene, material, mat, material.surfaceShader.opacity.texture_id, aiTextureType_OPACITY);
|
||||
ss << " material[" << pScene->mNumMaterials << "]: opacity tex id " << material.surfaceShader.opacity.texture_id << "\n";
|
||||
}
|
||||
if (material.surfaceShader.displacement.is_texture()) {
|
||||
assignTexture(render_scene, material, mat, material.surfaceShader.displacement.texture_id, aiTextureType_DISPLACEMENT);
|
||||
ss << " material[" << pScene->mNumMaterials << "]: displacement tex id " << material.surfaceShader.displacement.texture_id << "\n";
|
||||
}
|
||||
if (material.surfaceShader.clearcoatRoughness.is_texture()) {
|
||||
ss << " material[" << pScene->mNumMaterials << "]: clearcoatRoughness tex id " << material.surfaceShader.clearcoatRoughness.texture_id << "\n";
|
||||
}
|
||||
if (material.surfaceShader.opacityThreshold.is_texture()) {
|
||||
ss << " material[" << pScene->mNumMaterials << "]: opacityThreshold tex id " << material.surfaceShader.opacityThreshold.texture_id << "\n";
|
||||
}
|
||||
if (material.surfaceShader.ior.is_texture()) {
|
||||
ss << " material[" << pScene->mNumMaterials << "]: ior tex id " << material.surfaceShader.ior.texture_id << "\n";
|
||||
}
|
||||
if (!ss.str().empty()) {
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
}
|
||||
|
||||
pScene->mMaterials[pScene->mNumMaterials] = mat;
|
||||
++pScene->mNumMaterials;
|
||||
}
|
||||
}
|
||||
|
||||
void USDImporterImplTinyusdz::textures(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
const std::string &nameWExt) {
|
||||
UNUSED(pScene);
|
||||
const size_t numTextures{render_scene.textures.size()};
|
||||
UNUSED(numTextures); // Ignore unused variable when -Werror enabled
|
||||
stringstream ss;
|
||||
ss.str("");
|
||||
ss << "textures(): model" << nameWExt << ", numTextures: " << numTextures;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
size_t i{0};
|
||||
UNUSED(i);
|
||||
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 << "|";
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* "owned" as in, used "new" to allocate and aiScene now responsible for "delete"
|
||||
*
|
||||
* @param render_scene renderScene object
|
||||
* @param image textureImage object
|
||||
* @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;
|
||||
aiTexture *tex = new aiTexture();
|
||||
size_t pos = image.asset_identifier.find_last_of('/');
|
||||
string embTexName{image.asset_identifier.substr(pos + 1)};
|
||||
tex->mFilename.Set(image.asset_identifier.c_str());
|
||||
tex->mHeight = image.height;
|
||||
// const size_t imageBytesCount{render_scene.buffers[image.buffer_id].data.size() / image.channels};
|
||||
tex->mWidth = image.width;
|
||||
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];
|
||||
memcpy(tex->pcData, &render_scene.buffers[image.buffer_id].data[0], imageBytesCount);
|
||||
} else {
|
||||
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 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].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);
|
||||
}
|
||||
ss.str("");
|
||||
ss << "ownedEmbeddedTextureFor(): imageTexelsCount: " << imageTexelsCount << ", channels: " << image.channels;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
}
|
||||
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
|
||||
ss.str("");
|
||||
ss << "textureImages(): model" << nameWExt << ", numTextureImages: " << numTextureImages;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
pScene->mTextures = nullptr; // Need to iterate over images before knowing if valid textures available
|
||||
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();
|
||||
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()) {
|
||||
aiTexture *tex = ownedEmbeddedTextureFor(
|
||||
render_scene,
|
||||
image,
|
||||
nameWExt);
|
||||
if (pScene->mTextures == nullptr) {
|
||||
ss.str("");
|
||||
ss << " Init pScene->mTextures[" << render_scene.images.size() << "]";
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
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;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
pScene->mTextures[pScene->mNumTextures++] = tex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
ss.str("");
|
||||
ss << "buffers(): model" << nameWExt << ", numBuffers: " << numBuffers;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
size_t i = 0;
|
||||
for (const auto &buffer : render_scene.buffers) {
|
||||
ss.str("");
|
||||
ss << " buffer[" << i << "]: count: " << buffer.data.size() << ", type: " << to_string(buffer.componentType);
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void USDImporterImplTinyusdz::setupNodes(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
|
||||
const std::string &nameWExt) {
|
||||
stringstream ss;
|
||||
|
||||
pScene->mRootNode = nodes(render_scene, 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,
|
||||
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, render_scene.nodes[0], meshNodes);
|
||||
}
|
||||
|
||||
using Assimp::tinyusdzNodeTypeFor;
|
||||
using Assimp::tinyUsdzMat4ToAiMat4;
|
||||
using tinyusdz::tydra::NodeType;
|
||||
aiNode *USDImporterImplTinyusdz::nodesRecursive(
|
||||
aiNode *pNodeParent,
|
||||
const tinyusdz::tydra::Node &node,
|
||||
std::map<size_t, tinyusdz::tydra::Node> &meshNodes) {
|
||||
stringstream ss;
|
||||
aiNode *cNode = new aiNode();
|
||||
cNode->mParent = pNodeParent;
|
||||
cNode->mName.Set(node.prim_name);
|
||||
cNode->mTransformation = tinyUsdzMat4ToAiMat4(node.local_matrix.m);
|
||||
ss.str("");
|
||||
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() << ")";
|
||||
}
|
||||
ss << " has " << node.children.size() << " children";
|
||||
if (node.id > -1) {
|
||||
ss << "\n node mesh id: " << node.id << " (node type: " << tinyusdzNodeTypeFor(node.nodeType) << ")";
|
||||
meshNodes[node.id] = node;
|
||||
}
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
if (!node.children.empty()) {
|
||||
cNode->mNumChildren = static_cast<unsigned int>(node.children.size());
|
||||
cNode->mChildren = new aiNode *[cNode->mNumChildren];
|
||||
}
|
||||
|
||||
size_t i{0};
|
||||
for (const auto &childNode: node.children) {
|
||||
cNode->mChildren[i] = nodesRecursive(cNode, childNode, meshNodes);
|
||||
++i;
|
||||
}
|
||||
return cNode;
|
||||
}
|
||||
|
||||
void USDImporterImplTinyusdz::sanityCheckNodesRecursive(
|
||||
aiNode *cNode) {
|
||||
stringstream ss;
|
||||
ss.str("");
|
||||
ss << "sanityCheckNodesRecursive(): node " << cNode->mName.C_Str();
|
||||
if (cNode->mParent != nullptr) {
|
||||
ss << " (parent " << cNode->mParent->mName.C_Str() << ")";
|
||||
}
|
||||
ss << " has " << cNode->mNumChildren << " children";
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
for (size_t i = 0; i < cNode->mNumChildren; ++i) {
|
||||
sanityCheckNodesRecursive(cNode->mChildren[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void USDImporterImplTinyusdz::setupBlendShapes(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
const std::string &nameWExt) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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())};
|
||||
UNUSED(numBlendShapeTargets); // Ignore unused variable when -Werror enabled
|
||||
ss.str("");
|
||||
ss << " blendShapesForMesh(): mesh[" << meshIdx << "], numBlendShapeTargets: " << numBlendShapeTargets;
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
if (numBlendShapeTargets > 0) {
|
||||
pScene->mMeshes[meshIdx]->mNumAnimMeshes = numBlendShapeTargets;
|
||||
pScene->mMeshes[meshIdx]->mAnimMeshes = new aiAnimMesh *[pScene->mMeshes[meshIdx]->mNumAnimMeshes];
|
||||
}
|
||||
auto mapIter = render_scene.meshes[meshIdx].targets.begin();
|
||||
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};
|
||||
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";
|
||||
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]] +=
|
||||
tinyUsdzScaleOrPosToAssimp(shapeTarget.pointOffsets[iVert]);
|
||||
}
|
||||
for (size_t iVert = 0; iVert < shapeTarget.normalOffsets.size(); ++iVert) {
|
||||
pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx]->mNormals[shapeTarget.pointIndices[iVert]] +=
|
||||
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";
|
||||
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
|
||||
++animMeshIdx;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_USD_IMPORTER
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file USDLoader.h
|
||||
* @brief Declaration of the USD importer class.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED
|
||||
#define AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED
|
||||
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/types.h>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include "tinyusdz.hh"
|
||||
#include "tydra/render-data.hh"
|
||||
|
||||
namespace Assimp {
|
||||
class USDImporterImplTinyusdz {
|
||||
public:
|
||||
USDImporterImplTinyusdz() = default;
|
||||
~USDImporterImplTinyusdz() = default;
|
||||
|
||||
void InternReadFile(
|
||||
const std::string &pFile,
|
||||
aiScene *pScene,
|
||||
IOSystem *pIOHandler);
|
||||
|
||||
void meshes(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
const std::string &nameWExt);
|
||||
|
||||
void verticesForMesh(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
size_t meshIdx,
|
||||
const std::string &nameWExt);
|
||||
|
||||
void facesForMesh(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
size_t meshIdx,
|
||||
const std::string &nameWExt);
|
||||
|
||||
void normalsForMesh(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
size_t meshIdx,
|
||||
const std::string &nameWExt);
|
||||
|
||||
void materialsForMesh(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
size_t meshIdx,
|
||||
const std::string &nameWExt);
|
||||
|
||||
void uvsForMesh(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
size_t meshIdx,
|
||||
const std::string &nameWExt);
|
||||
|
||||
void materials(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
const std::string &nameWExt);
|
||||
|
||||
void textures(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
const std::string &nameWExt);
|
||||
|
||||
void textureImages(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
const std::string &nameWExt);
|
||||
|
||||
void buffers(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
const std::string &nameWExt);
|
||||
|
||||
void setupNodes(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
|
||||
const std::string &nameWExt
|
||||
);
|
||||
|
||||
aiNode *nodes(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
|
||||
const std::string &nameWExt);
|
||||
|
||||
aiNode *nodesRecursive(
|
||||
aiNode *pNodeParent,
|
||||
const tinyusdz::tydra::Node &node,
|
||||
std::map<size_t, tinyusdz::tydra::Node> &meshNodes);
|
||||
|
||||
void sanityCheckNodesRecursive(
|
||||
aiNode *pNode);
|
||||
|
||||
void setupBlendShapes(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
const std::string &nameWExt);
|
||||
|
||||
void blendShapesForMesh(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene,
|
||||
size_t meshIdx,
|
||||
const std::string &nameWExt);
|
||||
};
|
||||
} // namespace Assimp
|
||||
#endif // AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED
|
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, 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 ASSIMP_BUILD_NO_USD_IMPORTER
|
||||
#include "USDLoaderImplTinyusdzHelper.h"
|
||||
|
||||
#include "../../../contrib/tinyusdz/assimp_tinyusdz_logging.inc"
|
||||
|
||||
namespace {
|
||||
//const char *const TAG = "tinyusdz helper";
|
||||
}
|
||||
|
||||
using ChannelType = tinyusdz::tydra::AnimationChannel::ChannelType;
|
||||
std::string Assimp::tinyusdzAnimChannelTypeFor(ChannelType animChannel) {
|
||||
switch (animChannel) {
|
||||
case ChannelType::Transform: {
|
||||
return "Transform";
|
||||
}
|
||||
case ChannelType::Translation: {
|
||||
return "Translation";
|
||||
}
|
||||
case ChannelType::Rotation: {
|
||||
return "Rotation";
|
||||
}
|
||||
case ChannelType::Scale: {
|
||||
return "Scale";
|
||||
}
|
||||
case ChannelType::Weight: {
|
||||
return "Weight";
|
||||
}
|
||||
default:
|
||||
return "Invalid";
|
||||
}
|
||||
}
|
||||
|
||||
using tinyusdz::tydra::NodeType;
|
||||
std::string Assimp::tinyusdzNodeTypeFor(NodeType type) {
|
||||
switch (type) {
|
||||
case NodeType::Xform: {
|
||||
return "Xform";
|
||||
}
|
||||
case NodeType::Mesh: {
|
||||
return "Mesh";
|
||||
}
|
||||
case NodeType::Camera: {
|
||||
return "Camera";
|
||||
}
|
||||
case NodeType::Skeleton: {
|
||||
return "Skeleton";
|
||||
}
|
||||
case NodeType::PointLight: {
|
||||
return "PointLight";
|
||||
}
|
||||
case NodeType::DirectionalLight: {
|
||||
return "DirectionalLight";
|
||||
}
|
||||
case NodeType::EnvmapLight: {
|
||||
return "EnvmapLight";
|
||||
}
|
||||
default:
|
||||
return "Invalid";
|
||||
}
|
||||
}
|
||||
|
||||
aiMatrix4x4 Assimp::tinyUsdzMat4ToAiMat4(const double matIn[4][4]) {
|
||||
aiMatrix4x4 matOut;
|
||||
matOut.a1 = matIn[0][0];
|
||||
matOut.a2 = matIn[0][1];
|
||||
matOut.a3 = matIn[0][2];
|
||||
matOut.a4 = matIn[0][3];
|
||||
matOut.b1 = matIn[1][0];
|
||||
matOut.b2 = matIn[1][1];
|
||||
matOut.b3 = matIn[1][2];
|
||||
matOut.b4 = matIn[1][3];
|
||||
matOut.c1 = matIn[2][0];
|
||||
matOut.c2 = matIn[2][1];
|
||||
matOut.c3 = matIn[2][2];
|
||||
matOut.c4 = matIn[2][3];
|
||||
matOut.d1 = matIn[3][0];
|
||||
matOut.d2 = matIn[3][1];
|
||||
matOut.d3 = matIn[3][2];
|
||||
matOut.d4 = matIn[3][3];
|
||||
// matOut.a1 = matIn[0][0];
|
||||
// matOut.a2 = matIn[1][0];
|
||||
// matOut.a3 = matIn[2][0];
|
||||
// matOut.a4 = matIn[3][0];
|
||||
// matOut.b1 = matIn[0][1];
|
||||
// matOut.b2 = matIn[1][1];
|
||||
// matOut.b3 = matIn[2][1];
|
||||
// matOut.b4 = matIn[3][1];
|
||||
// matOut.c1 = matIn[0][2];
|
||||
// matOut.c2 = matIn[1][2];
|
||||
// matOut.c3 = matIn[2][2];
|
||||
// matOut.c4 = matIn[3][2];
|
||||
// matOut.d1 = matIn[0][3];
|
||||
// matOut.d2 = matIn[1][3];
|
||||
// matOut.d3 = matIn[2][3];
|
||||
// matOut.d4 = matIn[3][3];
|
||||
return matOut;
|
||||
}
|
||||
|
||||
aiVector3D Assimp::tinyUsdzScaleOrPosToAssimp(const std::array<float, 3> &scaleOrPosIn) {
|
||||
return aiVector3D(scaleOrPosIn[0], scaleOrPosIn[1], scaleOrPosIn[2]);
|
||||
}
|
||||
|
||||
aiQuaternion Assimp::tinyUsdzQuatToAiQuat(const std::array<float, 4> &quatIn) {
|
||||
// tinyusdz "quat" is x,y,z,w
|
||||
// aiQuaternion is w,x,y,z
|
||||
return aiQuaternion(
|
||||
quatIn[3], quatIn[0], quatIn[1], quatIn[2]);
|
||||
}
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_USD_IMPORTER
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef AI_USDLOADER_IMPL_TINYUSDZ_HELPER_H_INCLUDED
|
||||
#define AI_USDLOADER_IMPL_TINYUSDZ_HELPER_H_INCLUDED
|
||||
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/types.h>
|
||||
#include "tinyusdz.hh"
|
||||
#include "tydra/render-data.hh"
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
std::string tinyusdzAnimChannelTypeFor(
|
||||
tinyusdz::tydra::AnimationChannel::ChannelType animChannel);
|
||||
std::string tinyusdzNodeTypeFor(tinyusdz::tydra::NodeType type);
|
||||
aiMatrix4x4 tinyUsdzMat4ToAiMat4(const double matIn[4][4]);
|
||||
|
||||
aiVector3D tinyUsdzScaleOrPosToAssimp(const std::array<float, 3> &scaleOrPosIn);
|
||||
|
||||
/**
|
||||
* Convert quaternion from tinyusdz "quat" to assimp "aiQuaternion" type
|
||||
*
|
||||
* @param quatIn tinyusdz float[4] in x,y,z,w order
|
||||
* @return assimp aiQuaternion converted from input
|
||||
*/
|
||||
aiQuaternion tinyUsdzQuatToAiQuat(const std::array<float, 4> &quatIn);
|
||||
|
||||
} // namespace Assimp
|
||||
#endif // AI_USDLOADER_IMPL_TINYUSDZ_HELPER_H_INCLUDED
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file USDLoader.cpp
|
||||
* @brief Implementation of the USD importer class
|
||||
*/
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_USD_IMPORTER
|
||||
#include <memory>
|
||||
|
||||
// internal headers
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <assimp/anim.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/scene.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/StreamReader.h>
|
||||
|
||||
#include "USDLoaderUtil.h"
|
||||
|
||||
namespace Assimp {
|
||||
using namespace std;
|
||||
bool isUsda(const std::string &pFile) {
|
||||
size_t pos = pFile.find_last_of('.');
|
||||
if (pos == string::npos) {
|
||||
return false;
|
||||
}
|
||||
string ext = pFile.substr(pos + 1);
|
||||
if (ext.size() != 4) {
|
||||
return false;
|
||||
}
|
||||
return (ext[0] == 'u' || ext[0] == 'U') && (ext[1] == 's' || ext[1] == 'S') && (ext[2] == 'd' || ext[2] == 'D') && (ext[3] == 'a' || ext[3] == 'A');
|
||||
}
|
||||
|
||||
bool isUsdc(const std::string &pFile) {
|
||||
size_t pos = pFile.find_last_of('.');
|
||||
if (pos == string::npos) {
|
||||
return false;
|
||||
}
|
||||
string ext = pFile.substr(pos + 1);
|
||||
if (ext.size() != 4) {
|
||||
return false;
|
||||
}
|
||||
return (ext[0] == 'u' || ext[0] == 'U') && (ext[1] == 's' || ext[1] == 'S') && (ext[2] == 'd' || ext[2] == 'D') && (ext[3] == 'c' || ext[3] == 'C');
|
||||
}
|
||||
|
||||
bool isUsdz(const std::string &pFile) {
|
||||
size_t pos = pFile.find_last_of('.');
|
||||
if (pos == string::npos) {
|
||||
return false;
|
||||
}
|
||||
string ext = pFile.substr(pos + 1);
|
||||
if (ext.size() != 4) {
|
||||
return false;
|
||||
}
|
||||
return (ext[0] == 'u' || ext[0] == 'U') && (ext[1] == 's' || ext[1] == 'S') && (ext[2] == 'd' || ext[2] == 'D') && (ext[3] == 'z' || ext[3] == 'Z');
|
||||
}
|
||||
|
||||
bool isUsd(const std::string &pFile) {
|
||||
size_t pos = pFile.find_last_of('.');
|
||||
if (pos == string::npos) {
|
||||
return false;
|
||||
}
|
||||
string ext = pFile.substr(pos + 1);
|
||||
if (ext.size() != 3) {
|
||||
return false;
|
||||
}
|
||||
return (ext[0] == 'u' || ext[0] == 'U') && (ext[1] == 's' || ext[1] == 'S') && (ext[2] == 'd' || ext[2] == 'D');
|
||||
}
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_USD_IMPORTER
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file USDLoader.h
|
||||
* @brief Declaration of the USD importer class.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef AI_USDLOADER_UTIL_H_INCLUDED
|
||||
#define AI_USDLOADER_UTIL_H_INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
bool isUsda(const std::string &pFile);
|
||||
bool isUsdc(const std::string &pFile);
|
||||
bool isUsdz(const std::string &pFile);
|
||||
bool isUsd(const std::string &pFile);
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // AI_USDLOADER_UTIL_H_INCLUDED
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file USDLoader.h
|
||||
* @brief Declaration of the USD importer class.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef AI_USDPREPROCESSOR_H_INCLUDED
|
||||
#define AI_USDPREPROCESSOR_H_INCLUDED
|
||||
|
||||
#define UNUSED(x) (void) x
|
||||
|
||||
#endif // AI_USDPREPROCESSOR_H_INCLUDED
|
|
@ -452,7 +452,7 @@ void UnrealImporter::InternReadFile(const std::string &pFile,
|
|||
aiColor3D color(1.f, 1.f, 1.f);
|
||||
|
||||
aiString s;
|
||||
::ai_snprintf(s.data, MAXLEN, "mat%u_tx%u_", i, materials[i].tex);
|
||||
::ai_snprintf(s.data, AI_MAXLEN, "mat%u_tx%u_", i, materials[i].tex);
|
||||
|
||||
// set the two-sided flag
|
||||
if (materials[i].type == Unreal::MF_NORMAL_TS) {
|
||||
|
@ -472,7 +472,7 @@ void UnrealImporter::InternReadFile(const std::string &pFile,
|
|||
|
||||
// a special name for the weapon attachment point
|
||||
if (materials[i].type == Unreal::MF_WEAPON_PLACEHOLDER) {
|
||||
s.length = ::ai_snprintf(s.data, MAXLEN, "$WeaponTag$");
|
||||
s.length = ::ai_snprintf(s.data, AI_MAXLEN, "$WeaponTag$");
|
||||
color = aiColor3D(0.f, 0.f, 0.f);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ inline void SetMaterialColorProperty(std::vector<int> &embeddedTexIdxs, Asset &
|
|||
if (texIdx != -1) { // embedded
|
||||
// setup texture reference string (copied from ColladaLoader::FindFilenameForEffectTexture)
|
||||
uri.data[0] = '*';
|
||||
uri.length = 1 + ASSIMP_itoa10(uri.data + 1, MAXLEN - 1, texIdx);
|
||||
uri.length = 1 + ASSIMP_itoa10(uri.data + 1, AI_MAXLEN - 1, texIdx);
|
||||
}
|
||||
|
||||
mat->AddProperty(&uri, _AI_MATKEY_TEXTURE_BASE, texType, 0);
|
||||
|
@ -242,7 +242,7 @@ void glTFImporter::ImportMeshes(glTF::Asset &r) {
|
|||
if (mesh.primitives.size() > 1) {
|
||||
ai_uint32 &len = aim->mName.length;
|
||||
aim->mName.data[len] = '-';
|
||||
len += 1 + ASSIMP_itoa10(aim->mName.data + len + 1, unsigned(MAXLEN - len - 1), p);
|
||||
len += 1 + ASSIMP_itoa10(aim->mName.data + len + 1, unsigned(AI_MAXLEN - len - 1), p);
|
||||
}
|
||||
|
||||
switch (prim.mode) {
|
||||
|
|
|
@ -1440,7 +1440,7 @@ inline void MaterialSheen::SetDefaults() {
|
|||
inline void MaterialVolume::SetDefaults() {
|
||||
//KHR_materials_volume properties
|
||||
thicknessFactor = 0.f;
|
||||
attenuationDistance = INFINITY;
|
||||
attenuationDistance = std::numeric_limits<float>::infinity();
|
||||
SetVector(attenuationColor, defaultAttenuationColor);
|
||||
}
|
||||
|
||||
|
|
|
@ -507,7 +507,7 @@ namespace glTF2 {
|
|||
|
||||
WriteTex(materialVolume, volume.thicknessTexture, "thicknessTexture", w.mAl);
|
||||
|
||||
if (volume.attenuationDistance != INFINITY) {
|
||||
if (volume.attenuationDistance != std::numeric_limits<float>::infinity()) {
|
||||
WriteFloat(materialVolume, volume.attenuationDistance, "attenuationDistance", w.mAl);
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ static void SetMaterialTextureProperty(std::vector<int> &embeddedTexIdxs, Asset
|
|||
if (texIdx != -1) { // embedded
|
||||
// setup texture reference string (copied from ColladaLoader::FindFilenameForEffectTexture)
|
||||
uri.data[0] = '*';
|
||||
uri.length = 1 + ASSIMP_itoa10(uri.data + 1, MAXLEN - 1, texIdx);
|
||||
uri.length = 1 + ASSIMP_itoa10(uri.data + 1, AI_MAXLEN - 1, texIdx);
|
||||
}
|
||||
|
||||
mat->AddProperty(&uri, AI_MATKEY_TEXTURE(texType, texSlot));
|
||||
|
@ -539,7 +539,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
if (mesh.primitives.size() > 1) {
|
||||
ai_uint32 &len = aim->mName.length;
|
||||
aim->mName.data[len] = '-';
|
||||
len += 1 + ASSIMP_itoa10(aim->mName.data + len + 1, unsigned(MAXLEN - len - 1), p);
|
||||
len += 1 + ASSIMP_itoa10(aim->mName.data + len + 1, unsigned(AI_MAXLEN - len - 1), p);
|
||||
}
|
||||
|
||||
switch (prim.mode) {
|
||||
|
|
|
@ -828,6 +828,17 @@ ADD_ASSIMP_IMPORTER( 3D
|
|||
AssetLib/Unreal/UnrealLoader.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( USD
|
||||
AssetLib/USD/USDLoader.cpp
|
||||
AssetLib/USD/USDLoader.h
|
||||
AssetLib/USD/USDLoaderImplTinyusdz.cpp
|
||||
AssetLib/USD/USDLoaderImplTinyusdz.h
|
||||
AssetLib/USD/USDLoaderImplTinyusdzHelper.cpp
|
||||
AssetLib/USD/USDLoaderImplTinyusdzHelper.h
|
||||
AssetLib/USD/USDLoaderUtil.cpp
|
||||
AssetLib/USD/USDLoaderUtil.h
|
||||
)
|
||||
|
||||
ADD_ASSIMP_IMPORTER( X
|
||||
AssetLib/X/XFileHelper.h
|
||||
AssetLib/X/XFileImporter.cpp
|
||||
|
@ -921,6 +932,123 @@ SET( Extra_SRCS
|
|||
)
|
||||
SOURCE_GROUP( Extra FILES ${Extra_SRCS})
|
||||
|
||||
# USD/USDA/USDC/USDZ support
|
||||
# tinyusdz
|
||||
IF (ASSIMP_BUILD_USD_IMPORTER)
|
||||
if (ASSIMP_BUILD_USD_VERBOSE_LOGS)
|
||||
ADD_DEFINITIONS( -DASSIMP_USD_VERBOSE_LOGS)
|
||||
endif ()
|
||||
# Use CMAKE_CURRENT_SOURCE_DIR which provides assimp-local path (CMAKE_SOURCE_DIR is
|
||||
# relative to top-level/main project)
|
||||
set(Tinyusdz_BASE_ABSPATH "${CMAKE_CURRENT_SOURCE_DIR}/../contrib/tinyusdz")
|
||||
set(Tinyusdz_REPO_ABSPATH "${Tinyusdz_BASE_ABSPATH}/autoclone")
|
||||
|
||||
# Note: ALWAYS specify a git commit hash (or tag) instead of a branch name; using a branch
|
||||
# name can lead to non-deterministic (unpredictable) results since the code is potentially
|
||||
# in flux
|
||||
# "dev" branch, 9 Jul 2024
|
||||
set(TINYUSDZ_GIT_TAG "bd2a1edbbf69f352a6c40730114db9918c384848")
|
||||
message("****")
|
||||
message("\n\n**** Cloning tinyusdz repo, git tag ${TINYUSDZ_GIT_TAG}\n\n")
|
||||
|
||||
# Patch required to build arm32 on android
|
||||
set(TINYUSDZ_PATCH_CMD git apply ${Tinyusdz_BASE_ABSPATH}/patches/tinyusdz.patch)
|
||||
|
||||
# Note: CMake's "FetchContent" (which executes at configure time) is much better for this use case
|
||||
# than "ExternalProject" (which executes at build time); we just want to clone a repo and
|
||||
# block (wait) as long as necessary until cloning is complete, so we immediately have full
|
||||
# access to the cloned source files
|
||||
include(FetchContent)
|
||||
# Only want to clone once (on Android, using SOURCE_DIR will clone per-ABI (x86, x86_64 etc))
|
||||
set(FETCHCONTENT_BASE_DIR ${Tinyusdz_REPO_ABSPATH})
|
||||
set(FETCHCONTENT_QUIET on) # Turn off to troubleshoot repo clone problems
|
||||
set(FETCHCONTENT_UPDATES_DISCONNECTED on) # Prevent other ABIs from re-cloning/re-patching etc
|
||||
FetchContent_Declare(
|
||||
tinyusdz_repo
|
||||
GIT_REPOSITORY "https://github.com/lighttransport/tinyusdz"
|
||||
GIT_TAG ${TINYUSDZ_GIT_TAG}
|
||||
PATCH_COMMAND ${TINYUSDZ_PATCH_CMD}
|
||||
)
|
||||
FetchContent_MakeAvailable(tinyusdz_repo)
|
||||
message("**** Finished cloning tinyusdz repo")
|
||||
message("****")
|
||||
|
||||
set(Tinyusdz_SRC_ABSPATH "${Tinyusdz_REPO_ABSPATH}/tinyusdz_repo-src/src")
|
||||
set(Tinyusdz_SRCS
|
||||
${Tinyusdz_SRC_ABSPATH}/ascii-parser.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/ascii-parser-basetype.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/ascii-parser-timesamples.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/ascii-parser-timesamples-array.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/asset-resolution.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/composition.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/crate-format.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/crate-pprint.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/crate-reader.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/image-loader.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/image-util.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/image-writer.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/io-util.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/linear-algebra.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/path-util.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/pprinter.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/prim-composition.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/prim-reconstruct.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/prim-types.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/primvar.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/stage.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/str-util.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/tiny-format.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/tinyusdz.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/tydra/attribute-eval.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/tydra/attribute-eval-typed.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/tydra/attribute-eval-typed-animatable.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/tydra/attribute-eval-typed-animatable-fallback.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/tydra/attribute-eval-typed-fallback.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/tydra/facial.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/tydra/prim-apply.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/tydra/render-data.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/tydra/scene-access.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/tydra/shader-network.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/usda-reader.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/usda-writer.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/usdc-reader.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/usdc-writer.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/usdGeom.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/usdLux.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/usdMtlx.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/usdShade.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/usdSkel.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/value-pprint.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/value-types.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/xform.cc
|
||||
)
|
||||
|
||||
set(Tinyusdz_DEP_SOURCES
|
||||
${Tinyusdz_SRC_ABSPATH}/external/fpng.cpp
|
||||
#${Tinyusdz_SRC_ABSPATH}/external/staticstruct.cc
|
||||
#${Tinyusdz_SRC_ABSPATH}/external/string_id/database.cpp
|
||||
#${Tinyusdz_SRC_ABSPATH}/external/string_id/error.cpp
|
||||
#${Tinyusdz_SRC_ABSPATH}/external/string_id/string_id.cpp
|
||||
#${Tinyusdz_SRC_ABSPATH}/external/tinyxml2/tinyxml2.cpp
|
||||
${Tinyusdz_SRC_ABSPATH}/integerCoding.cpp
|
||||
${Tinyusdz_SRC_ABSPATH}/lz4-compression.cc
|
||||
${Tinyusdz_SRC_ABSPATH}/lz4/lz4.c
|
||||
)
|
||||
|
||||
set(tinyusdz_INCLUDE_DIRS "${Tinyusdz_SRC_ABSPATH}")
|
||||
INCLUDE_DIRECTORIES(${tinyusdz_INCLUDE_DIRS})
|
||||
SOURCE_GROUP( Contrib\\Tinyusdz
|
||||
FILES
|
||||
${Tinyusdz_SRCS}
|
||||
${Tinyusdz_DEP_SOURCES}
|
||||
)
|
||||
MESSAGE(STATUS "tinyusdz enabled")
|
||||
ELSE() # IF (ASSIMP_BUILD_USD_IMPORTER)
|
||||
set(Tinyusdz_SRCS "")
|
||||
set(Tinyusdz_DEP_SOURCES "")
|
||||
MESSAGE(STATUS "tinyusdz disabled")
|
||||
ENDIF() # IF (ASSIMP_BUILD_USD_IMPORTER)
|
||||
|
||||
# pugixml
|
||||
IF(ASSIMP_HUNTER_ENABLED)
|
||||
hunter_add_package(pugixml)
|
||||
|
@ -1171,6 +1299,8 @@ SET( assimp_src
|
|||
${openddl_parser_SRCS}
|
||||
${open3dgc_SRCS}
|
||||
${ziplib_SRCS}
|
||||
${Tinyusdz_SRCS}
|
||||
${Tinyusdz_DEP_SOURCES}
|
||||
${Pugixml_SRCS}
|
||||
${stb_SRCS}
|
||||
# Necessary to show the headers in the project when using the VC++ generator:
|
||||
|
|
|
@ -743,14 +743,14 @@ ASSIMP_API void aiVector2DivideByVector(
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ASSIMP_API float aiVector2Length(
|
||||
ASSIMP_API ai_real aiVector2Length(
|
||||
const C_STRUCT aiVector2D *v) {
|
||||
ai_assert(nullptr != v);
|
||||
return v->Length();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ASSIMP_API float aiVector2SquareLength(
|
||||
ASSIMP_API ai_real aiVector2SquareLength(
|
||||
const C_STRUCT aiVector2D *v) {
|
||||
ai_assert(nullptr != v);
|
||||
return v->SquareLength();
|
||||
|
@ -764,7 +764,7 @@ ASSIMP_API void aiVector2Negate(
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ASSIMP_API float aiVector2DotProduct(
|
||||
ASSIMP_API ai_real aiVector2DotProduct(
|
||||
const C_STRUCT aiVector2D *a,
|
||||
const C_STRUCT aiVector2D *b) {
|
||||
ai_assert(nullptr != a);
|
||||
|
@ -859,14 +859,14 @@ ASSIMP_API void aiVector3DivideByVector(
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ASSIMP_API float aiVector3Length(
|
||||
ASSIMP_API ai_real aiVector3Length(
|
||||
const C_STRUCT aiVector3D *v) {
|
||||
ai_assert(nullptr != v);
|
||||
return v->Length();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ASSIMP_API float aiVector3SquareLength(
|
||||
ASSIMP_API ai_real aiVector3SquareLength(
|
||||
const C_STRUCT aiVector3D *v) {
|
||||
ai_assert(nullptr != v);
|
||||
return v->SquareLength();
|
||||
|
@ -880,7 +880,7 @@ ASSIMP_API void aiVector3Negate(
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ASSIMP_API float aiVector3DotProduct(
|
||||
ASSIMP_API ai_real aiVector3DotProduct(
|
||||
const C_STRUCT aiVector3D *a,
|
||||
const C_STRUCT aiVector3D *b) {
|
||||
ai_assert(nullptr != a);
|
||||
|
@ -966,7 +966,7 @@ ASSIMP_API void aiMatrix3Inverse(C_STRUCT aiMatrix3x3 *mat) {
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ASSIMP_API float aiMatrix3Determinant(const C_STRUCT aiMatrix3x3 *mat) {
|
||||
ASSIMP_API ai_real aiMatrix3Determinant(const C_STRUCT aiMatrix3x3 *mat) {
|
||||
ai_assert(nullptr != mat);
|
||||
return mat->Determinant();
|
||||
}
|
||||
|
@ -1066,7 +1066,7 @@ ASSIMP_API void aiMatrix4Inverse(C_STRUCT aiMatrix4x4 *mat) {
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ASSIMP_API float aiMatrix4Determinant(const C_STRUCT aiMatrix4x4 *mat) {
|
||||
ASSIMP_API ai_real aiMatrix4Determinant(const C_STRUCT aiMatrix4x4 *mat) {
|
||||
ai_assert(nullptr != mat);
|
||||
return mat->Determinant();
|
||||
}
|
||||
|
|
|
@ -250,9 +250,10 @@ void BaseImporter::GetExtensionList(std::set<std::string> &extensions) {
|
|||
/*static*/ bool BaseImporter::SimpleExtensionCheck(const std::string &pFile,
|
||||
const char *ext0,
|
||||
const char *ext1,
|
||||
const char *ext2) {
|
||||
const char *ext2,
|
||||
const char *ext3) {
|
||||
std::set<std::string> extensions;
|
||||
for (const char* ext : {ext0, ext1, ext2}) {
|
||||
for (const char* ext : {ext0, ext1, ext2, ext3}) {
|
||||
if (ext == nullptr) continue;
|
||||
extensions.emplace(ext);
|
||||
}
|
||||
|
|
|
@ -55,6 +55,9 @@ corresponding preprocessor flag to selectively disable formats.
|
|||
// Importers
|
||||
// (include_new_importers_here)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if !defined(ASSIMP_BUILD_NO_USD_IMPORTER)
|
||||
#include "AssetLib/USD/USDLoader.h"
|
||||
#endif
|
||||
#ifndef ASSIMP_BUILD_NO_X_IMPORTER
|
||||
#include "AssetLib/X/XFileImporter.h"
|
||||
#endif
|
||||
|
@ -230,6 +233,9 @@ void GetImporterInstanceList(std::vector<BaseImporter *> &out) {
|
|||
// (register_new_importers_here)
|
||||
// ----------------------------------------------------------------------------
|
||||
out.reserve(64);
|
||||
#if !defined(ASSIMP_BUILD_NO_USD_IMPORTER)
|
||||
out.push_back(new USDImporter());
|
||||
#endif
|
||||
#if (!defined ASSIMP_BUILD_NO_X_IMPORTER)
|
||||
out.push_back(new XFileImporter());
|
||||
#endif
|
||||
|
|
|
@ -78,7 +78,7 @@ inline void PrefixString(aiString &string, const char *prefix, unsigned int len)
|
|||
if (string.length >= 1 && string.data[0] == '$')
|
||||
return;
|
||||
|
||||
if (len + string.length >= MAXLEN - 1) {
|
||||
if (len + string.length >= AI_MAXLEN - 1) {
|
||||
ASSIMP_LOG_VERBOSE_DEBUG("Can't add an unique prefix because the string is too long");
|
||||
ai_assert(false);
|
||||
return;
|
||||
|
@ -408,7 +408,7 @@ void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector<At
|
|||
// where n is the index of the texture.
|
||||
// Copy here because we overwrite the string data in-place and the buffer inside of aiString
|
||||
// will be a lie if we just reinterpret from prop->mData. The size of mData is not guaranteed to be
|
||||
// MAXLEN in size.
|
||||
// AI_MAXLEN in size.
|
||||
aiString s(*(aiString *)prop->mData);
|
||||
if ('*' == s.data[0]) {
|
||||
// Offset the index and write it back ..
|
||||
|
|
|
@ -71,10 +71,6 @@ SpatialSort::SpatialSort() :
|
|||
mPlaneNormal.Normalize();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor
|
||||
SpatialSort::~SpatialSort() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void SpatialSort::Fill(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset,
|
||||
|
|
|
@ -88,6 +88,11 @@ private:
|
|||
|
||||
} // namespace Assimp
|
||||
|
||||
/// @brief Fixes an undefined reference error when linking in certain build environments.
|
||||
// May throw warnings about needing stdc++17, but should compile without issues on modern compilers.
|
||||
inline const size_t Assimp::StackAllocator::g_maxBytesPerBlock;
|
||||
inline const size_t Assimp::StackAllocator::g_startBytesPerBlock;
|
||||
|
||||
#include "StackAllocator.inl"
|
||||
|
||||
#endif // include guard
|
||||
|
|
|
@ -44,8 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "ScenePrivate.h"
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/version.h>
|
||||
|
||||
#include "revision.h"
|
||||
#include <assimp/revision.h>
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// Legal information string - don't remove this.
|
||||
|
@ -118,83 +117,3 @@ ASSIMP_API const char *aiGetBranchName() {
|
|||
return GitBranch;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ASSIMP_API aiScene::aiScene() :
|
||||
mFlags(0),
|
||||
mRootNode(nullptr),
|
||||
mNumMeshes(0),
|
||||
mMeshes(nullptr),
|
||||
mNumMaterials(0),
|
||||
mMaterials(nullptr),
|
||||
mNumAnimations(0),
|
||||
mAnimations(nullptr),
|
||||
mNumTextures(0),
|
||||
mTextures(nullptr),
|
||||
mNumLights(0),
|
||||
mLights(nullptr),
|
||||
mNumCameras(0),
|
||||
mCameras(nullptr),
|
||||
mMetaData(nullptr),
|
||||
mName(),
|
||||
mNumSkeletons(0),
|
||||
mSkeletons(nullptr),
|
||||
mPrivate(new Assimp::ScenePrivateData()) {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ASSIMP_API aiScene::~aiScene() {
|
||||
// delete all sub-objects recursively
|
||||
delete mRootNode;
|
||||
|
||||
// To make sure we won't crash if the data is invalid it's
|
||||
// much better to check whether both mNumXXX and mXXX are
|
||||
// valid instead of relying on just one of them.
|
||||
if (mNumMeshes && mMeshes) {
|
||||
for (unsigned int a = 0; a < mNumMeshes; ++a) {
|
||||
delete mMeshes[a];
|
||||
}
|
||||
}
|
||||
delete[] mMeshes;
|
||||
|
||||
if (mNumMaterials && mMaterials) {
|
||||
for (unsigned int a = 0; a < mNumMaterials; ++a) {
|
||||
delete mMaterials[a];
|
||||
}
|
||||
}
|
||||
delete[] mMaterials;
|
||||
|
||||
if (mNumAnimations && mAnimations) {
|
||||
for (unsigned int a = 0; a < mNumAnimations; ++a) {
|
||||
delete mAnimations[a];
|
||||
}
|
||||
}
|
||||
delete[] mAnimations;
|
||||
|
||||
if (mNumTextures && mTextures) {
|
||||
for (unsigned int a = 0; a < mNumTextures; ++a) {
|
||||
delete mTextures[a];
|
||||
}
|
||||
}
|
||||
delete[] mTextures;
|
||||
|
||||
if (mNumLights && mLights) {
|
||||
for (unsigned int a = 0; a < mNumLights; ++a) {
|
||||
delete mLights[a];
|
||||
}
|
||||
}
|
||||
delete[] mLights;
|
||||
|
||||
if (mNumCameras && mCameras) {
|
||||
for (unsigned int a = 0; a < mNumCameras; ++a) {
|
||||
delete mCameras[a];
|
||||
}
|
||||
}
|
||||
delete[] mCameras;
|
||||
|
||||
aiMetadata::Dealloc(mMetaData);
|
||||
|
||||
delete[] mSkeletons;
|
||||
|
||||
delete static_cast<Assimp::ScenePrivateData *>(mPrivate);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,87 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
#include <assimp/scene.h>
|
||||
|
||||
#include "ScenePrivate.h"
|
||||
|
||||
aiScene::aiScene() :
|
||||
mFlags(0),
|
||||
mRootNode(nullptr),
|
||||
mNumMeshes(0),
|
||||
mMeshes(nullptr),
|
||||
mNumMaterials(0),
|
||||
mMaterials(nullptr),
|
||||
mNumAnimations(0),
|
||||
mAnimations(nullptr),
|
||||
mNumTextures(0),
|
||||
mTextures(nullptr),
|
||||
mNumLights(0),
|
||||
mLights(nullptr),
|
||||
mNumCameras(0),
|
||||
mCameras(nullptr),
|
||||
mMetaData(nullptr),
|
||||
mName(),
|
||||
mNumSkeletons(0),
|
||||
mSkeletons(nullptr),
|
||||
mPrivate(new Assimp::ScenePrivateData()) {
|
||||
// empty
|
||||
}
|
||||
|
||||
aiScene::~aiScene() {
|
||||
// delete all sub-objects recursively
|
||||
delete mRootNode;
|
||||
|
||||
// To make sure we won't crash if the data is invalid it's
|
||||
// much better to check whether both mNumXXX and mXXX are
|
||||
// valid instead of relying on just one of them.
|
||||
if (mNumMeshes && mMeshes) {
|
||||
for (unsigned int a = 0; a < mNumMeshes; ++a) {
|
||||
delete mMeshes[a];
|
||||
}
|
||||
}
|
||||
delete[] mMeshes;
|
||||
|
||||
if (mNumMaterials && mMaterials) {
|
||||
for (unsigned int a = 0; a < mNumMaterials; ++a) {
|
||||
delete mMaterials[a];
|
||||
}
|
||||
}
|
||||
delete[] mMaterials;
|
||||
|
||||
if (mNumAnimations && mAnimations) {
|
||||
for (unsigned int a = 0; a < mNumAnimations; ++a) {
|
||||
delete mAnimations[a];
|
||||
}
|
||||
}
|
||||
delete[] mAnimations;
|
||||
|
||||
if (mNumTextures && mTextures) {
|
||||
for (unsigned int a = 0; a < mNumTextures; ++a) {
|
||||
delete mTextures[a];
|
||||
}
|
||||
}
|
||||
delete[] mTextures;
|
||||
|
||||
if (mNumLights && mLights) {
|
||||
for (unsigned int a = 0; a < mNumLights; ++a) {
|
||||
delete mLights[a];
|
||||
}
|
||||
}
|
||||
delete[] mLights;
|
||||
|
||||
if (mNumCameras && mCameras) {
|
||||
for (unsigned int a = 0; a < mNumCameras; ++a) {
|
||||
delete mCameras[a];
|
||||
}
|
||||
}
|
||||
delete[] mCameras;
|
||||
|
||||
aiMetadata::Dealloc(mMetaData);
|
||||
|
||||
delete[] mSkeletons;
|
||||
|
||||
delete static_cast<Assimp::ScenePrivateData *>(mPrivate);
|
||||
}
|
||||
|
||||
aiNode::aiNode() :
|
||||
mName(""),
|
||||
mParent(nullptr),
|
||||
|
|
|
@ -174,6 +174,95 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial *pMat,
|
|||
return AI_SUCCESS;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get an array of floating-point values from the material.
|
||||
aiReturn aiGetMaterialDoubleArray(const aiMaterial *pMat,
|
||||
const char *pKey,
|
||||
unsigned int type,
|
||||
unsigned int index,
|
||||
double *pOut,
|
||||
unsigned int *pMax) {
|
||||
ai_assert(pOut != nullptr);
|
||||
ai_assert(pMat != nullptr);
|
||||
|
||||
const aiMaterialProperty *prop;
|
||||
aiGetMaterialProperty(pMat, pKey, type, index, (const aiMaterialProperty **)&prop);
|
||||
if (nullptr == prop) {
|
||||
return AI_FAILURE;
|
||||
}
|
||||
|
||||
// data is given in floats, convert to ai_real
|
||||
unsigned int iWrite = 0;
|
||||
if (aiPTI_Float == prop->mType || aiPTI_Buffer == prop->mType) {
|
||||
iWrite = prop->mDataLength / sizeof(float);
|
||||
if (pMax) {
|
||||
iWrite = std::min(*pMax, iWrite);
|
||||
;
|
||||
}
|
||||
|
||||
for (unsigned int a = 0; a < iWrite; ++a) {
|
||||
pOut[a] = static_cast<ai_real>(reinterpret_cast<float *>(prop->mData)[a]);
|
||||
}
|
||||
|
||||
if (pMax) {
|
||||
*pMax = iWrite;
|
||||
}
|
||||
}
|
||||
// data is given in doubles, convert to float
|
||||
else if (aiPTI_Double == prop->mType) {
|
||||
iWrite = prop->mDataLength / sizeof(double);
|
||||
if (pMax) {
|
||||
iWrite = std::min(*pMax, iWrite);
|
||||
;
|
||||
}
|
||||
for (unsigned int a = 0; a < iWrite; ++a) {
|
||||
pOut[a] = static_cast<ai_real>(reinterpret_cast<double *>(prop->mData)[a]);
|
||||
}
|
||||
if (pMax) {
|
||||
*pMax = iWrite;
|
||||
}
|
||||
}
|
||||
// data is given in ints, convert to float
|
||||
else if (aiPTI_Integer == prop->mType) {
|
||||
iWrite = prop->mDataLength / sizeof(int32_t);
|
||||
if (pMax) {
|
||||
iWrite = std::min(*pMax, iWrite);
|
||||
}
|
||||
for (unsigned int a = 0; a < iWrite; ++a) {
|
||||
pOut[a] = static_cast<ai_real>(reinterpret_cast<int32_t *>(prop->mData)[a]);
|
||||
}
|
||||
if (pMax) {
|
||||
*pMax = iWrite;
|
||||
}
|
||||
}
|
||||
// a string ... read floats separated by spaces
|
||||
else {
|
||||
if (pMax) {
|
||||
iWrite = *pMax;
|
||||
}
|
||||
// strings are zero-terminated with a 32 bit length prefix, so this is safe
|
||||
const char *cur = prop->mData + 4;
|
||||
ai_assert(prop->mDataLength >= 5);
|
||||
ai_assert(!prop->mData[prop->mDataLength - 1]);
|
||||
for (unsigned int a = 0;; ++a) {
|
||||
cur = fast_atoreal_move<double>(cur, pOut[a]);
|
||||
if (a == iWrite - 1) {
|
||||
break;
|
||||
}
|
||||
if (!IsSpace(*cur)) {
|
||||
ASSIMP_LOG_ERROR("Material property", pKey,
|
||||
" is a string; failed to parse a float array out of it.");
|
||||
return AI_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (pMax) {
|
||||
*pMax = iWrite;
|
||||
}
|
||||
}
|
||||
return AI_SUCCESS;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get an array if integers from the material
|
||||
aiReturn aiGetMaterialIntegerArray(const aiMaterial *pMat,
|
||||
|
@ -486,7 +575,7 @@ aiReturn aiMaterial::AddBinaryProperty(const void *pInput,
|
|||
memcpy(pcNew->mData, pInput, pSizeInBytes);
|
||||
|
||||
pcNew->mKey.length = static_cast<ai_uint32>(::strlen(pKey));
|
||||
ai_assert(MAXLEN > pcNew->mKey.length);
|
||||
ai_assert(AI_MAXLEN > pcNew->mKey.length);
|
||||
strcpy(pcNew->mKey.data, pKey);
|
||||
|
||||
if (UINT_MAX != iOutIndex) {
|
||||
|
|
|
@ -53,7 +53,8 @@ namespace Assimp {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
LimitBoneWeightsProcess::LimitBoneWeightsProcess() : mMaxWeights(AI_LMW_MAX_WEIGHTS) {
|
||||
LimitBoneWeightsProcess::LimitBoneWeightsProcess() :
|
||||
mMaxWeights(AI_LMW_MAX_WEIGHTS), mRemoveEmptyBones(true) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode *nd, std::list<aiNode *> &n
|
|||
++it;
|
||||
}
|
||||
if (join_master && !join.empty()) {
|
||||
join_master->mName.length = ::ai_snprintf(join_master->mName.data, MAXLEN, "$MergedNode_%u", count_merged++);
|
||||
join_master->mName.length = ::ai_snprintf(join_master->mName.data, AI_MAXLEN, "$MergedNode_%u", count_merged++);
|
||||
|
||||
unsigned int out_meshes = 0;
|
||||
for (std::list<aiNode *>::const_iterator it = join.cbegin(); it != join.cend(); ++it) {
|
||||
|
|
|
@ -635,7 +635,7 @@ void PretransformVertices::Execute(aiScene *pScene) {
|
|||
aiNode *pcNode = new aiNode();
|
||||
*nodes = pcNode;
|
||||
pcNode->mParent = pScene->mRootNode;
|
||||
pcNode->mName.length = ai_snprintf(pcNode->mName.data, MAXLEN, "light_%u", i);
|
||||
pcNode->mName.length = ai_snprintf(pcNode->mName.data, AI_MAXLEN, "light_%u", i);
|
||||
pScene->mLights[i]->mName = pcNode->mName;
|
||||
}
|
||||
// generate camera nodes
|
||||
|
@ -643,7 +643,7 @@ void PretransformVertices::Execute(aiScene *pScene) {
|
|||
aiNode *pcNode = new aiNode();
|
||||
*nodes = pcNode;
|
||||
pcNode->mParent = pScene->mRootNode;
|
||||
pcNode->mName.length = ::ai_snprintf(pcNode->mName.data, MAXLEN, "cam_%u", i);
|
||||
pcNode->mName.length = ::ai_snprintf(pcNode->mName.data, AI_MAXLEN, "cam_%u", i);
|
||||
pScene->mCameras[i]->mName = pcNode->mName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) {
|
|||
if (ppcMaterials[idx]) {
|
||||
aiString sz;
|
||||
if( ppcMaterials[idx]->Get(AI_MATKEY_NAME, sz) != AI_SUCCESS ) {
|
||||
sz.length = ::ai_snprintf(sz.data,MAXLEN,"JoinedMaterial_#%u",p);
|
||||
sz.length = ::ai_snprintf(sz.data, AI_MAXLEN,"JoinedMaterial_#%u",p);
|
||||
((aiMaterial*)ppcMaterials[idx])->AddProperty(&sz,AI_MATKEY_NAME);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -390,8 +390,8 @@ void TextureTransformStep::Execute( aiScene* pScene) {
|
|||
cnt = 0;
|
||||
for (it = trafo.begin();it != trafo.end(); ++it,++cnt) {
|
||||
if ((*it).lockedPos != AI_TT_UV_IDX_LOCK_NONE && (*it).lockedPos != cnt) {
|
||||
it2 = trafo.begin();unsigned int t = 0;
|
||||
while (t != (*it).lockedPos)
|
||||
it2 = trafo.begin();
|
||||
while ((*it2).lockedPos != (*it).lockedPos)
|
||||
++it2;
|
||||
|
||||
if ((*it2).lockedPos != AI_TT_UV_IDX_LOCK_NONE) {
|
||||
|
|
|
@ -371,20 +371,7 @@ void ValidateDSProcess::Validate(const aiMesh *pMesh) {
|
|||
ReportWarning("There are unreferenced vertices");
|
||||
}
|
||||
|
||||
// texture channel 2 may not be set if channel 1 is zero ...
|
||||
{
|
||||
unsigned int i = 0;
|
||||
for (; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
|
||||
if (!pMesh->HasTextureCoords(i)) break;
|
||||
}
|
||||
for (; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i)
|
||||
if (pMesh->HasTextureCoords(i)) {
|
||||
ReportError("Texture coordinate channel %i exists "
|
||||
"although the previous channel was nullptr.",
|
||||
i);
|
||||
}
|
||||
}
|
||||
// the same for the vertex colors
|
||||
// vertex color channel 2 may not be set if channel 1 is zero ...
|
||||
{
|
||||
unsigned int i = 0;
|
||||
for (; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
|
||||
|
@ -909,9 +896,9 @@ void ValidateDSProcess::Validate(const aiNode *pNode) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ValidateDSProcess::Validate(const aiString *pString) {
|
||||
if (pString->length > MAXLEN) {
|
||||
if (pString->length > AI_MAXLEN) {
|
||||
ReportError("aiString::length is too large (%u, maximum is %lu)",
|
||||
pString->length, MAXLEN);
|
||||
pString->length, AI_MAXLEN);
|
||||
}
|
||||
const char *sz = pString->data;
|
||||
while (true) {
|
||||
|
@ -920,7 +907,7 @@ void ValidateDSProcess::Validate(const aiString *pString) {
|
|||
ReportError("aiString::data is invalid: the terminal zero is at a wrong offset");
|
||||
}
|
||||
break;
|
||||
} else if (sz >= &pString->data[MAXLEN]) {
|
||||
} else if (sz >= &pString->data[AI_MAXLEN]) {
|
||||
ReportError("aiString::data is invalid. There is no terminal character");
|
||||
}
|
||||
++sz;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "revision.h"
|
||||
#include <assimp/revision.h>
|
||||
#ifdef __GNUC__
|
||||
#include "winresrc.h"
|
||||
#else
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# tinyusdz
|
||||
"tinyusdz" C++ project provides USD/USDA/UDSC/UDSZ 3D model file format suport
|
||||
|
||||
## Automatic repo clone
|
||||
tinyusdz repo is automatically cloned. Users who haven't opted-in to USD support
|
||||
won't be burdened with the extra download volume.
|
||||
|
||||
To update te git commit hash pulled down, modify `TINYUSDZ_GIT_TAG` in file
|
||||
`code/CMakeLists.txt`
|
||||
|
||||
## Notes
|
||||
Couldn't leverage tinyusdz CMakeLists.txt. Fell back to compiling source files specified in
|
||||
"android" example.
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* Usage
|
||||
* Add line below all other #include statements:
|
||||
* #include "../../../assimp_tinyusdz_logging.inc"
|
||||
* to files:
|
||||
* - contrib/tinyusdz/tinyusdz_repo/src/tydra/render-data.cc
|
||||
* - contrib/tinyusdz/tinyusdz_repo/src/tydra/scene-access.cc
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
#include <sstream>
|
||||
#include <android/log.h>
|
||||
|
||||
#define TINYUSDZLOGT(tag, ...) ((void)__android_log_print(ANDROID_LOG_DEBUG, tag, __VA_ARGS__))
|
||||
#define TINYUSDZLOG0(tag, ...) ((void)__android_log_print(ANDROID_LOG_DEFAULT, tag, __VA_ARGS__))
|
||||
#define TINYUSDZLOGD(tag, ...) ((void)__android_log_print(ANDROID_LOG_DEBUG, tag, __VA_ARGS__))
|
||||
#define TINYUSDZLOGI(tag, ...) ((void)__android_log_print(ANDROID_LOG_INFO, tag, __VA_ARGS__))
|
||||
#define TINYUSDZLOGW(tag, ...) ((void)__android_log_print(ANDROID_LOG_WARN, tag, __VA_ARGS__))
|
||||
#define TINYUSDZLOGE(tag, ...) ((void)__android_log_print(ANDROID_LOG_ERROR, tag, __VA_ARGS__))
|
||||
#else
|
||||
#define TINYUSDZLOGT(tag, ...)
|
||||
#define TINYUSDZLOG0(tag, ...)
|
||||
#define TINYUSDZLOGD(tag, ...)
|
||||
#define TINYUSDZLOGI(tag, ...)
|
||||
#define TINYUSDZLOGW(tag, ...)
|
||||
#define TINYUSDZLOGE(tag, ...)
|
||||
#endif // #if defined(__ANDROID__)
|
||||
|
||||
#if defined(TINYUSDZ_LOCAL_DEBUG_PRINT)
|
||||
#if defined(__ANDROID__)
|
||||
#if defined(ASSIMP_USD_VERBOSE_LOGS)
|
||||
// Works well but _extremely_ verbose
|
||||
#define DCOUT(x) \
|
||||
do { \
|
||||
std::stringstream ss; \
|
||||
ss << __FILE__ << ":" << __func__ << ":" \
|
||||
<< std::to_string(__LINE__) << " " << x << "\n"; \
|
||||
TINYUSDZLOGE("tinyusdz", "%s", ss.str().c_str()); \
|
||||
} while (false)
|
||||
#else // defined(ASSIMP_USD_VERBOSE_LOGS)
|
||||
// Silent version
|
||||
#define DCOUT(x) \
|
||||
do { \
|
||||
std::stringstream ss; \
|
||||
ss << __FILE__ << ":" << __func__ << ":" \
|
||||
<< std::to_string(__LINE__) << " " << x << "\n"; \
|
||||
} while (false)
|
||||
#endif // defined(ASSIMP_USD_VERBOSE_LOGS)
|
||||
#else // defined(__ANDROID__)
|
||||
#define DCOUT(x) \
|
||||
do { \
|
||||
std::cout << __FILE__ << ":" << __func__ << ":" \
|
||||
<< std::to_string(__LINE__) << " " << x << "\n"; \
|
||||
} while (false)
|
||||
#endif // #if defined(__ANDROID__)
|
||||
#endif // #if defined(TINYUSDZ_LOCAL_DEBUG_PRINT)
|
|
@ -0,0 +1,40 @@
|
|||
# Tinyusdz patch files
|
||||
|
||||
Pending acceptance of proposed changes upstream, need to resort to patching to keep things moving
|
||||
|
||||
## Tinyusdz files needing patches
|
||||
|
||||
### `tinyusdz_repo/src/external/stb_image_resize2.h`
|
||||
Without patch, build will fail for armeabi-v7a ABI via android NDK
|
||||
|
||||
Add `#elif` block as indicated below around line `2407`
|
||||
```
|
||||
#elif defined(STBIR_WASM) || (defined(STBIR_NEON) && defined(_MSC_VER) && defined(_M_ARM)) // WASM or 32-bit ARM on MSVC/clang
|
||||
...
|
||||
#elif defined(STBIR_NEON) && (defined(__ANDROID__) && defined(__arm__)) // 32-bit ARM on android NDK
|
||||
|
||||
static stbir__inline void stbir__half_to_float_SIMD(float * output, stbir__FP16 const * input)
|
||||
{
|
||||
// TODO: this stub is just to allow build on armeabi-v7a via android NDK
|
||||
}
|
||||
|
||||
static stbir__inline void stbir__float_to_half_SIMD(stbir__FP16 * output, float const * input)
|
||||
{
|
||||
// TODO: this stub is just to allow build on armeabi-v7a via android NDK
|
||||
}
|
||||
|
||||
static stbir__inline float stbir__half_to_float( stbir__FP16 h )
|
||||
{
|
||||
// TODO: this stub is just to allow build on armeabi-v7a via android NDK
|
||||
return 0;
|
||||
}
|
||||
|
||||
static stbir__inline stbir__FP16 stbir__float_to_half( float f )
|
||||
{
|
||||
// TODO: this stub is just to allow build on armeabi-v7a via android NDK
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(STBIR_NEON) && defined(_MSC_VER) && defined(_M_ARM64) && !defined(__clang__) // 64-bit ARM on MSVC (not clang)
|
||||
```
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
diff -rupN -x .git autoclone/tinyusdz_repo-src/src/external/stb_image_resize2.h tinyusdz_repo_patch/src/external/stb_image_resize2.h
|
||||
--- autoclone/tinyusdz_repo-src/src/external/stb_image_resize2.h 2024-07-09 21:29:48.556969900 -0700
|
||||
+++ tinyusdz_repo_patch/src/external/stb_image_resize2.h 2024-07-09 23:03:47.379316700 -0700
|
||||
@@ -2404,6 +2404,38 @@ static stbir__inline stbir_uint8 stbir__
|
||||
}
|
||||
}
|
||||
|
||||
+#elif defined(STBIR_NEON) && (defined(__ANDROID__) && defined(__arm__)) // 32-bit ARM on android NDK
|
||||
+
|
||||
+ // TODO As of Apr 2024, tinyusdz doesn't support building on armeabi-v7a (32 bit arm) for android
|
||||
+ // (falls through to arm64 block and build fails)
|
||||
+ //
|
||||
+ // For assimp integration, the image processing utilities aren't used at all, so it's safe to
|
||||
+ // essentially replace the functions with dummy no-ops.
|
||||
+ //
|
||||
+ // This will need to be done manually whenever the tinyusdz source files are updated in assimp,
|
||||
+ // as it seems unlikely this will be fixed in the tinyusdz project
|
||||
+ static stbir__inline void stbir__half_to_float_SIMD(float * output, stbir__FP16 const * input)
|
||||
+ {
|
||||
+ // TODO: this stub is just to allow build on armeabi-v7a via android NDK
|
||||
+ }
|
||||
+
|
||||
+ static stbir__inline void stbir__float_to_half_SIMD(stbir__FP16 * output, float const * input)
|
||||
+ {
|
||||
+ // TODO: this stub is just to allow build on armeabi-v7a via android NDK
|
||||
+ }
|
||||
+
|
||||
+ static stbir__inline float stbir__half_to_float( stbir__FP16 h )
|
||||
+ {
|
||||
+ // TODO: this stub is just to allow build on armeabi-v7a via android NDK
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ static stbir__inline stbir__FP16 stbir__float_to_half( float f )
|
||||
+ {
|
||||
+ // TODO: this stub is just to allow build on armeabi-v7a via android NDK
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
#elif defined(STBIR_NEON) && defined(_MSC_VER) && defined(_M_ARM64) && !defined(__clang__) // 64-bit ARM on MSVC (not clang)
|
||||
|
||||
static stbir__inline void stbir__half_to_float_SIMD(float * output, stbir__FP16 const * input)
|
|
@ -5267,7 +5267,7 @@ struct mz_zip_internal_state_tag {
|
|||
(array_ptr)->m_element_size = element_size
|
||||
|
||||
#if defined(DEBUG) || defined(_DEBUG)
|
||||
static MZ_FORCEINLINE mz_uint
|
||||
static MZ_FORCEINLINE size_t
|
||||
mz_zip_array_range_check(const mz_zip_array *pArray, mz_uint index) {
|
||||
MZ_ASSERT(index < pArray->m_size);
|
||||
return index;
|
||||
|
|
|
@ -13,10 +13,14 @@
|
|||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
/* For Visual Studio only, NOT MinGW (GCC) -- ThatOSDev */
|
||||
#pragma warning( disable : 4706 )
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(_MSC_VER) || \
|
||||
defined(__MINGW32__)
|
||||
/* Win32, DOS, MSVC, MSVS */
|
||||
#pragma warning( disable : 4706 )
|
||||
/* Win32, DOS, MSVC, MSVS, MinGW(GCC for windows) */
|
||||
#include <direct.h>
|
||||
|
||||
#define STRCLONE(STR) ((STR) ? _strdup(STR) : NULL)
|
||||
|
@ -1239,7 +1243,7 @@ int zip_entry_openbyindex(struct zip_t *zip, size_t index) {
|
|||
if (!(pHeader = &MZ_ZIP_ARRAY_ELEMENT(
|
||||
&pZip->m_pState->m_central_dir, mz_uint8,
|
||||
MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets,
|
||||
mz_uint32, index)))) {
|
||||
mz_uint32, (mz_uint)index)))) {
|
||||
// cannot find header in central directory
|
||||
return ZIP_ENOHDR;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ __Importers__:
|
|||
- [STL](https://en.wikipedia.org/wiki/STL_(file_format))
|
||||
- TER
|
||||
- UC
|
||||
- [USD](https://en.wikipedia.org/wiki/Universal_Scene_Description)
|
||||
- VTA
|
||||
- X
|
||||
- [X3D](https://en.wikipedia.org/wiki/X3D)
|
||||
|
|
|
@ -277,7 +277,8 @@ public: // static utilities
|
|||
const std::string &pFile,
|
||||
const char *ext0,
|
||||
const char *ext1 = nullptr,
|
||||
const char *ext2 = nullptr);
|
||||
const char *ext2 = nullptr,
|
||||
const char *ext3 = nullptr);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Check whether a file has one of the passed file extensions
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
unsigned int pElementOffset);
|
||||
|
||||
/** Destructor */
|
||||
~SpatialSort();
|
||||
~SpatialSort() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Sets the input data for the SpatialSort. This replaces existing data, if any.
|
||||
|
|
|
@ -57,9 +57,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <iomanip>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define AI_SIZEFMT "%Iu"
|
||||
# define AI_SIZEFMT "%Iu"
|
||||
#else
|
||||
#define AI_SIZEFMT "%zu"
|
||||
# define AI_SIZEFMT "%zu"
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
@ -99,9 +99,9 @@ inline int ai_snprintf(char *outBuf, size_t size, const char *format, ...) {
|
|||
}
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
#define ai_snprintf __mingw_snprintf
|
||||
# define ai_snprintf __mingw_snprintf
|
||||
#else
|
||||
#define ai_snprintf snprintf
|
||||
# define ai_snprintf snprintf
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
@ -185,6 +185,7 @@ AI_FORCE_INLINE std::string ai_rgba2hex(int r, int g, int b, int a, bool with_he
|
|||
// ---------------------------------------------------------------------------------
|
||||
/// @brief Performs a trim from start (in place)
|
||||
/// @param s string to trim.
|
||||
// ---------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE void ai_trim_left(std::string &s) {
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
|
||||
return !std::isspace(ch);
|
||||
|
@ -195,7 +196,6 @@ AI_FORCE_INLINE void ai_trim_left(std::string &s) {
|
|||
/// @brief Performs a trim from end (in place).
|
||||
/// @param s string to trim.
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE void ai_trim_right(std::string &s) {
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
|
||||
return !std::isspace(ch);
|
||||
|
@ -214,6 +214,10 @@ AI_FORCE_INLINE std::string ai_trim(std::string &s) {
|
|||
return out;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
/// @brief Performs a to lower operation onto on single character.
|
||||
/// @param in The character
|
||||
/// @return the character as lower-case.
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE char_t ai_tolower(char_t in) {
|
||||
|
@ -233,6 +237,10 @@ AI_FORCE_INLINE std::string ai_tolower(const std::string &in) {
|
|||
return out;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
/// @brief Performs a to upper operation onto on single character.
|
||||
/// @param in The character
|
||||
/// @return the character as upper-case.
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE char_t ai_toupper(char_t in) {
|
||||
|
@ -243,6 +251,7 @@ AI_FORCE_INLINE char_t ai_toupper(char_t in) {
|
|||
/// @brief Performs a ToLower-operation and return the upper-case string.
|
||||
/// @param in The incoming string.
|
||||
/// @return The string as uppercase.
|
||||
// ---------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE std::string ai_str_toupper(const std::string &in) {
|
||||
std::string out(in);
|
||||
std::transform(out.begin(), out.end(), out.begin(), [](char c) { return ai_toupper(c); });
|
||||
|
@ -255,6 +264,7 @@ AI_FORCE_INLINE std::string ai_str_toupper(const std::string &in) {
|
|||
/// @param in The incoming string.
|
||||
/// @param placeholder Placeholder character, default is a question mark.
|
||||
/// @return The string, with all non-printable characters replaced.
|
||||
// ---------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE std::string ai_str_toprintable(const std::string &in, char placeholder = '?') {
|
||||
std::string out(in);
|
||||
std::transform(out.begin(), out.end(), out.begin(), [placeholder] (unsigned char c) {
|
||||
|
@ -271,9 +281,9 @@ AI_FORCE_INLINE std::string ai_str_toprintable(const std::string &in, char place
|
|||
/// @param placeholder Placeholder character, default is a question mark.
|
||||
/// @return The string, with all non-printable characters replaced. Will return an
|
||||
/// empty string if in is null or len is <= 0.
|
||||
// ---------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE std::string ai_str_toprintable(const char *in, int len, char placeholder = '?') {
|
||||
return (in && len > 0) ? ai_str_toprintable(std::string(in, len), placeholder) : std::string();
|
||||
}
|
||||
|
||||
|
||||
#endif // INCLUDED_AI_STRINGUTILS_H
|
||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -61,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <functional>
|
||||
|
||||
namespace Assimp {
|
||||
namespace Assimp {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// std::plus-family operates on operands with identical types - we need to
|
||||
|
@ -231,7 +230,8 @@ private:
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
/// This time binary arithmetic of v0 with a floating-point number
|
||||
template <template <typename, typename, typename> class op> static Vertex BinaryOp(const Vertex& v0, ai_real f) {
|
||||
template <template <typename, typename, typename> class op>
|
||||
static Vertex BinaryOp(const Vertex& v0, ai_real f) {
|
||||
// this is a heavy task for the compiler to optimize ... *pray*
|
||||
|
||||
Vertex res;
|
||||
|
@ -244,14 +244,15 @@ private:
|
|||
res.texcoords[i] = op<aiVector3D,ai_real,aiVector3D>()(v0.texcoords[i],f);
|
||||
}
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
|
||||
res.colors[i] = op<aiColor4D,ai_real,aiColor4D>()(v0.colors[i],f);
|
||||
res.colors[i] = op<aiColor4D,float, aiColor4D>()(v0.colors[i],f);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** This time binary arithmetic of v0 with a floating-point number */
|
||||
template <template <typename, typename, typename> class op> static Vertex BinaryOp(ai_real f, const Vertex& v0) {
|
||||
template <template <typename, typename, typename> class op>
|
||||
static Vertex BinaryOp(ai_real f, const Vertex& v0) {
|
||||
// this is a heavy task for the compiler to optimize ... *pray*
|
||||
|
||||
Vertex res;
|
||||
|
@ -264,7 +265,7 @@ private:
|
|||
res.texcoords[i] = op<ai_real,aiVector3D,aiVector3D>()(f,v0.texcoords[i]);
|
||||
}
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
|
||||
res.colors[i] = op<ai_real,aiColor4D,aiColor4D>()(f,v0.colors[i]);
|
||||
res.colors[i] = op<float, aiColor4D,aiColor4D>()(f,v0.colors[i]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#define INCLUDED_AI_IRRXML_WRAPPER
|
||||
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
||||
#include "BaseImporter.h"
|
||||
|
@ -210,21 +211,27 @@ public:
|
|||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsString(XmlNode &node, std::string &text);
|
||||
|
||||
/// @brief Will try to get the value of the node as a real.
|
||||
/// @param[in] node The node to search in.
|
||||
/// @param[out] v The value as a ai_real.
|
||||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsReal(XmlNode &node, ai_real &v);
|
||||
|
||||
/// @brief Will try to get the value of the node as a float.
|
||||
/// @param[in] node The node to search in.
|
||||
/// @param[out] text The value as a float.
|
||||
/// @param[out]v The value as a float.
|
||||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsFloat(XmlNode &node, ai_real &v);
|
||||
static inline bool getValueAsFloat(XmlNode &node, float &v);
|
||||
|
||||
/// @brief Will try to get the value of the node as an integer.
|
||||
/// @param[in] node The node to search in.
|
||||
/// @param[out] text The value as a int.
|
||||
/// @param[in] node The node to search in.
|
||||
/// @param[out] i The value as a int.
|
||||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsInt(XmlNode &node, int &v);
|
||||
|
||||
/// @brief Will try to get the value of the node as an bool.
|
||||
/// @param[in] node The node to search in.
|
||||
/// @param[out] text The value as a bool.
|
||||
/// @param[in] node The node to search in.
|
||||
/// @param[out] v The value as a bool.
|
||||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsBool(XmlNode &node, bool &v);
|
||||
|
||||
|
@ -447,12 +454,25 @@ inline bool TXmlParser<TNodeType>::getValueAsString(XmlNode &node, std::string &
|
|||
}
|
||||
|
||||
text = node.text().as_string();
|
||||
text = ai_trim(text);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getValueAsFloat(XmlNode &node, ai_real &v) {
|
||||
inline bool TXmlParser<TNodeType>::getValueAsReal(XmlNode& node, ai_real& v) {
|
||||
if (node.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
v = node.text().as_float();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getValueAsFloat(XmlNode &node, float &v) {
|
||||
if (node.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -59,6 +59,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/**
|
||||
*/
|
||||
enum aiAnimInterpolation {
|
||||
/** */
|
||||
aiAnimInterpolation_Step,
|
||||
|
||||
/** */
|
||||
aiAnimInterpolation_Linear,
|
||||
|
||||
/** */
|
||||
aiAnimInterpolation_Spherical_Linear,
|
||||
|
||||
/** */
|
||||
aiAnimInterpolation_Cubic_Spline,
|
||||
|
||||
/** */
|
||||
#ifndef SWIG
|
||||
_aiAnimInterpolation_Force32Bit = INT_MAX
|
||||
#endif
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** A time-value pair specifying a certain 3D vector for the given time. */
|
||||
struct aiVectorKey {
|
||||
|
@ -68,21 +90,18 @@ struct aiVectorKey {
|
|||
/** The value of this key */
|
||||
C_STRUCT aiVector3D mValue;
|
||||
|
||||
/** The interpolation setting of this key */
|
||||
C_ENUM aiAnimInterpolation mInterpolation;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/// @brief The default constructor.
|
||||
aiVectorKey() AI_NO_EXCEPT
|
||||
: mTime(0.0),
|
||||
mValue() {
|
||||
// empty
|
||||
}
|
||||
: mTime(0.0), mValue(), mInterpolation(aiAnimInterpolation_Linear) {}
|
||||
|
||||
/// @brief Construction from a given time and key value.
|
||||
|
||||
aiVectorKey(double time, const aiVector3D &value) :
|
||||
mTime(time), mValue(value) {
|
||||
// empty
|
||||
}
|
||||
mTime(time), mValue(value), mInterpolation(aiAnimInterpolation_Linear){}
|
||||
|
||||
typedef aiVector3D elem_type;
|
||||
|
||||
|
@ -116,16 +135,16 @@ struct aiQuatKey {
|
|||
/** The value of this key */
|
||||
C_STRUCT aiQuaternion mValue;
|
||||
|
||||
/** The interpolation setting of this key */
|
||||
C_ENUM aiAnimInterpolation mInterpolation;
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiQuatKey() AI_NO_EXCEPT
|
||||
: mTime(0.0),
|
||||
mValue() {
|
||||
// empty
|
||||
}
|
||||
: mTime(0.0), mValue(), mInterpolation(aiAnimInterpolation_Linear) {}
|
||||
|
||||
/** Construction from a given time and key value */
|
||||
aiQuatKey(double time, const aiQuaternion &value) :
|
||||
mTime(time), mValue(value) {}
|
||||
mTime(time), mValue(value), mInterpolation(aiAnimInterpolation_Linear) {}
|
||||
|
||||
typedef aiQuaternion elem_type;
|
||||
|
||||
|
|
|
@ -644,14 +644,14 @@ ASSIMP_API void aiVector2DivideByVector(
|
|||
/** Get the length of a 2D vector.
|
||||
* @return v Vector to evaluate
|
||||
*/
|
||||
ASSIMP_API float aiVector2Length(
|
||||
ASSIMP_API ai_real aiVector2Length(
|
||||
const C_STRUCT aiVector2D *v);
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Get the squared length of a 2D vector.
|
||||
* @return v Vector to evaluate
|
||||
*/
|
||||
ASSIMP_API float aiVector2SquareLength(
|
||||
ASSIMP_API ai_real aiVector2SquareLength(
|
||||
const C_STRUCT aiVector2D *v);
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
@ -667,7 +667,7 @@ ASSIMP_API void aiVector2Negate(
|
|||
* @param b Second vector
|
||||
* @return The dot product of vectors
|
||||
*/
|
||||
ASSIMP_API float aiVector2DotProduct(
|
||||
ASSIMP_API ai_real aiVector2DotProduct(
|
||||
const C_STRUCT aiVector2D *a,
|
||||
const C_STRUCT aiVector2D *b);
|
||||
|
||||
|
@ -774,14 +774,14 @@ ASSIMP_API void aiVector3DivideByVector(
|
|||
/** Get the length of a 3D vector.
|
||||
* @return v Vector to evaluate
|
||||
*/
|
||||
ASSIMP_API float aiVector3Length(
|
||||
ASSIMP_API ai_real aiVector3Length(
|
||||
const C_STRUCT aiVector3D *v);
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Get the squared length of a 3D vector.
|
||||
* @return v Vector to evaluate
|
||||
*/
|
||||
ASSIMP_API float aiVector3SquareLength(
|
||||
ASSIMP_API ai_real aiVector3SquareLength(
|
||||
const C_STRUCT aiVector3D *v);
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
@ -797,7 +797,7 @@ ASSIMP_API void aiVector3Negate(
|
|||
* @param b Second vector
|
||||
* @return The dot product of vectors
|
||||
*/
|
||||
ASSIMP_API float aiVector3DotProduct(
|
||||
ASSIMP_API ai_real aiVector3DotProduct(
|
||||
const C_STRUCT aiVector3D *a,
|
||||
const C_STRUCT aiVector3D *b);
|
||||
|
||||
|
@ -889,7 +889,7 @@ ASSIMP_API void aiMatrix3Inverse(
|
|||
/** Get the determinant of a 3x3 matrix.
|
||||
* @param mat Matrix to get the determinant from
|
||||
*/
|
||||
ASSIMP_API float aiMatrix3Determinant(
|
||||
ASSIMP_API ai_real aiMatrix3Determinant(
|
||||
const C_STRUCT aiMatrix3x3 *mat);
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
@ -999,7 +999,7 @@ ASSIMP_API void aiMatrix4Inverse(
|
|||
* @param mat Matrix to get the determinant from
|
||||
* @return The determinant of the matrix
|
||||
*/
|
||||
ASSIMP_API float aiMatrix4Determinant(
|
||||
ASSIMP_API ai_real aiMatrix4Determinant(
|
||||
const C_STRUCT aiMatrix4x4 *mat);
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
|
|
@ -88,12 +88,12 @@ public:
|
|||
TReal r, g, b, a;
|
||||
}; // !struct aiColor4D
|
||||
|
||||
typedef aiColor4t<ai_real> aiColor4D;
|
||||
typedef aiColor4t<float> aiColor4D;
|
||||
|
||||
#else
|
||||
|
||||
struct aiColor4D {
|
||||
ai_real r, g, b, a;
|
||||
float r, g, b, a;
|
||||
};
|
||||
|
||||
#endif // __cplusplus
|
||||
|
|
|
@ -196,15 +196,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#ifdef __cplusplus
|
||||
/* No explicit 'struct' and 'enum' tags for C++, this keeps showing up
|
||||
* in doxydocs.
|
||||
*/
|
||||
* in doxydocs. */
|
||||
#define C_STRUCT
|
||||
#define C_ENUM
|
||||
#else
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/* To build the documentation, make sure ASSIMP_DOXYGEN_BUILD
|
||||
* is defined by Doxygen's preprocessor. The corresponding
|
||||
* entries in the DOXYFILE are: */
|
||||
* is defined by Doxygen's preprocessor. The corresponding
|
||||
* entries in the DOXYFILE are: */
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#if 0
|
||||
ENABLE_PREPROCESSING = YES
|
||||
|
@ -251,7 +250,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/* Define ASSIMP_DOUBLE_PRECISION to compile assimp
|
||||
* with double precision support (64-bit). */
|
||||
* with double precision support (64-bit). */
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef ASSIMP_DOUBLE_PRECISION
|
||||
|
@ -343,4 +342,4 @@ constexpr ai_real ai_epsilon = (ai_real) 1e-6;
|
|||
|
||||
#define AI_COUNT_OF(X) (sizeof(X) / sizeof((X)[0]))
|
||||
|
||||
#endif // !! AI_DEFINES_H_INC
|
||||
#endif // !! AI_DEFINES_H_INC
|
||||
|
|
|
@ -1527,7 +1527,7 @@ ASSIMP_API C_ENUM aiReturn aiGetMaterialFloatArray(
|
|||
const char *pKey,
|
||||
unsigned int type,
|
||||
unsigned int index,
|
||||
ai_real *pOut,
|
||||
float *pOut,
|
||||
unsigned int *pMax);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -1553,7 +1553,7 @@ inline aiReturn aiGetMaterialFloat(const C_STRUCT aiMaterial *pMat,
|
|||
const char *pKey,
|
||||
unsigned int type,
|
||||
unsigned int index,
|
||||
ai_real *pOut) {
|
||||
float *pOut) {
|
||||
return aiGetMaterialFloatArray(pMat, pKey, type, index, pOut, (unsigned int *)0x0);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::GetTexture( aiTextureType type,
|
|||
C_STRUCT aiString* path,
|
||||
aiTextureMapping* mapping /*= NULL*/,
|
||||
unsigned int* uvindex /*= NULL*/,
|
||||
ai_real* blend /*= NULL*/,
|
||||
float* blend /*= NULL*/,
|
||||
aiTextureOp* op /*= NULL*/,
|
||||
aiTextureMapMode* mapmode /*= NULL*/) const {
|
||||
return ::aiGetMaterialTexture(this,type,index,path,mapping,uvindex,blend,op,mapmode);
|
||||
|
@ -136,9 +136,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
|||
// Specialisation for a single bool.
|
||||
// Casts floating point and integer to bool
|
||||
template <>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn
|
||||
aiMaterial::Get(const char *pKey, unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char *pKey, unsigned int type,
|
||||
unsigned int idx, bool &pOut) const {
|
||||
const aiMaterialProperty *prop;
|
||||
const aiReturn ret = ::aiGetMaterialProperty(this, pKey, type, idx,
|
||||
|
@ -193,7 +191,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
|||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,ai_real& pOut) const {
|
||||
unsigned int idx, float& pOut) const {
|
||||
return aiGetMaterialFloat(this,pKey,type,idx,&pOut);
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -312,7 +310,6 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const int* pInput,
|
|||
pKey,type,index,aiPTI_Integer);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// The template specializations below are for backwards compatibility.
|
||||
// The recommended way to add material properties is using the non-template
|
||||
|
|
|
@ -729,8 +729,9 @@ struct aiMesh {
|
|||
/**
|
||||
* @brief Vertex texture coordinates, also known as UV channels.
|
||||
*
|
||||
* A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
|
||||
* vertex. nullptr if not present. The array is mNumVertices in size.
|
||||
* A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS channels per
|
||||
* vertex. Used and unused (nullptr) channels may go in any order.
|
||||
* The array is mNumVertices in size.
|
||||
*/
|
||||
C_STRUCT aiVector3D *mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||
|
||||
|
@ -950,8 +951,10 @@ struct aiMesh {
|
|||
//! @return the number of stored uv-channels.
|
||||
unsigned int GetNumUVChannels() const {
|
||||
unsigned int n(0);
|
||||
while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n]) {
|
||||
++n;
|
||||
for (unsigned i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++) {
|
||||
if (mTextureCoords[i]) {
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
|
|
|
@ -113,19 +113,19 @@ struct aiMetadata;
|
|||
*/
|
||||
// -------------------------------------------------------------------------------
|
||||
|
||||
inline aiMetadataType GetAiType(bool) {
|
||||
inline aiMetadataType GetAiType(const bool &) {
|
||||
return AI_BOOL;
|
||||
}
|
||||
inline aiMetadataType GetAiType(int32_t) {
|
||||
return AI_INT32;
|
||||
}
|
||||
inline aiMetadataType GetAiType(uint64_t) {
|
||||
inline aiMetadataType GetAiType(const uint64_t &) {
|
||||
return AI_UINT64;
|
||||
}
|
||||
inline aiMetadataType GetAiType(float) {
|
||||
inline aiMetadataType GetAiType(const float &) {
|
||||
return AI_FLOAT;
|
||||
}
|
||||
inline aiMetadataType GetAiType(double) {
|
||||
inline aiMetadataType GetAiType(const double &) {
|
||||
return AI_DOUBLE;
|
||||
}
|
||||
inline aiMetadataType GetAiType(const aiString &) {
|
||||
|
@ -137,10 +137,10 @@ inline aiMetadataType GetAiType(const aiVector3D &) {
|
|||
inline aiMetadataType GetAiType(const aiMetadata &) {
|
||||
return AI_AIMETADATA;
|
||||
}
|
||||
inline aiMetadataType GetAiType(int64_t) {
|
||||
inline aiMetadataType GetAiType(const int64_t &) {
|
||||
return AI_INT64;
|
||||
}
|
||||
inline aiMetadataType GetAiType(uint32_t) {
|
||||
inline aiMetadataType GetAiType(const uint32_t &) {
|
||||
return AI_UINT32;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue