icculus quake2 doxygen  1.0 dev
r_alias.c File Reference
#include "r_local.h"
#include "anorms.h"

Go to the source code of this file.

Classes

struct  aliasbatchedtransformdata_t
 

Macros

#define LIGHT_MIN   5
 
#define NUMVERTEXNORMALS   162
 
#define BBOX_TRIVIAL_ACCEPT   0
 
#define BBOX_MUST_CLIP_XY   1
 
#define BBOX_MUST_CLIP_Z   2
 
#define BBOX_TRIVIAL_REJECT   8
 

Functions

void R_AliasSetUpLerpData (dmdl_t *pmdl, float backlerp)
 
void R_AliasSetUpTransform (void)
 
void R_AliasTransformVector (vec3_t in, vec3_t out, float m[3][4])
 
void R_AliasProjectAndClipTestFinalVert (finalvert_t *fv)
 
void R_AliasTransformFinalVerts (int numpoints, finalvert_t *fv, dtrivertx_t *oldv, dtrivertx_t *newv)
 
void R_AliasLerpFrames (dmdl_t *paliashdr, float backlerp)
 
unsigned long R_AliasCheckFrameBBox (daliasframe_t *frame, float worldxf[3][4])
 
qboolean R_AliasCheckBBox (void)
 
void R_AliasPreparePoints (void)
 
static qboolean R_AliasSetupSkin (void)
 
void R_AliasSetupLighting (void)
 
void R_AliasSetupFrames (dmdl_t *pmdl)
 
void R_AliasDrawModel (void)
 

Variables

byte iractive
 
int r_amodels_drawn
 
affinetridesc_t r_affinetridesc
 
vec3_t r_plightvec
 
vec3_t r_lerped [1024]
 
vec3_t r_lerp_frontv
 
vec3_t r_lerp_backv
 
vec3_t r_lerp_move
 
int r_ambientlight
 
int r_aliasblendcolor
 
float r_shadelight
 
daliasframe_tr_thisframe
 
daliasframe_tr_lastframe
 
dmdl_ts_pmdl
 
float aliastransform [3][4]
 
float aliasworldtransform [3][4]
 
float aliasoldworldtransform [3][4]
 
static float s_ziscale
 
static vec3_t s_alias_forward
 
static vec3_t s_alias_right
 
static vec3_t s_alias_up
 
float r_avertexnormals [NUMVERTEXNORMALS][3]
 
aliasbatchedtransformdata_t aliasbatchedtransformdata
 

Macro Definition Documentation

◆ BBOX_MUST_CLIP_XY

#define BBOX_MUST_CLIP_XY   1

Definition at line 81 of file r_alias.c.

◆ BBOX_MUST_CLIP_Z

#define BBOX_MUST_CLIP_Z   2

Definition at line 82 of file r_alias.c.

◆ BBOX_TRIVIAL_ACCEPT

#define BBOX_TRIVIAL_ACCEPT   0

Definition at line 80 of file r_alias.c.

◆ BBOX_TRIVIAL_REJECT

#define BBOX_TRIVIAL_REJECT   8

Definition at line 83 of file r_alias.c.

◆ LIGHT_MIN

#define LIGHT_MIN   5

Definition at line 27 of file r_alias.c.

◆ NUMVERTEXNORMALS

#define NUMVERTEXNORMALS   162

Definition at line 58 of file r_alias.c.

Function Documentation

◆ R_AliasCheckBBox()

qboolean R_AliasCheckBBox ( void  )

Definition at line 178 of file r_alias.c.

179 {
180  unsigned long ccodes[2] = { 0, 0 };
181 
183 
184  /*
185  ** non-lerping model
186  */
187  if ( currententity->backlerp == 0 )
188  {
189  if ( ccodes[0] == BBOX_TRIVIAL_ACCEPT )
190  return BBOX_TRIVIAL_ACCEPT;
191  else if ( ccodes[0] & BBOX_TRIVIAL_REJECT )
192  return BBOX_TRIVIAL_REJECT;
193  else
194  return ( ccodes[0] & ~BBOX_TRIVIAL_REJECT );
195  }
196 
198 
199  if ( ( ccodes[0] | ccodes[1] ) == BBOX_TRIVIAL_ACCEPT )
200  return BBOX_TRIVIAL_ACCEPT;
201  else if ( ( ccodes[0] & ccodes[1] ) & BBOX_TRIVIAL_REJECT )
202  return BBOX_TRIVIAL_REJECT;
203  else
204  return ( ccodes[0] | ccodes[1] ) & ~BBOX_TRIVIAL_REJECT;
205 }

Referenced by R_AliasDrawModel().

◆ R_AliasCheckFrameBBox()

unsigned long R_AliasCheckFrameBBox ( daliasframe_t frame,
float  worldxf[3][4] 
)

Definition at line 90 of file r_alias.c.

