Move duplicate code to glFT common header.
parent
18531e3677
commit
0fef0e1101
|
@ -51,14 +51,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_IMPORTER)
|
||||
|
||||
#include "glTFCommon.h"
|
||||
#include <assimp/Exceptional.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// clang-format off
|
||||
|
||||
#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
|
||||
#pragma GCC diagnostic push
|
||||
|
@ -99,15 +101,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# endif
|
||||
#endif
|
||||
|
||||
// clang-format on
|
||||
|
||||
#include "AssetLib/glTF/glTFCommon.h"
|
||||
|
||||
namespace glTF {
|
||||
using glTFCommon::shared_ptr;
|
||||
using glTFCommon::IOSystem;
|
||||
using glTFCommon::IOStream;
|
||||
|
||||
using rapidjson::Value;
|
||||
using glTFCommon::IOStream;
|
||||
using glTFCommon::IOSystem;
|
||||
using glTFCommon::Nullable;
|
||||
using glTFCommon::Ref;
|
||||
using glTFCommon::shared_ptr;
|
||||
|
||||
using rapidjson::Document;
|
||||
using rapidjson::Value;
|
||||
|
||||
class Asset;
|
||||
class AssetWriter;
|
||||
|
@ -117,16 +124,18 @@ namespace glTF {
|
|||
struct Light;
|
||||
struct Skin;
|
||||
|
||||
using glTFCommon::mat4;
|
||||
using glTFCommon::vec3;
|
||||
using glTFCommon::vec4;
|
||||
using glTFCommon::mat4;
|
||||
|
||||
//! Magic number for GLB files
|
||||
#define AI_GLB_MAGIC_NUMBER "glTF"
|
||||
|
||||
// clang-format off
|
||||
#ifdef ASSIMP_API
|
||||
# include <assimp/Compiler/pushpack1.h>
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
//! For the KHR_binary_glTF extension (binary .glb file)
|
||||
//! 20-byte header (+ the JSON + a "body" data section)
|
||||
|
@ -138,10 +147,11 @@ namespace glTF {
|
|||
uint32_t sceneFormat; //!< Specifies the format of the glTF scene (see the SceneFormat enum)
|
||||
} PACK_STRUCT;
|
||||
|
||||
// clang-format off
|
||||
#ifdef ASSIMP_API
|
||||
# include <assimp/Compiler/poppack1.h>
|
||||
#endif
|
||||
|
||||
// clang-format on
|
||||
|
||||
//! Values for the GLB_Header::sceneFormat field
|
||||
enum SceneFormat {
|
||||
|
@ -220,8 +230,7 @@ namespace glTF {
|
|||
};
|
||||
|
||||
//! Values for the Texture::format and Texture::internalFormat fields
|
||||
enum TextureFormat
|
||||
{
|
||||
enum TextureFormat {
|
||||
TextureFormat_ALPHA = 6406,
|
||||
TextureFormat_RGB = 6407,
|
||||
TextureFormat_RGBA = 6408,
|
||||
|
@ -230,40 +239,42 @@ namespace glTF {
|
|||
};
|
||||
|
||||
//! Values for the Texture::target field
|
||||
enum TextureTarget
|
||||
{
|
||||
enum TextureTarget {
|
||||
TextureTarget_TEXTURE_2D = 3553
|
||||
};
|
||||
|
||||
//! Values for the Texture::type field
|
||||
enum TextureType
|
||||
{
|
||||
enum TextureType {
|
||||
TextureType_UNSIGNED_BYTE = 5121,
|
||||
TextureType_UNSIGNED_SHORT_5_6_5 = 33635,
|
||||
TextureType_UNSIGNED_SHORT_4_4_4_4 = 32819,
|
||||
TextureType_UNSIGNED_SHORT_5_5_5_1 = 32820
|
||||
};
|
||||
|
||||
|
||||
//! Values for the Accessor::type field (helper class)
|
||||
class AttribType
|
||||
{
|
||||
class AttribType {
|
||||
public:
|
||||
enum Value
|
||||
{ SCALAR, VEC2, VEC3, VEC4, MAT2, MAT3, MAT4 };
|
||||
enum Value { SCALAR,
|
||||
VEC2,
|
||||
VEC3,
|
||||
VEC4,
|
||||
MAT2,
|
||||
MAT3,
|
||||
MAT4 };
|
||||
|
||||
private:
|
||||
static const size_t NUM_VALUES = static_cast<size_t>(MAT4) + 1;
|
||||
|
||||
struct Info
|
||||
{ const char* name; unsigned int numComponents; };
|
||||
struct Info {
|
||||
const char *name;
|
||||
unsigned int numComponents;
|
||||
};
|
||||
|
||||
template<int N> struct data
|
||||
{ static const Info infos[NUM_VALUES]; };
|
||||
template <int N>
|
||||
struct data { static const Info infos[NUM_VALUES]; };
|
||||
|
||||
public:
|
||||
inline static Value FromString(const char* str)
|
||||
{
|
||||
inline static Value FromString(const char *str) {
|
||||
for (size_t i = 0; i < NUM_VALUES; ++i) {
|
||||
if (strcmp(data<0>::infos[i].name, str) == 0) {
|
||||
return static_cast<Value>(i);
|
||||
|
@ -272,25 +283,23 @@ namespace glTF {
|
|||
return SCALAR;
|
||||
}
|
||||
|
||||
inline static const char* ToString(Value type)
|
||||
{
|
||||
inline static const char *ToString(Value type) {
|
||||
return data<0>::infos[static_cast<size_t>(type)].name;
|
||||
}
|
||||
|
||||
inline static unsigned int GetNumComponents(Value type)
|
||||
{
|
||||
inline static unsigned int GetNumComponents(Value type) {
|
||||
return data<0>::infos[static_cast<size_t>(type)].numComponents;
|
||||
}
|
||||
};
|
||||
|
||||
// must match the order of the AttribTypeTraits::Value enum!
|
||||
template<int N> const AttribType::Info
|
||||
template <int N>
|
||||
const AttribType::Info
|
||||
AttribType::data<N>::infos[AttribType::NUM_VALUES] = {
|
||||
{ "SCALAR", 1 }, { "VEC2", 2 }, { "VEC3", 3 }, { "VEC4", 4 }, { "MAT2", 4 }, { "MAT3", 9 }, { "MAT4", 16 }
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
//! A reference to one top-level object, which is valid
|
||||
//! until the Asset instance is destroyed
|
||||
template<class T>
|
||||
|
@ -314,35 +323,20 @@ namespace glTF {
|
|||
|
||||
T& operator*()
|
||||
{ return *((*vector)[index]); }
|
||||
};
|
||||
|
||||
//! Helper struct to represent values that might not be present
|
||||
template<class T>
|
||||
struct Nullable
|
||||
{
|
||||
T value;
|
||||
bool isPresent;
|
||||
|
||||
Nullable() : isPresent(false) {}
|
||||
Nullable(T& val) : value(val), isPresent(true) {}
|
||||
};
|
||||
|
||||
};*/
|
||||
|
||||
//! Base class for all glTF top-level objects
|
||||
struct Object
|
||||
{
|
||||
struct Object {
|
||||
std::string id; //!< The globally unique ID used to reference this object
|
||||
std::string name; //!< The user-defined name of this object
|
||||
|
||||
//! Objects marked as special are not exported (used to emulate the binary body buffer)
|
||||
virtual bool IsSpecial() const
|
||||
{ return false; }
|
||||
virtual bool IsSpecial() const { return false; }
|
||||
|
||||
virtual ~Object() {}
|
||||
|
||||
//! Maps special IDs to another ID, where needed. Subclasses may override it (statically)
|
||||
static const char* TranslateId(Asset& /*r*/, const char* id)
|
||||
{ return id; }
|
||||
static const char *TranslateId(Asset & /*r*/, const char *id) { return id; }
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -352,8 +346,7 @@ namespace glTF {
|
|||
//! A typed view into a BufferView. A BufferView contains raw binary data.
|
||||
//! An accessor provides a typed view into a BufferView or a subset of a BufferView
|
||||
//! similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer.
|
||||
struct Accessor : public Object
|
||||
{
|
||||
struct Accessor : public Object {
|
||||
Ref<BufferView> bufferView; //!< The ID of the bufferView. (required)
|
||||
unsigned int byteOffset; //!< The offset relative to the start of the bufferView in bytes. (required)
|
||||
unsigned int byteStride; //!< The stride, in bytes, between attributes referenced by this accessor. (default: 0)
|
||||
|
@ -375,8 +368,7 @@ namespace glTF {
|
|||
void WriteData(size_t count, const void *src_buffer, size_t src_stride);
|
||||
|
||||
//! Helper class to iterate the data
|
||||
class Indexer
|
||||
{
|
||||
class Indexer {
|
||||
friend struct Accessor;
|
||||
|
||||
// This field is reported as not used, making it protectd is the easiest way to work around it without going to the bottom of what the problem is:
|
||||
|
@ -391,25 +383,21 @@ namespace glTF {
|
|||
Indexer(Accessor &acc);
|
||||
|
||||
public:
|
||||
|
||||
//! Accesses the i-th value as defined by the accessor
|
||||
template <class T>
|
||||
T GetValue(int i);
|
||||
|
||||
//! Accesses the i-th value as defined by the accessor
|
||||
inline unsigned int GetUInt(int i)
|
||||
{
|
||||
inline unsigned int GetUInt(int i) {
|
||||
return GetValue<unsigned int>(i);
|
||||
}
|
||||
|
||||
inline bool IsValid() const
|
||||
{
|
||||
inline bool IsValid() const {
|
||||
return data != 0;
|
||||
}
|
||||
};
|
||||
|
||||
inline Indexer GetIndexer()
|
||||
{
|
||||
inline Indexer GetIndexer() {
|
||||
return Indexer(*this);
|
||||
}
|
||||
|
||||
|
@ -418,21 +406,17 @@ namespace glTF {
|
|||
};
|
||||
|
||||
//! A buffer points to binary geometry, animation, or skins.
|
||||
struct Buffer : public Object
|
||||
{
|
||||
struct Buffer : public Object {
|
||||
/********************* Types *********************/
|
||||
public:
|
||||
|
||||
enum Type
|
||||
{
|
||||
enum Type {
|
||||
Type_arraybuffer,
|
||||
Type_text
|
||||
};
|
||||
|
||||
/// \struct SEncodedRegion
|
||||
/// Descriptor of encoded region in "bufferView".
|
||||
struct SEncodedRegion
|
||||
{
|
||||
struct SEncodedRegion {
|
||||
const size_t Offset; ///< Offset from begin of "bufferView" to encoded region, in bytes.
|
||||
const size_t EncodedData_Length; ///< Size of encoded region, in bytes.
|
||||
uint8_t *const DecodedData; ///< Cached encoded data.
|
||||
|
@ -485,7 +469,6 @@ namespace glTF {
|
|||
SEncodedRegion *EncodedRegion_Current;
|
||||
|
||||
private:
|
||||
|
||||
shared_ptr<uint8_t> mData; //!< Pointer to the data
|
||||
bool mIsSpecial; //!< Set to true for special cases (e.g. the body buffer)
|
||||
size_t capacity = 0; //!< The capacity of the buffer in bytes. (default: 0)
|
||||
|
@ -496,7 +479,6 @@ namespace glTF {
|
|||
/******************* Functions *******************/
|
||||
|
||||
public:
|
||||
|
||||
Buffer();
|
||||
~Buffer();
|
||||
|
||||
|
@ -530,24 +512,19 @@ namespace glTF {
|
|||
size_t AppendData(uint8_t *data, size_t length);
|
||||
void Grow(size_t amount);
|
||||
|
||||
uint8_t* GetPointer()
|
||||
{ return mData.get(); }
|
||||
uint8_t *GetPointer() { return mData.get(); }
|
||||
|
||||
void MarkAsSpecial()
|
||||
{ mIsSpecial = true; }
|
||||
void MarkAsSpecial() { mIsSpecial = true; }
|
||||
|
||||
bool IsSpecial() const
|
||||
{ return mIsSpecial; }
|
||||
bool IsSpecial() const { return mIsSpecial; }
|
||||
|
||||
std::string GetURI()
|
||||
{ return std::string(this->id) + ".bin"; }
|
||||
std::string GetURI() { return std::string(this->id) + ".bin"; }
|
||||
|
||||
static const char *TranslateId(Asset &r, const char *id);
|
||||
};
|
||||
|
||||
//! A view into a buffer generally representing a subset of the buffer.
|
||||
struct BufferView : public Object
|
||||
{
|
||||
struct BufferView : public Object {
|
||||
Ref<Buffer> buffer; //! The ID of the buffer. (required)
|
||||
size_t byteOffset; //! The offset into the buffer in bytes. (required)
|
||||
size_t byteLength; //! The length of the bufferView in bytes. (default: 0)
|
||||
|
@ -557,18 +534,15 @@ namespace glTF {
|
|||
void Read(Value &obj, Asset &r);
|
||||
};
|
||||
|
||||
struct Camera : public Object
|
||||
{
|
||||
enum Type
|
||||
{
|
||||
struct Camera : public Object {
|
||||
enum Type {
|
||||
Perspective,
|
||||
Orthographic
|
||||
};
|
||||
|
||||
Type type;
|
||||
|
||||
union
|
||||
{
|
||||
union {
|
||||
struct {
|
||||
float aspectRatio; //!<The floating - point aspect ratio of the field of view. (0 = undefined = use the canvas one)
|
||||
float yfov; //!<The floating - point vertical field of view in radians. (required)
|
||||
|
@ -588,10 +562,8 @@ namespace glTF {
|
|||
void Read(Value &obj, Asset &r);
|
||||
};
|
||||
|
||||
|
||||
//! Image data used to create a texture.
|
||||
struct Image : public Object
|
||||
{
|
||||
struct Image : public Object {
|
||||
std::string uri; //! The uri of the image, that can be a file path, a data URI, etc.. (required)
|
||||
|
||||
Ref<BufferView> bufferView;
|
||||
|
@ -605,18 +577,14 @@ namespace glTF {
|
|||
size_t mDataLength;
|
||||
|
||||
public:
|
||||
|
||||
Image();
|
||||
void Read(Value &obj, Asset &r);
|
||||
|
||||
inline bool HasData() const
|
||||
{ return mDataLength > 0; }
|
||||
inline bool HasData() const { return mDataLength > 0; }
|
||||
|
||||
inline size_t GetDataLength() const
|
||||
{ return mDataLength; }
|
||||
inline size_t GetDataLength() const { return mDataLength; }
|
||||
|
||||
inline const uint8_t* GetData() const
|
||||
{ return mData.get(); }
|
||||
inline const uint8_t *GetData() const { return mData.get(); }
|
||||
|
||||
inline uint8_t *StealData();
|
||||
|
||||
|
@ -624,21 +592,18 @@ namespace glTF {
|
|||
};
|
||||
|
||||
//! Holds a material property that can be a texture or a color
|
||||
struct TexProperty
|
||||
{
|
||||
struct TexProperty {
|
||||
Ref<Texture> texture;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
//! The material appearance of a primitive.
|
||||
struct Material : public Object
|
||||
{
|
||||
struct Material : public Object {
|
||||
//Ref<Sampler> source; //!< The ID of the technique.
|
||||
//std::gltf_unordered_map<std::string, std::string> values; //!< A dictionary object of parameter values.
|
||||
|
||||
//! Techniques defined by KHR_materials_common
|
||||
enum Technique
|
||||
{
|
||||
enum Technique {
|
||||
Technique_undefined = 0,
|
||||
Technique_BLINN,
|
||||
Technique_PHONG,
|
||||
|
@ -664,12 +629,10 @@ namespace glTF {
|
|||
};
|
||||
|
||||
//! A set of primitives to be rendered. A node can contain one or more meshes. A node's transform places the mesh in the scene.
|
||||
struct Mesh : public Object
|
||||
{
|
||||
struct Mesh : public Object {
|
||||
typedef std::vector<Ref<Accessor>> AccessorList;
|
||||
|
||||
struct Primitive
|
||||
{
|
||||
struct Primitive {
|
||||
PrimitiveMode mode;
|
||||
|
||||
struct Attributes {
|
||||
|
@ -683,12 +646,10 @@ namespace glTF {
|
|||
|
||||
/// \struct SExtension
|
||||
/// Extension used for mesh.
|
||||
struct SExtension
|
||||
{
|
||||
struct SExtension {
|
||||
/// \enum EType
|
||||
/// Type of extension.
|
||||
enum EType
|
||||
{
|
||||
enum EType {
|
||||
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
|
||||
Compression_Open3DGC, ///< Compression of mesh data using Open3DGC algorithm.
|
||||
#endif
|
||||
|
@ -701,9 +662,8 @@ namespace glTF {
|
|||
/// \fn SExtension
|
||||
/// Constructor.
|
||||
/// \param [in] pType - type of extension.
|
||||
SExtension(const EType pType)
|
||||
: Type(pType)
|
||||
{}
|
||||
SExtension(const EType pType) :
|
||||
Type(pType) {}
|
||||
|
||||
virtual ~SExtension() {
|
||||
// empty
|
||||
|
@ -713,8 +673,7 @@ namespace glTF {
|
|||
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
|
||||
/// \struct SCompression_Open3DGC
|
||||
/// Compression of mesh data using Open3DGC algorithm.
|
||||
struct SCompression_Open3DGC : public SExtension
|
||||
{
|
||||
struct SCompression_Open3DGC : public SExtension {
|
||||
using SExtension::Type;
|
||||
|
||||
std::string Buffer; ///< ID of "buffer" used for storing compressed data.
|
||||
|
@ -728,8 +687,8 @@ namespace glTF {
|
|||
|
||||
/// \fn SCompression_Open3DGC
|
||||
/// Constructor.
|
||||
SCompression_Open3DGC()
|
||||
: SExtension(Compression_Open3DGC) {
|
||||
SCompression_Open3DGC() :
|
||||
SExtension(Compression_Open3DGC) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
@ -746,7 +705,11 @@ namespace glTF {
|
|||
|
||||
/// \fn ~Mesh()
|
||||
/// Destructor.
|
||||
~Mesh() { for(std::list<SExtension*>::iterator it = Extension.begin(), it_end = Extension.end(); it != it_end; it++) { delete *it; }; }
|
||||
~Mesh() {
|
||||
for (std::list<SExtension *>::iterator it = Extension.begin(), it_end = Extension.end(); it != it_end; it++) {
|
||||
delete *it;
|
||||
};
|
||||
}
|
||||
|
||||
/// \fn void Read(Value& pJSON_Object, Asset& pAsset_Root)
|
||||
/// Get mesh data from JSON-object and place them to root asset.
|
||||
|
@ -763,8 +726,7 @@ namespace glTF {
|
|||
#endif
|
||||
};
|
||||
|
||||
struct Node : public Object
|
||||
{
|
||||
struct Node : public Object {
|
||||
std::vector<Ref<Node>> children;
|
||||
std::vector<Ref<Mesh>> meshes;
|
||||
|
||||
|
@ -786,15 +748,12 @@ namespace glTF {
|
|||
void Read(Value &obj, Asset &r);
|
||||
};
|
||||
|
||||
struct Program : public Object
|
||||
{
|
||||
struct Program : public Object {
|
||||
Program() {}
|
||||
void Read(Value &obj, Asset &r);
|
||||
};
|
||||
|
||||
|
||||
struct Sampler : public Object
|
||||
{
|
||||
struct Sampler : public Object {
|
||||
SamplerMagFilter magFilter; //!< The texture magnification filter. (required)
|
||||
SamplerMinFilter minFilter; //!< The texture minification filter. (required)
|
||||
SamplerWrap wrapS; //!< The texture wrapping in the S direction. (required)
|
||||
|
@ -805,22 +764,19 @@ namespace glTF {
|
|||
void SetDefaults();
|
||||
};
|
||||
|
||||
struct Scene : public Object
|
||||
{
|
||||
struct Scene : public Object {
|
||||
std::vector<Ref<Node>> nodes;
|
||||
|
||||
Scene() {}
|
||||
void Read(Value &obj, Asset &r);
|
||||
};
|
||||
|
||||
struct Shader : public Object
|
||||
{
|
||||
struct Shader : public Object {
|
||||
Shader() {}
|
||||
void Read(Value &obj, Asset &r);
|
||||
};
|
||||
|
||||
struct Skin : public Object
|
||||
{
|
||||
struct Skin : public Object {
|
||||
Nullable<mat4> bindShapeMatrix; //!< Floating-point 4x4 transformation matrix stored in column-major order.
|
||||
Ref<Accessor> inverseBindMatrices; //!< The ID of the accessor containing the floating-point 4x4 inverse-bind matrices.
|
||||
std::vector<Ref<Node>> jointNames; //!< Joint names of the joints (nodes with a jointName property) in this skin.
|
||||
|
@ -830,21 +786,14 @@ namespace glTF {
|
|||
void Read(Value &obj, Asset &r);
|
||||
};
|
||||
|
||||
struct Technique : public Object
|
||||
{
|
||||
struct Parameters
|
||||
{
|
||||
|
||||
struct Technique : public Object {
|
||||
struct Parameters {
|
||||
};
|
||||
|
||||
struct States
|
||||
{
|
||||
|
||||
struct States {
|
||||
};
|
||||
|
||||
struct Functions
|
||||
{
|
||||
|
||||
struct Functions {
|
||||
};
|
||||
|
||||
Technique() {}
|
||||
|
@ -852,8 +801,7 @@ namespace glTF {
|
|||
};
|
||||
|
||||
//! A texture and its sampler.
|
||||
struct Texture : public Object
|
||||
{
|
||||
struct Texture : public Object {
|
||||
Ref<Sampler> sampler; //!< The ID of the sampler used by this texture. (required)
|
||||
Ref<Image> source; //!< The ID of the image used by this texture. (required)
|
||||
|
||||
|
@ -867,12 +815,9 @@ namespace glTF {
|
|||
void Read(Value &obj, Asset &r);
|
||||
};
|
||||
|
||||
|
||||
//! A light (from KHR_materials_common extension)
|
||||
struct Light : public Object
|
||||
{
|
||||
enum Type
|
||||
{
|
||||
struct Light : public Object {
|
||||
enum Type {
|
||||
Type_undefined,
|
||||
Type_ambient,
|
||||
Type_directional,
|
||||
|
@ -896,8 +841,7 @@ namespace glTF {
|
|||
void SetDefaults();
|
||||
};
|
||||
|
||||
struct Animation : public Object
|
||||
{
|
||||
struct Animation : public Object {
|
||||
struct AnimSampler {
|
||||
std::string id; //!< The ID of this sampler.
|
||||
std::string input; //!< The ID of a parameter in this animation to use as key-frame input.
|
||||
|
@ -933,10 +877,8 @@ namespace glTF {
|
|||
void Read(Value &obj, Asset &r);
|
||||
};
|
||||
|
||||
|
||||
//! Base class for LazyDict that acts as an interface
|
||||
class LazyDictBase
|
||||
{
|
||||
class LazyDictBase {
|
||||
public:
|
||||
virtual ~LazyDictBase() {}
|
||||
|
||||
|
@ -948,7 +890,6 @@ namespace glTF {
|
|||
#endif
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class LazyDict;
|
||||
|
||||
|
@ -956,12 +897,10 @@ namespace glTF {
|
|||
template <class T>
|
||||
void WriteLazyDict(LazyDict<T> &d, AssetWriter &w);
|
||||
|
||||
|
||||
//! Manages lazy loading of the glTF top-level objects, and keeps a reference to them by ID
|
||||
//! It is the owner the loaded objects, so when it is destroyed it also deletes them
|
||||
template <class T>
|
||||
class LazyDict : public LazyDictBase
|
||||
{
|
||||
class LazyDict : public LazyDictBase {
|
||||
friend class Asset;
|
||||
friend class AssetWriter;
|
||||
|
||||
|
@ -978,8 +917,7 @@ namespace glTF {
|
|||
void DetachFromDocument();
|
||||
|
||||
#if !defined(ASSIMP_BUILD_NO_EXPORT)
|
||||
void WriteObjects(AssetWriter& writer)
|
||||
{ WriteLazyDict<T>(*this, writer); }
|
||||
void WriteObjects(AssetWriter &writer) { WriteLazyDict<T>(*this, writer); }
|
||||
#endif
|
||||
|
||||
Ref<T> Add(T *obj);
|
||||
|
@ -993,20 +931,14 @@ namespace glTF {
|
|||
Ref<T> Get(const std::string &pID) { return Get(pID.c_str()); }
|
||||
|
||||
Ref<T> Create(const char *id);
|
||||
Ref<T> Create(const std::string& id)
|
||||
{ return Create(id.c_str()); }
|
||||
Ref<T> Create(const std::string &id) { return Create(id.c_str()); }
|
||||
|
||||
inline unsigned int Size() const
|
||||
{ return unsigned(mObjs.size()); }
|
||||
|
||||
inline T& operator[](size_t i)
|
||||
{ return *mObjs[i]; }
|
||||
inline unsigned int Size() const { return unsigned(mObjs.size()); }
|
||||
|
||||
inline T &operator[](size_t i) { return *mObjs[i]; }
|
||||
};
|
||||
|
||||
|
||||
struct AssetMetadata
|
||||
{
|
||||
struct AssetMetadata {
|
||||
std::string copyright; //!< A copyright message suitable for display to credit the content creator.
|
||||
std::string generator; //!< Tool that generated this glTF model.Useful for debugging.
|
||||
bool premultipliedAlpha; //!< Specifies if the shaders were generated with premultiplied alpha. (default: false)
|
||||
|
@ -1020,10 +952,8 @@ namespace glTF {
|
|||
|
||||
void Read(Document &doc);
|
||||
|
||||
AssetMetadata()
|
||||
: premultipliedAlpha(false)
|
||||
, version()
|
||||
{
|
||||
AssetMetadata() :
|
||||
premultipliedAlpha(false), version() {
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1032,8 +962,7 @@ namespace glTF {
|
|||
//
|
||||
|
||||
//! Root object for a glTF asset
|
||||
class Asset
|
||||
{
|
||||
class Asset {
|
||||
typedef std::gltf_unordered_map<std::string, int> IdMap;
|
||||
|
||||
template <class T>
|
||||
|
@ -1061,10 +990,8 @@ namespace glTF {
|
|||
Asset &operator=(const Asset &);
|
||||
|
||||
public:
|
||||
|
||||
//! Keeps info about the enabled extensions
|
||||
struct Extensions
|
||||
{
|
||||
struct Extensions {
|
||||
bool KHR_binary_glTF;
|
||||
bool KHR_materials_common;
|
||||
|
||||
|
@ -1072,7 +999,6 @@ namespace glTF {
|
|||
|
||||
AssetMetadata asset;
|
||||
|
||||
|
||||
// Dictionaries for each type of object
|
||||
|
||||
LazyDict<Accessor> accessors;
|
||||
|
@ -1097,27 +1023,19 @@ namespace glTF {
|
|||
Ref<Scene> scene;
|
||||
|
||||
public:
|
||||
Asset(IOSystem* io = 0)
|
||||
: mIOSystem(io)
|
||||
, asset()
|
||||
, accessors (*this, "accessors")
|
||||
, animations (*this, "animations")
|
||||
, buffers (*this, "buffers")
|
||||
, bufferViews (*this, "bufferViews")
|
||||
, cameras (*this, "cameras")
|
||||
, images (*this, "images")
|
||||
, materials (*this, "materials")
|
||||
, meshes (*this, "meshes")
|
||||
, nodes (*this, "nodes")
|
||||
Asset(IOSystem *io = 0) :
|
||||
mIOSystem(io), asset(), accessors(*this, "accessors"), animations(*this, "animations"), buffers(*this, "buffers"), bufferViews(*this, "bufferViews"), cameras(*this, "cameras"), images(*this, "images"), materials(*this, "materials"), meshes(*this, "meshes"), nodes(*this, "nodes")
|
||||
//, programs (*this, "programs")
|
||||
, samplers (*this, "samplers")
|
||||
, scenes (*this, "scenes")
|
||||
,
|
||||
samplers(*this, "samplers"),
|
||||
scenes(*this, "scenes")
|
||||
//, shaders (*this, "shaders")
|
||||
, skins (*this, "skins")
|
||||
,
|
||||
skins(*this, "skins")
|
||||
//, techniques (*this, "techniques")
|
||||
, textures (*this, "textures")
|
||||
, lights (*this, "lights", "KHR_materials_common")
|
||||
{
|
||||
,
|
||||
textures(*this, "textures"),
|
||||
lights(*this, "lights", "KHR_materials_common") {
|
||||
memset(&extensionsUsed, 0, sizeof(extensionsUsed));
|
||||
}
|
||||
|
||||
|
@ -1130,8 +1048,7 @@ namespace glTF {
|
|||
//! Search for an available name, starting from the given strings
|
||||
std::string FindUniqueID(const std::string &str, const char *suffix);
|
||||
|
||||
Ref<Buffer> GetBodyBuffer()
|
||||
{ return mBodyBuffer; }
|
||||
Ref<Buffer> GetBodyBuffer() { return mBodyBuffer; }
|
||||
|
||||
private:
|
||||
void ReadBinaryHeader(IOStream &stream);
|
||||
|
@ -1141,7 +1058,7 @@ namespace glTF {
|
|||
IOStream *OpenFile(const std::string &path, const char *mode, bool absolute = false);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace glTF
|
||||
|
||||
// Include the implementation of the methods
|
||||
#include "glTFAsset.inl"
|
||||
|
|
|
@ -56,130 +56,11 @@ using namespace glTFCommon;
|
|||
|
||||
namespace glTF {
|
||||
|
||||
namespace {
|
||||
|
||||
#if _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4706)
|
||||
#endif // _MSC_VER
|
||||
|
||||
//
|
||||
// JSON Value reading helpers
|
||||
//
|
||||
|
||||
template <class T>
|
||||
struct ReadHelper {
|
||||
static bool Read(Value &val, T &out) {
|
||||
return val.IsInt() ? out = static_cast<T>(val.GetInt()), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<bool> {
|
||||
static bool Read(Value &val, bool &out) {
|
||||
return val.IsBool() ? out = val.GetBool(), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<float> {
|
||||
static bool Read(Value &val, float &out) {
|
||||
return val.IsNumber() ? out = static_cast<float>(val.GetDouble()), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <unsigned int N>
|
||||
struct ReadHelper<float[N]> {
|
||||
static bool Read(Value &val, float (&out)[N]) {
|
||||
if (!val.IsArray() || val.Size() != N) return false;
|
||||
for (unsigned int i = 0; i < N; ++i) {
|
||||
if (val[i].IsNumber())
|
||||
out[i] = static_cast<float>(val[i].GetDouble());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<const char *> {
|
||||
static bool Read(Value &val, const char *&out) {
|
||||
return val.IsString() ? (out = val.GetString(), true) : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<std::string> {
|
||||
static bool Read(Value &val, std::string &out) {
|
||||
return val.IsString() ? (out = std::string(val.GetString(), val.GetStringLength()), true) : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct ReadHelper<Nullable<T>> {
|
||||
static bool Read(Value &val, Nullable<T> &out) {
|
||||
return out.isPresent = ReadHelper<T>::Read(val, out.value);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<uint64_t> {
|
||||
static bool Read(Value &val, uint64_t &out) {
|
||||
return val.IsUint64() ? out = val.GetUint64(), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<int64_t> {
|
||||
static bool Read(Value &val, int64_t &out) {
|
||||
return val.IsInt64() ? out = val.GetInt64(), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline static bool ReadValue(Value &val, T &out) {
|
||||
return ReadHelper<T>::Read(val, out);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline static bool ReadMember(Value &obj, const char *id, T &out) {
|
||||
Value::MemberIterator it = obj.FindMember(id);
|
||||
if (it != obj.MemberEnd()) {
|
||||
return ReadHelper<T>::Read(it->value, out);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline static T MemberOrDefault(Value &obj, const char *id, T defaultValue) {
|
||||
T out;
|
||||
return ReadMember(obj, id, out) ? out : defaultValue;
|
||||
}
|
||||
|
||||
inline Value *FindMember(Value &val, const char *id) {
|
||||
Value::MemberIterator it = val.FindMember(id);
|
||||
return (it != val.MemberEnd()) ? &it->value : 0;
|
||||
}
|
||||
|
||||
inline Value *FindString(Value &val, const char *id) {
|
||||
Value::MemberIterator it = val.FindMember(id);
|
||||
return (it != val.MemberEnd() && it->value.IsString()) ? &it->value : 0;
|
||||
}
|
||||
|
||||
inline Value *FindNumber(Value &val, const char *id) {
|
||||
Value::MemberIterator it = val.FindMember(id);
|
||||
return (it != val.MemberEnd() && it->value.IsNumber()) ? &it->value : 0;
|
||||
}
|
||||
|
||||
inline Value *FindArray(Value &val, const char *id) {
|
||||
Value::MemberIterator it = val.FindMember(id);
|
||||
return (it != val.MemberEnd() && it->value.IsArray()) ? &it->value : 0;
|
||||
}
|
||||
|
||||
inline Value *FindObject(Value &val, const char *id) {
|
||||
Value::MemberIterator it = val.FindMember(id);
|
||||
return (it != val.MemberEnd() && it->value.IsObject()) ? &it->value : 0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//
|
||||
// LazyDict methods
|
||||
|
|
|
@ -56,6 +56,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <rapidjson/error/en.h>
|
||||
#include <rapidjson/rapidjson.h>
|
||||
|
||||
// clang-format off
|
||||
|
||||
#ifdef ASSIMP_API
|
||||
# include <assimp/ByteSwapper.h>
|
||||
# include <assimp/DefaultIOSystem.h>
|
||||
|
@ -80,9 +82,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# define gltf_unordered_map unordered_map
|
||||
# endif
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
|
||||
namespace glTFCommon {
|
||||
|
||||
using rapidjson::Document;
|
||||
using rapidjson::Value;
|
||||
|
||||
#ifdef ASSIMP_API
|
||||
using Assimp::IOStream;
|
||||
using Assimp::IOSystem;
|
||||
|
@ -193,7 +200,6 @@ inline void CopyValue(const glTFCommon::mat4 &v, aiMatrix4x4 &o) {
|
|||
#endif // _MSC_VER
|
||||
|
||||
inline std::string getCurrentAssetDir(const std::string &pFile) {
|
||||
std::string path = pFile;
|
||||
int pos = std::max(int(pFile.rfind('/')), int(pFile.rfind('\\')));
|
||||
if (pos == int(std::string::npos)) {
|
||||
return std::string();
|
||||
|
@ -262,6 +268,284 @@ void EncodeBase64(const uint8_t *in, size_t inLength, std::string &out);
|
|||
#define CHECK_EXT(EXT) \
|
||||
if (exts.find(#EXT) != exts.end()) extensionsUsed.EXT = true;
|
||||
|
||||
|
||||
|
||||
//! Helper struct to represent values that might not be present
|
||||
template <class T>
|
||||
struct Nullable {
|
||||
T value;
|
||||
bool isPresent;
|
||||
|
||||
Nullable() :
|
||||
isPresent(false) {}
|
||||
Nullable(T &val) :
|
||||
value(val),
|
||||
isPresent(true) {}
|
||||
};
|
||||
|
||||
//! A reference to one top-level object, which is valid
|
||||
//! until the Asset instance is destroyed
|
||||
template <class T>
|
||||
class Ref {
|
||||
std::vector<T *> *vector;
|
||||
unsigned int index;
|
||||
|
||||
public:
|
||||
Ref() :
|
||||
vector(0),
|
||||
index(0) {}
|
||||
Ref(std::vector<T *> &vec, unsigned int idx) :
|
||||
vector(&vec),
|
||||
index(idx) {}
|
||||
|
||||
inline unsigned int GetIndex() const { return index; }
|
||||
|
||||
operator bool() const { return vector != 0; }
|
||||
|
||||
T *operator->() { return (*vector)[index]; }
|
||||
|
||||
T &operator*() { return *((*vector)[index]); }
|
||||
};
|
||||
|
||||
//
|
||||
// JSON Value reading helpers
|
||||
//
|
||||
|
||||
template <class T>
|
||||
struct ReadHelper {
|
||||
static bool Read(Value &val, T &out) {
|
||||
return val.IsInt() ? out = static_cast<T>(val.GetInt()), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<bool> {
|
||||
static bool Read(Value &val, bool &out) {
|
||||
return val.IsBool() ? out = val.GetBool(), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<float> {
|
||||
static bool Read(Value &val, float &out) {
|
||||
return val.IsNumber() ? out = static_cast<float>(val.GetDouble()), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <unsigned int N>
|
||||
struct ReadHelper<float[N]> {
|
||||
static bool Read(Value &val, float (&out)[N]) {
|
||||
if (!val.IsArray() || val.Size() != N) return false;
|
||||
for (unsigned int i = 0; i < N; ++i) {
|
||||
if (val[i].IsNumber())
|
||||
out[i] = static_cast<float>(val[i].GetDouble());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<const char *> {
|
||||
static bool Read(Value &val, const char *&out) {
|
||||
return val.IsString() ? (out = val.GetString(), true) : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<std::string> {
|
||||
static bool Read(Value &val, std::string &out) {
|
||||
return val.IsString() ? (out = std::string(val.GetString(), val.GetStringLength()), true) : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct ReadHelper<Nullable<T>> {
|
||||
static bool Read(Value &val, Nullable<T> &out) {
|
||||
return out.isPresent = ReadHelper<T>::Read(val, out.value);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<uint64_t> {
|
||||
static bool Read(Value &val, uint64_t &out) {
|
||||
return val.IsUint64() ? out = val.GetUint64(), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<int64_t> {
|
||||
static bool Read(Value &val, int64_t &out) {
|
||||
return val.IsInt64() ? out = val.GetInt64(), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline static bool ReadValue(Value &val, T &out) {
|
||||
return ReadHelper<T>::Read(val, out);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline static bool ReadMember(Value &obj, const char *id, T &out) {
|
||||
if (!obj.IsObject()) {
|
||||
return false;
|
||||
}
|
||||
Value::MemberIterator it = obj.FindMember(id);
|
||||
if (it != obj.MemberEnd()) {
|
||||
return ReadHelper<T>::Read(it->value, out);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline static T MemberOrDefault(Value &obj, const char *id, T defaultValue) {
|
||||
T out;
|
||||
return ReadMember(obj, id, out) ? out : defaultValue;
|
||||
}
|
||||
|
||||
inline Value *FindMember(Value &val, const char *id) {
|
||||
if (!val.IsObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
Value::MemberIterator it = val.FindMember(id);
|
||||
return (it != val.MemberEnd()) ? &it->value : nullptr;
|
||||
}
|
||||
|
||||
template <int N>
|
||||
inline void throwUnexpectedTypeError(const char (&expectedTypeName)[N], const char *memberId, const char *context, const char *extraContext) {
|
||||
std::string fullContext = context;
|
||||
if (extraContext && (strlen(extraContext) > 0)) {
|
||||
fullContext = fullContext + " (" + extraContext + ")";
|
||||
}
|
||||
throw DeadlyImportError("Member \"", memberId, "\" was not of type \"", expectedTypeName, "\" when reading ", fullContext);
|
||||
}
|
||||
|
||||
// Look-up functions with type checks. Context and extra context help the user identify the problem if there's an error.
|
||||
|
||||
inline Value *FindStringInContext(Value &val, const char *memberId, const char *context, const char *extraContext = nullptr) {
|
||||
if (!val.IsObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
Value::MemberIterator it = val.FindMember(memberId);
|
||||
if (it == val.MemberEnd()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!it->value.IsString()) {
|
||||
throwUnexpectedTypeError("string", memberId, context, extraContext);
|
||||
}
|
||||
return &it->value;
|
||||
}
|
||||
|
||||
inline Value *FindNumberInContext(Value &val, const char *memberId, const char *context, const char *extraContext = nullptr) {
|
||||
if (!val.IsObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
Value::MemberIterator it = val.FindMember(memberId);
|
||||
if (it == val.MemberEnd()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!it->value.IsNumber()) {
|
||||
throwUnexpectedTypeError("number", memberId, context, extraContext);
|
||||
}
|
||||
return &it->value;
|
||||
}
|
||||
|
||||
inline Value *FindUIntInContext(Value &val, const char *memberId, const char *context, const char *extraContext = nullptr) {
|
||||
if (!val.IsObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
Value::MemberIterator it = val.FindMember(memberId);
|
||||
if (it == val.MemberEnd()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!it->value.IsUint()) {
|
||||
throwUnexpectedTypeError("uint", memberId, context, extraContext);
|
||||
}
|
||||
return &it->value;
|
||||
}
|
||||
|
||||
inline Value *FindArrayInContext(Value &val, const char *memberId, const char *context, const char *extraContext = nullptr) {
|
||||
if (!val.IsObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
Value::MemberIterator it = val.FindMember(memberId);
|
||||
if (it == val.MemberEnd()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!it->value.IsArray()) {
|
||||
throwUnexpectedTypeError("array", memberId, context, extraContext);
|
||||
}
|
||||
return &it->value;
|
||||
}
|
||||
|
||||
inline Value *FindObjectInContext(Value &val, const char *memberId, const char *context, const char *extraContext = nullptr) {
|
||||
if (!val.IsObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
Value::MemberIterator it = val.FindMember(memberId);
|
||||
if (it == val.MemberEnd()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!it->value.IsObject()) {
|
||||
throwUnexpectedTypeError("object", memberId, context, extraContext);
|
||||
}
|
||||
return &it->value;
|
||||
}
|
||||
|
||||
inline Value *FindExtensionInContext(Value &val, const char *extensionId, const char *context, const char *extraContext = nullptr) {
|
||||
if (Value *extensionList = FindObjectInContext(val, "extensions", context, extraContext)) {
|
||||
if (Value *extension = FindObjectInContext(*extensionList, extensionId, context, extraContext)) {
|
||||
return extension;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Overloads when the value is the document.
|
||||
|
||||
inline Value *FindString(Document &doc, const char *memberId) {
|
||||
return FindStringInContext(doc, memberId, "the document");
|
||||
}
|
||||
|
||||
inline Value *FindNumber(Document &doc, const char *memberId) {
|
||||
return FindNumberInContext(doc, memberId, "the document");
|
||||
}
|
||||
|
||||
inline Value *FindUInt(Document &doc, const char *memberId) {
|
||||
return FindUIntInContext(doc, memberId, "the document");
|
||||
}
|
||||
|
||||
inline Value *FindArray(Document &val, const char *memberId) {
|
||||
return FindArrayInContext(val, memberId, "the document");
|
||||
}
|
||||
|
||||
inline Value *FindObject(Document &doc, const char *memberId) {
|
||||
return FindObjectInContext(doc, memberId, "the document");
|
||||
}
|
||||
|
||||
inline Value *FindExtension(Value &val, const char *extensionId) {
|
||||
return FindExtensionInContext(val, extensionId, "the document");
|
||||
}
|
||||
|
||||
inline Value *FindString(Value &val, const char *id) {
|
||||
Value::MemberIterator it = val.FindMember(id);
|
||||
return (it != val.MemberEnd() && it->value.IsString()) ? &it->value : 0;
|
||||
}
|
||||
|
||||
inline Value *FindObject(Value &val, const char *id) {
|
||||
Value::MemberIterator it = val.FindMember(id);
|
||||
return (it != val.MemberEnd() && it->value.IsObject()) ? &it->value : 0;
|
||||
}
|
||||
|
||||
inline Value *FindArray(Value &val, const char *id) {
|
||||
Value::MemberIterator it = val.FindMember(id);
|
||||
return (it != val.MemberEnd() && it->value.IsArray()) ? &it->value : 0;
|
||||
}
|
||||
|
||||
inline Value *FindNumber(Value &val, const char *id) {
|
||||
Value::MemberIterator it = val.FindMember(id);
|
||||
return (it != val.MemberEnd() && it->value.IsNumber()) ? &it->value : 0;
|
||||
}
|
||||
|
||||
} // namespace glTFCommon
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2021, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -43,35 +42,37 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/** @file GltfExporter.h
|
||||
* Declares the exporter class to write a scene to a gltf/glb file
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef AI_GLTFEXPORTER_H_INC
|
||||
#define AI_GLTFEXPORTER_H_INC
|
||||
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_EXPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_EXPORTER)
|
||||
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/material.h>
|
||||
#include <assimp/types.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
struct aiScene;
|
||||
struct aiNode;
|
||||
struct aiMaterial;
|
||||
|
||||
namespace glTF
|
||||
{
|
||||
namespace glTFCommon {
|
||||
template <class T>
|
||||
class Ref;
|
||||
|
||||
}
|
||||
|
||||
namespace glTF {
|
||||
class Asset;
|
||||
struct TexProperty;
|
||||
struct Node;
|
||||
}
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
} // namespace glTF
|
||||
|
||||
namespace Assimp {
|
||||
class IOSystem;
|
||||
class IOStream;
|
||||
class ExportProperties;
|
||||
|
@ -79,15 +80,13 @@ namespace Assimp
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
/** Helper class to export a given scene to an glTF file. */
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class glTFExporter
|
||||
{
|
||||
class glTFExporter {
|
||||
public:
|
||||
/// Constructor for a specific scene to export
|
||||
glTFExporter(const char *filename, IOSystem *pIOSystem, const aiScene *pScene,
|
||||
const ExportProperties *pProperties, bool binary);
|
||||
|
||||
private:
|
||||
|
||||
const char *mFilename;
|
||||
IOSystem *mIOSystem;
|
||||
std::shared_ptr<const aiScene> mScene;
|
||||
|
@ -107,12 +106,12 @@ namespace Assimp
|
|||
void ExportMaterials();
|
||||
void ExportMeshes();
|
||||
unsigned int ExportNodeHierarchy(const aiNode *n);
|
||||
unsigned int ExportNode(const aiNode* node, glTF::Ref<glTF::Node>& parent);
|
||||
unsigned int ExportNode(const aiNode *node, glTFCommon::Ref<glTF::Node> & parent);
|
||||
void ExportScene();
|
||||
void ExportAnimations();
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_GLTF_EXPORTER
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// clang-format off
|
||||
#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wclass-memaccess"
|
||||
|
@ -106,6 +107,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# define gltf_unordered_set unordered_set
|
||||
# endif
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#include <assimp/StringUtils.h>
|
||||
|
||||
|
@ -113,6 +115,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
namespace glTF2 {
|
||||
|
||||
using glTFCommon::Nullable;
|
||||
using glTFCommon::Ref;
|
||||
using glTFCommon::IOStream;
|
||||
using glTFCommon::IOSystem;
|
||||
using glTFCommon::shared_ptr;
|
||||
|
@ -319,44 +323,9 @@ const AttribType::Info
|
|||
{ "SCALAR", 1 }, { "VEC2", 2 }, { "VEC3", 3 }, { "VEC4", 4 }, { "MAT2", 4 }, { "MAT3", 9 }, { "MAT4", 16 }
|
||||
};
|
||||
|
||||
//! A reference to one top-level object, which is valid
|
||||
//! until the Asset instance is destroyed
|
||||
template <class T>
|
||||
class Ref {
|
||||
std::vector<T *> *vector;
|
||||
unsigned int index;
|
||||
|
||||
public:
|
||||
Ref() :
|
||||
vector(0),
|
||||
index(0) {}
|
||||
Ref(std::vector<T *> &vec, unsigned int idx) :
|
||||
vector(&vec),
|
||||
index(idx) {}
|
||||
|
||||
inline unsigned int GetIndex() const { return index; }
|
||||
|
||||
operator bool() const { return vector != 0; }
|
||||
|
||||
T *operator->() { return (*vector)[index]; }
|
||||
|
||||
T &operator*() { return *((*vector)[index]); }
|
||||
};
|
||||
|
||||
//! Helper struct to represent values that might not be present
|
||||
template <class T>
|
||||
struct Nullable {
|
||||
T value;
|
||||
bool isPresent;
|
||||
|
||||
Nullable() :
|
||||
isPresent(false) {}
|
||||
Nullable(T &val) :
|
||||
value(val),
|
||||
isPresent(true) {}
|
||||
};
|
||||
|
||||
struct CustomExtension {
|
||||
|
||||
//
|
||||
// A struct containing custom extension data added to a glTF2 file
|
||||
// Has to contain Object, Array, String, Double, Uint64, and Int64 at a minimum
|
||||
|
@ -553,7 +522,7 @@ public:
|
|||
|
||||
void MarkAsSpecial() { mIsSpecial = true; }
|
||||
|
||||
bool IsSpecial() const { return mIsSpecial; }
|
||||
bool IsSpecial() const override { return mIsSpecial; }
|
||||
|
||||
std::string GetURI() { return std::string(this->id) + ".bin"; }
|
||||
|
||||
|
@ -849,7 +818,7 @@ struct Material : public Object {
|
|||
|
||||
//! A set of primitives to be rendered. A node can contain one or more meshes. A node's transform places the mesh in the scene.
|
||||
struct Mesh : public Object {
|
||||
typedef std::vector<Ref<Accessor>> AccessorList;
|
||||
using AccessorList = std::vector<Ref<Accessor>>;
|
||||
|
||||
struct Primitive {
|
||||
PrimitiveMode mode;
|
||||
|
@ -880,7 +849,6 @@ struct Mesh : public Object {
|
|||
|
||||
Mesh() {}
|
||||
|
||||
/// \fn void Read(Value& pJSON_Object, Asset& pAsset_Root)
|
||||
/// Get mesh data from JSON-object and place them to root asset.
|
||||
/// \param [in] pJSON_Object - reference to pJSON-object from which data are read.
|
||||
/// \param [out] pAsset_Root - reference to root asset where data will be stored.
|
||||
|
@ -1023,8 +991,8 @@ class LazyDict : public LazyDictBase {
|
|||
friend class Asset;
|
||||
friend class AssetWriter;
|
||||
|
||||
typedef typename std::gltf_unordered_map<unsigned int, unsigned int> Dict;
|
||||
typedef typename std::gltf_unordered_map<std::string, unsigned int> IdDict;
|
||||
using Dict = typename std::gltf_unordered_map<unsigned int, unsigned int>;
|
||||
using IdDict = typename std::gltf_unordered_map<std::string, unsigned int>;
|
||||
|
||||
std::vector<T *> mObjs; //! The read objects
|
||||
Dict mObjsByOIndex; //! The read objects accessible by original index
|
||||
|
@ -1087,7 +1055,7 @@ struct AssetMetadata {
|
|||
|
||||
//! Root object for a glTF asset
|
||||
class Asset {
|
||||
typedef std::gltf_unordered_map<std::string, int> IdMap;
|
||||
using IdMap = std::gltf_unordered_map<std::string, int>;
|
||||
|
||||
template <class T>
|
||||
friend class LazyDict;
|
||||
|
|
|
@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
||||
// clang-format off
|
||||
#ifdef ASSIMP_ENABLE_DRACO
|
||||
|
||||
// Google draco library headers spew many warnings. Bad Google, no cookie
|
||||
|
@ -77,8 +78,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# error glTF: KHR_draco_mesh_compression: draco library must have DRACO_MESH_COMPRESSION_SUPPORTED
|
||||
#endif
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace glTFCommon;
|
||||
|
||||
namespace glTF2 {
|
||||
|
||||
|
@ -88,222 +91,6 @@ namespace {
|
|||
// JSON Value reading helpers
|
||||
//
|
||||
|
||||
template <class T>
|
||||
struct ReadHelper {
|
||||
static bool Read(Value &val, T &out) {
|
||||
return val.IsInt() ? out = static_cast<T>(val.GetInt()), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<bool> {
|
||||
static bool Read(Value &val, bool &out) {
|
||||
return val.IsBool() ? out = val.GetBool(), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<float> {
|
||||
static bool Read(Value &val, float &out) {
|
||||
return val.IsNumber() ? out = static_cast<float>(val.GetDouble()), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <unsigned int N>
|
||||
struct ReadHelper<float[N]> {
|
||||
static bool Read(Value &val, float (&out)[N]) {
|
||||
if (!val.IsArray() || val.Size() != N) return false;
|
||||
for (unsigned int i = 0; i < N; ++i) {
|
||||
if (val[i].IsNumber())
|
||||
out[i] = static_cast<float>(val[i].GetDouble());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<const char *> {
|
||||
static bool Read(Value &val, const char *&out) {
|
||||
return val.IsString() ? (out = val.GetString(), true) : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<std::string> {
|
||||
static bool Read(Value &val, std::string &out) {
|
||||
return val.IsString() ? (out = std::string(val.GetString(), val.GetStringLength()), true) : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<uint64_t> {
|
||||
static bool Read(Value &val, uint64_t &out) {
|
||||
return val.IsUint64() ? out = val.GetUint64(), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadHelper<int64_t> {
|
||||
static bool Read(Value &val, int64_t &out) {
|
||||
return val.IsInt64() ? out = val.GetInt64(), true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct ReadHelper<Nullable<T>> {
|
||||
static bool Read(Value &val, Nullable<T> &out) {
|
||||
return out.isPresent = ReadHelper<T>::Read(val, out.value);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline static bool ReadValue(Value &val, T &out) {
|
||||
return ReadHelper<T>::Read(val, out);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline static bool ReadMember(Value &obj, const char *id, T &out) {
|
||||
if (!obj.IsObject()) {
|
||||
return false;
|
||||
}
|
||||
Value::MemberIterator it = obj.FindMember(id);
|
||||
if (it != obj.MemberEnd()) {
|
||||
return ReadHelper<T>::Read(it->value, out);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline static T MemberOrDefault(Value &obj, const char *id, T defaultValue) {
|
||||
T out;
|
||||
return ReadMember(obj, id, out) ? out : defaultValue;
|
||||
}
|
||||
|
||||
inline Value *FindMember(Value &val, const char *id) {
|
||||
if (!val.IsObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
Value::MemberIterator it = val.FindMember(id);
|
||||
return (it != val.MemberEnd()) ? &it->value : nullptr;
|
||||
}
|
||||
|
||||
template<int N>
|
||||
inline void throwUnexpectedTypeError(const char (&expectedTypeName)[N], const char* memberId, const char* context, const char* extraContext) {
|
||||
std::string fullContext = context;
|
||||
if (extraContext && (strlen(extraContext) > 0))
|
||||
{
|
||||
fullContext = fullContext + " (" + extraContext + ")";
|
||||
}
|
||||
throw DeadlyImportError("Member \"", memberId, "\" was not of type \"", expectedTypeName, "\" when reading ", fullContext);
|
||||
}
|
||||
|
||||
// Look-up functions with type checks. Context and extra context help the user identify the problem if there's an error.
|
||||
|
||||
inline Value *FindStringInContext(Value &val, const char *memberId, const char* context, const char* extraContext = nullptr) {
|
||||
if (!val.IsObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
Value::MemberIterator it = val.FindMember(memberId);
|
||||
if (it == val.MemberEnd()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!it->value.IsString()) {
|
||||
throwUnexpectedTypeError("string", memberId, context, extraContext);
|
||||
}
|
||||
return &it->value;
|
||||
}
|
||||
|
||||
inline Value *FindNumberInContext(Value &val, const char *memberId, const char* context, const char* extraContext = nullptr) {
|
||||
if (!val.IsObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
Value::MemberIterator it = val.FindMember(memberId);
|
||||
if (it == val.MemberEnd()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!it->value.IsNumber()) {
|
||||
throwUnexpectedTypeError("number", memberId, context, extraContext);
|
||||
}
|
||||
return &it->value;
|
||||
}
|
||||
|
||||
inline Value *FindUIntInContext(Value &val, const char *memberId, const char* context, const char* extraContext = nullptr) {
|
||||
if (!val.IsObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
Value::MemberIterator it = val.FindMember(memberId);
|
||||
if (it == val.MemberEnd()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!it->value.IsUint()) {
|
||||
throwUnexpectedTypeError("uint", memberId, context, extraContext);
|
||||
}
|
||||
return &it->value;
|
||||
}
|
||||
|
||||
inline Value *FindArrayInContext(Value &val, const char *memberId, const char* context, const char* extraContext = nullptr) {
|
||||
if (!val.IsObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
Value::MemberIterator it = val.FindMember(memberId);
|
||||
if (it == val.MemberEnd()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!it->value.IsArray()) {
|
||||
throwUnexpectedTypeError("array", memberId, context, extraContext);
|
||||
}
|
||||
return &it->value;
|
||||
}
|
||||
|
||||
inline Value *FindObjectInContext(Value &val, const char *memberId, const char* context, const char* extraContext = nullptr) {
|
||||
if (!val.IsObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
Value::MemberIterator it = val.FindMember(memberId);
|
||||
if (it == val.MemberEnd()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!it->value.IsObject()) {
|
||||
throwUnexpectedTypeError("object", memberId, context, extraContext);
|
||||
}
|
||||
return &it->value;
|
||||
}
|
||||
|
||||
inline Value *FindExtensionInContext(Value &val, const char *extensionId, const char* context, const char* extraContext = nullptr) {
|
||||
if (Value *extensionList = FindObjectInContext(val, "extensions", context, extraContext)) {
|
||||
if (Value *extension = FindObjectInContext(*extensionList, extensionId, context, extraContext)) {
|
||||
return extension;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Overloads when the value is the document.
|
||||
|
||||
inline Value *FindString(Document &doc, const char *memberId) {
|
||||
return FindStringInContext(doc, memberId, "the document");
|
||||
}
|
||||
|
||||
inline Value *FindNumber(Document &doc, const char *memberId) {
|
||||
return FindNumberInContext(doc, memberId, "the document");
|
||||
}
|
||||
|
||||
inline Value *FindUInt(Document &doc, const char *memberId) {
|
||||
return FindUIntInContext(doc, memberId, "the document");
|
||||
}
|
||||
|
||||
inline Value *FindArray(Document &val, const char *memberId) {
|
||||
return FindArrayInContext(val, memberId, "the document");
|
||||
}
|
||||
|
||||
inline Value *FindObject(Document &doc, const char *memberId) {
|
||||
return FindObjectInContext(doc, memberId, "the document");
|
||||
}
|
||||
|
||||
inline Value *FindExtension(Value &val, const char *extensionId) {
|
||||
return FindExtensionInContext(val, extensionId, "the document");
|
||||
}
|
||||
|
||||
inline CustomExtension ReadExtensions(const char *name, Value &obj) {
|
||||
CustomExtension ret;
|
||||
ret.name = name;
|
||||
|
|
|
@ -57,7 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/IOSystem.hpp>
|
||||
|
||||
// Header files, standard library.
|
||||
#include <inttypes.h>
|
||||
#include <cinttypes>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2021, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -48,23 +47,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
|
||||
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/material.h>
|
||||
#include <assimp/types.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
struct aiScene;
|
||||
struct aiNode;
|
||||
struct aiMaterial;
|
||||
|
||||
namespace glTF2
|
||||
{
|
||||
namespace glTFCommon {
|
||||
template <class T>
|
||||
class Ref;
|
||||
|
||||
}
|
||||
|
||||
namespace glTF2 {
|
||||
class Asset;
|
||||
struct TexProperty;
|
||||
struct TextureInfo;
|
||||
|
@ -81,10 +82,9 @@ namespace glTF2
|
|||
typedef float(vec2)[2];
|
||||
typedef float(vec3)[3];
|
||||
typedef float(vec4)[4];
|
||||
}
|
||||
} // namespace glTF2
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
namespace Assimp {
|
||||
class IOSystem;
|
||||
class IOStream;
|
||||
class ExportProperties;
|
||||
|
@ -101,10 +101,10 @@ namespace Assimp
|
|||
|
||||
protected:
|
||||
void WriteBinaryData(IOStream *outfile, std::size_t sceneLength);
|
||||
void GetTexSampler(const aiMaterial& mat, glTF2::Ref<glTF2::Texture> texture, aiTextureType tt, unsigned int slot);
|
||||
void GetTexSampler(const aiMaterial &mat, glTFCommon::Ref<glTF2::Texture> texture, aiTextureType tt, unsigned int slot);
|
||||
void GetMatTexProp(const aiMaterial &mat, unsigned int &prop, const char *propName, aiTextureType tt, unsigned int idx);
|
||||
void GetMatTexProp(const aiMaterial &mat, float &prop, const char *propName, aiTextureType tt, unsigned int idx);
|
||||
void GetMatTex(const aiMaterial& mat, glTF2::Ref<glTF2::Texture>& texture, unsigned int &texCoord, aiTextureType tt, unsigned int slot);
|
||||
void GetMatTex(const aiMaterial &mat, glTFCommon::Ref<glTF2::Texture> &texture, unsigned int &texCoord, aiTextureType tt, unsigned int slot);
|
||||
void GetMatTex(const aiMaterial &mat, glTF2::TextureInfo &prop, aiTextureType tt, unsigned int slot);
|
||||
void GetMatTex(const aiMaterial &mat, glTF2::NormalTextureInfo &prop, aiTextureType tt, unsigned int slot);
|
||||
void GetMatTex(const aiMaterial &mat, glTF2::OcclusionTextureInfo &prop, aiTextureType tt, unsigned int slot);
|
||||
|
@ -119,7 +119,7 @@ namespace Assimp
|
|||
void ExportMeshes();
|
||||
void MergeMeshes();
|
||||
unsigned int ExportNodeHierarchy(const aiNode *n);
|
||||
unsigned int ExportNode(const aiNode* node, glTF2::Ref<glTF2::Node>& parent);
|
||||
unsigned int ExportNode(const aiNode *node, glTFCommon::Ref<glTF2::Node> &parent);
|
||||
void ExportScene();
|
||||
void ExportAnimations();
|
||||
|
||||
|
@ -133,7 +133,7 @@ namespace Assimp
|
|||
std::vector<unsigned char> mBodyData;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "AssetLib/glTF2/glTF2Importer.h"
|
||||
#include "PostProcessing/MakeVerboseFormat.h"
|
||||
#include "AssetLib/glTF2/glTF2Asset.h"
|
||||
|
||||
#if !defined(ASSIMP_BUILD_NO_EXPORT)
|
||||
#include "AssetLib/glTF2/glTF2AssetWriter.h"
|
||||
#endif
|
||||
|
@ -57,6 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/commonMetaData.h>
|
||||
#include <assimp/DefaultIOSystem.h>
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
@ -1536,11 +1538,9 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) {
|
|||
if (ext) {
|
||||
if (strcmp(ext, "jpeg") == 0) {
|
||||
ext = "jpg";
|
||||
}
|
||||
else if(strcmp(ext, "ktx2") == 0) { //basisu: ktx remains
|
||||
} else if(strcmp(ext, "ktx2") == 0) { //basisu: ktx remains
|
||||
ext = "kx2";
|
||||
}
|
||||
else if(strcmp(ext, "basis") == 0) { //basisu
|
||||
} else if(strcmp(ext, "basis") == 0) { //basisu
|
||||
ext = "bu";
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#define AI_GLTF2IMPORTER_H_INC
|
||||
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/DefaultIOSystem.h>
|
||||
|
||||
struct aiNode;
|
||||
|
||||
|
|
Loading…
Reference in New Issue