Quake II RTX doxygen  1.0 dev
mesh.c
Go to the documentation of this file.
1 /*
2 Copyright (C) 2003-2006 Andrey Nazarov
3 
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18 
19 #include "gl.h"
20 
21 typedef void (*tessfunc_t)(const maliasmesh_t *);
22 
23 static int oldframenum;
24 static int newframenum;
25 static float frontlerp;
26 static float backlerp;
27 static vec3_t origin;
28 static vec3_t oldscale;
29 static vec3_t newscale;
30 static vec3_t translate;
31 static vec_t shellscale;
33 static vec4_t color;
34 
35 static const vec_t *shadelight;
36 static vec3_t shadedir;
37 
38 static float celscale;
39 
40 static GLfloat shadowmatrix[16];
41 
42 static void setup_dotshading(void)
43 {
44  float cp, cy, sp, sy;
45  vec_t yaw;
46 
47  shadelight = NULL;
48 
49  if (!gl_dotshading->integer)
50  return;
51 
52  if (glr.ent->flags & RF_SHELL_MASK)
53  return;
54 
55  shadelight = color;
56 
57  // matches the anormtab.h precalculations
58  yaw = -DEG2RAD(glr.ent->angles[YAW]);
59  cy = cos(yaw);
60  sy = sin(yaw);
61  cp = cos(-M_PI / 4);
62  sp = sin(-M_PI / 4);
63  shadedir[0] = cp * cy;
64  shadedir[1] = cp * sy;
65  shadedir[2] = -sp;
66 }
67 
68 static inline vec_t shadedot(const vec_t *normal)
69 {
70  vec_t d = DotProduct(normal, shadedir);
71 
72  // matches the anormtab.h precalculations
73  if (d < 0) {
74  d *= 0.3f;
75  }
76 
77  return d + 1;
78 }
79 
80 static inline vec_t *get_static_normal(vec_t *normal, const maliasvert_t *vert)
81 {
82  unsigned int lat = vert->norm[0];
83  unsigned int lng = vert->norm[1];
84 
85  normal[0] = TAB_SIN(lat) * TAB_COS(lng);
86  normal[1] = TAB_SIN(lat) * TAB_SIN(lng);
87  normal[2] = TAB_COS(lat);
88 
89  return normal;
90 }
91 
92 static void tess_static_shell(const maliasmesh_t *mesh)
93 {
94  maliasvert_t *src_vert = &mesh->verts[newframenum * mesh->numverts];
95  vec_t *dst_vert = tess.vertices;
96  int count = mesh->numverts;
97  vec3_t normal;
98 
99  while (count--) {
100  get_static_normal(normal, src_vert);
101 
102  dst_vert[0] = normal[0] * shellscale +
103  src_vert->pos[0] * newscale[0] + translate[0];
104  dst_vert[1] = normal[1] * shellscale +
105  src_vert->pos[1] * newscale[1] + translate[1];
106  dst_vert[2] = normal[2] * shellscale +
107  src_vert->pos[2] * newscale[2] + translate[2];
108  dst_vert += 4;
109 
110  src_vert++;
111  }
112 }
113 
114 static void tess_static_shade(const maliasmesh_t *mesh)
115 {
116  maliasvert_t *src_vert = &mesh->verts[newframenum * mesh->numverts];
117  vec_t *dst_vert = tess.vertices;
118  int count = mesh->numverts;
119  vec3_t normal;
120  vec_t d;
121 
122  while (count--) {
123  d = shadedot(get_static_normal(normal, src_vert));
124 
125  dst_vert[0] = src_vert->pos[0] * newscale[0] + translate[0];
126  dst_vert[1] = src_vert->pos[1] * newscale[1] + translate[1];
127  dst_vert[2] = src_vert->pos[2] * newscale[2] + translate[2];
128  dst_vert[4] = shadelight[0] * d;
129  dst_vert[5] = shadelight[1] * d;
130  dst_vert[6] = shadelight[2] * d;
131  dst_vert[7] = shadelight[3];
132  dst_vert += VERTEX_SIZE;
133 
134  src_vert++;
135  }
136 }
137 
138 static void tess_static_plain(const maliasmesh_t *mesh)
139 {
140  maliasvert_t *src_vert = &mesh->verts[newframenum * mesh->numverts];
141  vec_t *dst_vert = tess.vertices;
142  int count = mesh->numverts;
143 
144  while (count--) {
145  dst_vert[0] = src_vert->pos[0] * newscale[0] + translate[0];
146  dst_vert[1] = src_vert->pos[1] * newscale[1] + translate[1];
147  dst_vert[2] = src_vert->pos[2] * newscale[2] + translate[2];
148  dst_vert += 4;
149 
150  src_vert++;
151  }
152 }
153 
154 static inline vec_t *get_lerped_normal(vec_t *normal,
155  const maliasvert_t *oldvert,
156  const maliasvert_t *newvert)
157 {
158  vec3_t oldnorm, newnorm, tmp;
159  vec_t len;
160 
161  get_static_normal(oldnorm, oldvert);
162  get_static_normal(newnorm, newvert);
163 
164  LerpVector2(oldnorm, newnorm, backlerp, frontlerp, tmp);
165 
166  // normalize result
167  len = 1 / VectorLength(tmp);
168  VectorScale(tmp, len, normal);
169 
170  return normal;
171 }
172 
173 static void tess_lerped_shell(const maliasmesh_t *mesh)
174 {
175  maliasvert_t *src_oldvert = &mesh->verts[oldframenum * mesh->numverts];
176  maliasvert_t *src_newvert = &mesh->verts[newframenum * mesh->numverts];
177  vec_t *dst_vert = tess.vertices;
178  int count = mesh->numverts;
179  vec3_t normal;
180 
181  while (count--) {
182  get_lerped_normal(normal, src_oldvert, src_newvert);
183 
184  dst_vert[0] = normal[0] * shellscale +
185  src_oldvert->pos[0] * oldscale[0] +
186  src_newvert->pos[0] * newscale[0] + translate[0];
187  dst_vert[1] = normal[1] * shellscale +
188  src_oldvert->pos[1] * oldscale[1] +
189  src_newvert->pos[1] * newscale[1] + translate[1];
190  dst_vert[2] = normal[2] * shellscale +
191  src_oldvert->pos[2] * oldscale[2] +
192  src_newvert->pos[2] * newscale[2] + translate[2];
193  dst_vert += 4;
194 
195  src_oldvert++;
196  src_newvert++;
197  }
198 }
199 
200 static void tess_lerped_shade(const maliasmesh_t *mesh)
201 {
202  maliasvert_t *src_oldvert = &mesh->verts[oldframenum * mesh->numverts];
203  maliasvert_t *src_newvert = &mesh->verts[newframenum * mesh->numverts];
204  vec_t *dst_vert = tess.vertices;
205  int count = mesh->numverts;
206  vec3_t normal;
207  vec_t d;
208 
209  while (count--) {
210  d = shadedot(get_lerped_normal(normal, src_oldvert, src_newvert));
211 
212  dst_vert[0] =
213  src_oldvert->pos[0] * oldscale[0] +
214  src_newvert->pos[0] * newscale[0] + translate[0];
215  dst_vert[1] =
216  src_oldvert->pos[1] * oldscale[1] +
217  src_newvert->pos[1] * newscale[1] + translate[1];
218  dst_vert[2] =
219  src_oldvert->pos[2] * oldscale[2] +
220  src_newvert->pos[2] * newscale[2] + translate[2];
221  dst_vert[4] = shadelight[0] * d;
222  dst_vert[5] = shadelight[1] * d;
223  dst_vert[6] = shadelight[2] * d;
224  dst_vert[7] = shadelight[3];
225  dst_vert += VERTEX_SIZE;
226 
227  src_oldvert++;
228  src_newvert++;
229  }
230 }
231 
232 static void tess_lerped_plain(const maliasmesh_t *mesh)
233 {
234  maliasvert_t *src_oldvert = &mesh->verts[oldframenum * mesh->numverts];
235  maliasvert_t *src_newvert = &mesh->verts[newframenum * mesh->numverts];
236  vec_t *dst_vert = tess.vertices;
237  int count = mesh->numverts;
238 
239  while (count--) {
240  dst_vert[0] =
241  src_oldvert->pos[0] * oldscale[0] +
242  src_newvert->pos[0] * newscale[0] + translate[0];
243  dst_vert[1] =
244  src_oldvert->pos[1] * oldscale[1] +
245  src_newvert->pos[1] * newscale[1] + translate[1];
246  dst_vert[2] =
247  src_oldvert->pos[2] * oldscale[2] +
248  src_newvert->pos[2] * newscale[2] + translate[2];
249  dst_vert += 4;
250 
251  src_oldvert++;
252  src_newvert++;
253  }
254 }
255 
256 static glCullResult_t cull_static_model(model_t *model)
257 {
258  maliasframe_t *newframe = &model->frames[newframenum];
259  vec3_t bounds[2];
260  glCullResult_t cull;
261 
262  if (glr.entrotated) {
263  cull = GL_CullSphere(origin, newframe->radius);
264  if (cull == CULL_OUT) {
265  c.spheresCulled++;
266  return cull;
267  }
268  if (cull == CULL_CLIP) {
269  cull = GL_CullLocalBox(origin, newframe->bounds);
270  if (cull == CULL_OUT) {
272  return cull;
273  }
274  }
275  } else {
276  VectorAdd(newframe->bounds[0], origin, bounds[0]);
277  VectorAdd(newframe->bounds[1], origin, bounds[1]);
278  cull = GL_CullBox(bounds);
279  if (cull == CULL_OUT) {
280  c.boxesCulled++;
281  return cull;
282  }
283  }
284 
285  VectorCopy(newframe->scale, newscale);
286  VectorCopy(newframe->translate, translate);
287 
288  return cull;
289 }
290 
291 static glCullResult_t cull_lerped_model(model_t *model)
292 {
293  maliasframe_t *newframe = &model->frames[newframenum];
294  maliasframe_t *oldframe = &model->frames[oldframenum];
295  vec3_t bounds[2];
296  vec_t radius;
297  glCullResult_t cull;
298 
299  if (glr.entrotated) {
300  radius = newframe->radius > oldframe->radius ?
301  newframe->radius : oldframe->radius;
302  cull = GL_CullSphere(origin, radius);
303  if (cull == CULL_OUT) {
304  c.spheresCulled++;
305  return cull;
306  }
307  UnionBounds(newframe->bounds, oldframe->bounds, bounds);
308  if (cull == CULL_CLIP) {
309  cull = GL_CullLocalBox(origin, bounds);
310  if (cull == CULL_OUT) {
312  return cull;
313  }
314  }
315  } else {
316  UnionBounds(newframe->bounds, oldframe->bounds, bounds);
317  VectorAdd(bounds[0], origin, bounds[0]);
318  VectorAdd(bounds[1], origin, bounds[1]);
319  cull = GL_CullBox(bounds);
320  if (cull == CULL_OUT) {
321  c.boxesCulled++;
322  return cull;
323  }
324  }
325 
326  VectorScale(oldframe->scale, backlerp, oldscale);
327  VectorScale(newframe->scale, frontlerp, newscale);
328 
329  LerpVector2(oldframe->translate, newframe->translate,
331 
332  return cull;
333 }
334 
335 static void setup_color(void)
336 {
337  int flags = glr.ent->flags;
338  float f, m;
339  int i;
340 
341  memset(&glr.lightpoint, 0, sizeof(glr.lightpoint));
342 
343  if (flags & RF_SHELL_MASK) {
344  VectorClear(color);
345  if (flags & RF_SHELL_HALF_DAM) {
346  color[0] = 0.56f;
347  color[1] = 0.59f;
348  color[2] = 0.45f;
349  }
350  if (flags & RF_SHELL_DOUBLE) {
351  color[0] = 0.9f;
352  color[1] = 0.7f;
353  }
354  if (flags & RF_SHELL_RED) {
355  color[0] = 1;
356  }
357  if (flags & RF_SHELL_GREEN) {
358  color[1] = 1;
359  }
360  if (flags & RF_SHELL_BLUE) {
361  color[2] = 1;
362  }
363  } else if (flags & RF_FULLBRIGHT) {
364  VectorSet(color, 1, 1, 1);
365  } else if ((flags & RF_IR_VISIBLE) && (glr.fd.rdflags & RDF_IRGOGGLES)) {
366  VectorSet(color, 1, 0, 0);
367  } else {
369 
370  if (flags & RF_MINLIGHT) {
371  for (i = 0; i < 3; i++) {
372  if (color[i] > 0.1f) {
373  break;
374  }
375  }
376  if (i == 3) {
377  VectorSet(color, 0.1f, 0.1f, 0.1f);
378  }
379  }
380 
381  if (flags & RF_GLOW) {
382  f = 0.1f * sin(glr.fd.time * 7);
383  for (i = 0; i < 3; i++) {
384  m = color[i] * 0.8f;
385  color[i] += f;
386  if (color[i] < m)
387  color[i] = m;
388  }
389  }
390 
391  for (i = 0; i < 3; i++) {
392  clamp(color[i], 0, 1);
393  }
394  }
395 
396  if (flags & RF_TRANSLUCENT) {
397  color[3] = glr.ent->alpha;
398  } else {
399  color[3] = 1;
400  }
401 }
402 
403 static void setup_celshading(void)
404 {
405  float value = Cvar_ClampValue(gl_celshading, 0, 10);
406  vec3_t dir;
407 
408  celscale = 0;
409 
410  if (value == 0)
411  return;
412 
413  if (glr.ent->flags & (RF_TRANSLUCENT | RF_SHELL_MASK))
414  return;
415 
416  VectorSubtract(origin, glr.fd.vieworg, dir);
417  celscale = 1.0f - VectorLength(dir) / 700.0f;
418 }
419 
420 static void draw_celshading(maliasmesh_t *mesh)
421 {
422  if (celscale < 0.01f || celscale > 1)
423  return;
424 
428 
430  qglPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
431  qglCullFace(GL_FRONT);
432  qglColor4f(0, 0, 0, color[3] * celscale);
433  qglDrawElements(GL_TRIANGLES, mesh->numindices, QGL_INDEX_ENUM,
434  mesh->indices);
435  qglCullFace(GL_BACK);
436  qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
437  qglLineWidth(1);
438 }
439 
440 static void setup_shadow(void)
441 {
442  GLfloat matrix[16], tmp[16];
443  cplane_t *plane;
444  vec3_t dir;
445 
446  shadowmatrix[15] = 0;
447 
448  if (!gl_shadows->integer)
449  return;
450 
451  if (glr.ent->flags & (RF_WEAPONMODEL | RF_NOSHADOW))
452  return;
453 
454  if (!glr.lightpoint.surf)
455  return;
456 
457  // position fake light source straight over the model
458  if (glr.lightpoint.surf->drawflags & DSURF_PLANEBACK)
459  VectorSet(dir, 0, 0, -1);
460  else
461  VectorSet(dir, 0, 0, 1);
462 
463  // project shadow on ground plane
464  plane = &glr.lightpoint.plane;
465 
466  matrix[0] = plane->normal[1] * dir[1] + plane->normal[2] * dir[2];
467  matrix[4] = -plane->normal[1] * dir[0];
468  matrix[8] = -plane->normal[2] * dir[0];
469  matrix[12] = plane->dist * dir[0];
470 
471  matrix[1] = -plane->normal[0] * dir[1];
472  matrix[5] = plane->normal[0] * dir[0] + plane->normal[2] * dir[2];
473  matrix[9] = -plane->normal[2] * dir[1];
474  matrix[13] = plane->dist * dir[1];
475 
476  matrix[2] = -plane->normal[0] * dir[2];
477  matrix[6] = -plane->normal[1] * dir[2];
478  matrix[10] = plane->normal[0] * dir[0] + plane->normal[1] * dir[1];
479  matrix[14] = plane->dist * dir[2];
480 
481  matrix[3] = 0;
482  matrix[7] = 0;
483  matrix[11] = 0;
484  matrix[15] = DotProduct(plane->normal, dir);
485 
486  GL_MultMatrix(tmp, glr.viewmatrix, matrix);
487 
488  // rotate for entity
489  matrix[0] = glr.entaxis[0][0];
490  matrix[4] = glr.entaxis[1][0];
491  matrix[8] = glr.entaxis[2][0];
492  matrix[12] = origin[0];
493 
494  matrix[1] = glr.entaxis[0][1];
495  matrix[5] = glr.entaxis[1][1];
496  matrix[9] = glr.entaxis[2][1];
497  matrix[13] = origin[1];
498 
499  matrix[2] = glr.entaxis[0][2];
500  matrix[6] = glr.entaxis[1][2];
501  matrix[10] = glr.entaxis[2][2];
502  matrix[14] = origin[2];
503 
504  matrix[3] = 0;
505  matrix[7] = 0;
506  matrix[11] = 0;
507  matrix[15] = 1;
508 
509  GL_MultMatrix(shadowmatrix, tmp, matrix);
510 }
511 
512 static void draw_shadow(maliasmesh_t *mesh)
513 {
514  if (shadowmatrix[15] < 0.5f)
515  return;
516 
517  // load shadow projection matrix
519 
520  // eliminate z-fighting by utilizing stencil buffer, if available
521  if (gl_config.stencilbits) {
522  qglEnable(GL_STENCIL_TEST);
523  qglStencilFunc(GL_EQUAL, 0, 0xff);
524  qglStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
525  }
526 
530 
531  qglEnable(GL_POLYGON_OFFSET_FILL);
532  qglPolygonOffset(-1.0f, -2.0f);
533  qglColor4f(0, 0, 0, color[3] * 0.5f);
534  qglDrawElements(GL_TRIANGLES, mesh->numindices, QGL_INDEX_ENUM,
535  mesh->indices);
536  qglDisable(GL_POLYGON_OFFSET_FILL);
537 
538  // once we have drawn something to stencil buffer, continue to clear it for
539  // the lifetime of OpenGL context. leaving stencil buffer "dirty" and
540  // clearing just depth is slower (verified for Nvidia and ATI drivers).
541  if (gl_config.stencilbits) {
542  qglDisable(GL_STENCIL_TEST);
543  gl_static.stencil_buffer_bit |= GL_STENCIL_BUFFER_BIT;
544  }
545 }
546 
547 static int texnum_for_mesh(maliasmesh_t *mesh)
548 {
549  entity_t *ent = glr.ent;
550 
551  if (ent->flags & RF_SHELL_MASK)
552  return TEXNUM_WHITE;
553 
554  if (ent->skin)
555  return IMG_ForHandle(ent->skin)->texnum;
556 
557  if (!mesh->numskins)
558  return TEXNUM_DEFAULT;
559 
560  if (ent->skinnum < 0 || ent->skinnum >= mesh->numskins) {
561  Com_DPrintf("%s: no such skin: %d\n", "GL_DrawAliasModel", ent->skinnum);
562  return mesh->skins[0]->texnum;
563  }
564 
565  if (mesh->skins[ent->skinnum]->texnum == TEXNUM_DEFAULT)
566  return mesh->skins[0]->texnum;
567 
568  return mesh->skins[ent->skinnum]->texnum;
569 }
570 
571 static void draw_alias_mesh(maliasmesh_t *mesh)
572 {
573  glStateBits_t state = GLS_DEFAULT;
574 
575  // fall back to entity matrix
577 
578  if (shadelight)
579  state |= GLS_SHADE_SMOOTH;
580 
581  if (glr.ent->flags & RF_TRANSLUCENT)
583 
584  GL_StateBits(state);
585 
587 
588  (*tessfunc)(mesh);
589  c.trisDrawn += mesh->numtris;
590 
591  if (shadelight) {
595  } else {
599  }
600 
601  GL_TexCoordPointer(2, 0, (GLfloat *)mesh->tcoords);
602 
603  GL_LockArrays(mesh->numverts);
604 
605  qglDrawElements(GL_TRIANGLES, mesh->numindices, QGL_INDEX_ENUM,
606  mesh->indices);
607 
608  draw_celshading(mesh);
609 
610  if (gl_showtris->integer) {
612  qglDrawElements(GL_TRIANGLES, mesh->numindices, QGL_INDEX_ENUM,
613  mesh->indices);
615  }
616 
617  // FIXME: unlock arrays before changing matrix?
618  draw_shadow(mesh);
619 
620  GL_UnlockArrays();
621 }
622 
623 void GL_DrawAliasModel(model_t *model)
624 {
625  entity_t *ent = glr.ent;
626  glCullResult_t cull;
627  int i;
628 
629  newframenum = ent->frame;
630  if (newframenum < 0 || newframenum >= model->numframes) {
631  Com_DPrintf("%s: no such frame %d\n", __func__, newframenum);
632  newframenum = 0;
633  }
634 
635  oldframenum = ent->oldframe;
636  if (oldframenum < 0 || oldframenum >= model->numframes) {
637  Com_DPrintf("%s: no such oldframe %d\n", __func__, oldframenum);
638  oldframenum = 0;
639  }
640 
641  backlerp = ent->backlerp;
642  frontlerp = 1.0f - backlerp;
643 
644  // optimized case
645  if (backlerp == 0)
647 
648  // interpolate origin, if necessarry
649  if (ent->flags & RF_FRAMELERP)
650  LerpVector2(ent->oldorigin, ent->origin,
652  else
653  VectorCopy(ent->origin, origin);
654 
655  // cull the model, setup scale and translate vectors
656  if (newframenum == oldframenum)
657  cull = cull_static_model(model);
658  else
659  cull = cull_lerped_model(model);
660  if (cull == CULL_OUT)
661  return;
662 
663  // setup parameters common for all meshes
664  setup_color();
667  setup_shadow();
668 
669  // select proper tessfunc
670  if (ent->flags & RF_SHELL_MASK) {
671  shellscale = (ent->flags & RF_WEAPONMODEL) ?
672  WEAPONSHELL_SCALE : POWERSUIT_SCALE;
675  } else if (shadelight) {
678  } else {
681  }
682 
683  float scale = 1.f;
684  if (ent->scale > 0.f)
685  scale = ent->scale;
686 
687  GL_RotateForEntity(origin, scale);
688 
689  if ((ent->flags & (RF_WEAPONMODEL | RF_LEFTHAND)) ==
690  (RF_WEAPONMODEL | RF_LEFTHAND)) {
691  qglMatrixMode(GL_PROJECTION);
692  qglScalef(-1, 1, 1);
693  qglMatrixMode(GL_MODELVIEW);
694  qglFrontFace(GL_CCW);
695  }
696 
697  if (ent->flags & RF_DEPTHHACK)
698  qglDepthRange(0, 0.25f);
699 
700  // draw all the meshes
701  for (i = 0; i < model->nummeshes; i++)
702  draw_alias_mesh(&model->meshes[i]);
703 
704  if (ent->flags & RF_DEPTHHACK)
705  qglDepthRange(0, 1);
706 
707  if ((ent->flags & (RF_WEAPONMODEL | RF_LEFTHAND)) ==
708  (RF_WEAPONMODEL | RF_LEFTHAND)) {
709  qglMatrixMode(GL_PROJECTION);
710  qglScalef(-1, 1, 1);
711  qglMatrixMode(GL_MODELVIEW);
712  qglFrontFace(GL_CW);
713  }
714 }
715 
shadowmatrix
static GLfloat shadowmatrix[16]
Definition: mesh.c:40
qglPolygonMode
#define qglPolygonMode
Definition: fixed.h:92
GLS_SHADE_SMOOTH
@ GLS_SHADE_SMOOTH
Definition: gl.h:294
maliasmesh_s
Definition: gl.h:232
translate
static vec3_t translate
Definition: mesh.c:30
maliasmesh_s::numindices
int numindices
Definition: gl.h:235
gl_celshading
cvar_t * gl_celshading
Definition: main.c:39
masliasvert_s::norm
byte norm[2]
Definition: gl.h:222
gl_showtris
cvar_t * gl_showtris
Definition: main.c:61
gl_dotshading
cvar_t * gl_dotshading
Definition: main.c:40
newframenum
static int newframenum
Definition: mesh.c:24
tessfunc
static tessfunc_t tessfunc
Definition: mesh.c:32
draw_alias_mesh
static void draw_alias_mesh(maliasmesh_t *mesh)
Definition: mesh.c:571
maliasmesh_s::tcoords
maliastc_t * tcoords
Definition: gl.h:238
maliasframe_s::scale
vec3_t scale
Definition: gl.h:226
GL_ColorFloatPointer
static void GL_ColorFloatPointer(GLint size, GLsizei stride, const GLfloat *pointer)
Definition: gl.h:356
texnum_for_mesh
static int texnum_for_mesh(maliasmesh_t *mesh)
Definition: mesh.c:547
get_static_normal
static vec_t * get_static_normal(vec_t *normal, const maliasvert_t *vert)
Definition: mesh.c:80
qglMatrixMode
#define qglMatrixMode
Definition: fixed.h:84
tess_static_shade
static void tess_static_shade(const maliasmesh_t *mesh)
Definition: mesh.c:114
qglCullFace
#define qglCullFace
Definition: fixed.h:49
qglDepthRange
#define qglDepthRange
Definition: fixed.h:53
glRefdef_t::entrotated
qboolean entrotated
Definition: gl.h:93
setup_color
static void setup_color(void)
Definition: mesh.c:335
statCounters_t::trisDrawn
int trisDrawn
Definition: gl.h:142
qglColor4f
#define qglColor4f
Definition: fixed.h:43
cull_static_model
static glCullResult_t cull_static_model(model_t *model)
Definition: mesh.c:256
GL_BindTexture
void GL_BindTexture(GLuint tmu, GLuint texnum)
Definition: state.c:40
GL_CullSphere
glCullResult_t GL_CullSphere(const vec3_t origin, float radius)
Definition: main.c:145
GLS_BLEND_BLEND
@ GLS_BLEND_BLEND
Definition: gl.h:285
maliasmesh_s::indices
QGL_INDEX_TYPE * indices
Definition: gl.h:236
backlerp
static float backlerp
Definition: mesh.c:26
GL_LockArrays
static void GL_LockArrays(GLsizei count)
Definition: gl.h:361
statCounters_t::boxesCulled
int boxesCulled
Definition: gl.h:146
GLA_VERTEX
@ GLA_VERTEX
Definition: gl.h:301
TAB_COS
#define TAB_COS(x)
Definition: gl.h:55
GL_UnlockArrays
static void GL_UnlockArrays(void)
Definition: gl.h:368
maliasmesh_s::verts
maliasvert_t * verts
Definition: gl.h:237
masliasvert_s::pos
short pos[3]
Definition: gl.h:221
glStatic_t::stencil_buffer_bit
GLbitfield stencil_buffer_bit
Definition: gl.h:70
GL_MultMatrix
void GL_MultMatrix(GLfloat *out, const GLfloat *a, const GLfloat *b)
Definition: main.c:290
gl_config
glConfig_t gl_config
Definition: main.c:29
setup_shadow
static void setup_shadow(void)
Definition: mesh.c:440
maliasframe_s::translate
vec3_t translate
Definition: gl.h:227
maliasmesh_s::numverts
int numverts
Definition: gl.h:233
maliasmesh_s::skins
image_t * skins[MAX_ALIAS_SKINS]
Definition: gl.h:239
qglStencilFunc
#define qglStencilFunc
Definition: fixed.h:101
shadedir
static vec3_t shadedir
Definition: mesh.c:36
VERTEX_SIZE
#define VERTEX_SIZE
Definition: gl.h:245
TEXNUM_BLACK
#define TEXNUM_BLACK
Definition: gl.h:444
TAB_SIN
#define TAB_SIN(x)
Definition: gl.h:54
GL_ArrayBits
void GL_ArrayBits(glArrayBits_t bits)
Definition: state.c:185
shellscale
static vec_t shellscale
Definition: mesh.c:31
maliasframe_s::bounds
vec3_t bounds[2]
Definition: gl.h:228
GL_RotateForEntity
void GL_RotateForEntity(vec3_t origin, float scale)
Definition: main.c:305
tess_lerped_plain
static void tess_lerped_plain(const maliasmesh_t *mesh)
Definition: mesh.c:232
TEXNUM_DEFAULT
#define TEXNUM_DEFAULT
Definition: gl.h:439
draw_shadow
static void draw_shadow(maliasmesh_t *mesh)
Definition: mesh.c:512
maliasframe_s::radius
vec_t radius
Definition: gl.h:229
tess_lerped_shell
static void tess_lerped_shell(const maliasmesh_t *mesh)
Definition: mesh.c:173
GL_LightPoint
void GL_LightPoint(vec3_t origin, vec3_t color)
Definition: world.c:233
Cvar_ClampValue
float Cvar_ClampValue(cvar_t *var, float min, float max)
Definition: cvar.c:571
UnionBounds
void UnionBounds(vec3_t a[2], vec3_t b[2], vec3_t c[2])
Definition: shared.c:111
shadedot
static vec_t shadedot(const vec_t *normal)
Definition: mesh.c:68
glRefdef_t::entmatrix
GLfloat entmatrix[16]
Definition: gl.h:95
glStateBits_t
glStateBits_t
Definition: gl.h:281
oldscale
static vec3_t oldscale
Definition: mesh.c:28
setup_dotshading
static void setup_dotshading(void)
Definition: mesh.c:42
m
static struct mdfour * m
Definition: mdfour.c:32
tess_static_plain
static void tess_static_plain(const maliasmesh_t *mesh)
Definition: mesh.c:138
GL_TexCoordPointer
static void GL_TexCoordPointer(GLint size, GLsizei stride, const GLfloat *pointer)
Definition: gl.h:339
origin
static vec3_t origin
Definition: mesh.c:27
GL_CullLocalBox
glCullResult_t GL_CullLocalBox(const vec3_t origin, vec3_t bounds[2])
Definition: main.c:185
qglDisable
#define qglDisable
Definition: fixed.h:54
qglFrontFace
#define qglFrontFace
Definition: fixed.h:64
GL_DisableOutlines
void GL_DisableOutlines(void)
Definition: state.c:471
glRefdef_t::viewmatrix
GLfloat viewmatrix[16]
Definition: gl.h:83
void
void(APIENTRY *qwglDrawBuffer)(GLenum mode)
glRefdef_t::lightpoint
lightpoint_t lightpoint
Definition: gl.h:96
qglScalef
#define qglScalef
Definition: fixed.h:98
qglColor4fv
#define qglColor4fv
Definition: fixed.h:44
GLS_DEFAULT
@ GLS_DEFAULT
Definition: gl.h:282
QGL_INDEX_ENUM
#define QGL_INDEX_ENUM
Definition: gl.h:49
qglDrawElements
#define qglDrawElements
Definition: fixed.h:57
tessfunc_t
void(* tessfunc_t)(const maliasmesh_t *)
Definition: mesh.c:21
gl_static
glStatic_t gl_static
Definition: main.c:28
GLA_TC
@ GLA_TC
Definition: gl.h:302
c
statCounters_t c
Definition: main.c:30
celscale
static float celscale
Definition: mesh.c:38
draw_celshading
static void draw_celshading(maliasmesh_t *mesh)
Definition: mesh.c:420
glr
glRefdef_t glr
Definition: main.c:27
setup_celshading
static void setup_celshading(void)
Definition: mesh.c:403
qglStencilOp
#define qglStencilOp
Definition: fixed.h:103
TEXNUM_WHITE
#define TEXNUM_WHITE
Definition: gl.h:443
GL_VertexPointer
static void GL_VertexPointer(GLint size, GLsizei stride, const GLfloat *pointer)
Definition: gl.h:334
masliasvert_s
Definition: gl.h:220
tess
tesselator_t tess
Definition: tess.c:21
frontlerp
static float frontlerp
Definition: mesh.c:25
GL_LoadMatrix
static void GL_LoadMatrix(const GLfloat *matrix)
Definition: gl.h:375
GLA_COLOR
@ GLA_COLOR
Definition: gl.h:304
qglLineWidth
#define qglLineWidth
Definition: fixed.h:78
maliasmesh_s::numtris
int numtris
Definition: gl.h:234
cull_lerped_model
static glCullResult_t cull_lerped_model(model_t *model)
Definition: mesh.c:291
newscale
static vec3_t newscale
Definition: mesh.c:29
shadelight
static const vec_t * shadelight
Definition: mesh.c:35
gl_shadows
cvar_t * gl_shadows
Definition: main.c:41
gl.h
statCounters_t::rotatedBoxesCulled
int rotatedBoxesCulled
Definition: gl.h:148
color
static vec4_t color
Definition: mesh.c:33
IMG_ForHandle
image_t * IMG_ForHandle(qhandle_t h)
Definition: images.c:1156
get_lerped_normal
static vec_t * get_lerped_normal(vec_t *normal, const maliasvert_t *oldvert, const maliasvert_t *newvert)
Definition: mesh.c:154
statCounters_t::spheresCulled
int spheresCulled
Definition: gl.h:147
glRefdef_t::entaxis
vec3_t entaxis[3]
Definition: gl.h:94
GL_DrawAliasModel
void GL_DrawAliasModel(model_t *model)
Definition: mesh.c:623
oldframenum
static int oldframenum
Definition: mesh.c:23
GL_CullBox
glCullResult_t GL_CullBox(vec3_t bounds[2])
Definition: main.c:122
glCullResult_t
glCullResult_t
Definition: gl.h:190
tesselator_t::vertices
GLfloat vertices[VERTEX_SIZE *TESS_MAX_VERTICES]
Definition: gl.h:463
qglPolygonOffset
#define qglPolygonOffset
Definition: fixed.h:93
GLS_DEPTHMASK_FALSE
@ GLS_DEPTHMASK_FALSE
Definition: gl.h:283
GL_EnableOutlines
void GL_EnableOutlines(void)
Definition: state.c:460
GL_StateBits
void GL_StateBits(glStateBits_t bits)
Definition: state.c:60
CULL_CLIP
@ CULL_CLIP
Definition: gl.h:193
tess_lerped_shade
static void tess_lerped_shade(const maliasmesh_t *mesh)
Definition: mesh.c:200
maliasframe_s
Definition: gl.h:225
glConfig_t::stencilbits
int stencilbits
Definition: gl.h:115
tess_static_shell
static void tess_static_shell(const maliasmesh_t *mesh)
Definition: mesh.c:92
glRefdef_t::ent
entity_t * ent
Definition: gl.h:92
maliasmesh_s::numskins
int numskins
Definition: gl.h:240
CULL_OUT
@ CULL_OUT
Definition: gl.h:191
glRefdef_t::fd
refdef_t fd
Definition: gl.h:81
qglEnable
#define qglEnable
Definition: fixed.h:58