3 void R_ClipSpriteImage (msprite_t *psprite, vec3_t origin, vec3_t right, vec3_t up)
8 float fleft, fright, fdown, fup;
9 frame = ((mspriteframe_t *)(psprite->ofs_frames + (int) psprite)) + currentrenderentity->frameblend[0].frame;
12 fright = frame->right;
14 for (i = 1;i < 4 && currentrenderentity->frameblend[i].lerp;i++)
16 frame = ((mspriteframe_t *)(psprite->ofs_frames + (int) psprite)) + currentrenderentity->frameblend[i].frame;
17 fleft = min(fleft , frame->left );
18 fdown = min(fdown , frame->down );
19 fright = max(fright, frame->right);
20 fup = max(fup , frame->up );
22 points[0][0] = origin[0] + fdown * up[0] + fleft * right[0];points[0][1] = origin[1] + fdown * up[1] + fleft * right[1];points[0][2] = origin[2] + fdown * up[2] + fleft * right[2];
23 points[1][0] = origin[0] + fup * up[0] + fleft * right[0];points[1][1] = origin[1] + fup * up[1] + fleft * right[1];points[1][2] = origin[2] + fup * up[2] + fleft * right[2];
24 points[2][0] = origin[0] + fup * up[0] + fright * right[0];points[2][1] = origin[1] + fup * up[1] + fright * right[1];points[2][2] = origin[2] + fup * up[2] + fright * right[2];
25 points[3][0] = origin[0] + fdown * up[0] + fright * right[0];points[3][1] = origin[1] + fdown * up[1] + fright * right[1];points[3][2] = origin[2] + fdown * up[2] + fright * right[2];
26 R_Clip_AddPolygon(&points[0][0], 4, sizeof(float[3]), false, R_Entity_Callback, currentrenderentity, NULL, NULL);
29 int R_SpriteSetup (int type, float org[3], float right[3], float up[3])
31 float matrix1[3][3], matrix2[3][3], matrix3[3][3];
33 VectorCopy(currentrenderentity->origin, org);
36 case SPR_VP_PARALLEL_UPRIGHT:
38 // vertical beam sprite, faces view plane
39 VectorNegate(vpn, matrix3[0]);
41 VectorNormalizeFast(matrix3[0]);
42 VectorVectors(matrix3[0], matrix3[1], matrix3[2]);
44 case SPR_FACING_UPRIGHT:
46 // vertical beam sprite, faces viewer's origin (not the view plane)
47 VectorSubtract(r_origin, currentrenderentity->origin, matrix3[0]);
49 VectorNormalizeFast(matrix3[0]);
50 VectorVectors(matrix3[0], matrix3[1], matrix3[2]);
53 Con_Printf("R_SpriteSetup: unknown sprite type %i\n", type);
54 // fall through to normal sprite
58 VectorCopy(vpn, matrix3[0]);
59 VectorCopy(vright, matrix3[1]);
60 VectorCopy(vup, matrix3[2]);
63 // bullet marks on walls
64 // ignores viewer entirely
65 AngleVectors (currentrenderentity->angles, matrix3[0], matrix3[1], matrix3[2]);
66 // nudge it toward the view, so it will be infront of the wall
67 VectorSubtract(org, vpn, org);
69 case SPR_VP_PARALLEL_ORIENTED:
70 // I have no idea what people would use this for
71 // oriented relative to view space
72 // FIXME: test this and make sure it mimicks software
73 AngleVectors (currentrenderentity->angles, matrix1[0], matrix1[1], matrix1[2]);
74 VectorCopy(vpn, matrix2[0]);
75 VectorCopy(vright, matrix2[1]);
76 VectorCopy(vup, matrix2[2]);
77 R_ConcatRotations (matrix1, matrix2, matrix3);
81 // don't draw if view origin is behind it
82 if (DotProduct(org, matrix3[0]) < (DotProduct(r_origin, matrix3[0]) - 1.0f))
85 if (currentrenderentity->scale != 1)
87 VectorScale(matrix3[1], currentrenderentity->scale, matrix3[1]);
88 VectorScale(matrix3[2], currentrenderentity->scale, matrix3[2]);
91 VectorCopy(matrix3[1], right);
92 VectorCopy(matrix3[2], up);
96 void R_ClipSprite (void)
98 vec3_t org, right, up;
101 if (currentrenderentity->frameblend[0].frame < 0)
104 psprite = Mod_Extradata(currentrenderentity->model);
105 if (R_SpriteSetup(psprite->type, org, right, up))
108 // LordHavoc: interpolated sprite rendering
109 R_ClipSpriteImage(psprite, org, right, up);
112 void GL_DrawSpriteImage (mspriteframe_t *frame, vec3_t origin, vec3_t up, vec3_t right, byte red, byte green, byte blue, int alpha)
115 alphaub = bound(0, alpha, 255);
116 transpolybegin(R_GetTexture(frame->texture), 0, R_GetTexture(frame->fogtexture), ((currentrenderentity->effects & EF_ADDITIVE) || (currentrenderentity->model->flags & EF_ADDITIVE)) ? TPOLYTYPE_ADD : TPOLYTYPE_ALPHA);
117 transpolyvertub(origin[0] + frame->down * up[0] + frame->left * right[0], origin[1] + frame->down * up[1] + frame->left * right[1], origin[2] + frame->down * up[2] + frame->left * right[2], 0, 1, red, green, blue, alphaub);
118 transpolyvertub(origin[0] + frame->up * up[0] + frame->left * right[0], origin[1] + frame->up * up[1] + frame->left * right[1], origin[2] + frame->up * up[2] + frame->left * right[2], 0, 0, red, green, blue, alphaub);
119 transpolyvertub(origin[0] + frame->up * up[0] + frame->right * right[0], origin[1] + frame->up * up[1] + frame->right * right[1], origin[2] + frame->up * up[2] + frame->right * right[2], 1, 0, red, green, blue, alphaub);
120 transpolyvertub(origin[0] + frame->down * up[0] + frame->right * right[0], origin[1] + frame->down * up[1] + frame->right * right[1], origin[2] + frame->down * up[2] + frame->right * right[2], 1, 1, red, green, blue, alphaub);
129 void R_DrawSpriteModel ()
132 vec3_t right, up, org, color;
136 if (currentrenderentity->frameblend[0].frame < 0)
139 psprite = Mod_Extradata(currentrenderentity->model);
140 if (R_SpriteSetup(psprite->type, org, right, up))
145 if ((currentrenderentity->model->flags & EF_FULLBRIGHT) || (currentrenderentity->effects & EF_FULLBRIGHT))
147 color[0] = currentrenderentity->colormod[0] * 255;
148 color[1] = currentrenderentity->colormod[1] * 255;
149 color[2] = currentrenderentity->colormod[2] * 255;
152 R_CompleteLightPoint(color, currentrenderentity->origin, true, NULL);
154 colorub[0] = bound(0, color[0], 255);
155 colorub[1] = bound(0, color[1], 255);
156 colorub[2] = bound(0, color[2], 255);
158 // LordHavoc: interpolated sprite rendering
159 for (i = 0;i < 4;i++)
160 if (currentrenderentity->frameblend[i].lerp)
161 GL_DrawSpriteImage(((mspriteframe_t *)(psprite->ofs_frames + (int) psprite)) + currentrenderentity->frameblend[i].frame, org, up, right, colorub[0],colorub[1],colorub[2], currentrenderentity->alpha*255*currentrenderentity->frameblend[i].lerp);