mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
update assimp lib
This commit is contained in:
parent
03a348deb7
commit
d3f8fee74e
1725 changed files with 196314 additions and 62009 deletions
124
Engine/lib/assimp/code/AssetLib/USD/USDLoader.cpp
Normal file
124
Engine/lib/assimp/code/AssetLib/USD/USDLoader.cpp
Normal file
|
|
@ -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
|
||||
|
||||
78
Engine/lib/assimp/code/AssetLib/USD/USDLoader.h
Normal file
78
Engine/lib/assimp/code/AssetLib/USD/USDLoader.h
Normal file
|
|
@ -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
|
||||
1001
Engine/lib/assimp/code/AssetLib/USD/USDLoaderImplTinyusdz.cpp
Normal file
1001
Engine/lib/assimp/code/AssetLib/USD/USDLoaderImplTinyusdz.cpp
Normal file
File diff suppressed because it is too large
Load diff
160
Engine/lib/assimp/code/AssetLib/USD/USDLoaderImplTinyusdz.h
Normal file
160
Engine/lib/assimp/code/AssetLib/USD/USDLoaderImplTinyusdz.h
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
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 animations(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
aiScene *pScene);
|
||||
|
||||
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,
|
||||
const std::string &nameWExt);
|
||||
|
||||
aiNode *nodes(
|
||||
const tinyusdz::tydra::RenderScene &render_scene,
|
||||
const std::string &nameWExt);
|
||||
|
||||
aiNode *nodesRecursive(
|
||||
aiNode *pNodeParent,
|
||||
const tinyusdz::tydra::Node &node,
|
||||
const std::vector<tinyusdz::tydra::SkelHierarchy> &skeletons);
|
||||
|
||||
aiNode *skeletonNodesRecursive(
|
||||
aiNode *pNodeParent,
|
||||
const tinyusdz::tydra::SkelNode &joint);
|
||||
|
||||
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,114 @@
|
|||
/*
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
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,92 @@
|
|||
/*
|
||||
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"
|
||||
#include <type_traits>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
std::string tinyusdzAnimChannelTypeFor(
|
||||
tinyusdz::tydra::AnimationChannel::ChannelType animChannel);
|
||||
std::string tinyusdzNodeTypeFor(tinyusdz::tydra::NodeType type);
|
||||
|
||||
template <typename T>
|
||||
aiMatrix4x4 tinyUsdzMat4ToAiMat4(const T matIn[4][4]) {
|
||||
static_assert(std::is_floating_point_v<T>, "Only floating-point types are allowed.");
|
||||
aiMatrix4x4 matOut;
|
||||
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 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
|
||||
116
Engine/lib/assimp/code/AssetLib/USD/USDLoaderUtil.cpp
Normal file
116
Engine/lib/assimp/code/AssetLib/USD/USDLoaderUtil.cpp
Normal file
|
|
@ -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
|
||||
60
Engine/lib/assimp/code/AssetLib/USD/USDLoaderUtil.h
Normal file
60
Engine/lib/assimp/code/AssetLib/USD/USDLoaderUtil.h
Normal file
|
|
@ -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
|
||||
50
Engine/lib/assimp/code/AssetLib/USD/USDPreprocessor.h
Normal file
50
Engine/lib/assimp/code/AssetLib/USD/USDPreprocessor.h
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue