UFO: Alien Invasion
Loading...
Searching...
No Matches
r_mesh.cpp
Go to the documentation of this file.
1
5
6/*
7All original material Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9Copyright (C) 1997-2001 Id Software, Inc.
10
11This program is free software; you can redistribute it and/or
12modify it under the terms of the GNU General Public License
13as published by the Free Software Foundation; either version 2
14of the License, or (at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20See the GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License
23along with this program; if not, write to the Free Software
24Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26*/
27
28#include "r_local.h"
29#include "r_lightmap.h"
30#include "r_light.h"
31#include "r_mesh.h"
32#include "r_mesh_anim.h"
33#include "r_error.h"
34#include "r_draw.h"
36
37static const float MESH_SHADOW_MAX_DISTANCE = 512.0;
38static const float MESH_SHADOW_ALPHA = 0.3;
39
41{
42 /* translate and rotate */
43 glTranslatef(mi->origin[0], mi->origin[1], mi->origin[2]);
44
45 glRotatef(mi->angles[0], 0, 0, 1);
46 glRotatef(mi->angles[1], 0, 1, 0);
47 glRotatef(mi->angles[2], 1, 0, 0);
48
49 /* scale by parameters */
50 if (mi->scale)
51 glScalef(mi->scale[0], mi->scale[1], mi->scale[2]);
52 if (mi->center)
53 glTranslatef(mi->center[0], mi->center[1], mi->center[2]);
54}
55
61static void R_DrawMeshModelShell (const mAliasMesh_t* mesh, const vec4_t color)
62{
63 /* check whether rgb is set */
64 if (!VectorNotEmpty(color))
65 return;
66
67 R_Color(color);
68
70
71 R_EnableShell(true);
72
73 glDrawArrays(GL_TRIANGLES, 0, mesh->num_tris * 3);
74
75 refdef.batchCount++;
76
77 R_EnableShell(false);
78
79 R_Color(nullptr);
80}
81
86static void R_DrawAliasFrameLerp (mAliasModel_t* mod, mAliasMesh_t* mesh, float backlerp, int framenum, int oldframenum, const vec4_t shellColor)
87{
88 R_FillArrayData(mod, mesh, backlerp, framenum, oldframenum, false);
89
90 R_EnableAnimation(mesh, backlerp, true);
91
92 glDrawArrays(GL_TRIANGLES, 0, mesh->num_tris * 3);
93
94 refdef.batchCount++;
95
96 R_DrawMeshModelShell(mesh, shellColor);
97
98 R_EnableAnimation(nullptr, 0.0, false);
99
100 R_CheckError();
101}
102
107static void R_DrawAliasStatic (const mAliasMesh_t* mesh, const vec4_t shellColor)
108{
109 R_BindArray(GL_VERTEX_ARRAY, GL_FLOAT, mesh->verts);
110 R_BindArray(GL_NORMAL_ARRAY, GL_FLOAT, mesh->normals);
111 if (r_state.active_normalmap || r_state.dynamic_lighting_enabled)
112 R_BindArray(GL_TANGENT_ARRAY, GL_FLOAT, mesh->tangents);
113 R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, mesh->texcoords);
114
115 glDrawArrays(GL_TRIANGLES, 0, mesh->num_tris * 3);
116
117 refdef.batchCount++;
118
119 R_DrawMeshModelShell(mesh, shellColor);
120}
121
123{
124 R_BindDefaultArray(GL_VERTEX_ARRAY);
125 R_BindDefaultArray(GL_NORMAL_ARRAY);
126 if (r_state.active_normalmap || r_state.dynamic_lighting_enabled)
128 R_BindDefaultArray(GL_TEXTURE_COORD_ARRAY);
129}
130
131static void R_DrawAliasStaticWithReset (const mAliasMesh_t* mesh, const vec4_t shellColor)
132{
133 R_DrawAliasStatic(mesh, shellColor);
135}
136
143static void R_ComputeGLMatrixFromTag (float* glMatrix, const mAliasTagOrientation_t* orient)
144{
145 glMatrix[0] = orient->axis[0][0];
146 glMatrix[4] = orient->axis[1][0];
147 glMatrix[8] = orient->axis[2][0];
148 glMatrix[12] = orient->origin[0];
149
150 glMatrix[1] = orient->axis[0][1];
151 glMatrix[5] = orient->axis[1][1];
152 glMatrix[9] = orient->axis[2][1];
153 glMatrix[13] = orient->origin[1];
154
155 glMatrix[2] = orient->axis[0][2];
156 glMatrix[6] = orient->axis[1][2];
157 glMatrix[10] = orient->axis[2][2];
158 glMatrix[14] = orient->origin[2];
159
160 glMatrix[3] = 0;
161 glMatrix[7] = 0;
162 glMatrix[11] = 0;
163 glMatrix[15] = 1;
164}
165
166#define R_GetTagOrientByFrame(mod, tagIndex, frame) &(((mod)->alias.tags)[tagIndex].orient[frame])
167
168void R_GetTags (const model_t* mod, const char* tagName, int currentFrame, int oldFrame, const mAliasTagOrientation_t** current, const mAliasTagOrientation_t** old)
169{
170 const int index = R_GetTagIndexByName(mod, tagName);
171 if (index == -1) {
172 *current = nullptr;
173 *old = nullptr;
174 Com_Printf("Could not get tags for tag %s of model %s\n", tagName, mod->name);
175 return;
176 }
177 *current = R_GetTagOrientByFrame(mod, index, currentFrame);
178 *old = R_GetTagOrientByFrame(mod, index, oldFrame);
179}
180
189bool R_GetTagMatrix (const model_t* mod, const char* tagName, int frame, float matrix[16])
190{
191 const int index = R_GetTagIndexByName(mod, tagName);
193
194 if (index == -1) {
195 Com_Printf("Could not get tag matrix for tag %s of model %s\n", tagName, mod->name);
196 return false;
197 }
198
199 orient = R_GetTagOrientByFrame(mod, index, frame);
200 R_ComputeGLMatrixFromTag(matrix, orient);
201 return true;
202}
203
212void R_InterpolateTransform (float backLerp, int numframes, const mAliasTagOrientation_t* current, const mAliasTagOrientation_t* old, float* interpolated)
213{
214 /* right on a frame? */
215 if (backLerp == 0.0) {
216 R_ComputeGLMatrixFromTag(interpolated, current);
217 return;
218 }
219 if (backLerp == 1.0) {
220 R_ComputeGLMatrixFromTag(interpolated, old);
221 return;
222 }
223
225 const float frontLerp = 1.0 - backLerp;
226
227 /* interpolate */
228 for (int i = 0; i < 3; i++) {
229 tag.origin[i] = old->origin[i] * backLerp + current->origin[i] * frontLerp;
230 tag.axis[0][i] = old->axis[0][i] * backLerp + current->axis[0][i] * frontLerp;
231 tag.axis[1][i] = old->axis[1][i] * backLerp + current->axis[1][i] * frontLerp;
232 tag.axis[2][i] = old->axis[2][i] * backLerp + current->axis[2][i] * frontLerp;
233 }
237
238 R_ComputeGLMatrixFromTag(interpolated, &tag);
239}
240
247int R_GetTagIndexByName (const model_t* mod, const char* tagName)
248{
249 if (!mod)
250 return -1;
251
252 if (mod->alias.num_tags == 0)
253 return -1;
254
255 assert(tagName);
256
257 /* find the right tag in the first frame - the index is the same in every other frame */
258 for (int i = 0; i < mod->alias.num_tags; i++) {
259 const mAliasTag_t* tag = &mod->alias.tags[i];
260 if (Q_streq(tag->name, tagName)) {
261 return i;
262 }
263 }
264
265 return -1;
266}
267
278void R_ModelAutoScale (const vec2_t boxSize, modelInfo_t* mi, vec3_t scale, vec3_t center)
279{
280 const float width = mi->model->modBox.getWidthX();
281 const float height = mi->model->modBox.getWidthZ();
282 const float factorX = boxSize[0] / width;
283 const float factorY = boxSize[1] / height;
284 const float size = std::min(factorX, factorY);
285
286 /* get center */
287 mi->model->modBox.getCenter(center);
288 VectorNegate(center, center);
290
291 mi->center = center;
292 mi->scale = scale;
293}
294
306void R_DrawModelDirect (modelInfo_t* mi, modelInfo_t* pmi, const char* tagname)
307{
308 image_t* skin;
309 mAliasMesh_t* mesh;
310
311 if (Q_strnull(mi->name))
312 return;
313
314 /* register the model */
315 mi->model = R_FindModel(mi->name);
316
317 /* check if the model exists */
318 if (!mi->model) {
319 Com_Printf("No model found for '%s'\n", mi->name);
320 return;
321 }
322
323 /* not yet fully loaded, so skip the rendering */
324 if (!mi->model->loaded)
325 return;
326
327 skin = R_AliasModelState(mi->model, &mi->mesh, &mi->frame, &mi->oldframe, &mi->skin);
328 if (skin == nullptr) {
329 Com_Printf("Model '%s' is broken\n", mi->name);
330 return;
331 }
332
333 glPushMatrix();
334 glScalef(viddef.rx, viddef.ry, (viddef.rx + viddef.ry) / 2);
335
336 R_Color(mi->color);
337
338 if (pmi) {
339 /* register the parent model */
340 pmi->model = R_FindModel(pmi->name);
341
342 /* transform - the next transform for the child model will be relative from the
343 * parent model location now */
345
346 /* tag transformation */
347 if (tagname) {
348 const mAliasTagOrientation_t* current = nullptr;
349 const mAliasTagOrientation_t* old = nullptr;
350 R_GetTags(pmi->model, tagname, pmi->frame, pmi->oldframe, &current, &old);
351 if (current != nullptr && old != nullptr) {
352 float interpolated[16];
353
354 /* do interpolation */
355 R_InterpolateTransform(pmi->backlerp, pmi->model->alias.num_frames, current, old, interpolated);
356
357 /* transform */
358 glMultMatrixf(interpolated);
359 R_CheckError();
360 }
361 }
362 }
363
364 /* transform */
366
367 /* we have to reenable this here - we are in 2d mode here already */
368 glEnable(GL_DEPTH_TEST);
369
370 /* draw it */
371 R_BindTexture(skin->texnum);
372
373 /* draw the model */
374 mesh = &mi->model->alias.meshes[0];
375 refdef.aliasCount += mesh->num_tris;
376 if (mi->model->alias.num_frames == 1)
378 else
380
381 /* show model bounding box */
382 if (r_showbox->integer)
384
385 glDisable(GL_DEPTH_TEST);
386
387 glPopMatrix();
388
389 R_Color(nullptr);
390}
391
398{
399 image_t* skin;
400 mAliasMesh_t* mesh;
401
402 /* check if the model exists */
403 if (!mi->model || !mi->model->loaded)
404 return;
405
406 skin = R_AliasModelState(mi->model, &mi->mesh, &mi->frame, &mi->oldframe, &mi->skin);
407 if (skin == nullptr) {
408 Com_Printf("Model '%s' is broken\n", mi->name);
409 return;
410 }
411
412 R_Color(mi->color);
413
414 glPushMatrix();
415
416 glTranslatef(mi->origin[0], mi->origin[1], mi->origin[2]);
417 glRotatef(mi->angles[YAW], 0, 0, 1);
418 glRotatef(mi->angles[PITCH], 0, 1, 0);
419 glRotatef(-mi->angles[ROLL], 1, 0, 0);
420
421 /* draw it */
422 R_BindTexture(skin->texnum);
423
424 /* draw the model */
425 mesh = &mi->model->alias.meshes[0];
426 refdef.aliasCount += mesh->num_tris;
427 if (mi->model->alias.num_frames == 1)
429 else
431
432 /* show model bounding box */
433 if (r_showbox->integer)
435
436 glPopMatrix();
437
438 R_Color(nullptr);
439}
440
447{
448 int i;
449 uint32_t aggregatemask;
450 vec3_t mins, maxs, origin, angles;
451 vec3_t vectors[3];
452 vec4_t bbox[8];
453
454 /* this is an approximation of the origin of the tagged model - we are
455 * using the origin of the parent entity to check the culling for the model
456 * that is placed relative to the tag */
457 if (e->tagent) {
458 VectorCopy(e->tagent->origin, origin);
459 VectorCopy(e->tagent->angles, angles);
460 } else {
462 VectorCopy(e->angles, angles);
463 }
464
465 /* determine scaled mins/maxs */
466 for (i = 0; i < 3; i++) {
467 if (e->scale[i]) {
468 mins[i] = e->model->modBox.mins[i] * e->scale[i];
469 maxs[i] = e->model->modBox.maxs[i] * e->scale[i];
470 } else {
471 mins[i] = e->model->modBox.mins[i];
472 maxs[i] = e->model->modBox.maxs[i];
473 }
474 }
475
476 /* rotate the bounding box */
477 angles[YAW] = -angles[YAW];
478 AngleVectors(angles, vectors[0], vectors[1], vectors[2]);
479
480 /* compute translated and rotate bounding box */
481 for (i = 0; i < 8; i++) {
482 vec3_t tmp;
483
484 tmp[0] = (i & 1) ? mins[0] : maxs[0];
485 tmp[1] = (i & 2) ? mins[1] : maxs[1];
486 tmp[2] = (i & 4) ? mins[2] : maxs[2];
487
488 bbox[i][0] = DotProduct(vectors[0], tmp);
489 bbox[i][1] = -DotProduct(vectors[1], tmp);
490 bbox[i][2] = DotProduct(vectors[2], tmp);
491
492 VectorAdd(origin, bbox[i], bbox[i]);
493 }
494
495 /* compute a full bounding box */
496 aggregatemask = ~0;
497
498 for (i = 0; i < 8; i++) {
499 int mask = 0;
500 const int size = lengthof(r_locals.frustum);
501
502 for (int j = 0; j < size; j++) {
503 const cBspPlane_t* bspPlane = &r_locals.frustum[j];
504 /* get the distance between the frustum normal vector and the
505 * current vector of the bounding box */
506 const float f = DotProduct(bspPlane->normal, bbox[i]);
507 if (f - bspPlane->dist < 0)
508 mask |= (1 << j);
509 }
510
511 aggregatemask &= mask;
512 }
513
514 if (aggregatemask)
515 return true;
516
517 return false;
518}
519
527{
528 if (mod->num_meshes == 1 || (refdef.rendererFlags & RDF_NOWORLDMODEL)) {
529 return &mod->meshes[0];
530 } else {
531 vec3_t dist;
533
534 /* get distance, set lod if available */
535 VectorSubtract(refdef.viewOrigin, origin, dist);
536 length = VectorLength(dist);
537 if (mod->num_meshes > 3 && length > 700) {
538 return &mod->meshes[3];
539 } if (mod->num_meshes > 2 && length > 600) {
540 return &mod->meshes[2];
541 } else if (length > 500) {
542 return &mod->meshes[1];
543 }
544
545 return &mod->meshes[0];
546 }
547}
548
549static void R_DrawAliasTags (const mAliasModel_t* mod)
550{
551 const uint32_t color[] = {0xFF0000FF, 0xFF00FF00, 0xFFFF0000};
552 glEnable(GL_LINE_SMOOTH);
554 R_EnableColorArray(true);
555
556 for (int i = 0; i < mod->num_tags; i++) {
557 const mAliasTag_t* tag = &mod->tags[i];
558 for (int j = 0; j < 3; j++) {
559 vec3_t out;
560 const mAliasTagOrientation_t* o = &tag->orient[mod->curFrame];
561 VectorMA(o->origin, 5, o->axis[j], out);
562 const vec3_t points[] = { { o->origin[0], o->origin[1], o->origin[2] }, { out[0], out[1], out[2] } };
563 GLbyte colorArray[8];
564
565 memcpy(&colorArray[0], &color[j], 4);
566 memcpy(&colorArray[4], &color[j], 4);
567
568 R_BindArray(GL_COLOR_ARRAY, GL_UNSIGNED_BYTE, colorArray);
569 R_BindArray(GL_VERTEX_ARRAY, GL_FLOAT, points);
570 glDrawArrays(GL_LINE_STRIP, 0, 2);
571
572 refdef.batchCount++;
573 }
574 }
575
576 /* restore default array bindings */
577 R_BindDefaultArray(GL_COLOR_ARRAY);
578 R_BindDefaultArray(GL_VERTEX_ARRAY);
579
580 R_EnableColorArray(false);
582 glDisable(GL_LINE_SMOOTH);
583}
584
586{
587 mAliasModel_t* mod = &e->model->alias;
588 mAliasMesh_t* lodMesh;
589
591
593 lodMesh = R_GetLevelOfDetailForModel(e->origin, mod);
594 refdef.aliasCount += lodMesh->num_tris;
595 if (mod->num_frames == 1)
596 R_DrawAliasStatic(lodMesh, e->shell);
597 else
598 R_DrawAliasFrameLerp(mod, lodMesh, e->as.backlerp, e->as.frame, e->as.oldframe, e->shell);
599
600 if (r_drawtags->integer) {
601 R_DrawAliasTags(mod);
602 }
603
604 return lodMesh;
605}
606
608{
609 vec3_t start, end;
610
611 if (e->lighting == nullptr)
612 return false;
613
614 if (e->lighting->lastShadowedFrame == r_locals.frame)
615 return true;
616
617 VectorCopy(e->origin, start);
618 VectorCopy(e->origin, end);
619
620 end[2] = start[2] - MESH_SHADOW_MAX_DISTANCE;
621
622 /* do the trace */
623 R_Trace(Line(start, end), 0.0, MASK_SOLID);
624
625 /* resolve the shadow origin and direction */
626 if (refdef.trace.leafnum) {
627 /* hit something */
628 VectorCopy(refdef.trace.endpos, e->lighting->shadowOrigin);
630 return true;
631 }
632
633 return false;
634}
635
641static void R_RotateForMeshShadow (const entity_t* e)
642{
643 if (!e) {
644 glPopMatrix();
645 } else {
647 float height;
648
650
651 height = -origin[2];
652
653 glPushMatrix();
654 glTranslatef(0, 0, -height + 1.0);
655 glRotatef(-e->angles[PITCH], 0.0, 1.0, 0.0);
656 glScalef(1.0, 1.0, 0.0);
657 }
658}
659
664static void R_DrawMeshShadow (entity_t* e, const mAliasMesh_t* mesh)
665{
666 vec4_t color;
667 const bool oldBlend = r_state.blend_enabled;
668 const bool lighting = r_state.lighting_enabled;
669 r_program_t* program = r_state.active_program;
670
671 if (!r_stencilshadows->integer)
672 return;
673
674 if (!r_shadows->value)
675 return;
676
677 if (r_wire->integer)
678 return;
679
680 if (e->flags & RF_NO_SHADOW)
681 return;
682
683 if (e->flags & RF_TRANSLUCENT)
684 return;
685
686 if (!R_UpdateShadowOrigin(e))
687 return;
688
689 if (e->lighting->shadowOrigin[2] > refdef.viewOrigin[2])
690 return;
691
692 Vector4Set(color, 0.0, 0.0, 0.0, r_shadows->value * MESH_SHADOW_ALPHA);
693 R_Color(color);
695 R_EnableBlend(true);
698
699 if (lighting)
700 R_EnableLighting(nullptr, false);
701 glDrawArrays(GL_TRIANGLES, 0, mesh->num_tris * 3);
702 refdef.batchCount++;
703 if (lighting)
704 R_EnableLighting(program, true);
705
706 R_EnableStencilTest(false);
707 R_RotateForMeshShadow(nullptr);
708 R_EnableBlend(oldBlend);
710 R_Color(nullptr);
711}
712
718{
719 if (!e->model->loaded)
720 return;
721 mAliasModel_t* mod = &e->model->alias;
722 /* the values are sane here already - see R_GetEntityLists */
723 const image_t* skin = mod->meshes[e->as.mesh].skins[e->skinnum].skin;
724 int i;
725 float g;
726 vec4_t color = {0.8, 0.8, 0.8, 1.0};
727 mAliasMesh_t* mesh;
728
729 /* IR goggles override color for entities that are affected */
730 if ((refdef.rendererFlags & RDF_IRGOGGLES) && (e->flags & RF_IRGOGGLES))
731 Vector4Set(e->shell, 1.0, 0.3, 0.3, 1.0);
732
733 if (e->flags & RF_PULSE) { /* and then adding in a pulse */
734 const float f = 1.0 + sin((refdef.time + (e->model->alias.meshes[0].num_tris)) * 6.0) * 0.33;
735 VectorScale(color, 1.0 + f, color);
736 }
737
738 g = 0.0;
739 /* find brightest component */
740 for (i = 0; i < 3; i++) {
741 if (color[i] > g) /* keep it */
742 g = color[i];
743 }
744
745 /* scale it back to 1.0 */
746 if (g > 1.0)
747 VectorScale(color, 1.0 / g, color);
748
749 R_Color(color);
750
751 assert(skin->texnum > 0);
752 R_BindTexture(skin->texnum);
753
755
758
760 if (r_debug_lights->integer) {
761 for (i = 0; i < e->lighting->numLights && i < r_dynamic_lights->integer; i++)
762 CL_ParticleSpawn("lightTracerDebug", 0, e->transform.matrix + 12, e->lighting->lights[i]->origin);
763 }
764
765 if (skin->normalmap)
767
768 if (skin->specularmap)
769 R_EnableSpecularMap(skin->specularmap, true);
770
771 if (skin->roughnessmap)
773
774 glPushMatrix();
775 glMultMatrixf(e->transform.matrix);
776
777 if (VectorNotEmpty(e->scale))
778 glScalef(e->scale[0], e->scale[1], e->scale[2]);
779
780 mesh = R_DrawAliasModelBuffer(e);
781
782 if (r_state.specularmap_enabled)
783 R_EnableSpecularMap(nullptr, false);
784
785 if (r_state.roughnessmap_enabled)
786 R_EnableRoughnessMap(nullptr, false);
787
788 R_EnableModelLights(nullptr, 0, false, false);
789
790 R_EnableGlowMap(nullptr);
791
792 if (r_state.active_normalmap)
793 R_EnableBumpmap(nullptr);
794
795 R_DrawMeshShadow(e, mesh);
796
797 if (mod->num_frames == 1)
799
800 glPopMatrix();
801
802 /* show model bounding box */
803 if (r_showbox->integer)
805
806 R_Color(nullptr);
807}
ptl_t * CL_ParticleSpawn(const char *name, int levelFlags, const vec3_t s, const vec3_t v, const vec3_t a)
Spawn a new particle to the map.
#define RDF_IRGOGGLES
Definition cl_renderer.h:35
#define RDF_NOWORLDMODEL
Definition cl_renderer.h:34
rendererData_t refdef
Definition r_main.cpp:45
void R_Color(const vec4_t rgba)
Change the color to given value.
Definition r_state.cpp:1011
viddef_t viddef
Definition cl_video.cpp:34
float getWidthX() const
Definition aabb.h:141
void getCenter(vec3_t center) const
Calculates the center of the bounding box.
Definition aabb.h:155
float getWidthZ() const
Definition aabb.h:147
Definition line.h:31
void Com_Printf(const char *const fmt,...)
Definition common.cpp:428
#define MASK_SOLID
Definition defines.h:272
voidpf void uLong size
Definition ioapi.h:42
voidpf uLong int origin
Definition ioapi.h:45
vec_t VectorLength(const vec3_t v)
Calculate the length of a vector.
Definition mathlib.cpp:434
const vec4_t vec4_origin
Definition mathlib.cpp:36
void VectorMA(const vec3_t veca, const float scale, const vec3_t vecb, vec3_t outVector)
Sets vector_out (vc) to vevtor1 (va) + scale * vector2 (vb).
Definition mathlib.cpp:261
void AngleVectors(const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Create the rotation matrix in order to rotate something.
Definition mathlib.cpp:631
void VectorNormalizeFast(vec3_t v)
fast vector normalize routine that does not check to make sure that length != 0, nor does it return l...
Definition mathlib.cpp:762
#define YAW
Definition mathlib.h:55
#define PITCH
Definition mathlib.h:54
#define ROLL
Definition mathlib.h:56
void R_ResetArrayState(void)
Definition r_array.cpp:185
void R_DrawBoundingBox(const AABB &absBox)
Draws the model bounding box.
Definition r_draw.cpp:690
void R_TransformForEntity(const entity_t *e, const vec3_t in, vec3_t out)
Definition r_entity.cpp:522
#define RF_NO_SHADOW
Definition r_entity.h:41
#define RF_IRGOGGLES
Definition r_entity.h:48
#define RF_TRANSLUCENT
Definition r_entity.h:35
#define RF_PULSE
Definition r_entity.h:47
Error checking function.
#define R_CheckError()
Definition r_error.h:30
#define GL_TANGENT_ARRAY
Definition r_gl.h:76
QGL_EXTERN GLuint GLsizei GLsizei * length
Definition r_gl.h:110
QGL_EXTERN GLuint index
Definition r_gl.h:110
QGL_EXTERN GLfloat f
Definition r_gl.h:114
QGL_EXTERN GLint i
Definition r_gl.h:113
image_t * r_envmaptextures[MAX_ENVMAPTEXTURES]
Definition r_image.cpp:50
void R_EnableModelLights(const light_t **lights, int numLights, bool inShadow, bool enable)
Enable or disable realtime dynamic lighting for models.
Definition r_light.cpp:149
void R_UpdateLightList(entity_t *ent)
Recalculate active lights list for the given entity; R_CalcTransform(ent) should be called before thi...
Definition r_light.cpp:394
void R_Trace(const Line &trLine, float size, int contentmask)
Moves the given mins/maxs volume through the world from start to end.
lightmap definitions
local graphics definitions
cvar_t * r_shadows
Definition r_main.cpp:87
cvar_t * r_wire
Definition r_main.cpp:91
cvar_t * r_drawtags
Definition r_main.cpp:110
cvar_t * r_showbox
Definition r_main.cpp:92
cvar_t * r_debug_lights
Definition r_main.cpp:71
cvar_t * r_stencilshadows
Definition r_main.cpp:88
cvar_t * r_dynamic_lights
Definition r_main.cpp:96
rlocals_t r_locals
Definition r_main.cpp:49
rstate_t r_state
Definition r_main.cpp:48
static mAliasMesh_t * R_GetLevelOfDetailForModel(const vec3_t origin, const mAliasModel_t *mod)
Searches an appropriate level-of-detail mesh for the given model.
Definition r_mesh.cpp:526
static const float MESH_SHADOW_ALPHA
Definition r_mesh.cpp:38
static void R_DrawAliasStaticWithReset(const mAliasMesh_t *mesh, const vec4_t shellColor)
Definition r_mesh.cpp:131
void R_DrawModelParticle(modelInfo_t *mi)
Renders a particle model for the battlescape.
Definition r_mesh.cpp:397
static void R_RotateForMeshShadow(const entity_t *e)
Applies translation, rotation and scale for the shadow of the specified entity. In order to reuse the...
Definition r_mesh.cpp:641
bool R_GetTagMatrix(const model_t *mod, const char *tagName, int frame, float matrix[16])
Definition r_mesh.cpp:189
static mAliasMesh_t * R_DrawAliasModelBuffer(entity_t *e)
Definition r_mesh.cpp:585
#define R_GetTagOrientByFrame(mod, tagIndex, frame)
Definition r_mesh.cpp:166
static bool R_UpdateShadowOrigin(entity_t *e)
Definition r_mesh.cpp:607
static void R_ComputeGLMatrixFromTag(float *glMatrix, const mAliasTagOrientation_t *orient)
Definition r_mesh.cpp:143
void R_InterpolateTransform(float backLerp, int numframes, const mAliasTagOrientation_t *current, const mAliasTagOrientation_t *old, float *interpolated)
Interpolate the transform for a model places on a tag of another model.
Definition r_mesh.cpp:212
static void R_DrawAliasStatic(const mAliasMesh_t *mesh, const vec4_t shellColor)
Static model render function.
Definition r_mesh.cpp:107
void R_DrawModelDirect(modelInfo_t *mi, modelInfo_t *pmi, const char *tagname)
Draws a model in 2d mode (for rendering model data from the ui).
Definition r_mesh.cpp:306
static void R_DrawAliasTags(const mAliasModel_t *mod)
Definition r_mesh.cpp:549
static void R_DrawAliasFrameLerp(mAliasModel_t *mod, mAliasMesh_t *mesh, float backlerp, int framenum, int oldframenum, const vec4_t shellColor)
Animated model render function.
Definition r_mesh.cpp:86
static void R_DrawMeshModelShell(const mAliasMesh_t *mesh, const vec4_t color)
Draws an animated, colored shell for the specified entity. Rather than re-lerping or re-scaling the e...
Definition r_mesh.cpp:61
bool R_CullMeshModel(const entity_t *e)
Checks whether a model is visible in the current scene.
Definition r_mesh.cpp:446
static void R_ResetArraysAfterStaticMeshRender(void)
Definition r_mesh.cpp:122
static void R_TransformModelDirect(modelInfo_t *mi)
Definition r_mesh.cpp:40
void R_GetTags(const model_t *mod, const char *tagName, int currentFrame, int oldFrame, const mAliasTagOrientation_t **current, const mAliasTagOrientation_t **old)
Definition r_mesh.cpp:168
static const float MESH_SHADOW_MAX_DISTANCE
Definition r_mesh.cpp:37
void R_DrawAliasModel(entity_t *e)
Draw a model from the battlescape entity list.
Definition r_mesh.cpp:717
static void R_DrawMeshShadow(entity_t *e, const mAliasMesh_t *mesh)
Re-draws the mesh using the stencil test. Meshes with stale lighting information, or with a lighting ...
Definition r_mesh.cpp:664
int R_GetTagIndexByName(const model_t *mod, const char *tagName)
Searches the tag data for the given name.
Definition r_mesh.cpp:247
void R_ModelAutoScale(const vec2_t boxSize, modelInfo_t *mi, vec3_t scale, vec3_t center)
Compute scale and center for a model info data structure.
Definition r_mesh.cpp:278
model_t * R_FindModel(const char *name)
Tries to load a model.
Definition r_model.cpp:203
image_t * R_AliasModelState(const model_t *mod, int *mesh, int *frame, int *oldFrame, int *skin)
void R_FillArrayData(mAliasModel_t *mod, mAliasMesh_t *mesh, float backlerp, int framenum, int oldframenum, bool prerender)
Converts the model data into the opengl arrays.
void R_EnableTexture(gltexunit_t *texunit, bool enable)
Definition r_state.cpp:303
void R_BindDefaultArray(GLenum target)
Binds the appropriate shared vertex array to the specified target.
Definition r_state.cpp:182
void R_EnableGlowMap(const image_t *image)
Definition r_state.cpp:664
bool R_EnableLighting(r_program_t *program, bool enable)
Enables hardware-accelerated lighting with the specified program. This should be called after any tex...
Definition r_state.cpp:350
void R_EnableBumpmap(const image_t *normalmap)
Enables bumpmapping and binds the given normalmap.
Definition r_state.cpp:465
void R_EnableBlend(bool enable)
Definition r_state.cpp:261
void R_EnableSpecularMap(const image_t *image, bool enable)
Definition r_state.cpp:707
void R_EnableRoughnessMap(const image_t *image, bool enable)
Definition r_state.cpp:725
void R_EnableShell(bool enable)
Definition r_state.cpp:551
void R_EnableColorArray(bool enable)
Definition r_state.cpp:332
void R_BindArray(GLenum target, GLenum type, const void *array)
Definition r_state.cpp:148
void R_EnableAnimation(const mAliasMesh_t *mesh, float backlerp, bool enable)
Enables animation using keyframe interpolation on the GPU.
Definition r_state.cpp:430
void R_EnableStencilTest(bool enable)
Definition r_state.cpp:290
#define texunit_diffuse
Definition r_state.h:68
#define R_BindTexture(tn)
Definition r_state.h:184
#define Q_streq(a, b)
Definition shared.h:136
bool Q_strnull(const char *string)
Definition shared.h:138
#define lengthof(x)
Definition shared.h:105
float backlerp
Definition r_entity.h:57
int oldframe
Definition r_entity.h:56
plane_t structure
Definition typedefs.h:20
float dist
Definition typedefs.h:22
vec3_t normal
Definition typedefs.h:21
vec3_t scale
Definition r_entity.h:99
int flags
Definition r_entity.h:112
lighting_t * lighting
Definition r_entity.h:125
vec3_t angles
Definition r_entity.h:98
struct model_s * model
Definition r_entity.h:97
vec4_t shell
Definition r_entity.h:121
vec3_t origin
Definition r_entity.h:101
int skinnum
Definition r_entity.h:110
animState_t as
Definition r_entity.h:117
transform_t transform
Definition r_entity.h:119
struct entity_s * tagent
Definition r_entity.h:106
struct image_s * specularmap
Definition r_image.h:71
struct image_s * roughnessmap
Definition r_image.h:72
GLuint texnum
Definition r_image.h:66
struct image_s * normalmap
Definition r_image.h:69
struct image_s * glowmap
Definition r_image.h:70
vec3_t origin
Definition r_light.h:30
vec3_t shadowOrigin
Definition r_lighting.h:43
bool inShadow
Definition r_lighting.h:41
int lastShadowedFrame
Definition r_lighting.h:44
int numLights
Definition r_lighting.h:37
const light_t * lights[MAX_ENTITY_LIGHTS]
Definition r_lighting.h:36
mAliasSkin_t * skins
vec_t * texcoords
mAliasTag_t * tags
mAliasFrame_t * frames
mAliasMesh_t * meshes
image_t * skin
char name[MODEL_MAX_PATH]
mAliasTagOrientation_t * orient
AABB modBox
Definition r_model.h:51
mAliasModel_t alias
Definition r_model.h:63
char name[MAX_QPATH]
Definition r_model.h:44
bool loaded
Definition r_model.h:54
float * origin
Definition cl_renderer.h:61
float * center
Definition cl_renderer.h:64
float * angles
Definition cl_renderer.h:62
float backlerp
Definition cl_renderer.h:67
const char * name
Definition cl_renderer.h:59
float * color
Definition cl_renderer.h:71
model_t * model
Definition cl_renderer.h:58
float * scale
Definition cl_renderer.h:63
float matrix[16]
Definition r_entity.h:88
float vec_t
Definition ufotypes.h:37
vec_t vec3_t[3]
Definition ufotypes.h:39
vec_t vec4_t[4]
Definition ufotypes.h:40
vec_t vec2_t[2]
Definition ufotypes.h:38
static const vec3_t scale
#define Vector4Set(v, r, g, b, a)
Definition vector.h:62
#define VectorNegate(src, dest)
Definition vector.h:58
#define VectorNotEmpty(a)
Definition vector.h:72
#define VectorSubtract(a, b, dest)
Definition vector.h:45
#define VectorCopy(src, dest)
Definition vector.h:51
#define VectorAdd(a, b, dest)
Definition vector.h:47
#define DotProduct(x, y)
Returns the distance between two 3-dimensional vectors.
Definition vector.h:44
#define VectorSet(v, x, y, z)
Definition vector.h:59
#define VectorScale(in, scale, out)
Definition vector.h:79