vrshoot

diff libs/assimp/MD4FileData.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/assimp/MD4FileData.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,218 @@
     1.4 +/*
     1.5 +Open Asset Import Library (ASSIMP)
     1.6 +----------------------------------------------------------------------
     1.7 +
     1.8 +Copyright (c) 2006-2010, ASSIMP Development Team
     1.9 +All rights reserved.
    1.10 +
    1.11 +Redistribution and use of this software in source and binary forms, 
    1.12 +with or without modification, are permitted provided that the 
    1.13 +following conditions are met:
    1.14 +
    1.15 +* Redistributions of source code must retain the above
    1.16 +  copyright notice, this list of conditions and the
    1.17 +  following disclaimer.
    1.18 +
    1.19 +* Redistributions in binary form must reproduce the above
    1.20 +  copyright notice, this list of conditions and the
    1.21 +  following disclaimer in the documentation and/or other
    1.22 +  materials provided with the distribution.
    1.23 +
    1.24 +* Neither the name of the ASSIMP team, nor the names of its
    1.25 +  contributors may be used to endorse or promote products
    1.26 +  derived from this software without specific prior
    1.27 +  written permission of the ASSIMP Development Team.
    1.28 +
    1.29 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    1.30 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    1.31 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.32 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    1.33 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.34 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    1.35 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.36 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    1.37 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    1.38 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    1.39 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.40 +
    1.41 +----------------------------------------------------------------------
    1.42 +*/
    1.43 +
    1.44 +/** @file Defines the helper data structures for importing MD4 files  */
    1.45 +#ifndef AI_MD4FILEHELPER_H_INC
    1.46 +#define AI_MD4FILEHELPER_H_INC
    1.47 +
    1.48 +#include <string>
    1.49 +#include <vector>
    1.50 +#include <sstream>
    1.51 +
    1.52 +#include "../include/aiTypes.h"
    1.53 +#include "../include/aiMesh.h"
    1.54 +#include "../include/aiAnim.h"
    1.55 +
    1.56 +#if defined(_MSC_VER) ||  defined(__BORLANDC__) ||	defined (__BCPLUSPLUS__)
    1.57 +#	pragma pack(push,1)
    1.58 +#	define PACK_STRUCT
    1.59 +#elif defined( __GNUC__ )
    1.60 +#	define PACK_STRUCT	__attribute__((packed))
    1.61 +#else
    1.62 +#	error Compiler not supported
    1.63 +#endif
    1.64 +
    1.65 +
    1.66 +namespace Assimp
    1.67 +{
    1.68 +// http://gongo.quakedev.com/md4.html
    1.69 +namespace MD4
    1.70 +{
    1.71 +
    1.72 +#define AI_MD4_MAGIC_NUMBER_BE	'IDP4'
    1.73 +#define AI_MD4_MAGIC_NUMBER_LE	'4PDI'
    1.74 +
    1.75 +// common limitations
    1.76 +#define AI_MD4_VERSION			4
    1.77 +#define AI_MD4_MAXQPATH			64
    1.78 +#define AI_MD4_MAX_FRAMES		2028
    1.79 +#define AI_MD4_MAX_SURFACES		32
    1.80 +#define AI_MD4_MAX_BONES		256
    1.81 +#define AI_MD4_MAX_VERTS		4096	
    1.82 +#define AI_MD4_MAX_TRIANGLES	8192	
    1.83 +
    1.84 +// ---------------------------------------------------------------------------
    1.85 +/** \brief Data structure for the MD4 main header
    1.86 + */
    1.87 +// ---------------------------------------------------------------------------
    1.88 +struct Header
    1.89 +{
    1.90 +	//! magic number
    1.91 +	int32_t magic;
    1.92 +
    1.93 +	//! file format version
    1.94 +	int32_t version;
    1.95 +
    1.96 +	//! original name in .pak archive
    1.97 +	unsigned char name[ AI_MD4_MAXQPATH ];
    1.98 +
    1.99 +	//! number of frames in the file
   1.100 +	int32_t NUM_FRAMES;
   1.101 +
   1.102 +	//! number of bones in the file
   1.103 +	int32_t NUM_BONES;
   1.104 +
   1.105 +	//! number of surfaces in the file
   1.106 +	int32_t NUM_SURFACES;
   1.107 +
   1.108 +	//! offset of the first frame
   1.109 +	int32_t OFS_FRAMES;
   1.110 +
   1.111 +	//! offset of the first bone
   1.112 +	int32_t OFS_BONES;
   1.113 +
   1.114 +	//! offset of the first surface
   1.115 +	int32_t OFS_SURFACES;
   1.116 +
   1.117 +	//! end of file
   1.118 +	int32_t OFS_EOF;
   1.119 +} PACK_STRUCT;
   1.120 +
   1.121 +// ---------------------------------------------------------------------------
   1.122 +/** \brief Stores the local transformation matrix of a bone
   1.123 + */
   1.124 +// ---------------------------------------------------------------------------
   1.125 +struct BoneFrame
   1.126 +{  
   1.127 +	float matrix[3][4]; 
   1.128 +} PACK_STRUCT;
   1.129 +
   1.130 +// ---------------------------------------------------------------------------
   1.131 +/** \brief Stores the name / parent index / flag of a node
   1.132 + */
   1.133 +// ---------------------------------------------------------------------------
   1.134 +struct  BoneName
   1.135 +{  
   1.136 +	char name[32] ; 
   1.137 +	int parent ;
   1.138 +	int flags ;
   1.139 +}  PACK_STRUCT;
   1.140 +
   1.141 +// ---------------------------------------------------------------------------
   1.142 +/** \brief Data structure for a surface in a MD4 file
   1.143 + */
   1.144 +// ---------------------------------------------------------------------------
   1.145 +struct Surface
   1.146 +{  
   1.147 +	int32_t ident;
   1.148 +	char name[64];
   1.149 +	char shader[64];
   1.150 +	int32_t shaderIndex;
   1.151 +	int32_t lodBias;
   1.152 +	int32_t minLod;
   1.153 +	int32_t ofsHeader;
   1.154 +	int32_t numVerts;
   1.155 +	int32_t ofsVerts;
   1.156 +	int32_t numTris;
   1.157 +	int32_t ofsTris;
   1.158 +	int32_t numBoneRefs;
   1.159 +	int32_t ofsBoneRefs;
   1.160 +	int32_t ofsCollapseMap;
   1.161 +	int32_t ofsEnd;
   1.162 +} PACK_STRUCT;
   1.163 +
   1.164 +
   1.165 +// ---------------------------------------------------------------------------
   1.166 +/** \brief Data structure for a MD4 vertex' weight
   1.167 + */
   1.168 +// ---------------------------------------------------------------------------
   1.169 +struct Weight
   1.170 +{  
   1.171 +	int32_t boneIndex; 
   1.172 +	float boneWeight; 
   1.173 +	float offset[3]; 
   1.174 +} PACK_STRUCT; 
   1.175 +
   1.176 +// ---------------------------------------------------------------------------
   1.177 +/** \brief Data structure for a vertex in a MD4 file
   1.178 + */
   1.179 +// ---------------------------------------------------------------------------
   1.180 +struct Vertex
   1.181 +{  
   1.182 +	float vertex[3];
   1.183 +	float normal[3];
   1.184 +	float texCoords[2];
   1.185 +	int32_t numWeights;
   1.186 +	Weight weights[1];
   1.187 +} PACK_STRUCT; 
   1.188 +
   1.189 +// ---------------------------------------------------------------------------
   1.190 +/** \brief Data structure for a triangle in a MD4 file
   1.191 + */
   1.192 +// ---------------------------------------------------------------------------
   1.193 +struct Triangle 
   1.194 +{  
   1.195 +	int32_t indexes[3]; 
   1.196 +} PACK_STRUCT;
   1.197 +
   1.198 +// ---------------------------------------------------------------------------
   1.199 +/** \brief Data structure for a MD4 frame
   1.200 + */
   1.201 +// ---------------------------------------------------------------------------
   1.202 +struct Frame
   1.203 +{  
   1.204 +	float bounds[3][2];
   1.205 +	float localOrigin[3]; 
   1.206 +	float radius;
   1.207 +	BoneFrame bones[1]; 
   1.208 +} PACK_STRUCT; 
   1.209 +
   1.210 +
   1.211 +// reset packing to the original value
   1.212 +#if defined(_MSC_VER) ||  defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
   1.213 +#	pragma pack( pop )
   1.214 +#endif
   1.215 +#undef PACK_STRUCT
   1.216 +
   1.217 +
   1.218 +};
   1.219 +};
   1.220 +
   1.221 +#endif // !! AI_MD4FILEHELPER_H_INC
   1.222 \ No newline at end of file