Model_ma.h (3855B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. 23 24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. 25 26 =========================================================================== 27 */ 28 29 #ifndef __MODEL_MA_H__ 30 #define __MODEL_MA_H__ 31 32 /* 33 =============================================================================== 34 35 MA loader. (Maya Ascii Format) 36 37 =============================================================================== 38 */ 39 40 typedef struct { 41 char name[128]; 42 char parent[128]; 43 } maNodeHeader_t; 44 45 typedef struct { 46 char name[128]; 47 int size; 48 } maAttribHeader_t; 49 50 typedef struct maTransform_s { 51 idVec3 translate; 52 idVec3 rotate; 53 idVec3 scale; 54 maTransform_s* parent; 55 } maTransform_t; 56 57 typedef struct { 58 int edge[3]; 59 int vertexNum[3]; 60 int tVertexNum[3]; 61 int vertexColors[3]; 62 idVec3 vertexNormals[3]; 63 } maFace_t; 64 65 typedef struct { 66 67 //Transform to be applied 68 maTransform_t* transform; 69 70 //Verts 71 int numVertexes; 72 idVec3 * vertexes; 73 int numVertTransforms; 74 idVec4 * vertTransforms; 75 int nextVertTransformIndex; 76 77 //Texture Coordinates 78 int numTVertexes; 79 idVec2 * tvertexes; 80 81 //Edges 82 int numEdges; 83 idVec3 * edges; 84 85 //Colors 86 int numColors; 87 byte* colors; 88 89 //Faces 90 int numFaces; 91 maFace_t * faces; 92 93 //Normals 94 int numNormals; 95 idVec3 * normals; 96 bool normalsParsed; 97 int nextNormal; 98 99 } maMesh_t; 100 101 typedef struct { 102 char name[128]; 103 float uOffset, vOffset; // max lets you offset by material without changing texCoords 104 float uTiling, vTiling; // multiply tex coords by this 105 float angle; // in clockwise radians 106 } maMaterial_t; 107 108 typedef struct { 109 char name[128]; 110 int materialRef; 111 char materialName[128]; 112 113 maMesh_t mesh; 114 } maObject_t; 115 116 117 typedef struct { 118 char name[128]; 119 char path[1024]; 120 } maFileNode_t; 121 122 typedef struct maMaterialNode_s { 123 char name[128]; 124 125 maMaterialNode_s* child; 126 maFileNode_t* file; 127 128 } maMaterialNode_t; 129 130 typedef struct maModel_s { 131 ID_TIME_T timeStamp; 132 idList<maMaterial_t *, TAG_MODEL> materials; 133 idList<maObject_t *, TAG_MODEL> objects; 134 idHashTable<maTransform_t*> transforms; 135 136 //Material Resolution 137 idHashTable<maFileNode_t*> fileNodes; 138 idHashTable<maMaterialNode_t*> materialNodes; 139 140 } maModel_t; 141 142 maModel_t *MA_Load( const char *fileName ); 143 void MA_Free( maModel_t *ma ); 144 145 #endif /* !__MODEL_MA_H__ */