2015-05-19 03:48:29 +00:00
|
|
|
/*
|
|
|
|
Open Asset Import Library (assimp)
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
2024-02-23 21:30:05 +00:00
|
|
|
Copyright (c) 2006-2024, assimp team
|
2018-01-28 18:42:05 +00:00
|
|
|
|
2017-05-09 17:57:36 +00:00
|
|
|
|
2015-05-19 03:48:29 +00:00
|
|
|
All rights reserved.
|
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the
|
2015-05-19 03:48:29 +00:00
|
|
|
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.
|
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
2015-05-19 03:48:29 +00:00
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
2015-05-19 03:52:10 +00:00
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
2015-05-19 03:48:29 +00:00
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
2015-05-19 03:52:10 +00:00
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
2015-05-19 03:48:29 +00:00
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
2015-05-19 03:52:10 +00:00
|
|
|
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
|
2015-05-19 03:48:29 +00:00
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
/** @file Defines the helper data structures for importing MDC files
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
**********************************************************************
|
2015-05-19 03:52:10 +00:00
|
|
|
File format specification:
|
2015-05-19 03:48:29 +00:00
|
|
|
http://themdcfile.planetwolfenstein.gamespy.com/MDC_File_Format.pdf
|
|
|
|
**********************************************************************
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifndef AI_MDCFILEHELPER_H_INC
|
|
|
|
#define AI_MDCFILEHELPER_H_INC
|
|
|
|
|
2016-06-06 20:04:29 +00:00
|
|
|
#include <assimp/types.h>
|
|
|
|
#include <assimp/mesh.h>
|
|
|
|
#include <assimp/anim.h>
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2016-06-06 20:04:29 +00:00
|
|
|
#include <assimp/Compiler/pushpack1.h>
|
2015-05-19 03:48:29 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
namespace Assimp {
|
|
|
|
namespace MDC {
|
|
|
|
|
|
|
|
// to make it easier for us, we test the magic word against both "endianesses"
|
2015-05-19 03:57:13 +00:00
|
|
|
#define AI_MDC_MAGIC_NUMBER_BE AI_MAKE_MAGIC("CPDI")
|
|
|
|
#define AI_MDC_MAGIC_NUMBER_LE AI_MAKE_MAGIC("IDPC")
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// common limitations
|
2015-05-19 03:57:13 +00:00
|
|
|
#define AI_MDC_VERSION 2
|
|
|
|
#define AI_MDC_MAXQPATH 64
|
|
|
|
#define AI_MDC_MAX_BONES 128
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
#define AI_MDC_CVERT_BIAS 127.0f
|
|
|
|
#define AI_MDC_DELTA_SCALING 4.0f
|
|
|
|
#define AI_MDC_BASE_SCALING (1.0f / 64.0f)
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** \brief Data structure for a MDC file's main header
|
|
|
|
*/
|
2018-09-21 18:13:35 +00:00
|
|
|
struct Header {
|
2015-05-19 03:57:13 +00:00
|
|
|
uint32_t ulIdent ;
|
|
|
|
uint32_t ulVersion ;
|
|
|
|
char ucName [ AI_MDC_MAXQPATH ] ;
|
|
|
|
uint32_t ulFlags ;
|
|
|
|
uint32_t ulNumFrames ;
|
|
|
|
uint32_t ulNumTags ;
|
|
|
|
uint32_t ulNumSurfaces ;
|
|
|
|
uint32_t ulNumSkins ;
|
|
|
|
uint32_t ulOffsetBorderFrames ;
|
|
|
|
uint32_t ulOffsetTagNames ;
|
|
|
|
uint32_t ulOffsetTagFrames ;
|
|
|
|
uint32_t ulOffsetSurfaces ;
|
|
|
|
uint32_t ulOffsetEnd ;
|
2015-05-19 03:48:29 +00:00
|
|
|
} PACK_STRUCT ;
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** \brief Data structure for a MDC file's surface header
|
|
|
|
*/
|
2018-09-21 18:13:35 +00:00
|
|
|
struct Surface {
|
2015-05-19 03:57:13 +00:00
|
|
|
uint32_t ulIdent ;
|
|
|
|
char ucName [ AI_MDC_MAXQPATH ] ;
|
|
|
|
uint32_t ulFlags ;
|
|
|
|
uint32_t ulNumCompFrames ;
|
|
|
|
uint32_t ulNumBaseFrames ;
|
|
|
|
uint32_t ulNumShaders ;
|
|
|
|
uint32_t ulNumVertices ;
|
|
|
|
uint32_t ulNumTriangles ;
|
|
|
|
uint32_t ulOffsetTriangles ;
|
|
|
|
uint32_t ulOffsetShaders ;
|
|
|
|
uint32_t ulOffsetTexCoords ;
|
|
|
|
uint32_t ulOffsetBaseVerts ;
|
|
|
|
uint32_t ulOffsetCompVerts ;
|
|
|
|
uint32_t ulOffsetFrameBaseFrames ;
|
|
|
|
uint32_t ulOffsetFrameCompFrames ;
|
|
|
|
uint32_t ulOffsetEnd;
|
2018-09-21 14:25:27 +00:00
|
|
|
Surface() AI_NO_EXCEPT
|
2018-09-21 14:07:09 +00:00
|
|
|
: ulIdent()
|
|
|
|
, ulFlags()
|
|
|
|
, ulNumCompFrames()
|
|
|
|
, ulNumBaseFrames()
|
2021-07-29 11:28:51 +00:00
|
|
|
, ulNumShaders()
|
2018-09-21 14:07:09 +00:00
|
|
|
, ulNumVertices()
|
|
|
|
, ulNumTriangles()
|
|
|
|
, ulOffsetTriangles()
|
|
|
|
, ulOffsetShaders()
|
|
|
|
, ulOffsetTexCoords()
|
2021-07-29 11:28:51 +00:00
|
|
|
, ulOffsetBaseVerts()
|
2018-09-21 14:07:09 +00:00
|
|
|
, ulOffsetCompVerts()
|
|
|
|
, ulOffsetFrameBaseFrames()
|
|
|
|
, ulOffsetFrameCompFrames()
|
|
|
|
, ulOffsetEnd() {
|
2015-05-19 03:57:13 +00:00
|
|
|
ucName[AI_MDC_MAXQPATH-1] = '\0';
|
|
|
|
}
|
2015-05-19 03:48:29 +00:00
|
|
|
} PACK_STRUCT;
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** \brief Data structure for a MDC frame
|
|
|
|
*/
|
2018-09-21 18:13:35 +00:00
|
|
|
struct Frame {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! bounding box minimum coords
|
|
|
|
aiVector3D bboxMin ;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! bounding box maximum coords
|
|
|
|
aiVector3D bboxMax ;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! local origin of the frame
|
|
|
|
aiVector3D localOrigin ;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! radius of the BB
|
|
|
|
float radius ;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Name of the frame
|
|
|
|
char name [ 16 ] ;
|
2017-06-21 21:02:46 +00:00
|
|
|
} /*PACK_STRUCT*/;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** \brief Data structure for a MDC triangle
|
|
|
|
*/
|
2018-09-21 18:13:35 +00:00
|
|
|
struct Triangle {
|
2015-05-19 03:57:13 +00:00
|
|
|
uint32_t aiIndices[3];
|
2015-05-19 03:48:29 +00:00
|
|
|
} PACK_STRUCT;
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** \brief Data structure for a MDC texture coordinate
|
|
|
|
*/
|
2018-09-21 18:13:35 +00:00
|
|
|
struct TexturCoord {
|
2015-05-19 03:57:13 +00:00
|
|
|
float u,v;
|
2015-05-19 03:48:29 +00:00
|
|
|
} PACK_STRUCT;
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** \brief Data structure for a MDC base vertex
|
|
|
|
*/
|
2018-09-21 18:13:35 +00:00
|
|
|
struct BaseVertex {
|
2015-05-19 03:57:13 +00:00
|
|
|
int16_t x,y,z;
|
|
|
|
uint16_t normal;
|
2015-05-19 03:48:29 +00:00
|
|
|
} PACK_STRUCT;
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** \brief Data structure for a MDC compressed vertex
|
|
|
|
*/
|
2018-09-21 18:13:35 +00:00
|
|
|
struct CompressedVertex {
|
2015-05-19 03:57:13 +00:00
|
|
|
uint8_t xd,yd,zd,nd;
|
2015-05-19 03:48:29 +00:00
|
|
|
} PACK_STRUCT;
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** \brief Data structure for a MDC shader
|
|
|
|
*/
|
2018-09-21 18:13:35 +00:00
|
|
|
struct Shader {
|
2015-05-19 03:57:13 +00:00
|
|
|
char ucName [ AI_MDC_MAXQPATH ] ;
|
|
|
|
uint32_t ulPath;
|
2015-05-19 03:48:29 +00:00
|
|
|
} PACK_STRUCT;
|
|
|
|
|
2016-06-06 20:04:29 +00:00
|
|
|
#include <assimp/Compiler/poppack1.h>
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Build a floating point vertex from the compressed data in MDC files
|
|
|
|
*/
|
|
|
|
void BuildVertex(const Frame& frame,
|
2015-05-19 03:57:13 +00:00
|
|
|
const BaseVertex& bvert,
|
|
|
|
const CompressedVertex& cvert,
|
|
|
|
aiVector3D& vXYZOut,
|
|
|
|
aiVector3D& vNorOut);
|
2018-09-21 18:13:35 +00:00
|
|
|
}
|
|
|
|
}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
#endif // !! AI_MDCFILEHELPER_H_INC
|