91 {
92  unsigned long aggregate_and_clipcode = ~0U,
93  aggregate_or_clipcode = 0;
94  int i;
95  vec3_t mins, maxs;
96  vec3_t transformed_min, transformed_max;
97  qboolean zclipped = false, zfullyclipped = true;
98 
99  /*
100  ** get the exact frame bounding box
101  */
102  for (i=0 ; i<3 ; i++)
103  {
104  mins[i] = frame->translate[i];
105  maxs[i] = mins[i] + frame->scale[i]*255;
106  }
107 
108  /*
109  ** transform the min and max values into view space
110  */
111  R_AliasTransformVector( mins, transformed_min, aliastransform );
112  R_AliasTransformVector( maxs, transformed_max, aliastransform );
113 
114  if ( transformed_min[2] >= ALIAS_Z_CLIP_PLANE )
115  zfullyclipped = false;
116  if ( transformed_max[2] >= ALIAS_Z_CLIP_PLANE )
117  zfullyclipped = false;
118 
119  if ( zfullyclipped )
120  {
121  return BBOX_TRIVIAL_REJECT;
122  }
123  if ( zclipped )
124  {
125  return ( BBOX_MUST_CLIP_XY | BBOX_MUST_CLIP_Z );
126  }
127 
128  /*
129  ** build a transformed bounding box from the given min and max
130  */
131  for ( i = 0; i < 8; i++ )
132  {
133  int j;
134  vec3_t tmp, transformed;
135  unsigned long clipcode = 0;
136 
137  if ( i & 1 )
138  tmp[0] = mins[0];
139  else
140  tmp[0] = maxs[0];
141 
142  if ( i & 2 )
143  tmp[1] = mins[1];
144  else
145  tmp[1] = maxs[1];
146 
147  if ( i & 4 )
148  tmp[2] = mins[2];
149  else
150  tmp[2] = maxs[2];
151 
152  R_AliasTransformVector( tmp, transformed, worldxf );
153 
154  for ( j = 0; j < 4; j++ )
155  {
156  float dp = DotProduct( transformed, view_clipplanes[j].normal );
157 
158  if ( ( dp - view_clipplanes[j].dist ) < 0.0F )
159  clipcode |= 1 << j;
160  }
161 
162  aggregate_and_clipcode &= clipcode;
163  aggregate_or_clipcode |= clipcode;
164  }
165 
166  if ( aggregate_and_clipcode )
167  {
168  return BBOX_TRIVIAL_REJECT;
169  }
170  if ( !aggregate_or_clipcode )
171  {
172  return BBOX_TRIVIAL_ACCEPT;
173  }
174 
175  return BBOX_MUST_CLIP_XY;
176 }

Referenced by R_AliasCheckBBox().

◆ R_AliasDrawModel()

void R_AliasDrawModel ( void  )

Definition at line 1038 of file r_alias.c.

1039 {
1040  extern void (*d_pdrawspans)(void *);
1041  extern void R_PolysetDrawSpans8_Opaque( void * );
1042  extern void R_PolysetDrawSpans8_33( void * );
1043  extern void R_PolysetDrawSpans8_66( void * );
1044  extern void R_PolysetDrawSpansConstant8_33( void * );
1045  extern void R_PolysetDrawSpansConstant8_66( void * );
1046 
1048 
1049  if ( r_lerpmodels->value == 0 )
1050  currententity->backlerp = 0;
1051 
1053  {
1054  if ( r_lefthand->value == 1.0F )
1056  else if ( r_lefthand->value == 2.0F )
1057  return;
1058  }
1059 
1060  /*
1061  ** we have to set our frame pointers and transformations before
1062  ** doing any real work
1063  */
1066 
1067  // see if the bounding box lets us trivially reject, also sets
1068  // trivial accept status
1070  {
1071  if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) )
1072  {
1074  }
1075  return;
1076  }
1077 
1078  // set up the skin and verify it exists
1079  if ( !R_AliasSetupSkin () )
1080  {
1081  ri.Con_Printf( PRINT_ALL, "R_AliasDrawModel %s: NULL skin found\n",
1082  currentmodel->name);
1083  return;
1084  }
1085 
1086  r_amodels_drawn++;
1088 
1089  /*
1090  ** select the proper span routine based on translucency
1091  */
1092  // PMM - added double damage shell
1093  // PMM - reordered to handle blending
1095  {
1096  int color;
1097 
1098  // PMM - added double
1100  // PMM - reordered, new shells after old shells (so they get overriden)
1101 
1102  if ( color == RF_SHELL_RED )
1104  else if ( color == RF_SHELL_GREEN )
1106  else if ( color == RF_SHELL_BLUE )
1108  else if ( color == (RF_SHELL_RED | RF_SHELL_GREEN) )
1110  else if ( color == (RF_SHELL_RED | RF_SHELL_BLUE) )
1112  else if ( color == (RF_SHELL_BLUE | RF_SHELL_GREEN) )
1114  // PMM - added this .. it's yellowish
1115  else if ( color == (RF_SHELL_DOUBLE) )
1117  else if ( color == (RF_SHELL_HALF_DAM) )
1119  // pmm
1120  else
1122 /* if ( color & RF_SHELL_RED )
1123  {
1124  if ( ( color & RF_SHELL_BLUE) && ( color & RF_SHELL_GREEN) )
1125  r_aliasblendcolor = SHELL_WHITE_COLOR;
1126  else if ( color & (RF_SHELL_BLUE | RF_SHELL_DOUBLE))
1127  r_aliasblendcolor = SHELL_RB_COLOR;
1128  else
1129  r_aliasblendcolor = SHELL_RED_COLOR;
1130  }
1131  else if ( color & RF_SHELL_BLUE)
1132  {
1133  if ( color & RF_SHELL_DOUBLE )
1134  r_aliasblendcolor = SHELL_CYAN_COLOR;
1135  else
1136  r_aliasblendcolor = SHELL_BLUE_COLOR;
1137  }
1138  else if ( color & (RF_SHELL_DOUBLE) )
1139  r_aliasblendcolor = SHELL_DOUBLE_COLOR;
1140  else if ( color & (RF_SHELL_HALF_DAM) )
1141  r_aliasblendcolor = SHELL_HALF_DAM_COLOR;
1142  else if ( color & RF_SHELL_GREEN )
1143  r_aliasblendcolor = SHELL_GREEN_COLOR;
1144  else
1145  r_aliasblendcolor = SHELL_WHITE_COLOR;
1146 */
1147 
1148  if ( currententity->alpha > 0.33 )
1150  else
1152  }
1153  else if ( currententity->flags & RF_TRANSLUCENT )
1154  {
1155  if ( currententity->alpha > 0.66 )
1157  else if ( currententity->alpha > 0.33 )
1159  else
1161  }
1162  else
1163  {
1165  }
1166 
1167  /*
1168  ** compute this_frame and old_frame addresses
1169  */
1171 
1173  s_ziscale = (float)0x8000 * (float)0x10000 * 3.0;
1174  else
1175  s_ziscale = (float)0x8000 * (float)0x10000;
1176 
1178 
1179  if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) )
1180  {
1182  }
1183 }

Referenced by R_DrawEntitiesOnList().

◆ R_AliasLerpFrames()

void R_AliasLerpFrames ( dmdl_t paliashdr,
float  backlerp 
)

◆ R_AliasPreparePoints()

void R_AliasPreparePoints ( void  )

Definition at line 238 of file r_alias.c.

239 {
240  int i;
241  dstvert_t *pstverts;
242  dtriangle_t *ptri;
243  finalvert_t *pfv[3];
244  finalvert_t finalverts[MAXALIASVERTS +
245  ((CACHE_SIZE - 1) / sizeof(finalvert_t)) + 3];
246  finalvert_t *pfinalverts;
247 
248 //PGM
250 // iractive = 0;
251 // if(r_newrefdef.rdflags & RDF_IRGOGGLES && currententity->flags & RF_IR_VISIBLE)
252 // iractive = 1;
253 //PGM
254 
255  // put work vertexes on stack, cache aligned
256  pfinalverts = (finalvert_t *)
257  (((long)&finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
258 
263 
268 
269 // clip and draw all triangles
270 //
271  pstverts = (dstvert_t *)((byte *)s_pmdl + s_pmdl->ofs_st);
272  ptri = (dtriangle_t *)((byte *)s_pmdl + s_pmdl->ofs_tris);
273 
274  if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) )
275  {
276  for (i=0 ; i<s_pmdl->num_tris ; i++, ptri++)
277  {
278  pfv[0] = &pfinalverts[ptri->index_xyz[0]];
279  pfv[1] = &pfinalverts[ptri->index_xyz[1]];
280  pfv[2] = &pfinalverts[ptri->index_xyz[2]];
281 
282  if ( pfv[0]->flags & pfv[1]->flags & pfv[2]->flags )
283  continue; // completely clipped
284 
285  // insert s/t coordinates
286  pfv[0]->s = pstverts[ptri->index_st[0]].s << 16;
287  pfv[0]->t = pstverts[ptri->index_st[0]].t << 16;
288 
289  pfv[1]->s = pstverts[ptri->index_st[1]].s << 16;
290  pfv[1]->t = pstverts[ptri->index_st[1]].t << 16;
291 
292  pfv[2]->s = pstverts[ptri->index_st[2]].s << 16;
293  pfv[2]->t = pstverts[ptri->index_st[2]].t << 16;
294 
295  if ( ! (pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) )
296  { // totally unclipped
297  aliastriangleparms.a = pfv[2];
298  aliastriangleparms.b = pfv[1];
299  aliastriangleparms.c = pfv[0];
300 
301  R_DrawTriangle();
302  }
303  else
304  {
305  R_AliasClipTriangle (pfv[2], pfv[1], pfv[0]);
306  }
307  }
308  }
309  else
310  {
311  for (i=0 ; i<s_pmdl->num_tris ; i++, ptri++)
312  {
313  pfv[0] = &pfinalverts[ptri->index_xyz[0]];
314  pfv[1] = &pfinalverts[ptri->index_xyz[1]];
315  pfv[2] = &pfinalverts[ptri->index_xyz[2]];
316 
317  if ( pfv[0]->flags & pfv[1]->flags & pfv[2]->flags )
318  continue; // completely clipped
319 
320  // insert s/t coordinates
321  pfv[0]->s = pstverts[ptri->index_st[0]].s << 16;
322  pfv[0]->t = pstverts[ptri->index_st[0]].t << 16;
323 
324  pfv[1]->s = pstverts[ptri->index_st[1]].s << 16;
325  pfv[1]->t = pstverts[ptri->index_st[1]].t << 16;
326 
327  pfv[2]->s = pstverts[ptri->index_st[2]].s << 16;
328  pfv[2]->t = pstverts[ptri->index_st[2]].t << 16;
329 
330  if ( ! (pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) )
331  { // totally unclipped
332  aliastriangleparms.a = pfv[0];
333  aliastriangleparms.b = pfv[1];
334  aliastriangleparms.c = pfv[2];
335 
336  R_DrawTriangle();
337  }
338  else
339  { // partially clipped
340  R_AliasClipTriangle (pfv[0], pfv[1], pfv[2]);
341  }
342  }
343  }
344 }

Referenced by R_AliasDrawModel().

◆ R_AliasProjectAndClipTestFinalVert()

void R_AliasProjectAndClipTestFinalVert ( finalvert_t fv)

Definition at line 803 of file r_alias.c.

804 {
805  float zi;
806  float x, y, z;
807 
808  // project points
809  x = fv->xyz[0];
810  y = fv->xyz[1];
811  z = fv->xyz[2];
812  zi = 1.0 / z;
813 
814  fv->zi = zi * s_ziscale;
815 
816  fv->u = (x * aliasxscale * zi) + aliasxcenter;
817  fv->v = (y * aliasyscale * zi) + aliasycenter;
818 
819  if (fv->u < r_refdef.aliasvrect.x)
820  fv->flags |= ALIAS_LEFT_CLIP;
821  if (fv->v < r_refdef.aliasvrect.y)
822  fv->flags |= ALIAS_TOP_CLIP;
823  if (fv->u > r_refdef.aliasvrectright)
824  fv->flags |= ALIAS_RIGHT_CLIP;
825  if (fv->v > r_refdef.aliasvrectbottom)
826  fv->flags |= ALIAS_BOTTOM_CLIP;
827 }

Referenced by R_Alias_clip_z(), and R_AliasTransformFinalVerts().

◆ R_AliasSetupFrames()

void R_AliasSetupFrames ( dmdl_t pmdl)

Definition at line 964 of file r_alias.c.

965 {
966  int thisframe = currententity->frame;
967  int lastframe = currententity->oldframe;
968 
969  if ( ( thisframe >= pmdl->num_frames ) || ( thisframe < 0 ) )
970  {
971  ri.Con_Printf (PRINT_ALL, "R_AliasSetupFrames %s: no such thisframe %d\n",
972  currentmodel->name, thisframe);
973  thisframe = 0;
974  }
975  if ( ( lastframe >= pmdl->num_frames ) || ( lastframe < 0 ) )
976  {
977  ri.Con_Printf (PRINT_ALL, "R_AliasSetupFrames %s: no such lastframe %d\n",
978  currentmodel->name, lastframe);
979  lastframe = 0;
980  }
981 
982  r_thisframe = (daliasframe_t *)((byte *)pmdl + pmdl->ofs_frames
983  + thisframe * pmdl->framesize);
984 
985  r_lastframe = (daliasframe_t *)((byte *)pmdl + pmdl->ofs_frames
986  + lastframe * pmdl->framesize);
987 }

Referenced by R_AliasDrawModel().

◆ R_AliasSetUpLerpData()

void R_AliasSetUpLerpData ( dmdl_t pmdl,
float  backlerp 
)

Definition at line 994 of file r_alias.c.

995 {
996  float frontlerp;
997  vec3_t translation, vectors[3];
998  int i;
999 
1000  frontlerp = 1.0F - backlerp;
1001 
1002  /*
1003  ** convert entity's angles into discrete vectors for R, U, and F
1004  */
1005  AngleVectors (currententity->angles, vectors[0], vectors[1], vectors[2]);
1006 
1007  /*
1008  ** translation is the vector from last position to this position
1009  */
1011 
1012  /*
1013  ** move should be the delta back to the previous frame * backlerp
1014  */
1015  r_lerp_move[0] = DotProduct(translation, vectors[0]); // forward
1016  r_lerp_move[1] = -DotProduct(translation, vectors[1]); // left
1017  r_lerp_move[2] = DotProduct(translation, vectors[2]); // up
1018 
1020 
1021  for (i=0 ; i<3 ; i++)
1022  {
1023  r_lerp_move[i] = backlerp*r_lerp_move[i] + frontlerp * r_thisframe->translate[i];
1024  }
1025 
1026  for (i=0 ; i<3 ; i++)
1027  {
1028  r_lerp_frontv[i] = frontlerp * r_thisframe->scale[i];
1029  r_lerp_backv[i] = backlerp * r_lastframe->scale[i];
1030  }
1031 }

Referenced by R_AliasDrawModel().

◆ R_AliasSetupLighting()

void R_AliasSetupLighting ( void  )

Definition at line 874 of file r_alias.c.

875 {
876  alight_t lighting;
877  float lightvec[3] = {-1, 0, 0};
878  vec3_t light;
879  int i, j;
880 
881  // all components of light should be identical in software
883  {
884  for (i=0 ; i<3 ; i++)
885  light[i] = 1.0;
886  }
887  else
888  {
890  }
891 
892  // save off light value for server to look at (BIG HACK!)
894  r_lightlevel->value = 150.0 * light[0];
895 
896 
898  {
899  for (i=0 ; i<3 ; i++)
900  if (light[i] < 0.1)
901  light[i] = 0.1;
902  }
903 
904  if ( currententity->flags & RF_GLOW )
905  { // bonus items will pulse with time
906  float scale;
907  float min;
908 
909  scale = 0.1 * sin(r_newrefdef.time*7);
910  for (i=0 ; i<3 ; i++)
911  {
912  min = light[i] * 0.8;
913  light[i] += scale;
914  if (light[i] < min)
915  light[i] = min;
916  }
917  }
918 
919  j = (light[0] + light[1] + light[2])*0.3333*255;
920 
921  lighting.ambientlight = j;
922  lighting.shadelight = j;
923 
924  lighting.plightvec = lightvec;
925 
926 // clamp lighting so it doesn't overbright as much
927  if (lighting.ambientlight > 128)
928  lighting.ambientlight = 128;
929  if (lighting.ambientlight + lighting.shadelight > 192)
930  lighting.shadelight = 192 - lighting.ambientlight;
931 
932 // guarantee that no vertex will ever be lit below LIGHT_MIN, so we don't have
933 // to clamp off the bottom
934  r_ambientlight = lighting.ambientlight;
935 
938 
940 
943 
944  r_shadelight = lighting.shadelight;
945 
946  if (r_shadelight < 0)
947  r_shadelight = 0;
948 
950 
951 // rotate the lighting vector into the model's frame of reference
953  r_plightvec[1] = -DotProduct( lighting.plightvec, s_alias_right );
954  r_plightvec[2] = DotProduct( lighting.plightvec, s_alias_up );
955 }

Referenced by R_AliasDrawModel().

◆ R_AliasSetupSkin()

static qboolean R_AliasSetupSkin ( void  )
static

Definition at line 834 of file r_alias.c.

835 {
836  int skinnum;
837  image_t *pskindesc;
838 
839  if (currententity->skin)
840  pskindesc = currententity->skin;
841  else
842  {
843  skinnum = currententity->skinnum;
844  if ((skinnum >= s_pmdl->num_skins) || (skinnum < 0))
845  {
846  ri.Con_Printf (PRINT_ALL, "R_AliasSetupSkin %s: no such skin # %d\n",
847  currentmodel->name, skinnum);
848  skinnum = 0;
849  }
850 
851  pskindesc = currentmodel->skins[skinnum];
852  }
853 
854  if ( !pskindesc )
855  return false;
856 
857  r_affinetridesc.pskin = pskindesc->pixels[0];
858  r_affinetridesc.skinwidth = pskindesc->width;
859  r_affinetridesc.skinheight = pskindesc->height;
860 
861  R_PolysetUpdateTables (); // FIXME: precalc edge lookups
862 
863  return true;
864 }

Referenced by R_AliasDrawModel().

◆ R_AliasSetUpTransform()

void R_AliasSetUpTransform ( void  )

Definition at line 352 of file r_alias.c.

