mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
Updated assimp to latest
This commit is contained in:
parent
25ce4477ce
commit
161bf7f83b
461 changed files with 34662 additions and 30165 deletions
|
|
@ -2,7 +2,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -44,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*
|
||||
* glTF Extensions Support:
|
||||
* KHR_materials_pbrSpecularGlossiness full
|
||||
* KHR_materials_unlit full
|
||||
*/
|
||||
#ifndef GLTF2ASSET_H_INC
|
||||
#define GLTF2ASSET_H_INC
|
||||
|
|
@ -65,7 +67,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifdef ASSIMP_API
|
||||
# include <memory>
|
||||
# include <assimp/DefaultIOSystem.h>
|
||||
# include "ByteSwapper.h"
|
||||
# include <assimp/ByteSwapper.h>
|
||||
#else
|
||||
# include <memory>
|
||||
# define AI_SWAP4(p)
|
||||
|
|
@ -88,7 +90,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#include "StringUtils.h"
|
||||
#include <assimp/StringUtils.h>
|
||||
|
||||
namespace glTF2
|
||||
{
|
||||
|
|
@ -136,7 +138,7 @@ namespace glTF2
|
|||
// Vec/matrix types, as raw float arrays
|
||||
typedef float (vec3)[3];
|
||||
typedef float (vec4)[4];
|
||||
typedef float (mat4)[16];
|
||||
typedef float (mat4)[16];
|
||||
|
||||
namespace Util
|
||||
{
|
||||
|
|
@ -165,31 +167,10 @@ namespace glTF2
|
|||
|
||||
//! Magic number for GLB files
|
||||
#define AI_GLB_MAGIC_NUMBER "glTF"
|
||||
|
||||
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_FACTOR "$mat.gltf.pbrMetallicRoughness.baseColorFactor", 0, 0
|
||||
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLIC_FACTOR "$mat.gltf.pbrMetallicRoughness.metallicFactor", 0, 0
|
||||
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_ROUGHNESS_FACTOR "$mat.gltf.pbrMetallicRoughness.roughnessFactor", 0, 0
|
||||
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_TEXTURE aiTextureType_DIFFUSE, 1
|
||||
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 0
|
||||
#define AI_MATKEY_GLTF_ALPHAMODE "$mat.gltf.alphaMode", 0, 0
|
||||
#define AI_MATKEY_GLTF_ALPHACUTOFF "$mat.gltf.alphaCutoff", 0, 0
|
||||
#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS "$mat.gltf.pbrSpecularGlossiness", 0, 0
|
||||
#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS_GLOSSINESS_FACTOR "$mat.gltf.pbrMetallicRoughness.glossinessFactor", 0, 0
|
||||
|
||||
#define _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE "$tex.file.texCoord"
|
||||
#define _AI_MATKEY_GLTF_MAPPINGNAME_BASE "$tex.mappingname"
|
||||
#define _AI_MATKEY_GLTF_MAPPINGID_BASE "$tex.mappingid"
|
||||
#define _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE "$tex.mappingfiltermag"
|
||||
#define _AI_MATKEY_GLTF_MAPPINGFILTER_MIN_BASE "$tex.mappingfiltermin"
|
||||
|
||||
#define AI_MATKEY_GLTF_TEXTURE_TEXCOORD _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE, type, N
|
||||
#define AI_MATKEY_GLTF_MAPPINGNAME(type, N) _AI_MATKEY_GLTF_MAPPINGNAME_BASE, type, N
|
||||
#define AI_MATKEY_GLTF_MAPPINGID(type, N) _AI_MATKEY_GLTF_MAPPINGID_BASE, type, N
|
||||
#define AI_MATKEY_GLTF_MAPPINGFILTER_MAG(type, N) _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE, type, N
|
||||
#define AI_MATKEY_GLTF_MAPPINGFILTER_MIN(type, N) _AI_MATKEY_GLTF_MAPPINGFILTER_MIN_BASE, type, N
|
||||
#include <assimp/pbrmaterial.h>
|
||||
|
||||
#ifdef ASSIMP_API
|
||||
#include "./../include/assimp/Compiler/pushpack1.h"
|
||||
#include <assimp/Compiler/pushpack1.h>
|
||||
#endif
|
||||
|
||||
//! For binary .glb files
|
||||
|
|
@ -208,7 +189,7 @@ namespace glTF2
|
|||
} PACK_STRUCT;
|
||||
|
||||
#ifdef ASSIMP_API
|
||||
#include "./../include/assimp/Compiler/poppack1.h"
|
||||
#include <assimp/Compiler/poppack1.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -322,6 +303,20 @@ namespace glTF2
|
|||
TextureType_UNSIGNED_SHORT_5_5_5_1 = 32820
|
||||
};
|
||||
|
||||
//! Values for the Animation::Target::path field
|
||||
enum AnimationPath {
|
||||
AnimationPath_TRANSLATION,
|
||||
AnimationPath_ROTATION,
|
||||
AnimationPath_SCALE,
|
||||
AnimationPath_WEIGHTS,
|
||||
};
|
||||
|
||||
//! Values for the Animation::Sampler::interpolation field
|
||||
enum Interpolation {
|
||||
Interpolation_LINEAR,
|
||||
Interpolation_STEP,
|
||||
Interpolation_CUBICSPLINE,
|
||||
};
|
||||
|
||||
//! Values for the Accessor::type field (helper class)
|
||||
class AttribType
|
||||
|
|
@ -406,7 +401,7 @@ namespace glTF2
|
|||
};
|
||||
|
||||
|
||||
//! Base classe for all glTF top-level objects
|
||||
//! Base class for all glTF top-level objects
|
||||
struct Object
|
||||
{
|
||||
int index; //!< The index of this object within its property container
|
||||
|
|
@ -435,9 +430,9 @@ namespace glTF2
|
|||
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)
|
||||
size_t byteOffset; //!< The offset relative to the start of the bufferView in bytes. (required)
|
||||
ComponentType componentType; //!< The datatype of components in the attribute. (required)
|
||||
unsigned int count; //!< The number of attributes referenced by this accessor. (required)
|
||||
size_t count; //!< The number of attributes referenced by this accessor. (required)
|
||||
AttribType::Value type; //!< Specifies if the attribute is a scalar, vector, or matrix. (required)
|
||||
std::vector<float> max; //!< Maximum value of each component in this attribute.
|
||||
std::vector<float> min; //!< Minimum value of each component in this attribute.
|
||||
|
|
@ -534,6 +529,7 @@ namespace glTF2
|
|||
//std::string uri; //!< The uri of the buffer. Can be a filepath, a data uri, etc. (required)
|
||||
size_t byteLength; //!< The length of the buffer in bytes. (default: 0)
|
||||
//std::string type; //!< XMLHttpRequest responseType (default: "arraybuffer")
|
||||
size_t capacity = 0; //!< The capacity of the buffer in bytes. (default: 0)
|
||||
|
||||
Type type;
|
||||
|
||||
|
|
@ -601,6 +597,7 @@ namespace glTF2
|
|||
/// \param [in] pReplace_Count - count of bytes in new data.
|
||||
/// \return true - if successfully replaced, false if input arguments is out of range.
|
||||
bool ReplaceData(const size_t pBufferData_Offset, const size_t pBufferData_Count, const uint8_t* pReplace_Data, const size_t pReplace_Count);
|
||||
bool ReplaceData_joint(const size_t pBufferData_Offset, const size_t pBufferData_Count, const uint8_t* pReplace_Data, const size_t pReplace_Count);
|
||||
|
||||
size_t AppendData(uint8_t* data, size_t length);
|
||||
void Grow(size_t amount);
|
||||
|
|
@ -660,7 +657,11 @@ namespace glTF2
|
|||
} ortographic;
|
||||
} cameraProperties;
|
||||
|
||||
Camera() {}
|
||||
Camera()
|
||||
: type(Perspective)
|
||||
, cameraProperties() {
|
||||
// empty
|
||||
}
|
||||
void Read(Value& obj, Asset& r);
|
||||
};
|
||||
|
||||
|
|
@ -677,7 +678,7 @@ namespace glTF2
|
|||
int width, height;
|
||||
|
||||
private:
|
||||
uint8_t* mData;
|
||||
std::unique_ptr<uint8_t[]> mData;
|
||||
size_t mDataLength;
|
||||
|
||||
public:
|
||||
|
|
@ -692,7 +693,7 @@ namespace glTF2
|
|||
{ return mDataLength; }
|
||||
|
||||
inline const uint8_t* GetData() const
|
||||
{ return mData; }
|
||||
{ return mData.get(); }
|
||||
|
||||
inline uint8_t* StealData();
|
||||
|
||||
|
|
@ -760,6 +761,9 @@ namespace glTF2
|
|||
//extension: KHR_materials_pbrSpecularGlossiness
|
||||
Nullable<PbrSpecularGlossiness> pbrSpecularGlossiness;
|
||||
|
||||
//extension: KHR_materials_unlit
|
||||
bool unlit;
|
||||
|
||||
Material() { SetDefaults(); }
|
||||
void Read(Value& obj, Asset& r);
|
||||
void SetDefaults();
|
||||
|
|
@ -781,10 +785,17 @@ namespace glTF2
|
|||
Ref<Accessor> indices;
|
||||
|
||||
Ref<Material> material;
|
||||
|
||||
struct Target {
|
||||
AccessorList position, normal, tangent;
|
||||
};
|
||||
std::vector<Target> targets;
|
||||
};
|
||||
|
||||
std::vector<Primitive> primitives;
|
||||
|
||||
std::vector<float> weights;
|
||||
|
||||
Mesh() {}
|
||||
|
||||
/// \fn void Read(Value& pJSON_Object, Asset& pAsset_Root)
|
||||
|
|
@ -878,56 +889,35 @@ namespace glTF2
|
|||
|
||||
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.
|
||||
std::string interpolation; //!< Type of interpolation algorithm to use between key-frames.
|
||||
std::string output; //!< The ID of a parameter in this animation to use as key-frame output.
|
||||
struct Sampler {
|
||||
Sampler() : interpolation(Interpolation_LINEAR) {}
|
||||
|
||||
Ref<Accessor> input; //!< Accessor reference to the buffer storing the key-frame times.
|
||||
Ref<Accessor> output; //!< Accessor reference to the buffer storing the key-frame values.
|
||||
Interpolation interpolation; //!< Type of interpolation algorithm to use between key-frames.
|
||||
};
|
||||
|
||||
struct AnimChannel {
|
||||
int sampler; //!< The index of a sampler in the containing animation's samplers property.
|
||||
struct Target {
|
||||
Target() : path(AnimationPath_TRANSLATION) {}
|
||||
|
||||
struct AnimTarget {
|
||||
Ref<Node> node; //!< The node to animate.
|
||||
std::string path; //!< The name of property of the node to animate ("translation", "rotation", or "scale").
|
||||
} target;
|
||||
Ref<Node> node; //!< The node to animate.
|
||||
AnimationPath path; //!< The property of the node to animate.
|
||||
};
|
||||
|
||||
struct AnimParameters {
|
||||
Ref<Accessor> TIME; //!< Accessor reference to a buffer storing a array of floating point scalar values.
|
||||
Ref<Accessor> rotation; //!< Accessor reference to a buffer storing a array of four-component floating-point vectors.
|
||||
Ref<Accessor> scale; //!< Accessor reference to a buffer storing a array of three-component floating-point vectors.
|
||||
Ref<Accessor> translation; //!< Accessor reference to a buffer storing a array of three-component floating-point vectors.
|
||||
struct Channel {
|
||||
Channel() : sampler(-1) {}
|
||||
|
||||
int sampler; //!< The sampler index containing the animation data.
|
||||
Target target; //!< The node and property to animate.
|
||||
};
|
||||
|
||||
// AnimChannel Channels[3]; //!< Connect the output values of the key-frame animation to a specific node in the hierarchy.
|
||||
// AnimParameters Parameters; //!< The samplers that interpolate between the key-frames.
|
||||
// AnimSampler Samplers[3]; //!< The parameterized inputs representing the key-frame data.
|
||||
|
||||
std::vector<AnimChannel> Channels; //!< Connect the output values of the key-frame animation to a specific node in the hierarchy.
|
||||
AnimParameters Parameters; //!< The samplers that interpolate between the key-frames.
|
||||
std::vector<AnimSampler> Samplers; //!< The parameterized inputs representing the key-frame data.
|
||||
std::vector<Sampler> samplers; //!< All the key-frame data for this animation.
|
||||
std::vector<Channel> channels; //!< Data to connect nodes to key-frames.
|
||||
|
||||
Animation() {}
|
||||
void Read(Value& obj, Asset& r);
|
||||
|
||||
//! Get accessor given an animation parameter name.
|
||||
Ref<Accessor> GetAccessor(std::string name) {
|
||||
if (name == "TIME") {
|
||||
return Parameters.TIME;
|
||||
} else if (name == "rotation") {
|
||||
return Parameters.rotation;
|
||||
} else if (name == "scale") {
|
||||
return Parameters.scale;
|
||||
} else if (name == "translation") {
|
||||
return Parameters.translation;
|
||||
}
|
||||
return Ref<Accessor>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Base class for LazyDict that acts as an interface
|
||||
class LazyDictBase
|
||||
{
|
||||
|
|
@ -1056,6 +1046,7 @@ namespace glTF2
|
|||
struct Extensions
|
||||
{
|
||||
bool KHR_materials_pbrSpecularGlossiness;
|
||||
bool KHR_materials_unlit;
|
||||
|
||||
} extensionsUsed;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue