vrshoot
view libs/assimp/MD2FileData.h @ 2:334d17aed7de
visual studio project files
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 02 Feb 2014 18:36:38 +0200 |
parents | |
children |
line source
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
5 Copyright (c) 2006-2012, assimp team
6 All rights reserved.
8 Redistribution and use of this software in source and binary forms,
9 with or without modification, are permitted provided that the
10 following conditions are met:
12 * Redistributions of source code must retain the above
13 copyright notice, this list of conditions and the
14 following disclaimer.
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the
18 following disclaimer in the documentation and/or other
19 materials provided with the distribution.
21 * Neither the name of the assimp team, nor the names of its
22 contributors may be used to endorse or promote products
23 derived from this software without specific prior
24 written permission of the assimp team.
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 ----------------------------------------------------------------------
39 */
41 /** @file MD2FileData.h
42 * @brief Defines helper data structures for importing MD2 files
43 * http://linux.ucla.edu/~phaethon/q3/formats/md2-schoenblum.html
44 */
45 #ifndef AI_MD2FILEHELPER_H_INC
46 #define AI_MD2FILEHELPER_H_INC
48 #include "assimp/types.h"
49 #include "assimp/mesh.h"
50 #include "assimp/anim.h"
52 #include "assimp/Compiler/pushpack1.h"
54 namespace Assimp {
55 namespace MD2 {
57 // to make it easier for us, we test the magic word against both "endianesses"
58 #define AI_MD2_MAGIC_NUMBER_BE AI_MAKE_MAGIC("IDP2")
59 #define AI_MD2_MAGIC_NUMBER_LE AI_MAKE_MAGIC("2PDI")
61 // common limitations
62 #define AI_MD2_VERSION 15
63 #define AI_MD2_MAXQPATH 64
64 #define AI_MD2_MAX_FRAMES 512
65 #define AI_MD2_MAX_SKINS 32
66 #define AI_MD2_MAX_VERTS 2048
67 #define AI_MD2_MAX_TRIANGLES 4096
69 // ---------------------------------------------------------------------------
70 /** \brief Data structure for the MD2 main header
71 */
72 struct Header
73 {
74 uint32_t magic;
75 uint32_t version;
76 uint32_t skinWidth;
77 uint32_t skinHeight;
78 uint32_t frameSize;
79 uint32_t numSkins;
80 uint32_t numVertices;
81 uint32_t numTexCoords;
82 uint32_t numTriangles;
83 uint32_t numGlCommands;
84 uint32_t numFrames;
85 uint32_t offsetSkins;
86 uint32_t offsetTexCoords;
87 uint32_t offsetTriangles;
88 uint32_t offsetFrames;
89 uint32_t offsetGlCommands;
90 uint32_t offsetEnd;
92 } PACK_STRUCT;
94 // ---------------------------------------------------------------------------
95 /** \brief Data structure for a MD2 OpenGl draw command
96 */
97 struct GLCommand
98 {
99 float s, t;
100 uint32_t vertexIndex;
101 } PACK_STRUCT;
103 // ---------------------------------------------------------------------------
104 /** \brief Data structure for a MD2 triangle
105 */
106 struct Triangle
107 {
108 uint16_t vertexIndices[3];
109 uint16_t textureIndices[3];
110 } PACK_STRUCT;
112 // ---------------------------------------------------------------------------
113 /** \brief Data structure for a MD2 vertex
114 */
115 struct Vertex
116 {
117 uint8_t vertex[3];
118 uint8_t lightNormalIndex;
119 } PACK_STRUCT;
121 // ---------------------------------------------------------------------------
122 /** \brief Data structure for a MD2 frame
123 */
124 struct Frame
125 {
126 float scale[3];
127 float translate[3];
128 char name[16];
129 Vertex vertices[1];
130 } PACK_STRUCT;
132 // ---------------------------------------------------------------------------
133 /** \brief Data structure for a MD2 texture coordinate
134 */
135 struct TexCoord
136 {
137 uint16_t s;
138 uint16_t t;
139 } PACK_STRUCT;
141 // ---------------------------------------------------------------------------
142 /** \brief Data structure for a MD2 skin
143 */
144 struct Skin
145 {
146 char name[AI_MD2_MAXQPATH]; /* texture file name */
147 } PACK_STRUCT;
149 #include "assimp/Compiler/poppack1.h"
152 // ---------------------------------------------------------------------------
153 //! Lookup a normal vector from Quake's normal lookup table
154 //! \param index Input index (0-161)
155 //! \param vOut Receives the output normal
156 void LookupNormalIndex(uint8_t index,aiVector3D& vOut);
159 }
160 }
162 #endif // !! include guard