353 {
354  int i;
355  static float viewmatrix[3][4];
356  vec3_t angles;
357 
358 // TODO: should really be stored with the entity instead of being reconstructed
359 // TODO: should use a look-up table
360 // TODO: could cache lazily, stored in the entity
361 //
362  angles[ROLL] = currententity->angles[ROLL];
363  angles[PITCH] = currententity->angles[PITCH];
364  angles[YAW] = currententity->angles[YAW];
366 
367 // TODO: can do this with simple matrix rearrangement
368 
369  memset( aliasworldtransform, 0, sizeof( aliasworldtransform ) );
370  memset( aliasoldworldtransform, 0, sizeof( aliasworldtransform ) );
371 
372  for (i=0 ; i<3 ; i++)
373  {
377  }
378 
382 
386 
387 // FIXME: can do more efficiently than full concatenation
388 // memcpy( rotationmatrix, t2matrix, sizeof( rotationmatrix ) );
389 
390 // R_ConcatTransforms (t2matrix, tmatrix, rotationmatrix);
391 
392 // TODO: should be global, set when vright, etc., set
393  VectorCopy (vright, viewmatrix[0]);
394  VectorCopy (vup, viewmatrix[1]);
395  VectorInverse (viewmatrix[1]);
396  VectorCopy (vpn, viewmatrix[2]);
397 
398  viewmatrix[0][3] = 0;
399  viewmatrix[1][3] = 0;
400  viewmatrix[2][3] = 0;
401 
402 // memcpy( aliasworldtransform, rotationmatrix, sizeof( aliastransform ) );
403 
405 
409 
413 }

Referenced by R_AliasDrawModel().

◆ R_AliasTransformFinalVerts()

void R_AliasTransformFinalVerts ( int  numpoints,
finalvert_t fv,
dtrivertx_t oldv,
dtrivertx_t newv 
)

Definition at line 739 of file r_alias.c.

740 {
741  int i;
742 
743  for ( i = 0; i < numpoints; i++, fv++, oldv++, newv++ )
744  {
745  int temp;
746  float lightcos, *plightnormal;
747  vec3_t lerped_vert;
748 
749  lerped_vert[0] = r_lerp_move[0] + oldv->v[0]*r_lerp_backv[0] + newv->v[0]*r_lerp_frontv[0];
750  lerped_vert[1] = r_lerp_move[1] + oldv->v[1]*r_lerp_backv[1] + newv->v[1]*r_lerp_frontv[1];
751  lerped_vert[2] = r_lerp_move[2] + oldv->v[2]*r_lerp_backv[2] + newv->v[2]*r_lerp_frontv[2];
752 
753  plightnormal = r_avertexnormals[newv->lightnormalindex];
754 
755  // PMM - added double damage shell
757  {
758  lerped_vert[0] += plightnormal[0] * POWERSUIT_SCALE;
759  lerped_vert[1] += plightnormal[1] * POWERSUIT_SCALE;
760  lerped_vert[2] += plightnormal[2] * POWERSUIT_SCALE;
761  }
762 
763  fv->xyz[0] = DotProduct(lerped_vert, aliastransform[0]) + aliastransform[0][3];
764  fv->xyz[1] = DotProduct(lerped_vert, aliastransform[1]) + aliastransform[1][3];
765  fv->xyz[2] = DotProduct(lerped_vert, aliastransform[2]) + aliastransform[2][3];
766 
767  fv->flags = 0;
768 
769  // lighting
770  lightcos = DotProduct (plightnormal, r_plightvec);
771  temp = r_ambientlight;
772 
773  if (lightcos < 0)
774  {
775  temp += (int)(r_shadelight * lightcos);
776 
777  // clamp; because we limited the minimum ambient and shading light, we
778  // don't have to clamp low light, just bright
779  if (temp < 0)
780  temp = 0;
781  }
782 
783  fv->l = temp;
784 
785  if ( fv->xyz[2] < ALIAS_Z_CLIP_PLANE )
786  {
787  fv->flags |= ALIAS_Z_CLIP;
788  }
789  else
790  {
792  }
793  }
794 }

Referenced by R_AliasPreparePoints().

◆ R_AliasTransformVector()

void R_AliasTransformVector ( vec3_t  in,
vec3_t  out,
float  m[3][4] 
)

Definition at line 213 of file r_alias.c.

214 {
215  out[0] = DotProduct(in, xf[0]) + xf[0][3];
216  out[1] = DotProduct(in, xf[1]) + xf[1][3];
217  out[2] = DotProduct(in, xf[2]) + xf[2][3];
218 }

Referenced by R_AliasCheckFrameBBox().

Variable Documentation

◆ aliasbatchedtransformdata

aliasbatchedtransformdata_t aliasbatchedtransformdata

Definition at line 236 of file r_alias.c.

Referenced by R_AliasPreparePoints().

◆ aliasoldworldtransform

float aliasoldworldtransform[3][4]

Definition at line 52 of file r_alias.c.

Referenced by R_AliasCheckBBox(), and R_AliasSetUpTransform().

◆ aliastransform

float aliastransform[3][4]

◆ aliasworldtransform

float aliasworldtransform[3][4]

Definition at line 51 of file r_alias.c.

Referenced by R_AliasCheckBBox(), and R_AliasSetUpTransform().

◆ iractive

byte iractive

Definition at line 134 of file r_polyse.c.

Referenced by R_AliasPreparePoints().

◆ r_affinetridesc

◆ r_aliasblendcolor

int r_aliasblendcolor

◆ r_ambientlight

int r_ambientlight

Definition at line 42 of file r_alias.c.

Referenced by R_AliasSetupLighting(), and R_AliasTransformFinalVerts().

◆ r_amodels_drawn

int r_amodels_drawn

Definition at line 34 of file r_alias.c.

Referenced by R_AliasDrawModel(), R_PrintAliasStats(), and R_SetupFrame().

◆ r_avertexnormals

float r_avertexnormals[NUMVERTEXNORMALS][3]
Initial value:
= {
}

Definition at line 60 of file r_alias.c.

Referenced by R_AliasTransformFinalVerts().

◆ r_lastframe

daliasframe_t * r_lastframe

◆ r_lerp_backv

vec3_t r_lerp_backv

Definition at line 40 of file r_alias.c.

Referenced by R_AliasSetUpLerpData(), and R_AliasTransformFinalVerts().

◆ r_lerp_frontv

vec3_t r_lerp_frontv

Definition at line 40 of file r_alias.c.

Referenced by R_AliasSetUpLerpData(), and R_AliasTransformFinalVerts().

