2015-05-19 03:48:29 +00:00
|
|
|
/*
|
|
|
|
Open Asset Import Library (assimp)
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
2018-01-28 18:42:05 +00:00
|
|
|
Copyright (c) 2006-2018, assimp team
|
|
|
|
|
2017-05-09 17:57:36 +00:00
|
|
|
|
2015-05-19 03:48:29 +00:00
|
|
|
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 MDLFileData.h
|
|
|
|
* @brief Definition of in-memory structures for the MDL file format.
|
|
|
|
*
|
|
|
|
* The specification has been taken from various sources on the internet.
|
|
|
|
* - http://tfc.duke.free.fr/coding/mdl-specs-en.html
|
|
|
|
* - Conitec's MED SDK
|
|
|
|
* - Many quite long HEX-editor sessions
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AI_MDLFILEHELPER_H_INC
|
|
|
|
#define AI_MDLFILEHELPER_H_INC
|
|
|
|
|
2017-06-21 21:02:46 +00:00
|
|
|
#include <assimp/anim.h>
|
|
|
|
#include <assimp/mesh.h>
|
|
|
|
#include <assimp/Compiler/pushpack1.h>
|
2018-01-06 00:18:33 +00:00
|
|
|
#include <assimp/ByteSwapper.h>
|
2015-05-19 03:48:29 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
struct aiMaterial;
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
namespace Assimp {
|
|
|
|
namespace MDL {
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
// to make it easier for us, we test the magic word against both "endianesses"
|
|
|
|
|
|
|
|
// magic bytes used in Quake 1 MDL meshes
|
2015-05-19 03:57:13 +00:00
|
|
|
#define AI_MDL_MAGIC_NUMBER_BE AI_MAKE_MAGIC("IDPO")
|
|
|
|
#define AI_MDL_MAGIC_NUMBER_LE AI_MAKE_MAGIC("OPDI")
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// magic bytes used in GameStudio A<very low> MDL meshes
|
2015-05-19 03:57:13 +00:00
|
|
|
#define AI_MDL_MAGIC_NUMBER_BE_GS3 AI_MAKE_MAGIC("MDL2")
|
|
|
|
#define AI_MDL_MAGIC_NUMBER_LE_GS3 AI_MAKE_MAGIC("2LDM")
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// magic bytes used in GameStudio A4 MDL meshes
|
2015-05-19 03:57:13 +00:00
|
|
|
#define AI_MDL_MAGIC_NUMBER_BE_GS4 AI_MAKE_MAGIC("MDL3")
|
|
|
|
#define AI_MDL_MAGIC_NUMBER_LE_GS4 AI_MAKE_MAGIC("3LDM")
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// magic bytes used in GameStudio A5+ MDL meshes
|
2015-05-19 03:57:13 +00:00
|
|
|
#define AI_MDL_MAGIC_NUMBER_BE_GS5a AI_MAKE_MAGIC("MDL4")
|
|
|
|
#define AI_MDL_MAGIC_NUMBER_LE_GS5a AI_MAKE_MAGIC("4LDM")
|
|
|
|
#define AI_MDL_MAGIC_NUMBER_BE_GS5b AI_MAKE_MAGIC("MDL5")
|
|
|
|
#define AI_MDL_MAGIC_NUMBER_LE_GS5b AI_MAKE_MAGIC("5LDM")
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// magic bytes used in GameStudio A7+ MDL meshes
|
2015-05-19 03:57:13 +00:00
|
|
|
#define AI_MDL_MAGIC_NUMBER_BE_GS7 AI_MAKE_MAGIC("MDL7")
|
|
|
|
#define AI_MDL_MAGIC_NUMBER_LE_GS7 AI_MAKE_MAGIC("7LDM")
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// common limitations for Quake1 meshes. The loader does not check them,
|
|
|
|
// (however it warns) but models should not exceed these limits.
|
|
|
|
#if (!defined AI_MDL_VERSION)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL_VERSION 6
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
#if (!defined AI_MDL_MAX_FRAMES)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL_MAX_FRAMES 256
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
#if (!defined AI_MDL_MAX_UVS)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL_MAX_UVS 1024
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
#if (!defined AI_MDL_MAX_VERTS)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL_MAX_VERTS 1024
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
#if (!defined AI_MDL_MAX_TRIANGLES)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL_MAX_TRIANGLES 2048
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// material key that is set for dummy materials that are
|
|
|
|
// just referencing another material
|
|
|
|
#if (!defined AI_MDL7_REFERRER_MATERIAL)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL7_REFERRER_MATERIAL "&&&referrer&&&",0,0
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Header
|
|
|
|
* \brief Data structure for the MDL main header
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct Header {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! magic number: "IDPO"
|
|
|
|
uint32_t ident;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! version number: 6
|
|
|
|
int32_t version;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! scale factors for each axis
|
2017-09-24 11:19:03 +00:00
|
|
|
ai_real scale[3];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! translation factors for each axis
|
2017-09-24 11:19:03 +00:00
|
|
|
ai_real translate[3];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! bounding radius of the mesh
|
|
|
|
float boundingradius;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Position of the viewer's exe. Ignored
|
2017-09-24 11:19:03 +00:00
|
|
|
ai_real vEyePos[3];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of textures
|
|
|
|
int32_t num_skins;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Texture width in pixels
|
|
|
|
int32_t skinwidth;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Texture height in pixels
|
|
|
|
int32_t skinheight;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of vertices contained in the file
|
|
|
|
int32_t num_verts;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of triangles contained in the file
|
|
|
|
int32_t num_tris;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of frames contained in the file
|
|
|
|
int32_t num_frames;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! 0 = synchron, 1 = random . Ignored
|
|
|
|
//! (MDLn formats: number of texture coordinates)
|
|
|
|
int32_t synctype;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! State flag
|
|
|
|
int32_t flags;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Could be the total size of the file (and not a float)
|
|
|
|
float size;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Header_MDL7
|
|
|
|
* \brief Data structure for the MDL 7 main header
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct Header_MDL7 {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! magic number: "MDL7"
|
|
|
|
char ident[4];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Version number. Ignored
|
|
|
|
int32_t version;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of bones in file
|
|
|
|
uint32_t bones_num;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of groups in file
|
|
|
|
uint32_t groups_num;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Size of data in the file
|
|
|
|
uint32_t data_size;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Ignored. Used to store entity specific information
|
|
|
|
int32_t entlump_size;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Ignored. Used to store MED related data
|
|
|
|
int32_t medlump_size;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Size of the Bone_MDL7 data structure used in the file
|
|
|
|
uint16_t bone_stc_size;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Size of the Skin_MDL 7 data structure used in the file
|
|
|
|
uint16_t skin_stc_size;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Size of a single color (e.g. in a material)
|
|
|
|
uint16_t colorvalue_stc_size;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Size of the Material_MDL7 data structure used in the file
|
|
|
|
uint16_t material_stc_size;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Size of a texture coordinate set in the file
|
|
|
|
uint16_t skinpoint_stc_size;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Size of a triangle in the file
|
|
|
|
uint16_t triangle_stc_size;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Size of a normal vertex in the file
|
|
|
|
uint16_t mainvertex_stc_size;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Size of a per-frame animated vertex in the file
|
|
|
|
//! (this is not supported)
|
|
|
|
uint16_t framevertex_stc_size;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Size of a bone animation matrix
|
|
|
|
uint16_t bonetrans_stc_size;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Size of the Frame_MDL7 data structure used in the file
|
|
|
|
uint16_t frame_stc_size;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Bone_MDL7
|
|
|
|
* \brief Data structure for a bone in a MDL7 file
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct Bone_MDL7 {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Index of the parent bone of *this* bone. 0xffff means:
|
|
|
|
//! "hey, I have no parent, I'm an orphan"
|
|
|
|
uint16_t parent_index;
|
|
|
|
uint8_t _unused_[2];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Relative position of the bone (relative to the
|
|
|
|
//! parent bone)
|
|
|
|
float x,y,z;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Optional name of the bone
|
|
|
|
char name[1 /* DUMMY SIZE */];
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
#if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS (16 + 20)
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_32_CHARS)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_32_CHARS (16 + 32)
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE (16)
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (!defined AI_MDL7_MAX_GROUPNAMESIZE)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL7_MAX_GROUPNAMESIZE 16
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif // ! AI_MDL7_MAX_GROUPNAMESIZE
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Group_MDL7
|
|
|
|
* \brief Group in a MDL7 file
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct Group_MDL7 {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! = '1' -> triangle based Mesh
|
|
|
|
unsigned char typ;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
int8_t deformers;
|
|
|
|
int8_t max_weights;
|
|
|
|
int8_t _unused_;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! size of data for this group in bytes ( MD7_GROUP stc. included).
|
|
|
|
int32_t groupdata_size;
|
|
|
|
char name[AI_MDL7_MAX_GROUPNAMESIZE];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of skins
|
|
|
|
int32_t numskins;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of texture coordinates
|
|
|
|
int32_t num_stpts;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of triangles
|
|
|
|
int32_t numtris;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of vertices
|
|
|
|
int32_t numverts;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of frames
|
|
|
|
int32_t numframes;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
#define AI_MDL7_SKINTYPE_MIPFLAG 0x08
|
|
|
|
#define AI_MDL7_SKINTYPE_MATERIAL 0x10
|
|
|
|
#define AI_MDL7_SKINTYPE_MATERIAL_ASCDEF 0x20
|
|
|
|
#define AI_MDL7_SKINTYPE_RGBFLAG 0x80
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
#if (!defined AI_MDL7_MAX_BONENAMESIZE)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL7_MAX_BONENAMESIZE 20
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif // !! AI_MDL7_MAX_BONENAMESIZE
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Deformer_MDL7
|
|
|
|
* \brief Deformer in a MDL7 file
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct Deformer_MDL7 {
|
2015-05-19 03:57:13 +00:00
|
|
|
int8_t deformer_version; // 0
|
|
|
|
int8_t deformer_typ; // 0 - bones
|
|
|
|
int8_t _unused_[2];
|
|
|
|
int32_t group_index;
|
|
|
|
int32_t elements;
|
|
|
|
int32_t deformerdata_size;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct DeformerElement_MDL7
|
|
|
|
* \brief Deformer element in a MDL7 file
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct DeformerElement_MDL7 {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! bei deformer_typ==0 (==bones) element_index == bone index
|
|
|
|
int32_t element_index;
|
|
|
|
char element_name[AI_MDL7_MAX_BONENAMESIZE];
|
|
|
|
int32_t weights;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct DeformerWeight_MDL7
|
|
|
|
* \brief Deformer weight in a MDL7 file
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct DeformerWeight_MDL7 {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! for deformer_typ==0 (==bones) index == vertex index
|
|
|
|
int32_t index;
|
|
|
|
float weight;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// don't know why this was in the original headers ...
|
|
|
|
typedef int32_t MD7_MATERIAL_ASCDEFSIZE;
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct ColorValue_MDL7
|
|
|
|
* \brief Data structure for a color value in a MDL7 file
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct ColorValue_MDL7 {
|
2015-05-19 03:57:13 +00:00
|
|
|
float r,g,b,a;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Material_MDL7
|
|
|
|
* \brief Data structure for a Material in a MDL7 file
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct Material_MDL7 {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Diffuse base color of the material
|
|
|
|
ColorValue_MDL7 Diffuse;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Ambient base color of the material
|
|
|
|
ColorValue_MDL7 Ambient;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Specular base color of the material
|
|
|
|
ColorValue_MDL7 Specular;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Emissive base color of the material
|
|
|
|
ColorValue_MDL7 Emissive;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Phong power
|
|
|
|
float Power;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Skin
|
|
|
|
* \brief Skin data structure #1 - used by Quake1, MDL2, MDL3 and MDL4
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct Skin {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! 0 = single (Skin), 1 = group (GroupSkin)
|
|
|
|
//! For MDL3-5: Defines the type of the skin and there
|
|
|
|
//! fore the size of the data to skip:
|
|
|
|
//-------------------------------------------------------
|
|
|
|
//! 2 for 565 RGB,
|
|
|
|
//! 3 for 4444 ARGB,
|
|
|
|
//! 10 for 565 mipmapped,
|
|
|
|
//! 11 for 4444 mipmapped (bpp = 2),
|
|
|
|
//! 12 for 888 RGB mipmapped (bpp = 3),
|
|
|
|
//! 13 for 8888 ARGB mipmapped (bpp = 4)
|
|
|
|
//-------------------------------------------------------
|
|
|
|
int32_t group;
|
|
|
|
|
|
|
|
//! Texture data
|
|
|
|
uint8_t *data;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Skin
|
|
|
|
* \brief Skin data structure #2 - used by MDL5, MDL6 and MDL7
|
|
|
|
* \see Skin
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct Skin_MDL5 {
|
2015-05-19 03:57:13 +00:00
|
|
|
int32_t size, width, height;
|
|
|
|
uint8_t *data;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// maximum length of texture file name
|
|
|
|
#if (!defined AI_MDL7_MAX_TEXNAMESIZE)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL7_MAX_TEXNAMESIZE 0x10
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** \struct Skin_MDL7
|
|
|
|
* \brief Skin data structure #3 - used by MDL7 and HMP7
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct Skin_MDL7 {
|
2015-05-19 03:57:13 +00:00
|
|
|
uint8_t typ;
|
|
|
|
int8_t _unused_[3];
|
|
|
|
int32_t width;
|
|
|
|
int32_t height;
|
|
|
|
char texture_name[AI_MDL7_MAX_TEXNAMESIZE];
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct RGB565
|
|
|
|
* \brief Data structure for a RGB565 pixel in a texture
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct RGB565 {
|
2015-05-19 03:57:13 +00:00
|
|
|
uint16_t r : 5;
|
|
|
|
uint16_t g : 6;
|
|
|
|
uint16_t b : 5;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct ARGB4
|
|
|
|
* \brief Data structure for a ARGB4444 pixel in a texture
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct ARGB4 {
|
2015-05-19 03:57:13 +00:00
|
|
|
uint16_t a : 4;
|
|
|
|
uint16_t r : 4;
|
|
|
|
uint16_t g : 4;
|
|
|
|
uint16_t b : 4;
|
2017-06-21 21:02:46 +00:00
|
|
|
} /*PACK_STRUCT*/;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct GroupSkin
|
|
|
|
* \brief Skin data structure #2 (group of pictures)
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct GroupSkin {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! 0 = single (Skin), 1 = group (GroupSkin)
|
2015-05-19 03:48:29 +00:00
|
|
|
int32_t group;
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of images
|
|
|
|
int32_t nb;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Time for each image
|
2015-05-19 03:48:29 +00:00
|
|
|
float *time;
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Data of each image
|
|
|
|
uint8_t **data;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct TexCoord
|
|
|
|
* \brief Texture coordinate data structure used by the Quake1 MDL format
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct TexCoord {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Is the vertex on the noundary between front and back piece?
|
|
|
|
int32_t onseam;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Texture coordinate in the tx direction
|
|
|
|
int32_t s;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Texture coordinate in the ty direction
|
|
|
|
int32_t t;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct TexCoord_MDL3
|
|
|
|
* \brief Data structure for an UV coordinate in the 3DGS MDL3 format
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct TexCoord_MDL3 {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! position, horizontally in range 0..skinwidth-1
|
|
|
|
int16_t u;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! position, vertically in range 0..skinheight-1
|
|
|
|
int16_t v;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct TexCoord_MDL7
|
|
|
|
* \brief Data structure for an UV coordinate in the 3DGS MDL7 format
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct TexCoord_MDL7 {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! position, horizontally in range 0..1
|
|
|
|
float u;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! position, vertically in range 0..1
|
|
|
|
float v;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct SkinSet_MDL7
|
|
|
|
* \brief Skin set data structure for the 3DGS MDL7 format
|
|
|
|
* MDL7 references UV coordinates per face via an index list.
|
|
|
|
* This allows the use of multiple skins per face with just one
|
|
|
|
* UV coordinate set.
|
|
|
|
*/
|
|
|
|
struct SkinSet_MDL7
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Index into the UV coordinate list
|
|
|
|
uint16_t st_index[3]; // size 6
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Material index
|
|
|
|
int32_t material; // size 4
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Triangle
|
|
|
|
* \brief Triangle data structure for the Quake1 MDL format
|
|
|
|
*/
|
|
|
|
struct Triangle
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
//! 0 = backface, 1 = frontface
|
|
|
|
int32_t facesfront;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Vertex indices
|
|
|
|
int32_t vertex[3];
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Triangle_MDL3
|
|
|
|
* \brief Triangle data structure for the 3DGS MDL3 format
|
|
|
|
*/
|
|
|
|
struct Triangle_MDL3
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Index of 3 3D vertices in range 0..numverts
|
|
|
|
uint16_t index_xyz[3];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Index of 3 skin vertices in range 0..numskinverts
|
|
|
|
uint16_t index_uv[3];
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Triangle_MDL7
|
|
|
|
* \brief Triangle data structure for the 3DGS MDL7 format
|
|
|
|
*/
|
|
|
|
struct Triangle_MDL7
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Vertex indices
|
|
|
|
uint16_t v_index[3]; // size 6
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Two skinsets. The second will be used for multi-texturing
|
|
|
|
SkinSet_MDL7 skinsets[2];
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
#if (!defined AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV (6+sizeof(SkinSet_MDL7)-sizeof(uint32_t))
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
#if (!defined AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV_WITH_MATINDEX)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV_WITH_MATINDEX (6+sizeof(SkinSet_MDL7))
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
#if (!defined AI_MDL7_TRIANGLE_STD_SIZE_TWO_UV)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL7_TRIANGLE_STD_SIZE_TWO_UV (6+2*sizeof(SkinSet_MDL7))
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Helper constants for Triangle::facesfront
|
|
|
|
#if (!defined AI_MDL_BACKFACE)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL_BACKFACE 0x0
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
#if (!defined AI_MDL_FRONTFACE)
|
2015-05-19 03:57:13 +00:00
|
|
|
# define AI_MDL_FRONTFACE 0x1
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Vertex
|
|
|
|
* \brief Vertex data structure
|
|
|
|
*/
|
|
|
|
struct Vertex
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
uint8_t v[3];
|
|
|
|
uint8_t normalIndex;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
struct Vertex_MDL4
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
uint16_t v[3];
|
|
|
|
uint8_t normalIndex;
|
|
|
|
uint8_t unused;
|
2015-05-19 03:48:29 +00:00
|
|
|
} PACK_STRUCT;
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
#define AI_MDL7_FRAMEVERTEX120503_STCSIZE 16
|
|
|
|
#define AI_MDL7_FRAMEVERTEX030305_STCSIZE 26
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Vertex_MDL7
|
|
|
|
* \brief Vertex data structure used in MDL7 files
|
|
|
|
*/
|
|
|
|
struct Vertex_MDL7
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
float x,y,z;
|
|
|
|
uint16_t vertindex; // = bone index
|
|
|
|
union {
|
|
|
|
uint8_t norm162index;
|
|
|
|
float norm[3];
|
|
|
|
};
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct BoneTransform_MDL7
|
|
|
|
* \brief bone transformation matrix structure used in MDL7 files
|
|
|
|
*/
|
|
|
|
struct BoneTransform_MDL7
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
//! 4*3
|
|
|
|
float m [4*4];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! the index of this vertex, 0.. header::bones_num - 1
|
|
|
|
uint16_t bone_index;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! I HATE 3DGS AND THE SILLY DEVELOPER WHO DESIGNED
|
|
|
|
//! THIS STUPID FILE FORMAT!
|
|
|
|
int8_t _unused_[2];
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
#define AI_MDL7_MAX_FRAMENAMESIZE 16
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Frame_MDL7
|
|
|
|
* \brief Frame data structure used by MDL7 files
|
|
|
|
*/
|
|
|
|
struct Frame_MDL7
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
char frame_name[AI_MDL7_MAX_FRAMENAMESIZE];
|
|
|
|
uint32_t vertices_count;
|
|
|
|
uint32_t transmatrix_count;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct SimpleFrame
|
|
|
|
* \brief Data structure for a simple frame
|
|
|
|
*/
|
|
|
|
struct SimpleFrame
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Minimum vertex of the bounding box
|
|
|
|
Vertex bboxmin;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Maximum vertex of the bounding box
|
|
|
|
Vertex bboxmax;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Name of the frame
|
|
|
|
char name[16];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Vertex list of the frame
|
|
|
|
Vertex *verts;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct Frame
|
|
|
|
* \brief Model frame data structure
|
|
|
|
*/
|
|
|
|
struct Frame
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
//! 0 = simple frame, !0 = group frame
|
|
|
|
int32_t type;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Frame data
|
|
|
|
SimpleFrame frame;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
struct SimpleFrame_MDLn_SP
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Minimum vertex of the bounding box
|
|
|
|
Vertex_MDL4 bboxmin;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Maximum vertex of the bounding box
|
|
|
|
Vertex_MDL4 bboxmax;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Name of the frame
|
|
|
|
char name[16];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Vertex list of the frame
|
|
|
|
Vertex_MDL4 *verts;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct GroupFrame
|
|
|
|
* \brief Data structure for a group of frames
|
|
|
|
*/
|
|
|
|
struct GroupFrame
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
//! 0 = simple frame, !0 = group frame
|
|
|
|
int32_t type;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Minimum vertex for all single frames
|
|
|
|
Vertex min;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Maximum vertex for all single frames
|
|
|
|
Vertex max;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Time for all single frames
|
|
|
|
float *time;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of single frames
|
|
|
|
SimpleFrame *frames;
|
2017-08-21 08:27:40 +00:00
|
|
|
} PACK_STRUCT;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2018-10-06 13:01:42 +00:00
|
|
|
#include <assimp/Compiler/poppack1.h>
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct IntFace_MDL7
|
|
|
|
* \brief Internal data structure to temporarily represent a face
|
|
|
|
*/
|
2017-06-21 21:02:46 +00:00
|
|
|
struct IntFace_MDL7 {
|
2015-05-19 03:57:13 +00:00
|
|
|
// provide a constructor for our own convenience
|
2018-09-21 17:43:19 +00:00
|
|
|
IntFace_MDL7() AI_NO_EXCEPT {
|
|
|
|
::memset( mIndices, 0, sizeof(uint32_t) *3);
|
|
|
|
::memset( iMatIndex, 0, sizeof( unsigned int) *2);
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Vertex indices
|
|
|
|
uint32_t mIndices[3];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Material index (maximally two channels, which are joined later)
|
|
|
|
unsigned int iMatIndex[2];
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct IntMaterial_MDL7
|
|
|
|
* \brief Internal data structure to temporarily represent a material
|
|
|
|
* which has been created from two single materials along with the
|
|
|
|
* original material indices.
|
|
|
|
*/
|
2018-09-21 14:07:09 +00:00
|
|
|
struct IntMaterial_MDL7 {
|
2015-05-19 03:57:13 +00:00
|
|
|
// provide a constructor for our own convenience
|
2018-09-21 14:25:27 +00:00
|
|
|
IntMaterial_MDL7() AI_NO_EXCEPT
|
2018-09-21 17:43:19 +00:00
|
|
|
: pcMat( nullptr ) {
|
|
|
|
::memset( iOldMatIndices, 0, sizeof(unsigned int) *2);
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Material instance
|
|
|
|
aiMaterial* pcMat;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Old material indices
|
|
|
|
unsigned int iOldMatIndices[2];
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
/** \struct IntBone_MDL7
|
|
|
|
* \brief Internal data structure to represent a bone in a MDL7 file with
|
|
|
|
* all of its animation channels assigned to it.
|
|
|
|
*/
|
|
|
|
struct IntBone_MDL7 : aiBone
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Default constructor
|
2018-09-21 14:25:27 +00:00
|
|
|
IntBone_MDL7() AI_NO_EXCEPT : iParent (0xffff)
|
2015-05-19 03:57:13 +00:00
|
|
|
{
|
|
|
|
pkeyPositions.reserve(30);
|
|
|
|
pkeyScalings.reserve(30);
|
|
|
|
pkeyRotations.reserve(30);
|
|
|
|
}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Parent bone of the bone
|
|
|
|
uint64_t iParent;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Relative position of the bone
|
|
|
|
aiVector3D vPosition;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Array of position keys
|
|
|
|
std::vector<aiVectorKey> pkeyPositions;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Array of scaling keys
|
|
|
|
std::vector<aiVectorKey> pkeyScalings;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Array of rotation keys
|
|
|
|
std::vector<aiQuatKey> pkeyRotations;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
//! Describes a MDL7 frame
|
|
|
|
struct IntFrameInfo_MDL7
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Construction from an existing frame header
|
|
|
|
IntFrameInfo_MDL7(BE_NCONST MDL::Frame_MDL7* _pcFrame,unsigned int _iIndex)
|
|
|
|
: iIndex(_iIndex)
|
|
|
|
, pcFrame(_pcFrame)
|
|
|
|
{}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Index of the frame
|
|
|
|
unsigned int iIndex;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Points to the header of the frame
|
|
|
|
BE_NCONST MDL::Frame_MDL7* pcFrame;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
//! Describes a MDL7 mesh group
|
|
|
|
struct IntGroupInfo_MDL7
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Default constructor
|
2018-09-21 14:25:27 +00:00
|
|
|
IntGroupInfo_MDL7() AI_NO_EXCEPT
|
2015-05-19 03:57:13 +00:00
|
|
|
: iIndex(0)
|
2018-09-21 14:07:09 +00:00
|
|
|
, pcGroup(nullptr)
|
|
|
|
, pcGroupUVs(nullptr)
|
|
|
|
, pcGroupTris(nullptr)
|
|
|
|
, pcGroupVerts(nullptr)
|
2015-05-19 03:57:13 +00:00
|
|
|
{}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Construction from an existing group header
|
|
|
|
IntGroupInfo_MDL7(BE_NCONST MDL::Group_MDL7* _pcGroup, unsigned int _iIndex)
|
|
|
|
: iIndex(_iIndex)
|
|
|
|
, pcGroup(_pcGroup)
|
2015-07-01 05:28:13 +00:00
|
|
|
, pcGroupUVs()
|
|
|
|
, pcGroupTris()
|
|
|
|
, pcGroupVerts()
|
2015-05-19 03:57:13 +00:00
|
|
|
{}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Index of the group
|
|
|
|
unsigned int iIndex;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Points to the header of the group
|
|
|
|
BE_NCONST MDL::Group_MDL7* pcGroup;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Points to the beginning of the uv coordinate section
|
|
|
|
BE_NCONST MDL::TexCoord_MDL7* pcGroupUVs;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Points to the beginning of the triangle section
|
|
|
|
MDL::Triangle_MDL7* pcGroupTris;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Points to the beginning of the vertex section
|
|
|
|
BE_NCONST MDL::Vertex_MDL7* pcGroupVerts;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
//! Holds the data that belongs to a MDL7 mesh group
|
|
|
|
struct IntGroupData_MDL7
|
|
|
|
{
|
2018-09-21 14:25:27 +00:00
|
|
|
IntGroupData_MDL7() AI_NO_EXCEPT
|
2018-02-06 17:22:32 +00:00
|
|
|
: bNeed2UV(false)
|
2015-05-19 03:57:13 +00:00
|
|
|
{}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Array of faces that belong to the group
|
2018-02-06 17:22:32 +00:00
|
|
|
std::vector<MDL::IntFace_MDL7> pcFaces;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Array of vertex positions
|
|
|
|
std::vector<aiVector3D> vPositions;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Array of vertex normals
|
|
|
|
std::vector<aiVector3D> vNormals;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Array of bones indices
|
|
|
|
std::vector<unsigned int> aiBones;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! First UV coordinate set
|
|
|
|
std::vector<aiVector3D> vTextureCoords1;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Optional second UV coordinate set
|
|
|
|
std::vector<aiVector3D> vTextureCoords2;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Specifies whether there are two texture
|
|
|
|
//! coordinate sets required
|
|
|
|
bool bNeed2UV;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
//! Holds data from an MDL7 file that is shared by all mesh groups
|
2018-09-21 14:07:09 +00:00
|
|
|
struct IntSharedData_MDL7 {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Default constructor
|
2018-09-21 14:25:27 +00:00
|
|
|
IntSharedData_MDL7() AI_NO_EXCEPT
|
2015-07-01 05:28:13 +00:00
|
|
|
: apcOutBones(),
|
|
|
|
iNum()
|
2015-05-19 03:57:13 +00:00
|
|
|
{
|
|
|
|
abNeedMaterials.reserve(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Destruction: properly delete all allocated resources
|
|
|
|
~IntSharedData_MDL7()
|
|
|
|
{
|
|
|
|
// kill all bones
|
|
|
|
if (this->apcOutBones)
|
|
|
|
{
|
|
|
|
for (unsigned int m = 0; m < iNum;++m)
|
|
|
|
delete this->apcOutBones[m];
|
|
|
|
delete[] this->apcOutBones;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Specifies which materials are used
|
|
|
|
std::vector<bool> abNeedMaterials;
|
|
|
|
|
|
|
|
//! List of all materials
|
|
|
|
std::vector<aiMaterial*> pcMats;
|
|
|
|
|
|
|
|
//! List of all bones
|
|
|
|
IntBone_MDL7** apcOutBones;
|
|
|
|
|
|
|
|
//! number of bones
|
|
|
|
unsigned int iNum;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
//! Contains input data for GenerateOutputMeshes_3DGS_MDL7
|
|
|
|
struct IntSplitGroupData_MDL7
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Construction from a given shared data set
|
|
|
|
IntSplitGroupData_MDL7(IntSharedData_MDL7& _shared,
|
|
|
|
std::vector<aiMesh*>& _avOutList)
|
|
|
|
|
2015-07-02 01:38:10 +00:00
|
|
|
: aiSplit(), shared(_shared), avOutList(_avOutList)
|
2015-05-19 03:57:13 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Destruction: properly delete all allocated resources
|
|
|
|
~IntSplitGroupData_MDL7()
|
|
|
|
{
|
|
|
|
// kill all face lists
|
|
|
|
if(this->aiSplit)
|
|
|
|
{
|
|
|
|
for (unsigned int m = 0; m < shared.pcMats.size();++m)
|
|
|
|
delete this->aiSplit[m];
|
|
|
|
delete[] this->aiSplit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Contains a list of all faces per material
|
|
|
|
std::vector<unsigned int>** aiSplit;
|
|
|
|
|
|
|
|
//! Shared data for all groups of the model
|
|
|
|
IntSharedData_MDL7& shared;
|
|
|
|
|
|
|
|
//! List of meshes
|
|
|
|
std::vector<aiMesh*>& avOutList;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
} // end namespaces
|
|
|
|
|
|
|
|
#endif // !! AI_MDLFILEHELPER_H_INC
|