Model_md3.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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_MD3_H__
  21. #define __MODEL_MD3_H__
  22. /*
  23. ========================================================================
  24. .MD3 triangle model file format
  25. Private structures used by the MD3 loader.
  26. ========================================================================
  27. */
  28. #define MD3_IDENT (('3'<<24)+('P'<<16)+('D'<<8)+'I')
  29. #define MD3_VERSION 15
  30. // surface geometry should not exceed these limits
  31. #define SHADER_MAX_VERTEXES 1000
  32. #define SHADER_MAX_INDEXES (6*SHADER_MAX_VERTEXES)
  33. // limits
  34. #define MD3_MAX_LODS 4
  35. #define MD3_MAX_TRIANGLES 8192 // per surface
  36. #define MD3_MAX_VERTS 4096 // per surface
  37. #define MD3_MAX_SHADERS 256 // per surface
  38. #define MD3_MAX_FRAMES 1024 // per model
  39. #define MD3_MAX_SURFACES 32 // per model
  40. #define MD3_MAX_TAGS 16 // per frame
  41. #define MAX_MD3PATH 64 // from quake3
  42. // vertex scales
  43. #define MD3_XYZ_SCALE (1.0/64)
  44. typedef struct md3Frame_s {
  45. idVec3 bounds[2];
  46. idVec3 localOrigin;
  47. float radius;
  48. char name[16];
  49. } md3Frame_t;
  50. typedef struct md3Tag_s {
  51. char name[MAX_MD3PATH]; // tag name
  52. idVec3 origin;
  53. idVec3 axis[3];
  54. } md3Tag_t;
  55. /*
  56. ** md3Surface_t
  57. **
  58. ** CHUNK SIZE
  59. ** header sizeof( md3Surface_t )
  60. ** shaders sizeof( md3Shader_t ) * numShaders
  61. ** triangles[0] sizeof( md3Triangle_t ) * numTriangles
  62. ** st sizeof( md3St_t ) * numVerts
  63. ** XyzNormals sizeof( md3XyzNormal_t ) * numVerts * numFrames
  64. */
  65. typedef struct md3Surface_s {
  66. int ident; //
  67. char name[MAX_MD3PATH]; // polyset name
  68. int flags;
  69. int numFrames; // all surfaces in a model should have the same
  70. int numShaders; // all surfaces in a model should have the same
  71. int numVerts;
  72. int numTriangles;
  73. int ofsTriangles;
  74. int ofsShaders; // offset from start of md3Surface_t
  75. int ofsSt; // texture coords are common for all frames
  76. int ofsXyzNormals; // numVerts * numFrames
  77. int ofsEnd; // next surface follows
  78. } md3Surface_t;
  79. typedef struct {
  80. char name[MAX_MD3PATH];
  81. const idMaterial * shader; // for in-game use
  82. } md3Shader_t;
  83. typedef struct {
  84. int indexes[3];
  85. } md3Triangle_t;
  86. typedef struct {
  87. float st[2];
  88. } md3St_t;
  89. typedef struct {
  90. short xyz[3];
  91. short normal;
  92. } md3XyzNormal_t;
  93. typedef struct md3Header_s {
  94. int ident;
  95. int version;
  96. char name[MAX_MD3PATH]; // model name
  97. int flags;
  98. int numFrames;
  99. int numTags;
  100. int numSurfaces;
  101. int numSkins;
  102. int ofsFrames; // offset for first frame
  103. int ofsTags; // numFrames * numTags
  104. int ofsSurfaces; // first surface, others follow
  105. int ofsEnd; // end of file
  106. } md3Header_t;
  107. #endif /* !__MODEL_MD3_H__ */