mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-27 07:15:37 +00:00
Just the functional assimp lib rather than the entire assimp repository unnecessarily.
This commit is contained in:
parent
0f7641a282
commit
e9ea38eda3
1747 changed files with 9012 additions and 925008 deletions
|
|
@ -2,8 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -45,7 +44,6 @@ 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
|
||||
|
|
@ -67,7 +65,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifdef ASSIMP_API
|
||||
# include <memory>
|
||||
# include <assimp/DefaultIOSystem.h>
|
||||
# include <assimp/ByteSwapper.h>
|
||||
# include "ByteSwapper.h"
|
||||
#else
|
||||
# include <memory>
|
||||
# define AI_SWAP4(p)
|
||||
|
|
@ -90,7 +88,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#include <assimp/StringUtils.h>
|
||||
#include "StringUtils.h"
|
||||
|
||||
namespace glTF2
|
||||
{
|
||||
|
|
@ -138,7 +136,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
|
||||
{
|
||||
|
|
@ -167,10 +165,31 @@ namespace glTF2
|
|||
|
||||
//! Magic number for GLB files
|
||||
#define AI_GLB_MAGIC_NUMBER "glTF"
|
||||
#include <assimp/pbrmaterial.h>
|
||||
|
||||
#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
|
||||
|
||||
#ifdef ASSIMP_API
|
||||
#include <assimp/Compiler/pushpack1.h>
|
||||
#include "./../include/assimp/Compiler/pushpack1.h"
|
||||
#endif
|
||||
|
||||
//! For binary .glb files
|
||||
|
|
@ -189,7 +208,7 @@ namespace glTF2
|
|||
} PACK_STRUCT;
|
||||
|
||||
#ifdef ASSIMP_API
|
||||
#include <assimp/Compiler/poppack1.h>
|
||||
#include "./../include/assimp/Compiler/poppack1.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -303,20 +322,6 @@ 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
|
||||
|
|
@ -401,7 +406,7 @@ namespace glTF2
|
|||
};
|
||||
|
||||
|
||||
//! Base class for all glTF top-level objects
|
||||
//! Base classe for all glTF top-level objects
|
||||
struct Object
|
||||
{
|
||||
int index; //!< The index of this object within its property container
|
||||
|
|
@ -596,7 +601,6 @@ 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);
|
||||
|
|
@ -673,7 +677,7 @@ namespace glTF2
|
|||
int width, height;
|
||||
|
||||
private:
|
||||
std::unique_ptr<uint8_t[]> mData;
|
||||
uint8_t* mData;
|
||||
size_t mDataLength;
|
||||
|
||||
public:
|
||||
|
|
@ -688,7 +692,7 @@ namespace glTF2
|
|||
{ return mDataLength; }
|
||||
|
||||
inline const uint8_t* GetData() const
|
||||
{ return mData.get(); }
|
||||
{ return mData; }
|
||||
|
||||
inline uint8_t* StealData();
|
||||
|
||||
|
|
@ -756,9 +760,6 @@ 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();
|
||||
|
|
@ -780,17 +781,10 @@ 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)
|
||||
|
|
@ -884,35 +878,56 @@ namespace glTF2
|
|||
|
||||
struct Animation : public Object
|
||||
{
|
||||
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 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 Target {
|
||||
Target() : path(AnimationPath_TRANSLATION) {}
|
||||
struct AnimChannel {
|
||||
int sampler; //!< The index of a sampler in the containing animation's samplers property.
|
||||
|
||||
Ref<Node> node; //!< The node to animate.
|
||||
AnimationPath path; //!< The property of the node to animate.
|
||||
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;
|
||||
};
|
||||
|
||||
struct Channel {
|
||||
Channel() : sampler(-1) {}
|
||||
|
||||
int sampler; //!< The sampler index containing the animation data.
|
||||
Target target; //!< The node and property 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.
|
||||
};
|
||||
|
||||
std::vector<Sampler> samplers; //!< All the key-frame data for this animation.
|
||||
std::vector<Channel> channels; //!< Data to connect nodes to key-frames.
|
||||
// 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.
|
||||
|
||||
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
|
||||
{
|
||||
|
|
@ -1041,7 +1056,6 @@ namespace glTF2
|
|||
struct Extensions
|
||||
{
|
||||
bool KHR_materials_pbrSpecularGlossiness;
|
||||
bool KHR_materials_unlit;
|
||||
|
||||
} extensionsUsed;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue