|
@@ -53,10 +53,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
#ifndef AI_MDLFILEHELPER_H_INC
|
|
|
#define AI_MDLFILEHELPER_H_INC
|
|
|
|
|
|
+#include <assimp/anim.h>
|
|
|
+#include <assimp/mesh.h>
|
|
|
+#include <assimp/Compiler/pushpack1.h>
|
|
|
#include "ByteSwapper.h"
|
|
|
-#include "./../include/assimp/anim.h"
|
|
|
-#include "./../include/assimp/mesh.h"
|
|
|
-#include "./../include/assimp/Compiler/pushpack1.h"
|
|
|
#include <stdint.h>
|
|
|
#include <vector>
|
|
|
|
|
@@ -90,7 +90,6 @@ namespace MDL {
|
|
|
#define AI_MDL_MAGIC_NUMBER_BE_GS7 AI_MAKE_MAGIC("MDL7")
|
|
|
#define AI_MDL_MAGIC_NUMBER_LE_GS7 AI_MAKE_MAGIC("7LDM")
|
|
|
|
|
|
-
|
|
|
// 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)
|
|
@@ -119,8 +118,7 @@ namespace MDL {
|
|
|
/** \struct Header
|
|
|
* \brief Data structure for the MDL main header
|
|
|
*/
|
|
|
-struct Header
|
|
|
-{
|
|
|
+struct Header {
|
|
|
//! magic number: "IDPO"
|
|
|
uint32_t ident;
|
|
|
|
|
@@ -166,15 +164,14 @@ struct Header
|
|
|
|
|
|
//! Could be the total size of the file (and not a float)
|
|
|
float size;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct Header_MDL7
|
|
|
* \brief Data structure for the MDL 7 main header
|
|
|
*/
|
|
|
-struct Header_MDL7
|
|
|
-{
|
|
|
+struct Header_MDL7 {
|
|
|
//! magic number: "MDL7"
|
|
|
char ident[4];
|
|
|
|
|
@@ -226,15 +223,14 @@ struct Header_MDL7
|
|
|
|
|
|
//! Size of the Frame_MDL7 data structure used in the file
|
|
|
uint16_t frame_stc_size;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct Bone_MDL7
|
|
|
* \brief Data structure for a bone in a MDL7 file
|
|
|
*/
|
|
|
-struct Bone_MDL7
|
|
|
-{
|
|
|
+struct Bone_MDL7 {
|
|
|
//! Index of the parent bone of *this* bone. 0xffff means:
|
|
|
//! "hey, I have no parent, I'm an orphan"
|
|
|
uint16_t parent_index;
|
|
@@ -246,7 +242,7 @@ struct Bone_MDL7
|
|
|
|
|
|
//! Optional name of the bone
|
|
|
char name[1 /* DUMMY SIZE */];
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
#if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS)
|
|
|
# define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS (16 + 20)
|
|
@@ -268,8 +264,7 @@ struct Bone_MDL7
|
|
|
/** \struct Group_MDL7
|
|
|
* \brief Group in a MDL7 file
|
|
|
*/
|
|
|
-struct Group_MDL7
|
|
|
-{
|
|
|
+struct Group_MDL7 {
|
|
|
//! = '1' -> triangle based Mesh
|
|
|
unsigned char typ;
|
|
|
|
|
@@ -295,7 +290,7 @@ struct Group_MDL7
|
|
|
|
|
|
//! Number of frames
|
|
|
int32_t numframes;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
#define AI_MDL7_SKINTYPE_MIPFLAG 0x08
|
|
|
#define AI_MDL7_SKINTYPE_MATERIAL 0x10
|
|
@@ -310,41 +305,36 @@ struct Group_MDL7
|
|
|
/** \struct Deformer_MDL7
|
|
|
* \brief Deformer in a MDL7 file
|
|
|
*/
|
|
|
-struct Deformer_MDL7
|
|
|
-{
|
|
|
+struct Deformer_MDL7 {
|
|
|
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;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct DeformerElement_MDL7
|
|
|
* \brief Deformer element in a MDL7 file
|
|
|
*/
|
|
|
-struct DeformerElement_MDL7
|
|
|
-{
|
|
|
+struct DeformerElement_MDL7 {
|
|
|
//! bei deformer_typ==0 (==bones) element_index == bone index
|
|
|
int32_t element_index;
|
|
|
char element_name[AI_MDL7_MAX_BONENAMESIZE];
|
|
|
int32_t weights;
|
|
|
-} PACK_STRUCT;
|
|
|
-
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct DeformerWeight_MDL7
|
|
|
* \brief Deformer weight in a MDL7 file
|
|
|
*/
|
|
|
-struct DeformerWeight_MDL7
|
|
|
-{
|
|
|
+struct DeformerWeight_MDL7 {
|
|
|
//! for deformer_typ==0 (==bones) index == vertex index
|
|
|
int32_t index;
|
|
|
float weight;
|
|
|
-} PACK_STRUCT;
|
|
|
-
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// don't know why this was in the original headers ...
|
|
|
typedef int32_t MD7_MATERIAL_ASCDEFSIZE;
|
|
@@ -353,17 +343,15 @@ typedef int32_t MD7_MATERIAL_ASCDEFSIZE;
|
|
|
/** \struct ColorValue_MDL7
|
|
|
* \brief Data structure for a color value in a MDL7 file
|
|
|
*/
|
|
|
-struct ColorValue_MDL7
|
|
|
-{
|
|
|
+struct ColorValue_MDL7 {
|
|
|
float r,g,b,a;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct Material_MDL7
|
|
|
* \brief Data structure for a Material in a MDL7 file
|
|
|
*/
|
|
|
-struct Material_MDL7
|
|
|
-{
|
|
|
+struct Material_MDL7 {
|
|
|
//! Diffuse base color of the material
|
|
|
ColorValue_MDL7 Diffuse;
|
|
|
|
|
@@ -378,15 +366,13 @@ struct Material_MDL7
|
|
|
|
|
|
//! Phong power
|
|
|
float Power;
|
|
|
-} PACK_STRUCT;
|
|
|
-
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct Skin
|
|
|
* \brief Skin data structure #1 - used by Quake1, MDL2, MDL3 and MDL4
|
|
|
*/
|
|
|
-struct Skin
|
|
|
-{
|
|
|
+struct Skin {
|
|
|
//! 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:
|
|
@@ -402,7 +388,7 @@ struct Skin
|
|
|
|
|
|
//! Texture data
|
|
|
uint8_t *data;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
@@ -410,11 +396,10 @@ struct Skin
|
|
|
* \brief Skin data structure #2 - used by MDL5, MDL6 and MDL7
|
|
|
* \see Skin
|
|
|
*/
|
|
|
-struct Skin_MDL5
|
|
|
-{
|
|
|
+struct Skin_MDL5 {
|
|
|
int32_t size, width, height;
|
|
|
uint8_t *data;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// maximum length of texture file name
|
|
|
#if (!defined AI_MDL7_MAX_TEXNAMESIZE)
|
|
@@ -425,44 +410,40 @@ struct Skin_MDL5
|
|
|
/** \struct Skin_MDL7
|
|
|
* \brief Skin data structure #3 - used by MDL7 and HMP7
|
|
|
*/
|
|
|
-struct Skin_MDL7
|
|
|
-{
|
|
|
+struct Skin_MDL7 {
|
|
|
uint8_t typ;
|
|
|
int8_t _unused_[3];
|
|
|
int32_t width;
|
|
|
int32_t height;
|
|
|
char texture_name[AI_MDL7_MAX_TEXNAMESIZE];
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct RGB565
|
|
|
* \brief Data structure for a RGB565 pixel in a texture
|
|
|
*/
|
|
|
-struct RGB565
|
|
|
-{
|
|
|
+struct RGB565 {
|
|
|
uint16_t r : 5;
|
|
|
uint16_t g : 6;
|
|
|
uint16_t b : 5;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct ARGB4
|
|
|
* \brief Data structure for a ARGB4444 pixel in a texture
|
|
|
*/
|
|
|
-struct ARGB4
|
|
|
-{
|
|
|
+struct ARGB4 {
|
|
|
uint16_t a : 4;
|
|
|
uint16_t r : 4;
|
|
|
uint16_t g : 4;
|
|
|
uint16_t b : 4;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /*PACK_STRUCT*/;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct GroupSkin
|
|
|
* \brief Skin data structure #2 (group of pictures)
|
|
|
*/
|
|
|
-struct GroupSkin
|
|
|
-{
|
|
|
+struct GroupSkin {
|
|
|
//! 0 = single (Skin), 1 = group (GroupSkin)
|
|
|
int32_t group;
|
|
|
|
|
@@ -474,14 +455,13 @@ struct GroupSkin
|
|
|
|
|
|
//! Data of each image
|
|
|
uint8_t **data;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct TexCoord
|
|
|
* \brief Texture coordinate data structure used by the Quake1 MDL format
|
|
|
*/
|
|
|
-struct TexCoord
|
|
|
-{
|
|
|
+struct TexCoord {
|
|
|
//! Is the vertex on the noundary between front and back piece?
|
|
|
int32_t onseam;
|
|
|
|
|
@@ -490,33 +470,31 @@ struct TexCoord
|
|
|
|
|
|
//! Texture coordinate in the ty direction
|
|
|
int32_t t;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct TexCoord_MDL3
|
|
|
* \brief Data structure for an UV coordinate in the 3DGS MDL3 format
|
|
|
*/
|
|
|
-struct TexCoord_MDL3
|
|
|
-{
|
|
|
+struct TexCoord_MDL3 {
|
|
|
//! position, horizontally in range 0..skinwidth-1
|
|
|
int16_t u;
|
|
|
|
|
|
//! position, vertically in range 0..skinheight-1
|
|
|
int16_t v;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct TexCoord_MDL7
|
|
|
* \brief Data structure for an UV coordinate in the 3DGS MDL7 format
|
|
|
*/
|
|
|
-struct TexCoord_MDL7
|
|
|
-{
|
|
|
+struct TexCoord_MDL7 {
|
|
|
//! position, horizontally in range 0..1
|
|
|
float u;
|
|
|
|
|
|
//! position, vertically in range 0..1
|
|
|
float v;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct SkinSet_MDL7
|
|
@@ -532,7 +510,7 @@ struct SkinSet_MDL7
|
|
|
|
|
|
//! Material index
|
|
|
int32_t material; // size 4
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct Triangle
|
|
@@ -545,7 +523,7 @@ struct Triangle
|
|
|
|
|
|
//! Vertex indices
|
|
|
int32_t vertex[3];
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct Triangle_MDL3
|
|
@@ -558,7 +536,7 @@ struct Triangle_MDL3
|
|
|
|
|
|
//! Index of 3 skin vertices in range 0..numskinverts
|
|
|
uint16_t index_uv[3];
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct Triangle_MDL7
|
|
@@ -571,7 +549,7 @@ struct Triangle_MDL7
|
|
|
|
|
|
//! Two skinsets. The second will be used for multi-texturing
|
|
|
SkinSet_MDL7 skinsets[2];
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
#if (!defined AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV)
|
|
|
# define AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV (6+sizeof(SkinSet_MDL7)-sizeof(uint32_t))
|
|
@@ -599,7 +577,7 @@ struct Vertex
|
|
|
{
|
|
|
uint8_t v[3];
|
|
|
uint8_t normalIndex;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
@@ -625,8 +603,7 @@ struct Vertex_MDL7
|
|
|
uint8_t norm162index;
|
|
|
float norm[3];
|
|
|
};
|
|
|
-} PACK_STRUCT;
|
|
|
-
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct BoneTransform_MDL7
|
|
@@ -643,12 +620,11 @@ struct BoneTransform_MDL7
|
|
|
//! I HATE 3DGS AND THE SILLY DEVELOPER WHO DESIGNED
|
|
|
//! THIS STUPID FILE FORMAT!
|
|
|
int8_t _unused_[2];
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
|
|
|
#define AI_MDL7_MAX_FRAMENAMESIZE 16
|
|
|
|
|
|
-
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct Frame_MDL7
|
|
|
* \brief Frame data structure used by MDL7 files
|
|
@@ -678,7 +654,7 @@ struct SimpleFrame
|
|
|
|
|
|
//! Vertex list of the frame
|
|
|
Vertex *verts;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct Frame
|
|
@@ -691,7 +667,7 @@ struct Frame
|
|
|
|
|
|
//! Frame data
|
|
|
SimpleFrame frame;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
@@ -708,7 +684,7 @@ struct SimpleFrame_MDLn_SP
|
|
|
|
|
|
//! Vertex list of the frame
|
|
|
Vertex_MDL4 *verts;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
/** \struct GroupFrame
|
|
@@ -730,7 +706,7 @@ struct GroupFrame
|
|
|
|
|
|
//! List of single frames
|
|
|
SimpleFrame *frames;
|
|
|
-} PACK_STRUCT;
|
|
|
+} /* PACK_STRUCT */;
|
|
|
|
|
|
#include "./../include/assimp/Compiler/poppack1.h"
|
|
|
|
|
@@ -738,8 +714,7 @@ struct GroupFrame
|
|
|
/** \struct IntFace_MDL7
|
|
|
* \brief Internal data structure to temporarily represent a face
|
|
|
*/
|
|
|
-struct IntFace_MDL7
|
|
|
-{
|
|
|
+struct IntFace_MDL7 {
|
|
|
// provide a constructor for our own convenience
|
|
|
IntFace_MDL7()
|
|
|
{
|