mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
* Adjustment: Update Assimp version to 5.0.1.
This commit is contained in:
parent
14ebeaf3eb
commit
4758f7bdaf
679 changed files with 50502 additions and 19698 deletions
|
|
@ -1,600 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, 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 HL1FileData.h
|
||||
* @brief Definition of in-memory structures for the
|
||||
* Half-Life 1 MDL file format.
|
||||
*/
|
||||
|
||||
#ifndef AI_HL1FILEDATA_INCLUDED
|
||||
#define AI_HL1FILEDATA_INCLUDED
|
||||
|
||||
#include "HalfLifeMDLBaseHeader.h"
|
||||
|
||||
#include <assimp/Compiler/pushpack1.h>
|
||||
#include <assimp/types.h>
|
||||
|
||||
namespace Assimp {
|
||||
namespace MDL {
|
||||
namespace HalfLife {
|
||||
|
||||
using vec3_t = float[3];
|
||||
|
||||
/** \struct Header_HL1
|
||||
* \brief Data structure for the HL1 MDL file header.
|
||||
*/
|
||||
struct Header_HL1 : HalfLifeMDLBaseHeader {
|
||||
//! The model name.
|
||||
char name[64];
|
||||
|
||||
//! The total file size in bytes.
|
||||
int32_t length;
|
||||
|
||||
//! Ideal eye position.
|
||||
vec3_t eyeposition;
|
||||
|
||||
//! Ideal movement hull size.
|
||||
vec3_t min;
|
||||
vec3_t max;
|
||||
|
||||
//! Clipping bounding box.
|
||||
vec3_t bbmin;
|
||||
vec3_t bbmax;
|
||||
|
||||
//! Was "flags".
|
||||
int32_t unused;
|
||||
|
||||
//! The number of bones.
|
||||
int32_t numbones;
|
||||
|
||||
//! Offset to the first bone chunk.
|
||||
int32_t boneindex;
|
||||
|
||||
//! The number of bone controllers.
|
||||
int32_t numbonecontrollers;
|
||||
|
||||
//! Offset to the first bone controller chunk.
|
||||
int32_t bonecontrollerindex;
|
||||
|
||||
//! The number of hitboxes.
|
||||
int32_t numhitboxes;
|
||||
|
||||
//! Offset to the first hitbox chunk.
|
||||
int32_t hitboxindex;
|
||||
|
||||
//! The number of sequences.
|
||||
int32_t numseq;
|
||||
|
||||
//! Offset to the first sequence description chunk.
|
||||
int32_t seqindex;
|
||||
|
||||
//! The number of sequence groups.
|
||||
int32_t numseqgroups;
|
||||
|
||||
//! Offset to the first sequence group chunk.
|
||||
int32_t seqgroupindex;
|
||||
|
||||
//! The number of textures.
|
||||
int32_t numtextures;
|
||||
|
||||
//! Offset to the first texture chunk.
|
||||
int32_t textureindex;
|
||||
|
||||
//! Offset to the first texture's image data.
|
||||
int32_t texturedataindex;
|
||||
|
||||
//! The number of replaceable textures.
|
||||
int32_t numskinref;
|
||||
|
||||
//! The number of skin families.
|
||||
int32_t numskinfamilies;
|
||||
|
||||
//! Offset to the first replaceable texture.
|
||||
int32_t skinindex;
|
||||
|
||||
//! The number of bodyparts.
|
||||
int32_t numbodyparts;
|
||||
|
||||
//! Offset the the first bodypart.
|
||||
int32_t bodypartindex;
|
||||
|
||||
//! The number of attachments.
|
||||
int32_t numattachments;
|
||||
|
||||
//! Offset the the first attachment chunk.
|
||||
int32_t attachmentindex;
|
||||
|
||||
//! Was "soundtable".
|
||||
int32_t unused2;
|
||||
|
||||
//! Was "soundindex".
|
||||
int32_t unused3;
|
||||
|
||||
//! Was "soundgroups".
|
||||
int32_t unused4;
|
||||
|
||||
//! Was "soundgroupindex".
|
||||
int32_t unused5;
|
||||
|
||||
//! The number of nodes in the sequence transition graph.
|
||||
int32_t numtransitions;
|
||||
|
||||
//! Offset the the first sequence transition.
|
||||
int32_t transitionindex;
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct SequenceHeader_HL1
|
||||
* \brief Data structure for the file header of a demand loaded
|
||||
* HL1 MDL sequence group file.
|
||||
*/
|
||||
struct SequenceHeader_HL1 : HalfLifeMDLBaseHeader {
|
||||
//! The sequence group file name.
|
||||
char name[64];
|
||||
|
||||
//! The total file size in bytes.
|
||||
int32_t length;
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct Bone_HL1
|
||||
* \brief Data structure for a bone in HL1 MDL files.
|
||||
*/
|
||||
struct Bone_HL1 {
|
||||
//! The bone name.
|
||||
char name[32];
|
||||
|
||||
//! The parent bone index. (-1) If it has no parent.
|
||||
int32_t parent;
|
||||
|
||||
//! Was "flags".
|
||||
int32_t unused;
|
||||
|
||||
//! Available bone controller per motion type.
|
||||
//! (-1) if no controller is available.
|
||||
int32_t bonecontroller[6];
|
||||
|
||||
/*! Default position and rotation values where
|
||||
* scale[0] = position.X
|
||||
* scale[1] = position.Y
|
||||
* scale[2] = position.Z
|
||||
* scale[3] = rotation.X
|
||||
* scale[4] = rotation.Y
|
||||
* scale[5] = rotation.Z
|
||||
*/
|
||||
float value[6];
|
||||
|
||||
/*! Compressed scale values where
|
||||
* scale[0] = position.X scale
|
||||
* scale[1] = position.Y scale
|
||||
* scale[2] = position.Z scale
|
||||
* scale[3] = rotation.X scale
|
||||
* scale[4] = rotation.Y scale
|
||||
* scale[5] = rotation.Z scale
|
||||
*/
|
||||
float scale[6];
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct BoneController_HL1
|
||||
* \brief Data structure for a bone controller in HL1 MDL files.
|
||||
*/
|
||||
struct BoneController_HL1 {
|
||||
//! Bone affected by this controller.
|
||||
int32_t bone;
|
||||
|
||||
//! The motion type.
|
||||
int32_t type;
|
||||
|
||||
//! The minimum and maximum values.
|
||||
float start;
|
||||
float end;
|
||||
|
||||
// Was "rest".
|
||||
int32_t unused;
|
||||
|
||||
// The bone controller channel.
|
||||
int32_t index;
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct Hitbox_HL1
|
||||
* \brief Data structure for a hitbox in HL1 MDL files.
|
||||
*/
|
||||
struct Hitbox_HL1 {
|
||||
//! The bone this hitbox follows.
|
||||
int32_t bone;
|
||||
|
||||
//! The hit group.
|
||||
int32_t group;
|
||||
|
||||
//! The hitbox minimum and maximum extents.
|
||||
vec3_t bbmin;
|
||||
vec3_t bbmax;
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct SequenceGroup_HL1
|
||||
* \brief Data structure for a sequence group in HL1 MDL files.
|
||||
*/
|
||||
struct SequenceGroup_HL1 {
|
||||
//! A textual name for this sequence group.
|
||||
char label[32];
|
||||
|
||||
//! The file name.
|
||||
char name[64];
|
||||
|
||||
//! Was "cache".
|
||||
int32_t unused;
|
||||
|
||||
//! Was "data".
|
||||
int32_t unused2;
|
||||
} PACK_STRUCT;
|
||||
|
||||
//! The type of blending for a sequence.
|
||||
enum SequenceBlendMode_HL1 {
|
||||
NoBlend = 1,
|
||||
TwoWayBlending = 2,
|
||||
FourWayBlending = 4,
|
||||
};
|
||||
|
||||
/** \struct SequenceDesc_HL1
|
||||
* \brief Data structure for a sequence description in HL1 MDL files.
|
||||
*/
|
||||
struct SequenceDesc_HL1 {
|
||||
//! The sequence name.
|
||||
char label[32];
|
||||
|
||||
//! Frames per second.
|
||||
float fps;
|
||||
|
||||
//! looping/non-looping flags.
|
||||
int32_t flags;
|
||||
|
||||
//! The sequence activity.
|
||||
int32_t activity;
|
||||
|
||||
//! The sequence activity weight.
|
||||
int32_t actweight;
|
||||
|
||||
//! The number of animation events.
|
||||
int32_t numevents;
|
||||
|
||||
//! Offset the the first animation event chunk.
|
||||
int32_t eventindex;
|
||||
|
||||
//! The number of frames in the sequence.
|
||||
int32_t numframes;
|
||||
|
||||
//! Was "numpivots".
|
||||
int32_t unused;
|
||||
|
||||
//! Was "pivotindex".
|
||||
int32_t unused2;
|
||||
|
||||
//! Linear motion type.
|
||||
int32_t motiontype;
|
||||
|
||||
//! Linear motion bone.
|
||||
int32_t motionbone;
|
||||
|
||||
//! Linear motion.
|
||||
vec3_t linearmovement;
|
||||
|
||||
//! Was "automoveposindex".
|
||||
int32_t unused3;
|
||||
|
||||
//! Was "automoveangleindex".
|
||||
int32_t unused4;
|
||||
|
||||
//! The sequence minimum and maximum extents.
|
||||
vec3_t bbmin;
|
||||
vec3_t bbmax;
|
||||
|
||||
//! The number of blend animations.
|
||||
int32_t numblends;
|
||||
|
||||
//! Offset to first the AnimValueOffset_HL1 chunk.
|
||||
//! This offset is relative to the SequenceHeader_HL1 of the file
|
||||
//! that contains the animation data.
|
||||
int32_t animindex;
|
||||
|
||||
//! The motion type of each blend controller.
|
||||
int32_t blendtype[2];
|
||||
|
||||
//! The starting value of each blend controller.
|
||||
float blendstart[2];
|
||||
|
||||
//! The ending value of each blend controller.
|
||||
float blendend[2];
|
||||
|
||||
//! Was "blendparent".
|
||||
int32_t unused5;
|
||||
|
||||
//! The sequence group.
|
||||
int32_t seqgroup;
|
||||
|
||||
//! The node at entry in the sequence transition graph.
|
||||
int32_t entrynode;
|
||||
|
||||
//! The node at exit in the sequence transition graph.
|
||||
int32_t exitnode;
|
||||
|
||||
//! Transition rules.
|
||||
int32_t nodeflags;
|
||||
|
||||
//! Was "nextseq"
|
||||
int32_t unused6;
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct AnimEvent_HL1
|
||||
* \brief Data structure for an animation event in HL1 MDL files.
|
||||
*/
|
||||
struct AnimEvent_HL1 {
|
||||
//! The frame at which this animation event occurs.
|
||||
int32_t frame;
|
||||
|
||||
//! The script event type.
|
||||
int32_t event;
|
||||
|
||||
//! was "type"
|
||||
int32_t unused;
|
||||
|
||||
//! Options. Could be path to sound WAVE files.
|
||||
char options[64];
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct Attachment_HL1
|
||||
* \brief Data structure for an attachment in HL1 MDL files.
|
||||
*/
|
||||
struct Attachment_HL1 {
|
||||
//! Was "name".
|
||||
char unused[32];
|
||||
|
||||
//! Was "type".
|
||||
int32_t unused2;
|
||||
|
||||
//! The bone this attachment follows.
|
||||
int32_t bone;
|
||||
|
||||
//! The attachment origin.
|
||||
vec3_t org;
|
||||
|
||||
//! Was "vectors"
|
||||
vec3_t unused3[3];
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct AnimValueOffset_HL1
|
||||
* \brief Data structure to hold offsets (one per motion type)
|
||||
* to the first animation frame value for a single bone
|
||||
* in HL1 MDL files.
|
||||
*/
|
||||
struct AnimValueOffset_HL1 {
|
||||
unsigned short offset[6];
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct AnimValue_HL1
|
||||
* \brief Data structure for an animation frame in HL1 MDL files.
|
||||
*/
|
||||
union AnimValue_HL1 {
|
||||
struct {
|
||||
uint8_t valid;
|
||||
uint8_t total;
|
||||
} num;
|
||||
short value;
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct Bodypart_HL1
|
||||
* \brief Data structure for a bodypart in HL1 MDL files.
|
||||
*/
|
||||
struct Bodypart_HL1 {
|
||||
//! The bodypart name.
|
||||
char name[64];
|
||||
|
||||
//! The number of available models for this bodypart.
|
||||
int32_t nummodels;
|
||||
|
||||
//! Used to convert from a global model index
|
||||
//! to a local bodypart model index.
|
||||
int32_t base;
|
||||
|
||||
//! The offset to the first model chunk.
|
||||
int32_t modelindex;
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct Texture_HL1
|
||||
* \brief Data structure for a texture in HL1 MDL files.
|
||||
*/
|
||||
struct Texture_HL1 {
|
||||
//! Texture file name.
|
||||
char name[64];
|
||||
|
||||
//! Texture flags.
|
||||
int32_t flags;
|
||||
|
||||
//! Texture width in pixels.
|
||||
int32_t width;
|
||||
|
||||
//! Texture height in pixels.
|
||||
int32_t height;
|
||||
|
||||
//! Offset to the image data.
|
||||
//! This offset is relative to the texture file header.
|
||||
int32_t index;
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct Model_HL1
|
||||
* \brief Data structure for a model in HL1 MDL files.
|
||||
*/
|
||||
struct Model_HL1 {
|
||||
//! Model name.
|
||||
char name[64];
|
||||
|
||||
//! Was "type".
|
||||
int32_t unused;
|
||||
|
||||
//! Was "boundingradius".
|
||||
float unused2;
|
||||
|
||||
//! The number of meshes in the model.
|
||||
int32_t nummesh;
|
||||
|
||||
//! Offset to the first mesh chunk.
|
||||
int32_t meshindex;
|
||||
|
||||
//! The number of unique vertices.
|
||||
int32_t numverts;
|
||||
|
||||
//! Offset to the vertex bone array.
|
||||
int32_t vertinfoindex;
|
||||
|
||||
//! Offset to the vertex array.
|
||||
int32_t vertindex;
|
||||
|
||||
//! The number of unique normals.
|
||||
int32_t numnorms;
|
||||
|
||||
//! Offset to the normal bone array.
|
||||
int32_t norminfoindex;
|
||||
|
||||
//! Offset to the normal array.
|
||||
int32_t normindex;
|
||||
|
||||
//! Was "numgroups".
|
||||
int32_t unused3;
|
||||
|
||||
//! Was "groupindex".
|
||||
int32_t unused4;
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct Mesh_HL1
|
||||
* \brief Data structure for a mesh in HL1 MDL files.
|
||||
*/
|
||||
struct Mesh_HL1 {
|
||||
//! Can be interpreted as the number of triangles in the mesh.
|
||||
int32_t numtris;
|
||||
|
||||
//! Offset to the start of the tris sequence.
|
||||
int32_t triindex;
|
||||
|
||||
//! The skin index.
|
||||
int32_t skinref;
|
||||
|
||||
//! The number of normals in the mesh.
|
||||
int32_t numnorms;
|
||||
|
||||
//! Was "normindex".
|
||||
int32_t unused;
|
||||
} PACK_STRUCT;
|
||||
|
||||
/** \struct Trivert
|
||||
* \brief Data structure for a trivert in HL1 MDL files.
|
||||
*/
|
||||
struct Trivert {
|
||||
//! Index into Model_HL1 vertex array.
|
||||
short vertindex;
|
||||
|
||||
//! Index into Model_HL1 normal array.
|
||||
short normindex;
|
||||
|
||||
//! Texture coordinates in absolute space (unnormalized).
|
||||
short s, t;
|
||||
} PACK_STRUCT;
|
||||
|
||||
#include <assimp/Compiler/poppack1.h>
|
||||
|
||||
#if (!defined AI_MDL_HL1_VERSION)
|
||||
#define AI_MDL_HL1_VERSION 10
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_MAX_TRIANGLES)
|
||||
#define AI_MDL_HL1_MAX_TRIANGLES 20000
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_MAX_VERTICES)
|
||||
#define AI_MDL_HL1_MAX_VERTICES 2048
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_MAX_SEQUENCES)
|
||||
#define AI_MDL_HL1_MAX_SEQUENCES 2048
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_MAX_SEQUENCE_GROUPS)
|
||||
#define AI_MDL_HL1_MAX_SEQUENCE_GROUPS 32
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_MAX_TEXTURES)
|
||||
#define AI_MDL_HL1_MAX_TEXTURES 100
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_MAX_SKIN_FAMILIES)
|
||||
#define AI_MDL_HL1_MAX_SKIN_FAMILIES 100
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_MAX_BONES)
|
||||
#define AI_MDL_HL1_MAX_BONES 128
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_MAX_BODYPARTS)
|
||||
#define AI_MDL_HL1_MAX_BODYPARTS 32
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_MAX_MODELS)
|
||||
#define AI_MDL_HL1_MAX_MODELS 32
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_MAX_MESHES)
|
||||
#define AI_MDL_HL1_MAX_MESHES 256
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_MAX_EVENTS)
|
||||
#define AI_MDL_HL1_MAX_EVENTS 1024
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_MAX_BONE_CONTROLLERS)
|
||||
#define AI_MDL_HL1_MAX_BONE_CONTROLLERS 8
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_MAX_ATTACHMENTS)
|
||||
#define AI_MDL_HL1_MAX_ATTACHMENTS 512
|
||||
#endif
|
||||
|
||||
// lighting options
|
||||
#if (!defined AI_MDL_HL1_STUDIO_NF_FLATSHADE)
|
||||
#define AI_MDL_HL1_STUDIO_NF_FLATSHADE 0x0001
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_STUDIO_NF_CHROME)
|
||||
#define AI_MDL_HL1_STUDIO_NF_CHROME 0x0002
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_STUDIO_NF_ADDITIVE)
|
||||
#define AI_MDL_HL1_STUDIO_NF_ADDITIVE 0x0020
|
||||
#endif
|
||||
#if (!defined AI_MDL_HL1_STUDIO_NF_MASKED)
|
||||
#define AI_MDL_HL1_STUDIO_NF_MASKED 0x0040
|
||||
#endif
|
||||
|
||||
} // namespace HalfLife
|
||||
} // namespace MDL
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // AI_HL1FILEDATA_INCLUDED
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, 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 HL1ImportDefinitions.h
|
||||
* @brief HL1 MDL loader specific definitions.
|
||||
*/
|
||||
|
||||
#ifndef AI_MDL_HL1_IMPORT_DEFINITIONS_INCLUDED
|
||||
#define AI_MDL_HL1_IMPORT_DEFINITIONS_INCLUDED
|
||||
|
||||
#define AI_MDL_HL1_NODE_ROOT "<MDL_root>"
|
||||
#define AI_MDL_HL1_NODE_BODYPARTS "<MDL_bodyparts>"
|
||||
#define AI_MDL_HL1_NODE_BONES "<MDL_bones>"
|
||||
#define AI_MDL_HL1_NODE_BONE_CONTROLLERS "<MDL_bone_controllers>"
|
||||
#define AI_MDL_HL1_NODE_SEQUENCE_INFOS "<MDL_sequence_infos>"
|
||||
#define AI_MDL_HL1_NODE_SEQUENCE_GROUPS "<MDL_sequence_groups>"
|
||||
#define AI_MDL_HL1_NODE_SEQUENCE_TRANSITION_GRAPH "<MDL_sequence_transition_graph>"
|
||||
#define AI_MDL_HL1_NODE_ATTACHMENTS "<MDL_attachments>"
|
||||
#define AI_MDL_HL1_NODE_HITBOXES "<MDL_hitboxes>"
|
||||
#define AI_MDL_HL1_NODE_GLOBAL_INFO "<MDL_global_info>"
|
||||
#define AI_MDL_HL1_NODE_ANIMATION_EVENTS "AnimationEvents"
|
||||
#define AI_MDL_HL1_NODE_BLEND_CONTROLLERS "BlendControllers"
|
||||
|
||||
#define AI_MDL_HL1_MATKEY_CHROME(type, N) "$mat.HL1.chrome", type, N
|
||||
|
||||
#endif // AI_MDL_HL1_IMPORT_DEFINITIONS_INCLUDED
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, 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 HL1ImportSettings.h
|
||||
* @brief Half-Life 1 MDL loader configuration settings.
|
||||
*/
|
||||
|
||||
#ifndef AI_HL1IMPORTSETTINGS_INCLUDED
|
||||
#define AI_HL1IMPORTSETTINGS_INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Assimp {
|
||||
namespace MDL {
|
||||
namespace HalfLife {
|
||||
|
||||
struct HL1ImportSettings {
|
||||
HL1ImportSettings() :
|
||||
read_animations(false),
|
||||
read_animation_events(false),
|
||||
read_blend_controllers(false),
|
||||
read_sequence_groups_info(false),
|
||||
read_sequence_transitions(false),
|
||||
read_attachments(false),
|
||||
read_bone_controllers(false),
|
||||
read_hitboxes(false),
|
||||
read_textures(false),
|
||||
read_misc_global_info(false) {
|
||||
}
|
||||
|
||||
bool read_animations;
|
||||
bool read_animation_events;
|
||||
bool read_blend_controllers;
|
||||
bool read_sequence_groups_info;
|
||||
bool read_sequence_transitions;
|
||||
bool read_attachments;
|
||||
bool read_bone_controllers;
|
||||
bool read_hitboxes;
|
||||
bool read_textures;
|
||||
bool read_misc_global_info;
|
||||
};
|
||||
|
||||
} // namespace HalfLife
|
||||
} // namespace MDL
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // AI_HL1IMPORTSETTINGS_INCLUDED
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,241 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, 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 HL1MDLLoader.h
|
||||
* @brief Declaration of the Half-Life 1 MDL loader.
|
||||
*/
|
||||
|
||||
#ifndef AI_HL1MDLLOADER_INCLUDED
|
||||
#define AI_HL1MDLLOADER_INCLUDED
|
||||
|
||||
#include "HL1FileData.h"
|
||||
#include "HL1ImportSettings.h"
|
||||
#include "UniqueNameGenerator.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/texture.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/DefaultIOSystem.h>
|
||||
#include <assimp/Exceptional.h>
|
||||
|
||||
namespace Assimp {
|
||||
namespace MDL {
|
||||
namespace HalfLife {
|
||||
|
||||
class HL1MDLLoader {
|
||||
public:
|
||||
HL1MDLLoader() = delete;
|
||||
HL1MDLLoader(const HL1MDLLoader &) = delete;
|
||||
|
||||
/** See variables descriptions at the end for more details. */
|
||||
HL1MDLLoader(
|
||||
aiScene *scene,
|
||||
IOSystem *io,
|
||||
const unsigned char *buffer,
|
||||
const std::string &file_path,
|
||||
const HL1ImportSettings &import_settings);
|
||||
|
||||
~HL1MDLLoader();
|
||||
|
||||
void load_file();
|
||||
|
||||
protected:
|
||||
/** \brief Validate the header data structure of a Half-Life 1 MDL file.
|
||||
* \param[in] header Input header to be validated.
|
||||
* \param[in] is_texture_header Whether or not we are reading an MDL
|
||||
* texture file.
|
||||
*/
|
||||
void validate_header(const Header_HL1 *header, bool is_texture_header);
|
||||
|
||||
void load_texture_file();
|
||||
void load_sequence_groups_files();
|
||||
void read_textures();
|
||||
void read_skins();
|
||||
void read_bones();
|
||||
void read_meshes();
|
||||
void read_animations();
|
||||
void read_sequence_groups_info();
|
||||
void read_sequence_infos();
|
||||
void read_sequence_transitions();
|
||||
void read_attachments();
|
||||
void read_hitboxes();
|
||||
void read_bone_controllers();
|
||||
void read_global_info();
|
||||
|
||||
private:
|
||||
void release_resources();
|
||||
|
||||
/** \brief Load a file and copy it's content to a buffer.
|
||||
* \param file_path The path to the file to be loaded.
|
||||
* \param buffer A pointer to a buffer to receive the data.
|
||||
*/
|
||||
template <typename MDLFileHeader>
|
||||
void load_file_into_buffer(const std::string &file_path, unsigned char *&buffer);
|
||||
|
||||
/** \brief Read an MDL texture.
|
||||
* \param[in] ptexture A pointer to an MDL texture.
|
||||
* \param[in] data A pointer to the data from \p ptexture.
|
||||
* \param[in] pal A pointer to the texture palette from \p ptexture.
|
||||
* \param[in,out] pResult A pointer to the output resulting Assimp texture.
|
||||
* \param[in,out] last_palette_color The last color from the image palette.
|
||||
*/
|
||||
void read_texture(const Texture_HL1 *ptexture,
|
||||
uint8_t *data, uint8_t *pal, aiTexture *pResult,
|
||||
aiColor3D &last_palette_color);
|
||||
|
||||
/** \brief This method reads a compressed anim value.
|
||||
* \param[in] panimvalue A pointer to the animation data.
|
||||
* \param[in] frame The frame to look for.
|
||||
* \param[in] bone_scale The current bone scale to apply to the compressed value.
|
||||
* \param[in,out] value The decompressed anim value at \p frame.
|
||||
*/
|
||||
void extract_anim_value(const AnimValue_HL1 *panimvalue,
|
||||
int frame, float bone_scale, float &value);
|
||||
|
||||
/**
|
||||
* \brief Given the number of blend animations, determine the number of blend controllers.
|
||||
*
|
||||
* \param[in] num_blend_animations The number of blend animations.
|
||||
* \param[out] num_blend_controllers The number of blend controllers.
|
||||
* \return True if the number of blend controllers was determined. False otherwise.
|
||||
*/
|
||||
static bool get_num_blend_controllers(const int num_blend_animations, int &num_blend_controllers);
|
||||
|
||||
/** Output scene to be filled */
|
||||
aiScene *scene_;
|
||||
|
||||
/** Output I/O handler. Required for additional IO operations. */
|
||||
IOSystem *io_;
|
||||
|
||||
/** Buffer from MDLLoader class. */
|
||||
const unsigned char *buffer_;
|
||||
|
||||
/** The full file path to the MDL file we are trying to load.
|
||||
* Used to locate other MDL files since MDL may store resources
|
||||
* in external MDL files. */
|
||||
const std::string &file_path_;
|
||||
|
||||
/** Configuration for HL1 MDL */
|
||||
const HL1ImportSettings &import_settings_;
|
||||
|
||||
/** Main MDL header. */
|
||||
const Header_HL1 *header_;
|
||||
|
||||
/** External MDL texture header. */
|
||||
const Header_HL1 *texture_header_;
|
||||
|
||||
/** External MDL animation headers.
|
||||
* One for each loaded animation file. */
|
||||
SequenceHeader_HL1 **anim_headers_;
|
||||
|
||||
/** Texture file data. */
|
||||
unsigned char *texture_buffer_;
|
||||
|
||||
/** Animation files data. */
|
||||
unsigned char **anim_buffers_;
|
||||
|
||||
/** The number of sequence groups. */
|
||||
int num_sequence_groups_;
|
||||
|
||||
/** The list of children to be appended to the scene's root node. */
|
||||
std::vector<aiNode *> rootnode_children_;
|
||||
|
||||
/** A unique name generator. Used to generate names for MDL values
|
||||
* that may have empty/duplicate names. */
|
||||
UniqueNameGenerator unique_name_generator_;
|
||||
|
||||
/** The list of unique sequence names. */
|
||||
std::vector<std::string> unique_sequence_names_;
|
||||
|
||||
/** The list of unique sequence groups names. */
|
||||
std::vector<std::string> unique_sequence_groups_names_;
|
||||
|
||||
/** Structure to store temporary bone information. */
|
||||
struct TempBone {
|
||||
|
||||
TempBone() :
|
||||
node(nullptr),
|
||||
absolute_transform(),
|
||||
offset_matrix() {}
|
||||
|
||||
aiNode *node;
|
||||
aiMatrix4x4 absolute_transform;
|
||||
aiMatrix4x4 offset_matrix;
|
||||
};
|
||||
|
||||
std::vector<TempBone> temp_bones_;
|
||||
|
||||
/** The number of available bone controllers in the model. */
|
||||
int num_blend_controllers_;
|
||||
|
||||
/** Self explanatory. */
|
||||
int total_models_;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename MDLFileHeader>
|
||||
void HL1MDLLoader::load_file_into_buffer(const std::string &file_path, unsigned char *&buffer) {
|
||||
if (!io_->Exists(file_path))
|
||||
throw DeadlyImportError("Missing file " + DefaultIOSystem::fileName(file_path) + ".");
|
||||
|
||||
std::unique_ptr<IOStream> file(io_->Open(file_path));
|
||||
|
||||
if (file.get() == NULL)
|
||||
throw DeadlyImportError("Failed to open MDL file " + DefaultIOSystem::fileName(file_path) + ".");
|
||||
|
||||
const size_t file_size = file->FileSize();
|
||||
if (file_size < sizeof(MDLFileHeader))
|
||||
throw DeadlyImportError("MDL file is too small.");
|
||||
|
||||
buffer = new unsigned char[1 + file_size];
|
||||
file->Read((void *)buffer, 1, file_size);
|
||||
buffer[file_size] = '\0';
|
||||
}
|
||||
|
||||
} // namespace HalfLife
|
||||
} // namespace MDL
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // AI_HL1MDLLOADER_INCLUDED
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, 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 HL1MeshTrivert.h
|
||||
* @brief This file contains the class declaration for the
|
||||
* HL1 mesh trivert class.
|
||||
*/
|
||||
|
||||
#ifndef AI_HL1MESHTRIVERT_INCLUDED
|
||||
#define AI_HL1MESHTRIVERT_INCLUDED
|
||||
|
||||
#include "HL1FileData.h"
|
||||
|
||||
namespace Assimp {
|
||||
namespace MDL {
|
||||
namespace HalfLife {
|
||||
|
||||
/* A class to help map model triverts to mesh triverts. */
|
||||
struct HL1MeshTrivert {
|
||||
HL1MeshTrivert() :
|
||||
vertindex(-1),
|
||||
normindex(-1),
|
||||
s(0),
|
||||
t(0),
|
||||
localindex(-1) {
|
||||
}
|
||||
|
||||
HL1MeshTrivert(short vertindex, short normindex, short s, short t, short localindex) :
|
||||
vertindex(vertindex),
|
||||
normindex(normindex),
|
||||
s(s),
|
||||
t(t),
|
||||
localindex() {
|
||||
}
|
||||
|
||||
HL1MeshTrivert(const Trivert &a) :
|
||||
vertindex(a.vertindex),
|
||||
normindex(a.normindex),
|
||||
s(a.s),
|
||||
t(a.t),
|
||||
localindex(-1) {
|
||||
}
|
||||
|
||||
inline bool operator==(const Trivert &a) const {
|
||||
return vertindex == a.vertindex &&
|
||||
normindex == a.normindex &&
|
||||
s == a.s &&
|
||||
t == a.t;
|
||||
}
|
||||
|
||||
inline bool operator!=(const Trivert &a) const {
|
||||
return !(*this == a);
|
||||
}
|
||||
|
||||
inline bool operator==(const HL1MeshTrivert &a) const {
|
||||
return localindex == a.localindex &&
|
||||
vertindex == a.vertindex &&
|
||||
normindex == a.normindex &&
|
||||
s == a.s &&
|
||||
t == a.t;
|
||||
}
|
||||
|
||||
inline bool operator!=(const HL1MeshTrivert &a) const {
|
||||
return !(*this == a);
|
||||
}
|
||||
|
||||
inline HL1MeshTrivert &operator=(const Trivert &other) {
|
||||
vertindex = other.vertindex;
|
||||
normindex = other.normindex;
|
||||
s = other.s;
|
||||
t = other.t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
short vertindex;
|
||||
short normindex;
|
||||
short s, t;
|
||||
short localindex;
|
||||
};
|
||||
|
||||
struct HL1MeshFace {
|
||||
short v0, v1, v2;
|
||||
};
|
||||
|
||||
} // namespace HalfLife
|
||||
} // namespace MDL
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // AI_HL1MESHTRIVERT_INCLUDED
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, 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 HalfLifeMDLBaseHeader.h */
|
||||
|
||||
#ifndef AI_HALFLIFEMDLBASEHEADER_INCLUDED
|
||||
#define AI_HALFLIFEMDLBASEHEADER_INCLUDED
|
||||
|
||||
#include <assimp/types.h>
|
||||
|
||||
namespace Assimp {
|
||||
namespace MDL {
|
||||
namespace HalfLife {
|
||||
|
||||
/** Used to interface different Valve MDL formats. */
|
||||
struct HalfLifeMDLBaseHeader
|
||||
{
|
||||
//! Magic number: "IDST"/"IDSQ"
|
||||
char ident[4];
|
||||
|
||||
//! The file format version.
|
||||
int32_t version;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // AI_HALFLIFEMDLBASEHEADER_INCLUDED
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, 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 LogFunctions.h */
|
||||
|
||||
#ifndef AI_MDL_HALFLIFE_LOGFUNCTIONS_INCLUDED
|
||||
#define AI_MDL_HALFLIFE_LOGFUNCTIONS_INCLUDED
|
||||
|
||||
#include <assimp/Logger.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace Assimp {
|
||||
namespace MDL {
|
||||
namespace HalfLife {
|
||||
|
||||
/**
|
||||
* \brief A function to log precise messages regarding limits exceeded.
|
||||
*
|
||||
* \param[in] subject Subject.
|
||||
* \param[in] current_amount Current amount.
|
||||
* \param[in] direct_object Direct object.
|
||||
* LIMIT Limit constant.
|
||||
*
|
||||
* Example: Model has 100 textures, which exceeds the limit (50)
|
||||
*
|
||||
* where \p subject is 'Model'
|
||||
* \p current_amount is '100'
|
||||
* \p direct_object is 'textures'
|
||||
* LIMIT is '50'
|
||||
*/
|
||||
template <int LIMIT>
|
||||
static inline void log_warning_limit_exceeded(
|
||||
const std::string &subject, int current_amount,
|
||||
const std::string &direct_object) {
|
||||
|
||||
ASSIMP_LOG_WARN(MDL_HALFLIFE_LOG_HEADER
|
||||
+ subject
|
||||
+ " has "
|
||||
+ std::to_string(current_amount) + " "
|
||||
+ direct_object
|
||||
+ ", which exceeds the limit ("
|
||||
+ std::to_string(LIMIT)
|
||||
+ ")");
|
||||
}
|
||||
|
||||
/** \brief Same as above, but uses 'Model' as the subject. */
|
||||
template <int LIMIT>
|
||||
static inline void log_warning_limit_exceeded(int current_amount,
|
||||
const std::string &direct_object) {
|
||||
log_warning_limit_exceeded<LIMIT>("Model", current_amount, direct_object);
|
||||
}
|
||||
|
||||
} // namespace HalfLife
|
||||
} // namespace MDL
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // AI_MDL_HALFLIFE_LOGFUNCTIONS_INCLUDED
|
||||
|
|
@ -1,180 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, 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 UniqueNameGenerator.cpp
|
||||
* @brief Implementation for the unique name generator.
|
||||
*/
|
||||
|
||||
#include "UniqueNameGenerator.h"
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <numeric>
|
||||
|
||||
namespace Assimp {
|
||||
namespace MDL {
|
||||
namespace HalfLife {
|
||||
|
||||
UniqueNameGenerator::UniqueNameGenerator() :
|
||||
template_name_("unnamed"),
|
||||
separator_("_") {
|
||||
}
|
||||
|
||||
UniqueNameGenerator::UniqueNameGenerator(const char *template_name) :
|
||||
template_name_(template_name),
|
||||
separator_("_") {
|
||||
}
|
||||
|
||||
UniqueNameGenerator::UniqueNameGenerator(const char *template_name, const char *separator) :
|
||||
template_name_(template_name),
|
||||
separator_(separator) {
|
||||
}
|
||||
|
||||
UniqueNameGenerator::~UniqueNameGenerator() {
|
||||
}
|
||||
|
||||
void UniqueNameGenerator::make_unique(std::vector<std::string> &names) {
|
||||
struct DuplicateInfo {
|
||||
DuplicateInfo() :
|
||||
indices(),
|
||||
next_id(0) {
|
||||
}
|
||||
|
||||
std::list<size_t> indices;
|
||||
size_t next_id;
|
||||
};
|
||||
|
||||
std::vector<size_t> empty_names_indices;
|
||||
std::vector<size_t> template_name_duplicates;
|
||||
std::map<std::string, DuplicateInfo> names_to_duplicates;
|
||||
|
||||
const std::string template_name_with_separator(template_name_ + separator_);
|
||||
|
||||
auto format_name = [&](const std::string &base_name, size_t id) -> std::string {
|
||||
return base_name + separator_ + std::to_string(id);
|
||||
};
|
||||
|
||||
auto generate_unique_name = [&](const std::string &base_name) -> std::string {
|
||||
auto *duplicate_info = &names_to_duplicates[base_name];
|
||||
|
||||
std::string new_name = "";
|
||||
|
||||
bool found_identical_name;
|
||||
bool tried_with_base_name_only = false;
|
||||
do {
|
||||
// Assume that no identical name exists.
|
||||
found_identical_name = false;
|
||||
|
||||
if (!tried_with_base_name_only) {
|
||||
// First try with only the base name.
|
||||
new_name = base_name;
|
||||
} else {
|
||||
// Create the name expected to be unique.
|
||||
new_name = format_name(base_name, duplicate_info->next_id);
|
||||
}
|
||||
|
||||
// Check in the list of duplicates for an identical name.
|
||||
for (size_t i = 0;
|
||||
i < names.size() &&
|
||||
!found_identical_name;
|
||||
++i) {
|
||||
if (new_name == names[i])
|
||||
found_identical_name = true;
|
||||
}
|
||||
|
||||
if (tried_with_base_name_only)
|
||||
++duplicate_info->next_id;
|
||||
|
||||
tried_with_base_name_only = true;
|
||||
|
||||
} while (found_identical_name);
|
||||
|
||||
return new_name;
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < names.size(); ++i) {
|
||||
// Check for empty names.
|
||||
if (names[i].find_first_not_of(' ') == std::string::npos) {
|
||||
empty_names_indices.push_back(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check for potential duplicate.
|
||||
a) Either if this name is the same as the template name or
|
||||
b) <template name><separator> is found at the beginning. */
|
||||
if (names[i] == template_name_ ||
|
||||
names[i].substr(0, template_name_with_separator.length()) == template_name_with_separator)
|
||||
template_name_duplicates.push_back(i);
|
||||
|
||||
// Map each unique name to it's duplicate.
|
||||
if (names_to_duplicates.count(names[i]) == 0)
|
||||
names_to_duplicates.insert({ names[i], DuplicateInfo()});
|
||||
else
|
||||
names_to_duplicates[names[i]].indices.push_back(i);
|
||||
}
|
||||
|
||||
// Make every non-empty name unique.
|
||||
for (auto it = names_to_duplicates.begin();
|
||||
it != names_to_duplicates.end(); ++it) {
|
||||
for (auto it2 = it->second.indices.begin();
|
||||
it2 != it->second.indices.end();
|
||||
++it2)
|
||||
names[*it2] = generate_unique_name(it->first);
|
||||
}
|
||||
|
||||
// Generate a unique name for every empty string.
|
||||
if (template_name_duplicates.size()) {
|
||||
// At least one string ressembles to <template name>.
|
||||
for (auto it = empty_names_indices.begin();
|
||||
it != empty_names_indices.end(); ++it)
|
||||
names[*it] = generate_unique_name(template_name_);
|
||||
} else {
|
||||
// No string alike <template name> exists.
|
||||
size_t i = 0;
|
||||
for (auto it = empty_names_indices.begin();
|
||||
it != empty_names_indices.end(); ++it, ++i)
|
||||
names[*it] = format_name(template_name_, i);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace HalfLife
|
||||
} // namespace MDL
|
||||
} // namespace Assimp
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, 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 UniqueNameGenerator.h
|
||||
* @brief Declaration of the unique name generator.
|
||||
*/
|
||||
|
||||
#ifndef AI_UNIQUENAMEGENERATOR_INCLUDED
|
||||
#define AI_UNIQUENAMEGENERATOR_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Assimp {
|
||||
namespace MDL {
|
||||
namespace HalfLife {
|
||||
|
||||
class UniqueNameGenerator {
|
||||
public:
|
||||
UniqueNameGenerator();
|
||||
UniqueNameGenerator(const char *template_name);
|
||||
UniqueNameGenerator(const char *template_name, const char *separator);
|
||||
~UniqueNameGenerator();
|
||||
|
||||
inline void set_template_name(const char *template_name) {
|
||||
template_name_ = template_name;
|
||||
}
|
||||
inline void set_separator(const char *separator) {
|
||||
separator_ = separator;
|
||||
}
|
||||
|
||||
void make_unique(std::vector<std::string> &names);
|
||||
|
||||
private:
|
||||
std::string template_name_;
|
||||
std::string separator_;
|
||||
};
|
||||
|
||||
} // namespace HalfLife
|
||||
} // namespace MDL
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // AI_UNIQUENAMEGENERATOR_INCLUDED
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -51,8 +51,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "MDL/MDLLoader.h"
|
||||
#include "MDL/MDLDefaultColorMap.h"
|
||||
#include "MD2/MD2FileData.h"
|
||||
#include "MDL/HalfLife/HL1MDLLoader.h"
|
||||
|
||||
#include <assimp/Macros.h>
|
||||
#include <assimp/qnan.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/Importer.hpp>
|
||||
|
|
@ -143,18 +143,6 @@ void MDLImporter::SetupProperties(const Importer* pImp)
|
|||
|
||||
// AI_CONFIG_IMPORT_MDL_COLORMAP - palette file
|
||||
configPalette = pImp->GetPropertyString(AI_CONFIG_IMPORT_MDL_COLORMAP,"colormap.lmp");
|
||||
|
||||
// Read configuration specific to MDL (Half-Life 1).
|
||||
mHL1ImportSettings.read_animations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS, true);
|
||||
if (mHL1ImportSettings.read_animations) {
|
||||
mHL1ImportSettings.read_animation_events = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATION_EVENTS, true);
|
||||
mHL1ImportSettings.read_blend_controllers = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_BLEND_CONTROLLERS, true);
|
||||
mHL1ImportSettings.read_sequence_transitions = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_SEQUENCE_TRANSITIONS, true);
|
||||
}
|
||||
mHL1ImportSettings.read_attachments = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_ATTACHMENTS, true);
|
||||
mHL1ImportSettings.read_bone_controllers = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_BONE_CONTROLLERS, true);
|
||||
mHL1ImportSettings.read_hitboxes = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_HITBOXES, true);
|
||||
mHL1ImportSettings.read_misc_global_info = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_MISC_GLOBAL_INFO, true);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -179,104 +167,83 @@ void MDLImporter::InternReadFile( const std::string& pFile,
|
|||
}
|
||||
|
||||
// This should work for all other types of MDL files, too ...
|
||||
// the HL1 sequence group header is one of the smallest, afaik
|
||||
// the quake header is one of the smallest, afaik
|
||||
iFileSize = (unsigned int)file->FileSize();
|
||||
if( iFileSize < sizeof(MDL::HalfLife::SequenceHeader_HL1)) {
|
||||
if( iFileSize < sizeof(MDL::Header)) {
|
||||
throw DeadlyImportError( "MDL File is too small.");
|
||||
}
|
||||
|
||||
// delete the file buffer and cleanup.
|
||||
auto DeleteBufferAndCleanup = [&]() {
|
||||
if (mBuffer) {
|
||||
delete [] mBuffer;
|
||||
mBuffer = nullptr;
|
||||
}
|
||||
AI_DEBUG_INVALIDATE_PTR(pIOHandler);
|
||||
AI_DEBUG_INVALIDATE_PTR(pScene);
|
||||
};
|
||||
|
||||
try {
|
||||
// Allocate storage and copy the contents of the file to a memory buffer
|
||||
mBuffer = new unsigned char[iFileSize+1];
|
||||
file->Read( (void*)mBuffer, 1, iFileSize);
|
||||
|
||||
// Append a binary zero to the end of the buffer.
|
||||
// this is just for safety that string parsing routines
|
||||
// find the end of the buffer ...
|
||||
mBuffer[iFileSize] = '\0';
|
||||
const uint32_t iMagicWord = *((uint32_t*)mBuffer);
|
||||
// Allocate storage and copy the contents of the file to a memory buffer
|
||||
mBuffer =new unsigned char[iFileSize+1];
|
||||
file->Read( (void*)mBuffer, 1, iFileSize);
|
||||
|
||||
// Determine the file subtype and call the appropriate member function
|
||||
// Append a binary zero to the end of the buffer.
|
||||
// this is just for safety that string parsing routines
|
||||
// find the end of the buffer ...
|
||||
mBuffer[iFileSize] = '\0';
|
||||
const uint32_t iMagicWord = *((uint32_t*)mBuffer);
|
||||
|
||||
// Original Quake1 format
|
||||
if (AI_MDL_MAGIC_NUMBER_BE == iMagicWord || AI_MDL_MAGIC_NUMBER_LE == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: Quake 1, magic word is IDPO");
|
||||
iGSFileVersion = 0;
|
||||
InternReadFile_Quake1();
|
||||
}
|
||||
// GameStudio A<old> MDL2 format - used by some test models that come with 3DGS
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS3 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS3 == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A2, magic word is MDL2");
|
||||
iGSFileVersion = 2;
|
||||
InternReadFile_Quake1();
|
||||
}
|
||||
// GameStudio A4 MDL3 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS4 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS4 == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL3");
|
||||
iGSFileVersion = 3;
|
||||
InternReadFile_3DGS_MDL345();
|
||||
}
|
||||
// GameStudio A5+ MDL4 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS5a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5a == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL4");
|
||||
iGSFileVersion = 4;
|
||||
InternReadFile_3DGS_MDL345();
|
||||
}
|
||||
// GameStudio A5+ MDL5 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS5b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5b == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A5, magic word is MDL5");
|
||||
iGSFileVersion = 5;
|
||||
InternReadFile_3DGS_MDL345();
|
||||
}
|
||||
// GameStudio A7 MDL7 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS7 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS7 == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A7, magic word is MDL7");
|
||||
iGSFileVersion = 7;
|
||||
InternReadFile_3DGS_MDL7();
|
||||
}
|
||||
// IDST/IDSQ Format (CS:S/HL^2, etc ...)
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2a == iMagicWord ||
|
||||
AI_MDL_MAGIC_NUMBER_BE_HL2b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2b == iMagicWord)
|
||||
{
|
||||
iGSFileVersion = 0;
|
||||
// Determine the file subtype and call the appropriate member function
|
||||
|
||||
HalfLife::HalfLifeMDLBaseHeader *pHeader = (HalfLife::HalfLifeMDLBaseHeader *)mBuffer;
|
||||
if (pHeader->version == AI_MDL_HL1_VERSION)
|
||||
{
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: Half-Life 1/Goldsrc Engine, magic word is IDST/IDSQ");
|
||||
InternReadFile_HL1(pFile, iMagicWord);
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: Source(tm) Engine, magic word is IDST/IDSQ");
|
||||
InternReadFile_HL2();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// print the magic word to the log file
|
||||
throw DeadlyImportError( "Unknown MDL subformat " + pFile +
|
||||
". Magic word (" + std::string((char*)&iMagicWord,4) + ") is not known");
|
||||
}
|
||||
|
||||
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
||||
pScene->mRootNode->mTransformation = aiMatrix4x4(1.f,0.f,0.f,0.f,
|
||||
0.f,0.f,1.f,0.f,0.f,-1.f,0.f,0.f,0.f,0.f,0.f,1.f);
|
||||
|
||||
DeleteBufferAndCleanup();
|
||||
} catch(...) {
|
||||
DeleteBufferAndCleanup();
|
||||
throw;
|
||||
// Original Quake1 format
|
||||
if (AI_MDL_MAGIC_NUMBER_BE == iMagicWord || AI_MDL_MAGIC_NUMBER_LE == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: Quake 1, magic word is IDPO");
|
||||
iGSFileVersion = 0;
|
||||
InternReadFile_Quake1();
|
||||
}
|
||||
// GameStudio A<old> MDL2 format - used by some test models that come with 3DGS
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS3 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS3 == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A2, magic word is MDL2");
|
||||
iGSFileVersion = 2;
|
||||
InternReadFile_Quake1();
|
||||
}
|
||||
// GameStudio A4 MDL3 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS4 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS4 == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL3");
|
||||
iGSFileVersion = 3;
|
||||
InternReadFile_3DGS_MDL345();
|
||||
}
|
||||
// GameStudio A5+ MDL4 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS5a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5a == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL4");
|
||||
iGSFileVersion = 4;
|
||||
InternReadFile_3DGS_MDL345();
|
||||
}
|
||||
// GameStudio A5+ MDL5 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS5b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5b == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A5, magic word is MDL5");
|
||||
iGSFileVersion = 5;
|
||||
InternReadFile_3DGS_MDL345();
|
||||
}
|
||||
// GameStudio A7 MDL7 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS7 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS7 == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A7, magic word is MDL7");
|
||||
iGSFileVersion = 7;
|
||||
InternReadFile_3DGS_MDL7();
|
||||
}
|
||||
// IDST/IDSQ Format (CS:S/HL^2, etc ...)
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2a == iMagicWord ||
|
||||
AI_MDL_MAGIC_NUMBER_BE_HL2b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2b == iMagicWord)
|
||||
{
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: Source(tm) Engine, magic word is IDST/IDSQ");
|
||||
iGSFileVersion = 0;
|
||||
InternReadFile_HL2();
|
||||
}
|
||||
else {
|
||||
// print the magic word to the log file
|
||||
throw DeadlyImportError( "Unknown MDL subformat " + pFile +
|
||||
". Magic word (" + std::string((char*)&iMagicWord,4) + ") is not known");
|
||||
}
|
||||
|
||||
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
||||
pScene->mRootNode->mTransformation = aiMatrix4x4(1.f,0.f,0.f,0.f,
|
||||
0.f,0.f,1.f,0.f,0.f,-1.f,0.f,0.f,0.f,0.f,0.f,1.f);
|
||||
|
||||
// delete the file buffer and cleanup
|
||||
delete [] mBuffer;
|
||||
mBuffer= nullptr;
|
||||
AI_DEBUG_INVALIDATE_PTR(pIOHandler);
|
||||
AI_DEBUG_INVALIDATE_PTR(pScene);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -1421,11 +1388,11 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
|||
avOutList[i].reserve(3);
|
||||
|
||||
// buffer to held the names of all groups in the file
|
||||
const size_t buffersize(AI_MDL7_MAX_GROUPNAMESIZE*pcHeader->groups_num);
|
||||
char* aszGroupNameBuffer = new char[ buffersize ];
|
||||
const size_t buffersize( AI_MDL7_MAX_GROUPNAMESIZE*pcHeader->groups_num );
|
||||
char* aszGroupNameBuffer = new char[ buffersize ];
|
||||
|
||||
// read all groups
|
||||
for (unsigned int iGroup = 0; iGroup < (unsigned int)pcHeader->groups_num; ++iGroup) {
|
||||
for (unsigned int iGroup = 0; iGroup < (unsigned int)pcHeader->groups_num;++iGroup) {
|
||||
MDL::IntGroupInfo_MDL7 groupInfo((BE_NCONST MDL::Group_MDL7*)szCurrent,iGroup);
|
||||
szCurrent = (const unsigned char*)(groupInfo.pcGroup+1);
|
||||
|
||||
|
|
@ -1586,7 +1553,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
|||
const size_t maxSize(buffersize - (i*AI_MDL7_MAX_GROUPNAMESIZE));
|
||||
pcNode->mName.length = ai_snprintf(szBuffer, maxSize, "Group_%u", p);
|
||||
} else {
|
||||
pcNode->mName.length = (ai_uint32)::strlen(szBuffer);
|
||||
pcNode->mName.length = ::strlen(szBuffer);
|
||||
}
|
||||
::strncpy(pcNode->mName.data,szBuffer,MAXLEN-1);
|
||||
++p;
|
||||
|
|
@ -1989,23 +1956,6 @@ void MDLImporter::JoinSkins_3DGS_MDL7(
|
|||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Read a Half-life 1 MDL
|
||||
void MDLImporter::InternReadFile_HL1(const std::string& pFile, const uint32_t iMagicWord)
|
||||
{
|
||||
// We can't correctly load an MDL from a MDL "sequence" file.
|
||||
if (iMagicWord == AI_MDL_MAGIC_NUMBER_BE_HL2b || iMagicWord == AI_MDL_MAGIC_NUMBER_LE_HL2b)
|
||||
throw DeadlyImportError("Impossible to properly load a model from an MDL sequence file.");
|
||||
|
||||
// Read the MDL file.
|
||||
HalfLife::HL1MDLLoader loader(
|
||||
pScene,
|
||||
pIOHandler,
|
||||
mBuffer,
|
||||
pFile,
|
||||
mHL1ImportSettings);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Read a half-life 2 MDL
|
||||
void MDLImporter::InternReadFile_HL2( )
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -51,7 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/BaseImporter.h>
|
||||
#include "MDLFileData.h"
|
||||
#include "HMP/HalfLifeFileData.h"
|
||||
#include "HalfLife/HL1ImportSettings.h"
|
||||
|
||||
struct aiNode;
|
||||
struct aiTexture;
|
||||
|
|
@ -78,7 +77,6 @@ using namespace MDL;
|
|||
* <li>3D Game Studio MDL3, MDL4</li>
|
||||
* <li>3D Game Studio MDL5</li>
|
||||
* <li>3D Game Studio MDL7</li>
|
||||
* <li>Halflife 1</li>
|
||||
* <li>Halflife 2</li>
|
||||
* </ul>
|
||||
* These formats are partially identical and it would be possible to load
|
||||
|
|
@ -133,11 +131,6 @@ protected:
|
|||
*/
|
||||
void InternReadFile_3DGS_MDL7( );
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Import a Half-Life 1 MDL file
|
||||
*/
|
||||
void InternReadFile_HL1(const std::string& pFile, const uint32_t iMagicWord);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Import a CS:S/HL2 MDL file (not fully implemented)
|
||||
*/
|
||||
|
|
@ -443,9 +436,6 @@ protected:
|
|||
|
||||
/** Size of the input file in bytes */
|
||||
unsigned int iFileSize;
|
||||
|
||||
/* Configuration for HL1 MDL */
|
||||
HalfLife::HL1ImportSettings mHL1ImportSettings;
|
||||
};
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -541,7 +541,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
|||
size_t iLen2 = iLen+1;
|
||||
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
|
||||
memcpy(szFile.data,(const char*)szCurrent,iLen2);
|
||||
szFile.length = (ai_uint32)iLen;
|
||||
szFile.length = iLen;
|
||||
|
||||
szCurrent += iLen2;
|
||||
|
||||
|
|
@ -710,7 +710,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
|||
aiString szFile;
|
||||
const size_t iLen = strlen((const char*)szCurrent);
|
||||
::memcpy(szFile.data,(const char*)szCurrent,iLen+1);
|
||||
szFile.length = (ai_uint32)iLen;
|
||||
szFile.length = iLen;
|
||||
|
||||
pcMatOut->AddProperty(&szFile,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||
|
||||
|
|
@ -831,7 +831,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
|||
aiString szFile;
|
||||
::memcpy(szFile.data,pcSkin->texture_name,sizeof(pcSkin->texture_name));
|
||||
szFile.data[sizeof(pcSkin->texture_name)] = '\0';
|
||||
szFile.length = (ai_uint32)::strlen(szFile.data);
|
||||
szFile.length = ::strlen(szFile.data);
|
||||
|
||||
pcMatOut->AddProperty(&szFile,AI_MATKEY_NAME);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue