Added support to load Half-Life 1 MDL files.

Added code to use Half-Life 1 MDL loader in MDLLoader.cpp.
Added Half-Life 1 MDL loader files to CMakeLists.
Added new options in config.h to use with Half-Life 1 MDL loader.
pull/2838/head
Marc-Antoine Lortie 2019-12-16 10:26:46 -05:00
parent 487ce954db
commit eed0bd3ef6
14 changed files with 2746 additions and 2 deletions

View File

@ -454,6 +454,16 @@ ADD_ASSIMP_IMPORTER( MDL
MDL/MDLLoader.cpp
MDL/MDLLoader.h
MDL/MDLMaterialLoader.cpp
MDL/HalfLife/HalfLifeMDLBaseHeader.h
MDL/HalfLife/HL1FileData.h
MDL/HalfLife/HL1MDLLoader.cpp
MDL/HalfLife/HL1MDLLoader.h
MDL/HalfLife/HL1ImportDefinitions.h
MDL/HalfLife/HL1ImportSettings.h
MDL/HalfLife/HL1MeshTrivert.h
MDL/HalfLife/LogFunctions.h
MDL/HalfLife/UniqueNameGenerator.cpp
MDL/HalfLife/UniqueNameGenerator.h
)
SET( MaterialSystem_SRCS

View File

@ -0,0 +1,355 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2019, 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 : HalfLifeMDLBaseHeader {
char name[64];
int32_t length;
vec3_t eyeposition; // ideal eye position
vec3_t min; // ideal movement hull size
vec3_t max;
vec3_t bbmin; // clipping bounding box
vec3_t bbmax;
int32_t unused; // was flags
int32_t numbones; // bones
int32_t boneindex;
int32_t numbonecontrollers; // bone controllers
int32_t bonecontrollerindex;
int32_t numhitboxes; // complex bounding boxes
int32_t hitboxindex;
int32_t numseq; // animation sequences
int32_t seqindex;
int32_t numseqgroups; // demand loaded sequences
int32_t seqgroupindex;
int32_t numtextures; // raw textures
int32_t textureindex;
int32_t texturedataindex;
int32_t numskinref; // replaceable textures
int32_t numskinfamilies;
int32_t skinindex;
int32_t numbodyparts;
int32_t bodypartindex;
int32_t numattachments; // queryable attachable points
int32_t attachmentindex;
int32_t unused2; // was "soundtable"
int32_t unused3; // was "soundindex"
int32_t unused4; // was "soundgroups"
int32_t unused5; // was "soundgroupindex"
int32_t numtransitions; // animation node to animation node transition graph
int32_t transitionindex;
} PACK_STRUCT;
// header for demand loaded sequence group data
struct SequenceHeader_HL1 : HalfLifeMDLBaseHeader {
char name[64];
int32_t length;
} PACK_STRUCT;
// bones
struct Bone_HL1 {
char name[32]; // bone name for symbolic links
int32_t parent; // parent bone
int32_t unused; // was "flags" -- ??
int32_t bonecontroller[6]; // bone controller index, -1 == none
float value[6]; // default DoF values
float scale[6]; // scale for delta DoF values
} PACK_STRUCT;
// bone controllers
struct BoneController_HL1 {
int32_t bone; // -1 == 0
int32_t type; // X, Y, Z, XR, YR, ZR, M
float start;
float end;
int32_t unused; // was "rest" - byte index value at rest
int32_t index; // 0-3 user set controller, 4 mouth
} PACK_STRUCT;
// intersection boxes
struct Hitbox_HL1 {
int32_t bone;
int32_t group; // intersection group
vec3_t bbmin; // bounding box
vec3_t bbmax;
} PACK_STRUCT;
//
// demand loaded sequence groups
//
struct SequenceGroup_HL1 {
char label[32]; // textual name
char name[64]; // file name
int32_t unused; // was "cache" - index pointer
int32_t unused2; // was "data" - hack for group 0
} PACK_STRUCT;
// The type of blending for a sequence.
enum SequenceBlendMode_HL1 {
NoBlend = 1,
TwoWayBlending = 2,
FourWayBlending = 4,
};
// sequence descriptions
struct SequenceDesc_HL1 {
char label[32]; // sequence label
float fps; // frames per second
int32_t flags; // looping/non-looping flags
int32_t activity;
int32_t actweight;
int32_t numevents;
int32_t eventindex;
int32_t numframes; // number of frames per sequence
int32_t unused; // was "numpivots" - number of foot pivots
int32_t unused2; // was "pivotindex"
int32_t motiontype;
int32_t motionbone;
vec3_t linearmovement;
int32_t unused3; // was "automoveposindex"
int32_t unused4; // was "automoveangleindex"
vec3_t bbmin; // per sequence bounding box
vec3_t bbmax;
int32_t numblends;
int32_t animindex; // mstudioanim_t pointer relative to start of sequence group data
// [blend][bone][X, Y, Z, XR, YR, ZR]
int32_t blendtype[2]; // X, Y, Z, XR, YR, ZR
float blendstart[2]; // starting value
float blendend[2]; // ending value
int32_t unused5; // was "blendparent"
int32_t seqgroup; // sequence group for demand loading
int32_t entrynode; // transition node at entry
int32_t exitnode; // transition node at exit
int32_t nodeflags; // transition rules
int32_t unused6; // was "nextseq" - auto advancing sequences
} PACK_STRUCT;
// events
struct AnimEvent_HL1 {
int32_t frame;
int32_t event;
int32_t unused; // was "type"
char options[64];
} PACK_STRUCT;
// attachment
struct Attachment_HL1 {
char unused[32]; // was "name"
int32_t unused2; // was "type"
int32_t bone;
vec3_t org; // attachment point
vec3_t unused3[3]; // was "vectors"
} PACK_STRUCT;
struct AnimValueOffset_HL1 {
unsigned short offset[6];
} PACK_STRUCT;
// animation frames
union AnimValue_HL1 {
struct {
uint8_t valid;
uint8_t total;
} num PACK_STRUCT;
short value;
} PACK_STRUCT;
// body part index
struct Bodypart_HL1 {
char name[64];
int32_t nummodels;
int32_t base;
int32_t modelindex; // index into models array
} PACK_STRUCT;
// skin info
struct Texture_HL1 {
char name[64];
int32_t flags;
int32_t width;
int32_t height;
int32_t index;
} PACK_STRUCT;
// studio models
struct Model_HL1 {
char name[64];
int32_t unused; // was "type"
float unused2; // was "boundingradius"
int32_t nummesh;
int32_t meshindex;
int32_t numverts; // number of unique vertices
int32_t vertinfoindex; // vertex bone info
int32_t vertindex; // vertex vec3_t
int32_t numnorms; // number of unique surface normals
int32_t norminfoindex; // normal bone info
int32_t normindex; // normal vec3_t
int32_t unused3; // was "numgroups" - deformation groups
int32_t unused4; // was "groupindex"
} PACK_STRUCT;
// meshes
struct Mesh_HL1 {
int32_t numtris;
int32_t triindex;
int32_t skinref;
int32_t numnorms; // per mesh normals
int32_t unused; // was "normindex" - normal vec3_t
} PACK_STRUCT;
struct Trivert {
short vertindex; // index into vertex array
short normindex; // index into normal array
short s, t; // s,t position on skin
} 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

View File

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2019, 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

View File

@ -0,0 +1,85 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2019, 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

View File

@ -0,0 +1,235 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2019, 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 <assimp/scene.h>
#include <assimp/texture.h>
#include <assimp/IOSystem.hpp>
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

View File

@ -0,0 +1,127 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2019, 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

View File

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2019, 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
{
char ident[4];
int32_t version;
};
}
}
}
#endif // AI_HALFLIFEMDLBASEHEADER_INCLUDED

