]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/qdata_heretic2/qcommon/fmodel.h
uncrustify! now the code is only ugly on the *inside*
[xonotic/netradiant.git] / tools / quake2 / qdata_heretic2 / qcommon / fmodel.h
1 /*
2    Copyright (C) 1999-2007 id Software, Inc. and contributors.
3    For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22
23 /*
24    ========================================================================
25
26    .FM triangle flexible model file format
27
28    ========================================================================
29  */
30
31 #ifndef __FMODEL_HEADER
32 #define __FMODEL_HEADER
33
34 #include "bspfile.h"
35
36 //typedef unsigned char         byte;
37 //typedef int   qboolean;
38 //typedef float vec3_t[3];
39
40 #define MAX_FM_TRIANGLES    2048
41 #define MAX_FM_VERTS        2048
42 #define MAX_FM_FRAMES       2048
43 #define MAX_FM_SKINS        64
44 #define MAX_FM_SKINNAME     64
45 #define MAX_FM_MESH_NODES   16      // also defined in game/qshared.h
46
47
48 #define DTRIVERTX_V0   0
49 #define DTRIVERTX_V1   1
50 #define DTRIVERTX_V2   2
51 #define DTRIVERTX_LNI  3
52 #define DTRIVERTX_SIZE 4
53
54 #define SKINPAGE_WIDTH 640
55 #define SKINPAGE_HEIGHT 480
56
57 #define ENCODED_WIDTH_X 92
58 #define ENCODED_WIDTH_Y 475
59 #define ENCODED_HEIGHT_X 128
60 #define ENCODED_HEIGHT_Y 475
61
62 #define SCALE_ADJUST_FACTOR 0.96
63
64 #define INFO_HEIGHT 5
65 #define INFO_Y ( SKINPAGE_HEIGHT - INFO_HEIGHT )
66
67 extern byte     *BasePalette;
68 extern byte     *BasePixels,*TransPixels;
69 extern int BaseWidth, BaseHeight, TransWidth, TransHeight;
70 extern int ScaleWidth, ScaleHeight;
71
72 int ExtractNumber( byte *pic, int x, int y );
73 void DrawTextChar( int x, int y, char *text );
74 void DrawLine( int x1, int y1, int x2, int y2 );
75
76 // the glcmd format:
77 // a positive integer starts a tristrip command, followed by that many
78 // vertex structures.
79 // a negative integer starts a trifan command, followed by -x vertexes
80 // a zero indicates the end of the command list.
81 // a vertex consists of a floating point s, a floating point t,
82 // and an integer vertex index.
83
84
85 // Initial Header
86 #define FM_HEADER_NAME  "header"
87 #define FM_HEADER_VER   2
88
89 typedef struct
90 {
91         int skinwidth;
92         int skinheight;
93         int framesize;              // byte size of each frame
94
95         int num_skins;
96         int num_xyz;
97         int num_st;                 // greater than num_xyz for seams
98         int num_tris;
99         int num_glcmds;             // dwords in strip/fan command list
100         int num_frames;
101         int num_mesh_nodes;
102 } fmheader_t;
103
104
105 // Skin Header
106 #define FM_SKIN_NAME    "skin"
107 #define FM_SKIN_VER     1
108
109
110 // ST Coord Header
111 #define FM_ST_NAME      "st coord"
112 #define FM_ST_VER       1
113
114 typedef struct
115 {
116         short s;
117         short t;
118 } fmstvert_t;
119
120
121 // Tri Header
122 #define FM_TRI_NAME     "tris"
123 #define FM_TRI_VER      1
124
125 typedef struct
126 {
127         short index_xyz[3];
128         short index_st[3];
129 } fmtriangle_t;
130
131
132 // Frame Header
133 #define FM_FRAME_NAME   "frames"
134 #define FM_FRAME_VER    1
135
136 // Frame for compression, just the names
137 #define FM_SHORT_FRAME_NAME "short frames"
138 #define FM_SHORT_FRAME_VER  1
139
140 // Normals for compressed frames
141 #define FM_NORMAL_NAME  "normals"
142 #define FM_NORMAL_VER   1
143
144 // Compressed Frame Data
145 #define FM_COMP_NAME    "comp data"
146 #define FM_COMP_VER 1
147
148 // GL Cmds Header
149 #define FM_GLCMDS_NAME  "glcmds"
150 #define FM_GLCMDS_VER   1
151
152
153 // Mesh Nodes Header
154 #define FM_MESH_NAME    "mesh nodes"
155 #define FM_MESH_VER     3
156
157 // Skeleton Header
158 #define FM_SKELETON_NAME "skeleton"
159 #define FM_SKELETON_VER 1
160
161 // References Header
162 #define FM_REFERENCES_NAME "references"
163 #define FM_REFERENCES_VER   1
164
165 typedef struct
166 {
167
168         union
169         {
170
171                 byte tris[MAX_FM_TRIANGLES >> 3];
172
173                 struct {
174                         short   *triIndicies;
175                         int num_tris;
176                 };
177
178         };
179
180         byte verts[MAX_FM_VERTS >> 3];
181         short start_glcmds, num_glcmds;
182 } fmmeshnode_t;
183
184 //=================================================================
185
186 // Frame info
187 typedef struct
188 {
189         byte v[3];              // scaled byte to fit in frame mins/maxs
190         byte lightnormalindex;
191 } fmtrivertx_t;
192
193 typedef struct
194 {
195         float scale[3];                 // multiply byte verts by this
196         float translate[3];             // then add this
197         char name[16];                  // frame name from grabbing
198         fmtrivertx_t verts[1];          // variable sized
199 } fmaliasframe_t;
200
201
202 #endif // #define __FMODEL_HEADER