◆ r_lerp_move

vec3_t r_lerp_move

Definition at line 40 of file r_alias.c.

Referenced by R_AliasSetUpLerpData(), and R_AliasTransformFinalVerts().

◆ r_lerped

vec3_t r_lerped[1024]

Definition at line 39 of file r_alias.c.

◆ r_plightvec

vec3_t r_plightvec

Definition at line 38 of file r_alias.c.

Referenced by R_AliasSetupLighting(), and R_AliasTransformFinalVerts().

◆ r_shadelight

float r_shadelight

Definition at line 44 of file r_alias.c.

Referenced by R_AliasSetupLighting(), and R_AliasTransformFinalVerts().

◆ r_thisframe

daliasframe_t* r_thisframe

◆ s_alias_forward

vec3_t s_alias_forward
static

Definition at line 55 of file r_alias.c.

Referenced by R_AliasSetupLighting(), and R_AliasSetUpTransform().

◆ s_alias_right

vec3_t s_alias_right
static

Definition at line 55 of file r_alias.c.

Referenced by R_AliasSetupLighting(), and R_AliasSetUpTransform().

◆ s_alias_up

vec3_t s_alias_up
static

Definition at line 55 of file r_alias.c.

Referenced by R_AliasSetupLighting(), and R_AliasSetUpTransform().

◆ s_pmdl

dmdl_t* s_pmdl

Definition at line 48 of file r_alias.c.

Referenced by R_AliasDrawModel(), R_AliasPreparePoints(), and R_AliasSetupSkin().

◆ s_ziscale

float s_ziscale
static

Definition at line 54 of file r_alias.c.

Referenced by R_AliasDrawModel(), and R_AliasProjectAndClipTestFinalVert().

