Model_ma.h 3.8 KB

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