View File

@ -0,0 +1,95 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2019, 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

View File

@ -0,0 +1,180 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2019, 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_or_assign(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

View File

@ -0,0 +1,81 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2019, 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

View File

@ -51,6 +51,7 @@ 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/qnan.h>
#include <assimp/StringUtils.h>
@ -142,6 +143,18 @@ 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);
}
// ------------------------------------------------------------------------------------------------
@ -224,9 +237,19 @@ void MDLImporter::InternReadFile( const std::string& pFile,
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();
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
@ -1955,6 +1978,23 @@ 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( )

View File

@ -51,6 +51,7 @@ 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;
@ -77,6 +78,7 @@ 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
@ -131,6 +133,11 @@ 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)
*/
@ -436,6 +443,9 @@ protected:
/** Size of the input file in bytes */
unsigned int iFileSize;
/* Configuration for HL1 MDL */
HalfLife::HL1ImportSettings mHL1ImportSettings;
};
} // end of namespace Assimp

View File

@ -695,6 +695,73 @@ enum aiComponent
#define AI_CONFIG_IMPORT_SMD_KEYFRAME "IMPORT_SMD_KEYFRAME"
#define AI_CONFIG_IMPORT_UNREAL_KEYFRAME "IMPORT_UNREAL_KEYFRAME"
// ---------------------------------------------------------------------------
/** @brief Set whether the MDL (HL1) importer will read animations.
*
* The default value is true (1)
* Property type: bool
*/
#define AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS "IMPORT_MDL_HL1_READ_ANIMATIONS"
// ---------------------------------------------------------------------------
/** @brief Set whether the MDL (HL1) importer will read animation events.
* \note This property requires AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS to be set to true.
*
* The default value is true (1)
* Property type: bool
*/
#define AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATION_EVENTS "IMPORT_MDL_HL1_READ_ANIMATION_EVENTS"
// ---------------------------------------------------------------------------
/** @brief Set whether the MDL (HL1) importer will read blend controllers.
* \note This property requires AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS to be set to true.
*
* The default value is true (1)
* Property type: bool
*/
#define AI_CONFIG_IMPORT_MDL_HL1_READ_BLEND_CONTROLLERS "IMPORT_MDL_HL1_READ_BLEND_CONTROLLERS"
// ---------------------------------------------------------------------------
/** @brief Set whether the MDL (HL1) importer will read sequence transition graph.
* \note This property requires AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS to be set to true.
*
* The default value is true (1)
* Property type: bool
*/
#define AI_CONFIG_IMPORT_MDL_HL1_READ_SEQUENCE_TRANSITIONS "IMPORT_MDL_HL1_READ_SEQUENCE_TRANSITIONS"
// ---------------------------------------------------------------------------
/** @brief Set whether the MDL (HL1) importer will read attachments info.
*
* The default value is true (1)
* Property type: bool
*/
#define AI_CONFIG_IMPORT_MDL_HL1_READ_ATTACHMENTS "IMPORT_MDL_HL1_READ_ATTACHMENTS"
// ---------------------------------------------------------------------------
/** @brief Set whether the MDL (HL1) importer will read bone controllers info.
*
* The default value is true (1)
* Property type: bool
*/
#define AI_CONFIG_IMPORT_MDL_HL1_READ_BONE_CONTROLLERS "IMPORT_MDL_HL1_READ_BONE_CONTROLLERS"
// ---------------------------------------------------------------------------
/** @brief Set whether the MDL (HL1) importer will read hitboxes info.
*
* The default value is true (1)
* Property type: bool
*/
#define AI_CONFIG_IMPORT_MDL_HL1_READ_HITBOXES "IMPORT_MDL_HL1_READ_HITBOXES"
// ---------------------------------------------------------------------------
/** @brief Set whether the MDL (HL1) importer will read miscellaneous global model info.
*
* The default value is true (1)
* Property type: bool
*/
#define AI_CONFIG_IMPORT_MDL_HL1_READ_MISC_GLOBAL_INFO "IMPORT_MDL_HL1_READ_MISC_GLOBAL_INFO"
// ---------------------------------------------------------------------------
/** Smd load multiple animations
*