vkQuake2 doxygen  1.0 dev
vk_model.c
Go to the documentation of this file.
1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 Copyright (C) 2018-2019 Krzysztof Kondrak
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program 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.
13 
14 See the GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 
20 */
21 // models.c -- model loading and caching
22 
23 #include "vk_local.h"
24 
27 
28 void Mod_LoadSpriteModel (model_t *mod, void *buffer);
29 void Mod_LoadBrushModel (model_t *mod, void *buffer);
30 void Mod_LoadAliasModel (model_t *mod, void *buffer);
31 
33 
34 #define MAX_MOD_KNOWN 512
37 
38 // the inline * models from the current map are kept seperate
40 
42 
43 /*
44 ===============
45 Mod_PointInLeaf
46 ===============
47 */
49 {
50  mnode_t *node;
51  float d;
52  cplane_t *plane;
53 
54  if (!model || !model->nodes)
55  ri.Sys_Error (ERR_DROP, "Mod_PointInLeaf: bad model");
56 
57  node = model->nodes;
58  while (1)
59  {
60  if (node->contents != -1)
61  return (mleaf_t *)node;
62  plane = node->plane;
63  d = DotProduct (p,plane->normal) - plane->dist;
64  if (d > 0)
65  node = node->children[0];
66  else
67  node = node->children[1];
68  }
69 
70  return NULL; // never reached
71 }
72 
73 
74 /*
75 ===================
76 Mod_DecompressVis
77 ===================
78 */
79 byte *Mod_DecompressVis (byte *in, model_t *model)
80 {
81  static byte decompressed[MAX_MAP_LEAFS/8];
82  int c;
83  byte *out;
84  int row;
85 
86  row = (model->vis->numclusters+7)>>3;
87  out = decompressed;
88 
89  if (!in)
90  { // no vis info, so make all visible
91  while (row)
92  {
93  *out++ = 0xff;
94  row--;
95  }
96  return decompressed;
97  }
98 
99  do
100  {
101  if (*in)
102  {
103  *out++ = *in++;
104  continue;
105  }
106 
107  c = in[1];
108  in += 2;
109  while (c)
110  {
111  *out++ = 0;
112  c--;
113  }
114  } while (out - decompressed < row);
115 
116  return decompressed;
117 }
118 
119 /*
120 ==============
121 Mod_ClusterPVS
122 ==============
123 */
124 byte *Mod_ClusterPVS (int cluster, model_t *model)
125 {
126  if (cluster == -1 || !model->vis)
127  return mod_novis;
128  return Mod_DecompressVis ( (byte *)model->vis + model->vis->bitofs[cluster][DVIS_PVS],
129  model);
130 }
131 
132 
133 //===============================================================================
134 
135 /*
136 ================
137 Mod_Modellist_f
138 ================
139 */
140 void Mod_Modellist_f (void)
141 {
142  int i;
143  model_t *mod;
144  int total;
145 
146  total = 0;
147  ri.Con_Printf (PRINT_ALL,"Loaded models:\n");
148  for (i=0, mod=mod_known ; i < mod_numknown ; i++, mod++)
149  {
150  if (!mod->name[0])
151  continue;
152  ri.Con_Printf (PRINT_ALL, "%8i : %s\n",mod->extradatasize, mod->name);
153  total += mod->extradatasize;
154  }
155  ri.Con_Printf (PRINT_ALL, "Total resident: %i\n", total);
156 }
157 
158 /*
159 ===============
160 Mod_Init
161 ===============
162 */
163 void Mod_Init (void)
164 {
165  memset (mod_novis, 0xff, sizeof(mod_novis));
166 }
167 
168 
169 
170 /*
171 ==================
172 Mod_ForName
173 
174 Loads in a model for the given name
175 ==================
176 */
178 {
179  model_t *mod;
180  unsigned *buf;
181  int i;
182 
183  if (!name[0])
184  ri.Sys_Error (ERR_DROP, "Mod_ForName: NULL name");
185 
186  //
187  // inline models are grabbed only from worldmodel
188  //
189  if (name[0] == '*')
190  {
191  i = atoi(name+1);
192  if (i < 1 || !r_worldmodel || i >= r_worldmodel->numsubmodels)
193  ri.Sys_Error (ERR_DROP, "bad inline model number");
194  return &mod_inline[i];
195  }
196 
197  //
198  // search the currently loaded models
199  //
200  for (i=0 , mod=mod_known ; i<mod_numknown ; i++, mod++)
201  {
202  if (!mod->name[0])
203  continue;
204  if (!strcmp (mod->name, name) )
205  return mod;
206  }
207 
208  //
209  // find a free model slot spot
210  //
211  for (i=0 , mod=mod_known ; i<mod_numknown ; i++, mod++)
212  {
213  if (!mod->name[0])
214  break; // free spot
215  }
216  if (i == mod_numknown)
217  {
219  ri.Sys_Error (ERR_DROP, "mod_numknown == MAX_MOD_KNOWN");
220  mod_numknown++;
221  }
222  strcpy (mod->name, name);
223 
224  //
225  // load the file
226  //
227  modfilelen = ri.FS_LoadFile (mod->name, (void **)&buf);
228  if (!buf)
229  {
230  if (crash)
231  ri.Sys_Error (ERR_DROP, "Mod_NumForName: %s not found", mod->name);
232  memset (mod->name, 0, sizeof(mod->name));
233  return NULL;
234  }
235 
236  loadmodel = mod;
237 
238  //
239  // fill it in
240  //
241 
242 
243  // call the apropriate loader
244 
245  switch (LittleLong(*(unsigned *)buf))
246  {
247  case IDALIASHEADER:
248  loadmodel->extradata = Hunk_Begin (0x200000);
249  Mod_LoadAliasModel (mod, buf);
250  break;
251 
252  case IDSPRITEHEADER:
253  loadmodel->extradata = Hunk_Begin (0x10000);
254  Mod_LoadSpriteModel (mod, buf);
255  break;
256 
257  case IDBSPHEADER:
258  loadmodel->extradata = Hunk_Begin (0x1000000);
259  Mod_LoadBrushModel (mod, buf);
260  break;
261 
262  default:
263  ri.Sys_Error (ERR_DROP,"Mod_NumForName: unknown fileid for %s", mod->name);
264  break;
265  }
266 
268 
269  ri.FS_FreeFile (buf);
270 
271  return mod;
272 }
273 
274 /*
275 ===============================================================================
276 
277  BRUSHMODEL LOADING
278 
279 ===============================================================================
280 */
281 
282 byte *mod_base;
283 
284 
285 /*
286 =================
287 Mod_LoadLighting
288 =================
289 */
291 {
292  if (!l->filelen)
293  {
295  return;
296  }
298  memcpy (loadmodel->lightdata, mod_base + l->fileofs, l->filelen);
299 }
300 
301 
302 /*
303 =================
304 Mod_LoadVisibility
305 =================
306 */
308 {
309  int i;
310 
311  if (!l->filelen)
312  {
313  loadmodel->vis = NULL;
314  return;
315  }
316  loadmodel->vis = Hunk_Alloc ( l->filelen);
317  memcpy (loadmodel->vis, mod_base + l->fileofs, l->filelen);
318 
320  for (i=0 ; i<loadmodel->vis->numclusters ; i++)
321  {
322  loadmodel->vis->bitofs[i][0] = LittleLong (loadmodel->vis->bitofs[i][0]);
323  loadmodel->vis->bitofs[i][1] = LittleLong (loadmodel->vis->bitofs[i][1]);
324  }
325 }
326 
327 
328 /*
329 =================
330 Mod_LoadVertexes
331 =================
332 */
334 {
335  dvertex_t *in;
336  mvertex_t *out;
337  int i, count;
338 
339  in = (void *)(mod_base + l->fileofs);
340  if (l->filelen % sizeof(*in))
341  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
342  count = l->filelen / sizeof(*in);
343  out = Hunk_Alloc ( count*sizeof(*out));
344 
345  loadmodel->vertexes = out;
347 
348  for ( i=0 ; i<count ; i++, in++, out++)
349  {
350  out->position[0] = LittleFloat (in->point[0]);
351  out->position[1] = LittleFloat (in->point[1]);
352  out->position[2] = LittleFloat (in->point[2]);
353  }
354 }
355 
356 /*
357 =================
358 RadiusFromBounds
359 =================
360 */
361 float RadiusFromBounds (vec3_t mins, vec3_t maxs)
362 {
363  int i;
364  vec3_t corner;
365 
366  for (i=0 ; i<3 ; i++)
367  {
368  corner[i] = fabs(mins[i]) > fabs(maxs[i]) ? fabs(mins[i]) : fabs(maxs[i]);
369  }
370 
371  return VectorLength (corner);
372 }
373 
374 
375 /*
376 =================
377 Mod_LoadSubmodels
378 =================
379 */
381 {
382  dmodel_t *in;
383  mmodel_t *out;
384  int i, j, count;
385 
386  in = (void *)(mod_base + l->fileofs);
387  if (l->filelen % sizeof(*in))
388  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
389  count = l->filelen / sizeof(*in);
390  out = Hunk_Alloc ( count*sizeof(*out));
391 
392  loadmodel->submodels = out;
394 
395  for ( i=0 ; i<count ; i++, in++, out++)
396  {
397  for (j=0 ; j<3 ; j++)
398  { // spread the mins / maxs by a pixel
399  out->mins[j] = LittleFloat (in->mins[j]) - 1;
400  out->maxs[j] = LittleFloat (in->maxs[j]) + 1;
401  out->origin[j] = LittleFloat (in->origin[j]);
402  }
403  out->radius = RadiusFromBounds (out->mins, out->maxs);
404  out->headnode = LittleLong (in->headnode);
405  out->firstface = LittleLong (in->firstface);
406  out->numfaces = LittleLong (in->numfaces);
407  }
408 }
409 
410 /*
411 =================
412 Mod_LoadEdges
413 =================
414 */
416 {
417  dedge_t *in;
418  medge_t *out;
419  int i, count;
420 
421  in = (void *)(mod_base + l->fileofs);
422  if (l->filelen % sizeof(*in))
423  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
424  count = l->filelen / sizeof(*in);
425  out = Hunk_Alloc ( (count + 1) * sizeof(*out));
426 
427  loadmodel->edges = out;
429 
430  for ( i=0 ; i<count ; i++, in++, out++)
431  {
432  out->v[0] = (unsigned short)LittleShort(in->v[0]);
433  out->v[1] = (unsigned short)LittleShort(in->v[1]);
434  }
435 }
436 
437 /*
438 =================
439 Mod_LoadTexinfo
440 =================
441 */
443 {
444  texinfo_t *in;
445  mtexinfo_t *out, *step;
446  int i, j, count;
447  char name[MAX_QPATH];
448  int next;
449 
450  in = (void *)(mod_base + l->fileofs);
451  if (l->filelen % sizeof(*in))
452  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
453  count = l->filelen / sizeof(*in);
454  out = Hunk_Alloc ( count*sizeof(*out));
455 
456  loadmodel->texinfo = out;
458 
459  for ( i=0 ; i<count ; i++, in++, out++)
460  {
461  for (j=0 ; j<4 ; j++)
462  {
463  out->vecs[0][j] = LittleFloat (in->vecs[0][j]);
464  out->vecs[1][j] = LittleFloat (in->vecs[1][j]);
465  }
466 
467  out->flags = LittleLong (in->flags);
468  next = LittleLong (in->nexttexinfo);
469  if (next > 0)
470  out->next = loadmodel->texinfo + next;
471  else
472  out->next = NULL;
473  Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture);
474 
475  out->image = Vk_FindImage (name, it_wall, NULL);
476  if (!out->image)
477  {
478  ri.Con_Printf (PRINT_ALL, "Couldn't load %s\n", name);
479  out->image = r_notexture;
480  }
481  }
482 
483  // count animation frames
484  for (i=0 ; i<count ; i++)
485  {
486  out = &loadmodel->texinfo[i];
487  out->numframes = 1;
488  for (step = out->next ; step && step != out ; step=step->next)
489  out->numframes++;
490  }
491 }
492 
493 /*
494 ================
495 CalcSurfaceExtents
496 
497 Fills in s->texturemins[] and s->extents[]
498 ================
499 */
501 {
502  float mins[2], maxs[2], val;
503  int i,j, e;
504  mvertex_t *v;
505  mtexinfo_t *tex;
506  int bmins[2], bmaxs[2];
507 
508  mins[0] = mins[1] = 999999;
509  maxs[0] = maxs[1] = -99999;
510 
511  tex = s->texinfo;
512 
513  for (i=0 ; i<s->numedges ; i++)
514  {
515  e = loadmodel->surfedges[s->firstedge+i];
516  if (e >= 0)
517  v = &loadmodel->vertexes[loadmodel->edges[e].v[0]];
518  else
519  v = &loadmodel->vertexes[loadmodel->edges[-e].v[1]];
520 
521  for (j=0 ; j<2 ; j++)
522  {
523  val = v->position[0] * tex->vecs[j][0] +
524  v->position[1] * tex->vecs[j][1] +
525  v->position[2] * tex->vecs[j][2] +
526  tex->vecs[j][3];
527  if (val < mins[j])
528  mins[j] = val;
529  if (val > maxs[j])
530  maxs[j] = val;
531  }
532  }
533 
534  for (i=0 ; i<2 ; i++)
535  {
536  bmins[i] = floor(mins[i]/16);
537  bmaxs[i] = ceil(maxs[i]/16);
538 
539  s->texturemins[i] = bmins[i] * 16;
540  s->extents[i] = (bmaxs[i] - bmins[i]) * 16;
541  }
542 }
543 
544 
547 void Vk_EndBuildingLightmaps (void);
549 
550 /*
551 =================
552 Mod_LoadFaces
553 =================
554 */
556 {
557  dface_t *in;
558  msurface_t *out;
559  int i, count, surfnum;
560  int planenum, side;
561  int ti;
562 
563  in = (void *)(mod_base + l->fileofs);
564  if (l->filelen % sizeof(*in))
565  ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
566  count = l->filelen / sizeof(*in);
567  out = Hunk_Alloc(count * sizeof(*out));
568 
569  loadmodel->surfaces = out;
571 
573 
575 
576  for (surfnum = 0; surfnum<count; surfnum++, in++, out++)
577  {
578  out->firstedge = LittleLong(in->firstedge);
579  out->numedges = LittleShort(in->numedges);
580  out->flags = 0;
581  out->polys = NULL;
582 
583  planenum = LittleShort(in->planenum);
584  side = LittleShort(in->side);
585  if (side)
586  out->flags |= SURF_PLANEBACK;
587 
588  out->plane = loadmodel->planes + planenum;
589 
590  ti = LittleShort(in->texinfo);
591  if (ti < 0 || ti >= loadmodel->numtexinfo)
592  ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: bad texinfo number");
593  out->texinfo = loadmodel->texinfo + ti;
594 
595  CalcSurfaceExtents(out);
596 
597  // lighting info
598 
599  for (i = 0; i<MAXLIGHTMAPS; i++)
600  out->styles[i] = in->styles[i];
601  i = LittleLong(in->lightofs);
602  if (i == -1)
603  out->samples = NULL;
604  else
605  out->samples = loadmodel->lightdata + i;
606 
607  // set the drawing flags
608 
609  if (out->texinfo->flags & SURF_WARP)
610  {
611  out->flags |= SURF_DRAWTURB;
612  for (i = 0; i<2; i++)
613  {
614  out->extents[i] = 16384;
615  out->texturemins[i] = -8192;
616  }
617  Vk_SubdivideSurface(out); // cut up polygon for warps
618  }
619 
620  // create lightmaps and polygons
621  if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANS33 | SURF_TRANS66 | SURF_WARP)))
623 
624  if (!(out->texinfo->flags & SURF_WARP))
626 
627  }
628 
630 }
631 
632 
633 /*
634 =================
635 Mod_SetParent
636 =================
637 */
638 void Mod_SetParent (mnode_t *node, mnode_t *parent)
639 {
640  node->parent = parent;
641  if (node->contents != -1)
642  return;
643  Mod_SetParent (node->children[0], node);
644  Mod_SetParent (node->children[1], node);
645 }
646 
647 /*
648 =================
649 Mod_LoadNodes
650 =================
651 */
653 {
654  int i, j, count, p;
655  dnode_t *in;
656  mnode_t *out;
657 
658  in = (void *)(mod_base + l->fileofs);
659  if (l->filelen % sizeof(*in))
660  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
661  count = l->filelen / sizeof(*in);
662  out = Hunk_Alloc ( count*sizeof(*out));
663 
664  loadmodel->nodes = out;
666 
667  for ( i=0 ; i<count ; i++, in++, out++)
668  {
669  for (j=0 ; j<3 ; j++)
670  {
671  out->minmaxs[j] = LittleShort (in->mins[j]);
672  out->minmaxs[3+j] = LittleShort (in->maxs[j]);
673  }
674 
675  p = LittleLong(in->planenum);
676  out->plane = loadmodel->planes + p;
677 
678  out->firstsurface = LittleShort (in->firstface);
679  out->numsurfaces = LittleShort (in->numfaces);
680  out->contents = -1; // differentiate from leafs
681 
682  for (j=0 ; j<2 ; j++)
683  {
684  p = LittleLong (in->children[j]);
685  if (p >= 0)
686  out->children[j] = loadmodel->nodes + p;
687  else
688  out->children[j] = (mnode_t *)(loadmodel->leafs + (-1 - p));
689  }
690  }
691 
692  Mod_SetParent (loadmodel->nodes, NULL); // sets nodes and leafs
693 }
694 
695 /*
696 =================
697 Mod_LoadLeafs
698 =================
699 */
701 {
702  dleaf_t *in;
703  mleaf_t *out;
704  int i, j, count, p;
705 // glpoly_t *poly;
706 
707  in = (void *)(mod_base + l->fileofs);
708  if (l->filelen % sizeof(*in))
709  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
710  count = l->filelen / sizeof(*in);
711  out = Hunk_Alloc ( count*sizeof(*out));
712 
713  loadmodel->leafs = out;
715 
716  for ( i=0 ; i<count ; i++, in++, out++)
717  {
718  for (j=0 ; j<3 ; j++)
719  {
720  out->minmaxs[j] = LittleShort (in->mins[j]);
721  out->minmaxs[3+j] = LittleShort (in->maxs[j]);
722  }
723 
724  p = LittleLong(in->contents);
725  out->contents = p;
726 
727  out->cluster = LittleShort(in->cluster);
728  out->area = LittleShort(in->area);
729 
731  LittleShort(in->firstleafface);
732  out->nummarksurfaces = LittleShort(in->numleaffaces);
733 
734  // gl underwater warp
735 #if 0
736  if (out->contents & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA|CONTENTS_THINWATER) )
737  {
738  for (j=0 ; j<out->nummarksurfaces ; j++)
739  {
741  for (poly = out->firstmarksurface[j]->polys ; poly ; poly=poly->next)
742  poly->flags |= SURF_UNDERWATER;
743  }
744  }
745 #endif
746  }
747 }
748 
749 /*
750 =================
751 Mod_LoadMarksurfaces
752 =================
753 */
755 {
756  int i, j, count;
757  short *in;
758  msurface_t **out;
759 
760  in = (void *)(mod_base + l->fileofs);
761  if (l->filelen % sizeof(*in))
762  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
763  count = l->filelen / sizeof(*in);
764  out = Hunk_Alloc ( count*sizeof(*out));
765 
766  loadmodel->marksurfaces = out;
768 
769  for ( i=0 ; i<count ; i++)
770  {
771  j = LittleShort(in[i]);
772  if (j < 0 || j >= loadmodel->numsurfaces)
773  ri.Sys_Error (ERR_DROP, "Mod_ParseMarksurfaces: bad surface number");
774  out[i] = loadmodel->surfaces + j;
775  }
776 }
777 
778 /*
779 =================
780 Mod_LoadSurfedges
781 =================
782 */
784 {
785  int i, count;
786  int *in, *out;
787 
788  in = (void *)(mod_base + l->fileofs);
789  if (l->filelen % sizeof(*in))
790  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
791  count = l->filelen / sizeof(*in);
792  if (count < 1 || count >= MAX_MAP_SURFEDGES)
793  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: bad surfedges count in %s: %i",
794  loadmodel->name, count);
795 
796  out = Hunk_Alloc ( count*sizeof(*out));
797 
798  loadmodel->surfedges = out;
800 
801  for ( i=0 ; i<count ; i++)
802  out[i] = LittleLong (in[i]);
803 }
804 
805 
806 /*
807 =================
808 Mod_LoadPlanes
809 =================
810 */
812 {
813  int i, j;
814  cplane_t *out;
815  dplane_t *in;
816  int count;
817  int bits;
818 
819  in = (void *)(mod_base + l->fileofs);
820  if (l->filelen % sizeof(*in))
821  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
822  count = l->filelen / sizeof(*in);
823  out = Hunk_Alloc ( count*2*sizeof(*out));
824 
825  loadmodel->planes = out;
827 
828  for ( i=0 ; i<count ; i++, in++, out++)
829  {
830  bits = 0;
831  for (j=0 ; j<3 ; j++)
832  {
833  out->normal[j] = LittleFloat (in->normal[j]);
834  if (out->normal[j] < 0)
835  bits |= 1<<j;
836  }
837 
838  out->dist = LittleFloat (in->dist);
839  out->type = LittleLong (in->type);
840  out->signbits = bits;
841  }
842 }
843 
844 /*
845 =================
846 Mod_LoadBrushModel
847 =================
848 */
850 {
851  int i;
852  dheader_t *header;
853  mmodel_t *bm;
854 
856  if (loadmodel != mod_known)
857  ri.Sys_Error (ERR_DROP, "Loaded a brush model after the world");
858 
859  header = (dheader_t *)buffer;
860 
861  i = LittleLong (header->version);
862  if (i != BSPVERSION)
863  ri.Sys_Error (ERR_DROP, "Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION);
864 
865 // swap all the lumps
866  mod_base = (byte *)header;
867 
868  for (i=0 ; i<sizeof(dheader_t)/4 ; i++)
869  ((int *)header)[i] = LittleLong ( ((int *)header)[i]);
870 
871 // load into heap
872 
874  Mod_LoadEdges (&header->lumps[LUMP_EDGES]);
877  Mod_LoadPlanes (&header->lumps[LUMP_PLANES]);
878  Mod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]);
879  Mod_LoadFaces (&header->lumps[LUMP_FACES]);
882  Mod_LoadLeafs (&header->lumps[LUMP_LEAFS]);
883  Mod_LoadNodes (&header->lumps[LUMP_NODES]);
884  Mod_LoadSubmodels (&header->lumps[LUMP_MODELS]);
885  mod->numframes = 2; // regular and alternate animation
886 
887 //
888 // set up the submodels
889 //
890  for (i=0 ; i<mod->numsubmodels ; i++)
891  {
892  model_t *starmod;
893 
894  bm = &mod->submodels[i];
895  starmod = &mod_inline[i];
896 
897  *starmod = *loadmodel;
898 
899  starmod->firstmodelsurface = bm->firstface;
900  starmod->nummodelsurfaces = bm->numfaces;
901  starmod->firstnode = bm->headnode;
902  if (starmod->firstnode >= loadmodel->numnodes)
903  ri.Sys_Error (ERR_DROP, "Inline model %i has bad firstnode", i);
904 
905  VectorCopy (bm->maxs, starmod->maxs);
906  VectorCopy (bm->mins, starmod->mins);
907  starmod->radius = bm->radius;
908 
909  if (i == 0)
910  *loadmodel = *starmod;
911 
912  starmod->numleafs = bm->visleafs;
913  }
914 }
915 
916 /*
917 ==============================================================================
918 
919 ALIAS MODELS
920 
921 ==============================================================================
922 */
923 
924 /*
925 =================
926 Mod_LoadAliasModel
927 =================
928 */
930 {
931  int i, j;
932  dmdl_t *pinmodel, *pheader;
933  dstvert_t *pinst, *poutst;
934  dtriangle_t *pintri, *pouttri;
935  daliasframe_t *pinframe, *poutframe;
936  int *pincmd, *poutcmd;
937  int version;
938 
939  pinmodel = (dmdl_t *)buffer;
940 
941  version = LittleLong (pinmodel->version);
942  if (version != ALIAS_VERSION)
943  ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
944  mod->name, version, ALIAS_VERSION);
945 
946  pheader = Hunk_Alloc (LittleLong(pinmodel->ofs_end));
947 
948  // byte swap the header fields and sanity check
949  for (i=0 ; i<sizeof(dmdl_t)/4 ; i++)
950  ((int *)pheader)[i] = LittleLong (((int *)buffer)[i]);
951 
952  if (pheader->skinheight > MAX_LBM_HEIGHT)
953  ri.Sys_Error (ERR_DROP, "model %s has a skin taller than %d", mod->name,
955 
956  if (pheader->num_xyz <= 0)
957  ri.Sys_Error (ERR_DROP, "model %s has no vertices", mod->name);
958 
959  if (pheader->num_xyz > MAX_VERTS)
960  ri.Sys_Error (ERR_DROP, "model %s has too many vertices", mod->name);
961 
962  if (pheader->num_st <= 0)
963  ri.Sys_Error (ERR_DROP, "model %s has no st vertices", mod->name);
964 
965  if (pheader->num_tris <= 0)
966  ri.Sys_Error (ERR_DROP, "model %s has no triangles", mod->name);
967 
968  if (pheader->num_frames <= 0)
969  ri.Sys_Error (ERR_DROP, "model %s has no frames", mod->name);
970 
971 //
972 // load base s and t vertices (not used in gl version)
973 //
974  pinst = (dstvert_t *) ((byte *)pinmodel + pheader->ofs_st);
975  poutst = (dstvert_t *) ((byte *)pheader + pheader->ofs_st);
976 
977  for (i=0 ; i<pheader->num_st ; i++)
978  {
979  poutst[i].s = LittleShort (pinst[i].s);
980  poutst[i].t = LittleShort (pinst[i].t);
981  }
982 
983 //
984 // load triangle lists
985 //
986  pintri = (dtriangle_t *) ((byte *)pinmodel + pheader->ofs_tris);
987  pouttri = (dtriangle_t *) ((byte *)pheader + pheader->ofs_tris);
988 
989  for (i=0 ; i<pheader->num_tris ; i++)
990  {
991  for (j=0 ; j<3 ; j++)
992  {
993  pouttri[i].index_xyz[j] = LittleShort (pintri[i].index_xyz[j]);
994  pouttri[i].index_st[j] = LittleShort (pintri[i].index_st[j]);
995  }
996  }
997 
998 //
999 // load the frames
1000 //
1001  for (i=0 ; i<pheader->num_frames ; i++)
1002  {
1003  pinframe = (daliasframe_t *) ((byte *)pinmodel
1004  + pheader->ofs_frames + i * pheader->framesize);
1005  poutframe = (daliasframe_t *) ((byte *)pheader
1006  + pheader->ofs_frames + i * pheader->framesize);
1007 
1008  memcpy (poutframe->name, pinframe->name, sizeof(poutframe->name));
1009  for (j=0 ; j<3 ; j++)
1010  {
1011  poutframe->scale[j] = LittleFloat (pinframe->scale[j]);
1012  poutframe->translate[j] = LittleFloat (pinframe->translate[j]);
1013  }
1014  // verts are all 8 bit, so no swapping needed
1015  memcpy (poutframe->verts, pinframe->verts,
1016  pheader->num_xyz*sizeof(dtrivertx_t));
1017 
1018  }
1019 
1020  mod->type = mod_alias;
1021 
1022  //
1023  // load the glcmds
1024  //
1025  pincmd = (int *) ((byte *)pinmodel + pheader->ofs_glcmds);
1026  poutcmd = (int *) ((byte *)pheader + pheader->ofs_glcmds);
1027  for (i=0 ; i<pheader->num_glcmds ; i++)
1028  poutcmd[i] = LittleLong (pincmd[i]);
1029 
1030 
1031  // register all skins
1032  memcpy ((char *)pheader + pheader->ofs_skins, (char *)pinmodel + pheader->ofs_skins,
1033  pheader->num_skins*MAX_SKINNAME);
1034  for (i=0 ; i<pheader->num_skins ; i++)
1035  {
1036  mod->skins[i] = Vk_FindImage ((char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME
1037  , it_skin, NULL);
1038  }
1039 
1040  mod->mins[0] = -32;
1041  mod->mins[1] = -32;
1042  mod->mins[2] = -32;
1043  mod->maxs[0] = 32;
1044  mod->maxs[1] = 32;
1045  mod->maxs[2] = 32;
1046 }
1047 
1048 /*
1049 ==============================================================================
1050 
1051 SPRITE MODELS
1052 
1053 ==============================================================================
1054 */
1055 
1056 /*
1057 =================
1058 Mod_LoadSpriteModel
1059 =================
1060 */
1062 {
1063  dsprite_t *sprin, *sprout;
1064  int i;
1065 
1066  sprin = (dsprite_t *)buffer;
1067  sprout = Hunk_Alloc (modfilelen);
1068 
1069  sprout->ident = LittleLong (sprin->ident);
1070  sprout->version = LittleLong (sprin->version);
1071  sprout->numframes = LittleLong (sprin->numframes);
1072 
1073  if (sprout->version != SPRITE_VERSION)
1074  ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
1075  mod->name, sprout->version, SPRITE_VERSION);
1076 
1077  if (sprout->numframes > MAX_MD2SKINS)
1078  ri.Sys_Error (ERR_DROP, "%s has too many frames (%i > %i)",
1079  mod->name, sprout->numframes, MAX_MD2SKINS);
1080 
1081  // byte swap everything
1082  for (i=0 ; i<sprout->numframes ; i++)
1083  {
1084  sprout->frames[i].width = LittleLong (sprin->frames[i].width);
1085  sprout->frames[i].height = LittleLong (sprin->frames[i].height);
1086  sprout->frames[i].origin_x = LittleLong (sprin->frames[i].origin_x);
1087  sprout->frames[i].origin_y = LittleLong (sprin->frames[i].origin_y);
1088  memcpy (sprout->frames[i].name, sprin->frames[i].name, MAX_SKINNAME);
1089  mod->skins[i] = Vk_FindImage (sprout->frames[i].name,
1090  it_sprite, NULL);
1091  }
1092 
1093  mod->type = mod_sprite;
1094 }
1095 
1096 //=============================================================================
1097 
1098 /*
1099 @@@@@@@@@@@@@@@@@@@@@
1100 R_BeginRegistration
1101 
1102 Specifies the model that will be used as the world
1103 @@@@@@@@@@@@@@@@@@@@@
1104 */
1105 void R_BeginRegistration (char *model)
1106 {
1107  char fullname[MAX_QPATH];
1108  cvar_t *flushmap;
1109 
1111  r_oldviewcluster = -1; // force markleafs
1112 
1113  Com_sprintf (fullname, sizeof(fullname), "maps/%s.bsp", model);
1114 
1115  // explicitly free the old map if different
1116  // this guarantees that mod_known[0] is the world map
1117  flushmap = ri.Cvar_Get ("flushmap", "0", 0);
1118  if ( strcmp(mod_known[0].name, fullname) || flushmap->value)
1119  Mod_Free (&mod_known[0]);
1120  r_worldmodel = Mod_ForName(fullname, true);
1121 
1122  r_viewcluster = -1;
1123 }
1124 
1125 
1126 /*
1127 @@@@@@@@@@@@@@@@@@@@@
1128 R_RegisterModel
1129 
1130 @@@@@@@@@@@@@@@@@@@@@
1131 */
1133 {
1134  model_t *mod;
1135  int i;
1136  dsprite_t *sprout;
1137  dmdl_t *pheader;
1138 
1139  mod = Mod_ForName (name, false);
1140  if (mod)
1141  {
1143 
1144  // register any images used by the models
1145  if (mod->type == mod_sprite)
1146  {
1147  sprout = (dsprite_t *)mod->extradata;
1148  for (i=0 ; i<sprout->numframes ; i++)
1149  mod->skins[i] = Vk_FindImage (sprout->frames[i].name, it_sprite, NULL);
1150  }
1151  else if (mod->type == mod_alias)
1152  {
1153  pheader = (dmdl_t *)mod->extradata;
1154  for (i=0 ; i<pheader->num_skins ; i++)
1155  mod->skins[i] = Vk_FindImage ((char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME, it_skin, NULL);
1156 //PGM
1157  mod->numframes = pheader->num_frames;
1158 //PGM
1159  }
1160  else if (mod->type == mod_brush)
1161  {
1162  for (i=0 ; i<mod->numtexinfo ; i++)
1164  }
1165  }
1166  return mod;
1167 }
1168 
1169 
1170 /*
1171 @@@@@@@@@@@@@@@@@@@@@
1172 R_EndRegistration
1173 
1174 @@@@@@@@@@@@@@@@@@@@@
1175 */
1177 {
1178  int i;
1179  model_t *mod;
1180 
1181  for (i=0, mod=mod_known ; i<mod_numknown ; i++, mod++)
1182  {
1183  if (!mod->name[0])
1184  continue;
1186  { // don't need this model
1187  Mod_Free (mod);
1188  }
1189  }
1190 
1192 }
1193 
1194 
1195 //=============================================================================
1196 
1197 
1198 /*
1199 ================
1200 Mod_Free
1201 ================
1202 */
1203 void Mod_Free (model_t *mod)
1204 {
1205  Hunk_Free (mod->extradata);
1206  memset (mod, 0, sizeof(*mod));
1207 }
1208 
1209 /*
1210 ================
1211 Mod_FreeAll
1212 ================
1213 */
1214 void Mod_FreeAll (void)
1215 {
1216  int i;
1217 
1218  for (i=0 ; i<mod_numknown ; i++)
1219  {
1220  if (mod_known[i].extradatasize)
1221  Mod_Free (&mod_known[i]);
1222  }
1223 }
LUMP_VISIBILITY
#define LUMP_VISIBILITY
Definition: qfiles.h:265
MAX_MAP_LEAFS
#define MAX_MAP_LEAFS
Definition: qfiles.h:239
model_s::numvertexes
int numvertexes
Definition: r_model.h:207
it_sprite
@ it_sprite
Definition: r_local.h:65
dsprframe_t::name
char name[MAX_SKINNAME]
Definition: qfiles.h:178
cplane_s::normal
vec3_t normal
Definition: q_shared.h:415
LUMP_EDGES
#define LUMP_EDGES
Definition: qfiles.h:273
dmdl_t::ofs_glcmds
int ofs_glcmds
Definition: qfiles.h:157
cplane_s::type
byte type
Definition: q_shared.h:417
currentmodel
model_t * currentmodel
Definition: r_main.c:39
dheader_t
Definition: qfiles.h:283
RadiusFromBounds
float RadiusFromBounds(vec3_t mins, vec3_t maxs)
Definition: vk_model.c:361
msurface_s::plane
mplane_t * plane
Definition: r_model.h:100
msurface_s::styles
byte styles[MAXLIGHTMAPS]
Definition: r_model.h:115
Hunk_Begin
void * Hunk_Begin(int maxsize)
Definition: q_shwin.c:41
Mod_LoadNodes
void Mod_LoadNodes(lump_t *l)
Definition: vk_model.c:652
MAX_QPATH
#define MAX_QPATH
Definition: q_shared.h:80
mtexinfo_s::numframes
int numframes
Definition: r_model.h:89
mleaf_s::area
int area
Definition: r_model.h:155
model_s::numplanes
int numplanes
Definition: r_model.h:201
daliasframe_t::scale
float scale[3]
Definition: qfiles.h:121
vk_local.h
LittleShort
short LittleShort(short l)
Definition: q_shared.c:946
model_s::vis
dvis_t * vis
Definition: r_model.h:229
dnode_t
Definition: qfiles.h:381
R_RegisterModel
struct model_s * R_RegisterModel(char *name)
Definition: vk_model.c:1132
lump_t::filelen
int filelen
Definition: qfiles.h:259
r_notexture
image_t * r_notexture
Definition: gl_rmain.c:44
CONTENTS_WATER
#define CONTENTS_WATER
Definition: qfiles.h:338
Vk_BeginBuildingLightmaps
void Vk_BeginBuildingLightmaps(model_t *m)
Definition: vk_rsurf.c:1249
Mod_PointInLeaf
mleaf_t * Mod_PointInLeaf(vec3_t p, model_t *model)
Definition: vk_model.c:48
mvertex_t
Definition: r_model.h:45
model_s::nummodelsurfaces
int nummodelsurfaces
Definition: r_model.h:196
Mod_Init
void Mod_Init(void)
Definition: vk_model.c:163
mmodel_t::numfaces
int numfaces
Definition: gl_model.h:53
mod_numknown
int mod_numknown
Definition: vk_model.c:36
dplane_t
Definition: qfiles.h:318
Hunk_Free
void Hunk_Free(void *base)
Definition: q_shwin.c:99
ri
refimport_t ri
Definition: r_main.c:25
LUMP_MODELS
#define LUMP_MODELS
Definition: qfiles.h:275
IDSPRITEHEADER
#define IDSPRITEHEADER
Definition: qfiles.h:170
v
GLdouble v
Definition: qgl_win.c:143
it_wall
@ it_wall
Definition: r_local.h:66
mmodel_t::visleafs
int visleafs
Definition: gl_model.h:52
dmdl_t::num_tris
int num_tris
Definition: qfiles.h:149
cplane_s::signbits
byte signbits
Definition: q_shared.h:418
dsprframe_t::height
int height
Definition: qfiles.h:176
Mod_LoadVertexes
void Mod_LoadVertexes(lump_t *l)
Definition: vk_model.c:333
Vk_SubdivideSurface
void Vk_SubdivideSurface(msurface_t *fa)
Definition: vk_warp.c:164
model_s::edges
medge_t * edges
Definition: r_model.h:211
Mod_LoadAliasModel
void Mod_LoadAliasModel(model_t *mod, void *buffer)
Definition: vk_model.c:929
mtexinfo_s
Definition: r_model.h:83
refimport_t::FS_LoadFile
int(* FS_LoadFile)(char *name, void **buf)
Definition: ref.h:209
refimport_t::Cvar_Get
cvar_t *(* Cvar_Get)(char *name, char *value, int flags)
Definition: ref.h:216
qboolean
qboolean
Definition: q_shared.h:63
i
int i
Definition: q_shared.c:305
msurface_s::numedges
int numedges
Definition: r_model.h:104
model_s::firstnode
int firstnode
Definition: r_model.h:214
LUMP_LEAFS
#define LUMP_LEAFS
Definition: qfiles.h:270
Mod_Modellist_f
void Mod_Modellist_f(void)
Definition: vk_model.c:140
mnode_s::parent
struct mnode_s * parent
Definition: r_model.h:131
dstvert_t::s
short s
Definition: qfiles.h:97
MAX_MAP_SURFEDGES
#define MAX_MAP_SURFEDGES
Definition: qfiles.h:246
mnode_s
Definition: r_model.h:123
dmdl_t::skinheight
int skinheight
Definition: qfiles.h:143
buffer
GLenum GLfloat * buffer
Definition: qgl_win.c:151
model_s
Definition: r_model.h:171
glpoly_s::next
struct glpoly_s * next
Definition: gl_model.h:88
dtrivertx_t
Definition: qfiles.h:107
mleaf_s::firstmarksurface
msurface_t ** firstmarksurface
Definition: r_model.h:157
r_oldviewcluster
int r_oldviewcluster
Definition: r_local.h:791
model_s::marksurfaces
msurface_t ** marksurfaces
Definition: r_model.h:227
msurface_s::samples
byte * samples
Definition: r_model.h:116
mmodel_t
Definition: gl_model.h:46
mnode_s::children
struct mnode_s * children[2]
Definition: r_model.h:135
image_s::registration_sequence
int registration_sequence
Definition: r_local.h:77
mleaf_s::contents
int contents
Definition: r_model.h:146
SURF_WARP
#define SURF_WARP
Definition: qfiles.h:372
msurface_s::extents
short extents[2]
Definition: r_model.h:110
DVIS_PVS
#define DVIS_PVS
Definition: qfiles.h:461
cvar_s
Definition: q_shared.h:324
mod_brush
@ mod_brush
Definition: r_model.h:169
LUMP_NODES
#define LUMP_NODES
Definition: qfiles.h:266
lump_t::fileofs
int fileofs
Definition: qfiles.h:259
LUMP_LEAFFACES
#define LUMP_LEAFFACES
Definition: qfiles.h:271
mleaf_s
Definition: r_model.h:143
SURF_TRANS66
#define SURF_TRANS66
Definition: qfiles.h:374
model_s::extradata
void * extradata
Definition: r_model.h:235
Mod_LoadFaces
void Mod_LoadFaces(lump_t *l)
Definition: vk_model.c:555
dvertex_t
Definition: qfiles.h:300
refimport_t::FS_FreeFile
void(* FS_FreeFile)(void *buf)
Definition: ref.h:210
r_viewcluster
int r_viewcluster
Definition: r_main.c:108
j
GLint j
Definition: qgl_win.c:150
IDBSPHEADER
#define IDBSPHEADER
Definition: qfiles.h:219
model_s::numsubmodels
int numsubmodels
Definition: r_model.h:198
mod_known
model_t mod_known[MAX_MOD_KNOWN]
Definition: vk_model.c:35
mvertex_t::position
vec3_t position
Definition: r_model.h:47
Vk_FreeUnusedImages
void Vk_FreeUnusedImages(void)
Definition: vk_image.c:1587
dsprite_t
Definition: qfiles.h:181
model_s::numedges
int numedges
Definition: r_model.h:210
SURF_PLANEBACK
#define SURF_PLANEBACK
Definition: r_model.h:68
dtriangle_t::index_st
short index_st[3]
Definition: qfiles.h:104
model_s::registration_sequence
int registration_sequence
Definition: r_model.h:175
refimport_t::Con_Printf
void(* Con_Printf)(int print_level, char *str,...)
Definition: ref.h:202
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:751
mtexinfo_s::image
image_t * image
Definition: r_model.h:87
dmodel_t
Definition: qfiles.h:290
dmdl_t::ofs_end
int ofs_end
Definition: qfiles.h:158
model_s::numframes
int numframes
Definition: r_model.h:178
LittleFloat
float LittleFloat(float l)
Definition: q_shared.c:950
SPRITE_VERSION
#define SPRITE_VERSION
Definition: qfiles.h:172
model_s::texinfo
mtexinfo_t * texinfo
Definition: r_model.h:218
dmdl_t::ofs_frames
int ofs_frames
Definition: qfiles.h:156
dvis_t::numclusters
int numclusters
Definition: qfiles.h:465
medge_t
Definition: r_model.h:77
LittleLong
int LittleLong(int l)
Definition: q_shared.c:948
dmdl_t::num_glcmds
int num_glcmds
Definition: qfiles.h:150
model_s::type
modtype_t type
Definition: r_model.h:177
dtriangle_t::index_xyz
short index_xyz[3]
Definition: qfiles.h:103
mnode_s::minmaxs
short minmaxs[6]
Definition: r_model.h:129
Mod_LoadSubmodels
void Mod_LoadSubmodels(lump_t *l)
Definition: vk_model.c:380
dstvert_t
Definition: qfiles.h:95
Mod_SetParent
void Mod_SetParent(mnode_t *node, mnode_t *parent)
Definition: vk_model.c:638
Mod_LoadMarksurfaces
void Mod_LoadMarksurfaces(lump_t *l)
Definition: vk_model.c:754
VectorLength
vec_t VectorLength(vec3_t v)
Definition: q_shared.c:762
model_s::numsurfedges
int numsurfedges
Definition: r_model.h:223
msurface_s::texinfo
mtexinfo_t * texinfo
Definition: r_model.h:112
model_s::leafs
mleaf_t * leafs
Definition: r_model.h:205
dmdl_t::version
int version
Definition: qfiles.h:140
mmodel_t::headnode
int headnode
Definition: gl_model.h:51
t
GLdouble t
Definition: qgl_win.c:328
model_s::nodes
mnode_t * nodes
Definition: r_model.h:215
dedge_t
Definition: qfiles.h:404
model_s::mins
vec3_t mins
Definition: r_model.h:185
mleaf_s::cluster
int cluster
Definition: r_model.h:154
loadmodel
model_t * loadmodel
Definition: vk_model.c:25
dstvert_t::t
short t
Definition: qfiles.h:98
refimport_t::Sys_Error
void(* Sys_Error)(int err_level, char *str,...)
Definition: ref.h:194
dmdl_t::num_skins
int num_skins
Definition: qfiles.h:146
R_EndRegistration
void R_EndRegistration(void)
Definition: vk_model.c:1176
DotProduct
#define DotProduct(x, y)
Definition: q_shared.h:162
dmdl_t::num_xyz
int num_xyz
Definition: qfiles.h:147
SURF_TRANS33
#define SURF_TRANS33
Definition: qfiles.h:373
r_worldmodel
model_t * r_worldmodel
Definition: r_main.c:41
mmodel_t::radius
float radius
Definition: gl_model.h:50
cvar_s::value
float value
Definition: q_shared.h:331
cplane_s::dist
float dist
Definition: q_shared.h:416
model_s::lightdata
byte * lightdata
Definition: r_model.h:231
registration_sequence
int registration_sequence
Definition: vk_model.c:41
SURF_DRAWTURB
#define SURF_DRAWTURB
Definition: r_model.h:70
Vk_FindImage
image_t * Vk_FindImage(char *name, imagetype_t type, qvksampler_t *samplerType)
Definition: vk_image.c:1508
dmdl_t::framesize
int framesize
Definition: qfiles.h:144
Hunk_End
int Hunk_End(void)
Definition: q_shwin.c:81
LUMP_LIGHTING
#define LUMP_LIGHTING
Definition: qfiles.h:269
NULL
#define NULL
Definition: q_shared.h:67
dheader_t::lumps
lump_t lumps[HEADER_LUMPS]
Definition: qfiles.h:287
model_s::surfedges
int * surfedges
Definition: r_model.h:224
mleaf_s::minmaxs
short minmaxs[6]
Definition: r_model.h:149
mleaf_s::nummarksurfaces
int nummarksurfaces
Definition: r_model.h:158
daliasframe_t::translate
float translate[3]
Definition: qfiles.h:122
Mod_LoadLeafs
void Mod_LoadLeafs(lump_t *l)
Definition: vk_model.c:700
LUMP_VERTEXES
#define LUMP_VERTEXES
Definition: qfiles.h:264
MAX_MD2SKINS
#define MAX_MD2SKINS
Definition: qfiles.h:92
ERR_DROP
#define ERR_DROP
Definition: qcommon.h:744
mod_novis
byte mod_novis[MAX_MAP_LEAFS/8]
Definition: vk_model.c:32
dsprite_t::frames
dsprframe_t frames[1]
Definition: qfiles.h:185
CalcSurfaceExtents
void CalcSurfaceExtents(msurface_t *s)
Definition: vk_model.c:500
it_skin
@ it_skin
Definition: r_local.h:64
Mod_ClusterPVS
byte * Mod_ClusterPVS(int cluster, model_t *model)
Definition: vk_model.c:124
dsprframe_t::width
int width
Definition: qfiles.h:176
name
cvar_t * name
Definition: cl_main.c:79
LUMP_FACES
#define LUMP_FACES
Definition: qfiles.h:268
MAXLIGHTMAPS
#define MAXLIGHTMAPS
Definition: qfiles.h:409
Mod_DecompressVis
byte * Mod_DecompressVis(byte *in, model_t *model)
Definition: vk_model.c:79
msurface_s::flags
int flags
Definition: r_model.h:101
mod_sprite
@ mod_sprite
Definition: r_model.h:169
MAX_LBM_HEIGHT
#define MAX_LBM_HEIGHT
Definition: r_local.h:184
dvis_t::bitofs
int bitofs[8][2]
Definition: qfiles.h:466
LUMP_SURFEDGES
#define LUMP_SURFEDGES
Definition: qfiles.h:274
model_s::maxs
vec3_t maxs
Definition: r_model.h:185
s
static fixed16_t s
Definition: r_scan.c:30
model_s::radius
float radius
Definition: gl_model.h:189
Vk_CreateSurfaceLightmap
void Vk_CreateSurfaceLightmap(msurface_t *surf)
Definition: vk_rsurf.c:1212
CONTENTS_SLIME
#define CONTENTS_SLIME
Definition: qfiles.h:337
Mod_LoadVisibility
void Mod_LoadVisibility(lump_t *l)
Definition: vk_model.c:307
Mod_LoadEdges
void Mod_LoadEdges(lump_t *l)
Definition: vk_model.c:415
mtexinfo_s::next
struct mtexinfo_s * next
Definition: r_model.h:90
mmodel_t::origin
vec3_t origin
Definition: gl_model.h:49
dsprite_t::ident
int ident
Definition: qfiles.h:182
msurface_s::polys
glpoly_t * polys
Definition: gl_model.h:111
Mod_LoadBrushModel
void Mod_LoadBrushModel(model_t *mod, void *buffer)
Definition: vk_model.c:849
dheader_t::version
int version
Definition: qfiles.h:286
texinfo_s
Definition: qfiles.h:392
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:165
model_s::skins
image_t * skins[MAX_MD2SKINS]
Definition: r_model.h:234
mtexinfo_s::vecs
float vecs[2][4]
Definition: r_model.h:85
mod_base
byte * mod_base
Definition: vk_model.c:282
BSPVERSION
#define BSPVERSION
Definition: qfiles.h:222
lump_t
Definition: qfiles.h:257
MAX_VERTS
#define MAX_VERTS
Definition: qfiles.h:90
Mod_LoadTexinfo
void Mod_LoadTexinfo(lump_t *l)
Definition: vk_model.c:442
model_s::name
char name[MAX_QPATH]
Definition: r_model.h:173
model_s::numtexinfo
int numtexinfo
Definition: r_model.h:217
mnode_s::contents
int contents
Definition: r_model.h:126
mnode_s::firstsurface
unsigned short firstsurface
Definition: r_model.h:137
Mod_ForName
model_t * Mod_ForName(char *name, qboolean crash)
Definition: vk_model.c:177
dsprite_t::numframes
int numframes
Definition: qfiles.h:184
Mod_LoadSpriteModel
void Mod_LoadSpriteModel(model_t *mod, void *buffer)
Definition: vk_model.c:1061
dsprframe_t::origin_y
int origin_y
Definition: qfiles.h:177
model_s::firstmodelsurface
int firstmodelsurface
Definition: r_model.h:196
model_s::surfaces
msurface_t * surfaces
Definition: r_model.h:221
daliasframe_t
Definition: qfiles.h:119
medge_t::v
unsigned short v[2]
Definition: r_model.h:79
mnode_s::plane
mplane_t * plane
Definition: r_model.h:134
LUMP_TEXINFO
#define LUMP_TEXINFO
Definition: qfiles.h:267
dleaf_t
Definition: qfiles.h:424
dface_t
Definition: qfiles.h:410
mod_alias
@ mod_alias
Definition: r_model.h:169
R_BeginRegistration
void R_BeginRegistration(char *model)
Definition: vk_model.c:1105
CONTENTS_LAVA
#define CONTENTS_LAVA
Definition: qfiles.h:336
model_s::numleafs
int numleafs
Definition: r_model.h:204
Mod_FreeAll
void Mod_FreeAll(void)
Definition: vk_model.c:1214
mmodel_t::mins
vec3_t mins
Definition: gl_model.h:48
MAX_SKINNAME
#define MAX_SKINNAME
Definition: qfiles.h:93
daliasframe_t::name
char name[16]
Definition: qfiles.h:123
daliasframe_t::verts
dtrivertx_t verts[1]
Definition: qfiles.h:124
model_s::submodels
dmodel_t * submodels
Definition: r_model.h:199
LUMP_PLANES
#define LUMP_PLANES
Definition: qfiles.h:263
msurface_s
Definition: r_model.h:93
dmdl_t::ofs_skins
int ofs_skins
Definition: qfiles.h:153
mtexinfo_s::flags
int flags
Definition: r_model.h:88
model_s::numnodes
int numnodes
Definition: r_model.h:213
msurface_s::texturemins
short texturemins[2]
Definition: r_model.h:109
ALIAS_VERSION
#define ALIAS_VERSION
Definition: qfiles.h:87
MAX_MOD_KNOWN
#define MAX_MOD_KNOWN
Definition: vk_model.c:34
model_s::planes
mplane_t * planes
Definition: r_model.h:202
Vk_BuildPolygonFromSurface
void Vk_BuildPolygonFromSurface(msurface_t *fa)
Definition: vk_rsurf.c:1136
dsprframe_t::origin_x
int origin_x
Definition: qfiles.h:177
dsprite_t::version
int version
Definition: qfiles.h:183
dmdl_t::ofs_st
int ofs_st
Definition: qfiles.h:154
Mod_LoadSurfedges
void Mod_LoadSurfedges(lump_t *l)
Definition: vk_model.c:783
dmdl_t::num_st
int num_st
Definition: qfiles.h:148
dmdl_t::ofs_tris
int ofs_tris
Definition: qfiles.h:155
IDALIASHEADER
#define IDALIASHEADER
Definition: qfiles.h:86
cplane_s
Definition: q_shared.h:413
Mod_LoadLighting
void Mod_LoadLighting(lump_t *l)
Definition: vk_model.c:290
modfilelen
int modfilelen
Definition: vk_model.c:26
mnode_s::numsurfaces
unsigned short numsurfaces
Definition: r_model.h:138
model_s::vertexes
mvertex_t * vertexes
Definition: r_model.h:208
SURF_UNDERWATER
#define SURF_UNDERWATER
Definition: gl_model.h:66
dtriangle_t
Definition: qfiles.h:101
model_s::nummarksurfaces
int nummarksurfaces
Definition: r_model.h:226
mmodel_t::firstface
int firstface
Definition: gl_model.h:53
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:134
Hunk_Alloc
void * Hunk_Alloc(int size)
Definition: q_shwin.c:57
Com_sprintf
void Com_sprintf(char *dest, int size, char *fmt,...)
Definition: q_shared.c:1223
mmodel_t::maxs
vec3_t maxs
Definition: gl_model.h:48
dmdl_t
Definition: qfiles.h:137
Mod_LoadPlanes
void Mod_LoadPlanes(lump_t *l)
Definition: vk_model.c:811
Mod_Free
void Mod_Free(model_t *mod)
Definition: vk_model.c:1203
count
GLint GLsizei count
Definition: qgl_win.c:128
dmdl_t::num_frames
int num_frames
Definition: qfiles.h:151
msurface_s::firstedge
int firstedge
Definition: r_model.h:103
SURF_SKY
#define SURF_SKY
Definition: qfiles.h:371
Vk_EndBuildingLightmaps
void Vk_EndBuildingLightmaps(void)
Definition: vk_rsurf.c:1296
model_s::extradatasize
int extradatasize
Definition: r_model.h:236
model_s::numsurfaces
int numsurfaces
Definition: r_model.h:220
mod_inline
model_t mod_inline[MAX_MOD_KNOWN]
Definition: vk_model.c:39