RF_TRANSLUCENT
#define RF_TRANSLUCENT
Definition: q_shared.h:618
R_PolysetDrawSpans8_33
void R_PolysetDrawSpans8_33(spanpackage_t *pspanpackage)
Definition: r_polyse.c:820
ALIAS_Z_CLIP_PLANE
#define ALIAS_Z_CLIP_PLANE
Definition: r_local.h:227
r_thisframe
daliasframe_t * r_thisframe
Definition: r_alias.c:47
dtrivertx_t::lightnormalindex
byte lightnormalindex
Definition: qfiles.h:110
RF_SHELL_RED
#define RF_SHELL_RED
Definition: q_shared.h:623
BBOX_MUST_CLIP_Z
#define BBOX_MUST_CLIP_Z
Definition: r_alias.c:82
currentmodel
model_t * currentmodel
Definition: r_main.c:37
entity_s::skin
struct image_s * skin
Definition: ref.h:75
YAW
#define YAW
Definition: q_shared.h:66
entity_s::origin
float origin[3]
Definition: ref.h:57
RF_IR_VISIBLE
#define RF_IR_VISIBLE
Definition: q_shared.h:629
daliasframe_t::scale
float scale[3]
Definition: qfiles.h:121
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
RF_MINLIGHT
#define RF_MINLIGHT
Definition: q_shared.h:613
VectorSubtract
#define VectorSubtract(a, b, c)
Definition: q_shared.h:156
aliasbatchedtransformdata
aliasbatchedtransformdata_t aliasbatchedtransformdata
Definition: r_alias.c:236
RF_SHELL_HALF_DAM
#define RF_SHELL_HALF_DAM
Definition: q_shared.h:631
R_AliasSetupSkin
static qboolean R_AliasSetupSkin(void)
Definition: r_alias.c:834
R_PolysetUpdateTables
void R_PolysetUpdateTables(void)
Definition: r_polyse.c:182
ri
refimport_t ri
Definition: r_main.c:25
aliasxcenter
float aliasxcenter
Definition: r_local.h:702
RF_SHELL_GREEN
#define RF_SHELL_GREEN
Definition: q_shared.h:624
aliastriangleparms_t::b
finalvert_t * b
Definition: r_local.h:712
s_alias_forward
static vec3_t s_alias_forward
Definition: r_alias.c:55
U
#define U(a, b, c, d, k, s)
Definition: md4.c:25
s_alias_up
static vec3_t s_alias_up
Definition: r_alias.c:55
dmdl_t::num_tris
int num_tris
Definition: qfiles.h:149
CACHE_SIZE
#define CACHE_SIZE
Definition: d_ifacea.h:22
R_PolysetDrawSpans8_66
void R_PolysetDrawSpans8_66(spanpackage_t *pspanpackage)
Definition: r_polyse.c:928
vright
vec3_t vright
Definition: r_main.c:68
R_LightPoint
void R_LightPoint(vec3_t p, vec3_t color)
Definition: r_light.c:224
qboolean
qboolean
Definition: q_shared.h:56
x
GLint GLenum GLint x
Definition: qgl_win.c:116
z
GLdouble GLdouble z
Definition: qgl_win.c:283
entity_s::skinnum
int skinnum
Definition: ref.h:70
i
int i
Definition: q_shared.c:305
BBOX_MUST_CLIP_XY
#define BBOX_MUST_CLIP_XY
Definition: r_alias.c:81
dstvert_t::s
short s
Definition: qfiles.h:97
fv
float fv
Definition: r_edge.c:75
d_pdrawspans
void(* d_pdrawspans)(spanpackage_t *pspanpackage)
Definition: r_polyse.c:117
PITCH
#define PITCH
Definition: q_shared.h:65
r_origin
vec3_t r_origin
Definition: r_main.c:69
refdef_t::rdflags
int rdflags
Definition: ref.h:128
R_PolysetDrawSpans8_Opaque
void R_PolysetDrawSpans8_Opaque(spanpackage_t *pspanpackage)
Definition: r_polyse.c:1038
finalvert_s::t
int t
Definition: r_local.h:282
aliasbatchedtransformdata_t::num_points
int num_points
Definition: r_alias.c:230
entity_s::flags
int flags
Definition: ref.h:76
currententity
entity_t * currententity
Definition: r_bsp.c:28
aliasbatchedtransformdata_t::dest_verts
finalvert_t * dest_verts
Definition: r_alias.c:233
SHELL_DOUBLE_COLOR
#define SHELL_DOUBLE_COLOR
Definition: ref.h:42
finalvert_s
Definition: r_local.h:281
R_DrawTriangle
void R_DrawTriangle(void)
Definition: r_polyse.c:204
R_AliasClipTriangle
void R_AliasClipTriangle(finalvert_t *index0, finalvert_t *index1, finalvert_t *index2)
Definition: r_aclip.c:231
r_lefthand
cvar_t * r_lefthand
Definition: r_main.c:111
model_s::extradata
void * extradata
Definition: r_model.h:235
ALIAS_Z_CLIP
#define ALIAS_Z_CLIP
Definition: r_local.h:207
vup
vec3_t vup
Definition: r_main.c:66
j
GLint j
Definition: qgl_win.c:150
r_plightvec
vec3_t r_plightvec
Definition: r_alias.c:38
aliasxscale
float aliasxscale
Definition: r_main.c:79
aliasycenter
float aliasycenter
Definition: r_local.h:702
AngleVectors
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Definition: q_shared.c:93
RF_WEAPONMODEL
#define RF_WEAPONMODEL
Definition: q_shared.h:615
dtriangle_t::index_st
short index_st[3]
Definition: qfiles.h:104
refimport_t::Con_Printf
void(* Con_Printf)(int print_level, char *str,...)
Definition: ref.h:228
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:743
r_shadelight
float r_shadelight
Definition: r_alias.c:44
SHELL_BLUE_COLOR
#define SHELL_BLUE_COLOR
Definition: ref.h:34
SHELL_RED_COLOR
#define SHELL_RED_COLOR
Definition: ref.h:32
R_PolysetDrawSpansConstant8_33
void R_PolysetDrawSpansConstant8_33(spanpackage_t *pspanpackage)
Definition: r_polyse.c:884
entity_s::alpha
float alpha
Definition: ref.h:73
dmdl_t::ofs_frames
int ofs_frames
Definition: qfiles.h:156
R_AliasProjectAndClipTestFinalVert
void R_AliasProjectAndClipTestFinalVert(finalvert_t *fv)
Definition: r_alias.c:803
image_s::height
int height
Definition: r_local.h:69
r_lerpmodels
cvar_t * r_lerpmodels
Definition: r_main.c:130
SHELL_BG_COLOR
#define SHELL_BG_COLOR
Definition: ref.h:39
ALIAS_BOTTOM_CLIP
#define ALIAS_BOTTOM_CLIP
Definition: r_local.h:206
dtriangle_t::index_xyz
short index_xyz[3]
Definition: qfiles.h:103
ROLL
#define ROLL
Definition: q_shared.h:67
aliasoldworldtransform
float aliasoldworldtransform[3][4]
Definition: r_alias.c:52
dstvert_t
Definition: qfiles.h:95
RF_DEPTHHACK
#define RF_DEPTHHACK
Definition: q_shared.h:617
oldrefdef_t::aliasvrectbottom
int aliasvrectbottom
Definition: r_local.h:116
RDF_IRGOGGLES
#define RDF_IRGOGGLES
Definition: q_shared.h:649
r_affinetridesc
affinetridesc_t r_affinetridesc
Definition: r_alias.c:36
r_lastframe
daliasframe_t * r_lastframe
Definition: r_alias.c:47
alight_t::shadelight
int shadelight
Definition: r_local.h:335
dstvert_t::t
short t
Definition: qfiles.h:98
dmdl_t::num_skins
int num_skins
Definition: qfiles.h:146
entity_s::oldframe
int oldframe
Definition: ref.h:64
R_AliasCheckFrameBBox
unsigned long R_AliasCheckFrameBBox(daliasframe_t *frame, float worldxf[3][4])
Definition: r_alias.c:90
RF_SHELL_DOUBLE
#define RF_SHELL_DOUBLE
Definition: q_shared.h:630
r_newrefdef
refdef_t r_newrefdef
Definition: r_main.c:36
DotProduct
#define DotProduct(x, y)
Definition: q_shared.h:155
dmdl_t::num_xyz
int num_xyz
Definition: qfiles.h:147
R_AliasTransformFinalVerts
void R_AliasTransformFinalVerts(int numpoints, finalvert_t *fv, dtrivertx_t *oldv, dtrivertx_t *newv)
Definition: r_alias.c:739
cvar_s::value
float value
Definition: q_shared.h:324
entity_s::backlerp
float backlerp
Definition: ref.h:69
dmdl_t::framesize
int framesize
Definition: qfiles.h:144
F
#define F(X, Y, Z)
Definition: md4.c:13
refdef_t::time
float time
Definition: ref.h:127
vrect_s::x
int x
Definition: vid.h:24
SHELL_HALF_DAM_COLOR
#define SHELL_HALF_DAM_COLOR
Definition: ref.h:43
image_s::pixels
byte * pixels[4]
Definition: r_local.h:72
image_s::width
int width
Definition: r_local.h:69
alight_t::plightvec
float * plightvec
Definition: r_local.h:336
RF_GLOW
#define RF_GLOW
Definition: q_shared.h:622
VectorInverse
void VectorInverse(vec3_t v)
Definition: q_shared.c:775
daliasframe_t::translate
float translate[3]
Definition: qfiles.h:122
dtrivertx_t::v
byte v[3]
Definition: qfiles.h:109
r_lightlevel
cvar_t * r_lightlevel
Definition: r_main.c:134
SHELL_GREEN_COLOR
#define SHELL_GREEN_COLOR
Definition: ref.h:33
R_PolysetDrawSpansConstant8_66
void R_PolysetDrawSpansConstant8_66(spanpackage_t *pspanpackage)
Definition: r_polyse.c:993
affinetridesc_t::skinwidth
int skinwidth
Definition: r_local.h:307
VectorAdd
#define VectorAdd(a, b, c)
Definition: q_shared.h:157
SHELL_RG_COLOR
#define SHELL_RG_COLOR
Definition: ref.h:36
r_amodels_drawn
int r_amodels_drawn
Definition: r_alias.c:34
y
GLint y
Definition: qgl_win.c:115
aliastriangleparms_t::a
finalvert_t * a
Definition: r_local.h:712
entity_s::frame
int frame
Definition: ref.h:58
R_AliasSetUpTransform
void R_AliasSetUpTransform(void)
Definition: r_alias.c:352
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:158
oldrefdef_t::aliasvrectright
int aliasvrectright
Definition: r_local.h:116
model_s::skins
image_t * skins[MAX_MD2SKINS]
Definition: r_model.h:234
R_AliasSetupFrames
void R_AliasSetupFrames(dmdl_t *pmdl)
Definition: r_alias.c:964
SHELL_RB_COLOR
#define SHELL_RB_COLOR
Definition: ref.h:38
iractive
byte iractive
Definition: r_polyse.c:134
aliasbatchedtransformdata_t::this_verts
dtrivertx_t * this_verts
Definition: r_alias.c:232
ALIAS_LEFT_CLIP
#define ALIAS_LEFT_CLIP
Definition: r_local.h:203
R_AliasCheckBBox
qboolean R_AliasCheckBBox(void)
Definition: r_alias.c:178
model_s::name
char name[MAX_QPATH]
Definition: r_model.h:173
POWERSUIT_SCALE
#define POWERSUIT_SCALE
Definition: ref.h:30
R_AliasSetUpLerpData
void R_AliasSetUpLerpData(dmdl_t *pmdl, float backlerp)
Definition: r_alias.c:994
SHELL_WHITE_COLOR
#define SHELL_WHITE_COLOR
Definition: ref.h:47
finalvert_s::s
int s
Definition: r_local.h:282
ALIAS_TOP_CLIP
#define ALIAS_TOP_CLIP
Definition: r_local.h:204
LIGHT_MIN
#define LIGHT_MIN
Definition: r_alias.c:27
aliasworldtransform
float aliasworldtransform[3][4]
Definition: r_alias.c:51
view_clipplanes
clipplane_t view_clipplanes[4]
Definition: r_rast.c:38
RF_FULLBRIGHT
#define RF_FULLBRIGHT
Definition: q_shared.h:616
alight_t
Definition: r_local.h:333
R_AliasPreparePoints
void R_AliasPreparePoints(void)
Definition: r_alias.c:238
daliasframe_t
Definition: qfiles.h:119
aliastransform
float aliastransform[3][4]
Definition: r_alias.c:50
daliasframe_t::verts
dtrivertx_t verts[1]
Definition: qfiles.h:124
aliastriangleparms_t::c
finalvert_t * c
Definition: r_local.h:712
aliasyscale
float aliasyscale
Definition: r_local.h:702
aliastriangleparms
aliastriangleparms_t aliastriangleparms
Definition: r_polyse.c:59
R_AliasSetupLighting
void R_AliasSetupLighting(void)
Definition: r_alias.c:874
RF_SHELL_BLUE
#define RF_SHELL_BLUE
Definition: q_shared.h:625
s_ziscale
static float s_ziscale
Definition: r_alias.c:54
R_AliasTransformVector
void R_AliasTransformVector(vec3_t in, vec3_t out, float m[3][4])
Definition: r_alias.c:213
dmdl_t::ofs_st
int ofs_st
Definition: qfiles.h:154
image_s
Definition: r_local.h:65
R_ConcatTransforms
void R_ConcatTransforms(float in1[3][4], float in2[3][4], float out[3][4])
Definition: q_shared.c:219
r_aliasblendcolor
int r_aliasblendcolor
Definition: r_alias.c:43
dmdl_t::ofs_tris
int ofs_tris
Definition: qfiles.h:155
affinetridesc_t::skinheight
int skinheight
Definition: r_local.h:308
aliasbatchedtransformdata_t::last_verts
dtrivertx_t * last_verts
Definition: r_alias.c:231
r_lerp_frontv
vec3_t r_lerp_frontv
Definition: r_alias.c:40
r_avertexnormals
float r_avertexnormals[NUMVERTEXNORMALS][3]
Definition: r_alias.c:60
VID_GRADES
#define VID_GRADES
Definition: r_local.h:153
dtriangle_t
Definition: qfiles.h:101
r_lerp_move
vec3_t r_lerp_move
Definition: r_alias.c:40
r_ambientlight
int r_ambientlight
Definition: r_alias.c:42
vpn
vec3_t vpn
Definition: r_main.c:67
entity_s::oldorigin
float oldorigin[3]
Definition: ref.h:63
oldrefdef_t::aliasvrect
vrect_t aliasvrect
Definition: r_local.h:114
BBOX_TRIVIAL_REJECT
#define BBOX_TRIVIAL_REJECT
Definition: r_alias.c:83
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:127
VID_CBITS
#define VID_CBITS
Definition: r_local.h:152
dmdl_t
Definition: qfiles.h:137
entity_s::angles
float angles[3]
Definition: ref.h:52
r_refdef
oldrefdef_t r_refdef
Definition: r_main.c:74
void
void(APIENTRY *qglAccum)(GLenum op
dmdl_t::num_frames
int num_frames
Definition: qfiles.h:151
s_alias_right
static vec3_t s_alias_right
Definition: r_alias.c:55
alight_t::ambientlight
int ambientlight
Definition: r_local.h:334
s_pmdl
dmdl_t * s_pmdl
Definition: r_alias.c:48
affinetridesc_t::pskin
void * pskin
Definition: r_local.h:305
vrect_s::y
int y
Definition: vid.h:24
MAXALIASVERTS
#define MAXALIASVERTS
Definition: r_local.h:226
BBOX_TRIVIAL_ACCEPT
#define BBOX_TRIVIAL_ACCEPT
Definition: r_alias.c:80
ALIAS_RIGHT_CLIP
#define ALIAS_RIGHT_CLIP
Definition: r_local.h:205
r_lerp_backv
vec3_t r_lerp_backv
Definition: r_alias.c:40