vkQuake2 doxygen  1.0 dev
r_sprite.c
Go to the documentation of this file.
1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (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.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 */
20 // r_sprite.c
21 #include "r_local.h"
22 
23 extern polydesc_t r_polydesc;
24 
26 void R_PolygonCalculateGradients (void);
27 
28 extern void R_PolyChooseSpanletRoutine( float alpha, qboolean isturbulent );
29 
31 
32 extern void R_ClipAndDrawPoly( float alpha, qboolean isturbulent, qboolean textured );
33 
34 /*
35 ** R_DrawSprite
36 **
37 ** Draw currententity / currentmodel as a single texture
38 ** mapped polygon
39 */
40 void R_DrawSprite (void)
41 {
42  vec5_t *pverts;
43  vec3_t left, up, right, down;
44  dsprite_t *s_psprite;
45  dsprframe_t *s_psprframe;
46 
47 
48  s_psprite = (dsprite_t *)currentmodel->extradata;
49 #if 0
50  if (currententity->frame >= s_psprite->numframes
51  || currententity->frame < 0)
52  {
53  ri.Con_Printf (PRINT_ALL, "No such sprite frame %i\n",
55  currententity->frame = 0;
56  }
57 #endif
58  currententity->frame %= s_psprite->numframes;
59 
60  s_psprframe = &s_psprite->frames[currententity->frame];
61 
63  r_polydesc.pixel_width = s_psprframe->width;
64  r_polydesc.pixel_height = s_psprframe->height;
65  r_polydesc.dist = 0;
66 
67  // generate the sprite's axes, completely parallel to the viewplane.
71 
72 // build the sprite poster in worldspace
74  s_psprframe->width - s_psprframe->origin_x, right);
76  s_psprframe->height - s_psprframe->origin_y, up);
78  -s_psprframe->origin_x, left);
80  -s_psprframe->origin_y, down);
81 
82  // invert UP vector for sprites
84 
85  pverts = r_clip_verts[0];
86 
87  pverts[0][0] = r_entorigin[0] + up[0] + left[0];
88  pverts[0][1] = r_entorigin[1] + up[1] + left[1];
89  pverts[0][2] = r_entorigin[2] + up[2] + left[2];
90  pverts[0][3] = 0;
91  pverts[0][4] = 0;
92 
93  pverts[1][0] = r_entorigin[0] + up[0] + right[0];
94  pverts[1][1] = r_entorigin[1] + up[1] + right[1];
95  pverts[1][2] = r_entorigin[2] + up[2] + right[2];
96  pverts[1][3] = s_psprframe->width;
97  pverts[1][4] = 0;
98 
99  pverts[2][0] = r_entorigin[0] + down[0] + right[0];
100  pverts[2][1] = r_entorigin[1] + down[1] + right[1];
101  pverts[2][2] = r_entorigin[2] + down[2] + right[2];
102  pverts[2][3] = s_psprframe->width;
103  pverts[2][4] = s_psprframe->height;
104 
105  pverts[3][0] = r_entorigin[0] + down[0] + left[0];
106  pverts[3][1] = r_entorigin[1] + down[1] + left[1];
107  pverts[3][2] = r_entorigin[2] + down[2] + left[2];
108  pverts[3][3] = 0;
109  pverts[3][4] = s_psprframe->height;
110 
111  r_polydesc.nump = 4;
115 
118  R_ClipAndDrawPoly ( currententity->alpha, false, true );
119  else
120  R_ClipAndDrawPoly ( 1.0F, false, true );
122 }
123 
RF_TRANSLUCENT
#define RF_TRANSLUCENT
Definition: q_shared.h:604
currentmodel
model_t * currentmodel
Definition: r_main.c:39
MAXWORKINGVERTS
#define MAXWORKINGVERTS
Definition: r_local.h:167
ri
refimport_t ri
Definition: r_main.c:25
R_BuildPolygonFromSurface
void R_BuildPolygonFromSurface(msurface_t *fa)
Definition: r_poly.c:1160
dsprframe_t::height
int height
Definition: qfiles.h:176
vright
vec3_t vright
Definition: r_main.c:74
VectorScale
void VectorScale(vec3_t in, vec_t scale, vec3_t out)
Definition: q_shared.c:782
qboolean
qboolean
Definition: q_shared.h:63
modelorg
vec3_t modelorg
Definition: r_bsp.c:29
R_PolygonCalculateGradients
void R_PolygonCalculateGradients(void)
Definition: r_poly.c:1245
polydesc_t::pixel_width
int pixel_width
Definition: r_local.h:416
polydesc_t::stipple_parity
int stipple_parity
Definition: r_local.h:423
R_PolyChooseSpanletRoutine
void R_PolyChooseSpanletRoutine(float alpha, qboolean isturbulent)
entity_s::flags
int flags
Definition: ref.h:76
currententity
entity_t * currententity
Definition: r_bsp.c:28
r_local.h
polydesc_t::vpn
vec3_t vpn
Definition: r_local.h:418
polydesc_t::viewer_position
float viewer_position[3]
Definition: r_local.h:421
model_s::extradata
void * extradata
Definition: r_model.h:235
vup
vec3_t vup
Definition: r_main.c:72
r_clip_verts
vec5_t r_clip_verts[2][MAXWORKINGVERTS+2]
Definition: r_poly.c:52
dsprite_t
Definition: qfiles.h:181
polydesc_t::pixels
byte * pixels
Definition: r_local.h:415
polydesc_t::t_offset
float t_offset
Definition: r_local.h:420
refimport_t::Con_Printf
void(* Con_Printf)(int print_level, char *str,...)
Definition: ref.h:202
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:751
polydesc_t::s_offset
float s_offset
Definition: r_local.h:420
entity_s::alpha
float alpha
Definition: ref.h:73
polydesc_t::nump
int nump
Definition: r_local.h:413
polydesc_t::dist
float dist
Definition: r_local.h:419
r_polydesc
polydesc_t r_polydesc
Definition: r_poly.c:45
F
#define F(X, Y, Z)
Definition: md4.c:13
image_s::pixels
byte * pixels[4]
Definition: r_local.h:78
VectorInverse
void VectorInverse(vec3_t v)
Definition: q_shared.c:775
alpha
GLfloat GLfloat GLfloat alpha
Definition: qgl_win.c:74
dsprite_t::frames
dsprframe_t frames[1]
Definition: qfiles.h:185
dsprframe_t::width
int width
Definition: qfiles.h:176
entity_s::frame
int frame
Definition: ref.h:58
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:165
R_DrawSprite
void R_DrawSprite(void)
Definition: r_sprite.c:40
model_s::skins
image_t * skins[MAX_MD2SKINS]
Definition: r_model.h:234
up
static vec3_t up
Definition: p_view.c:29
polydesc_t
Definition: r_local.h:411
dsprite_t::numframes
int numframes
Definition: qfiles.h:184
dsprframe_t::origin_y
int origin_y
Definition: qfiles.h:177
polydesc_t::vup
vec3_t vup
Definition: r_local.h:418
vec5_t
vec_t vec5_t[5]
Definition: q_shared.h:135
msurface_s
Definition: r_model.h:93
dsprframe_t
Definition: qfiles.h:174
R_ClipAndDrawPoly
void R_ClipAndDrawPoly(float alpha, qboolean isturbulent, qboolean textured)
dsprframe_t::origin_x
int origin_x
Definition: qfiles.h:177
right
GLdouble right
Definition: qgl_win.c:159
r_entorigin
vec3_t r_entorigin
Definition: r_bsp.c:31
polydesc_t::pixel_height
int pixel_height
Definition: r_local.h:417
vpn
vec3_t vpn
Definition: r_main.c:73
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:134
polydesc_t::vright
vec3_t vright
Definition: r_local.h:418