From e5b201e7175b0c9bd5676115ea41693b4e3b55cb Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 17 Sep 2002 21:27:46 +0000 Subject: [PATCH] added R_CalcBeamVerts function, calculates vertex array for beam polygon git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2385 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 30 ++++++++++++++++++++++++++++++ render.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/gl_rmain.c b/gl_rmain.c index 0b211789..56b902ad 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -823,3 +823,33 @@ void R_DrawNoModel(entity_render_t *ent) // R_DrawNoModelCallback(ent, 0); } +void R_CalcBeamVerts (float *vert, vec3_t org1, vec3_t org2, float width) +{ + vec3_t right1, right2, diff, normal; + + VectorSubtract (org2, org1, normal); + VectorNormalizeFast (normal); + + // calculate 'right' vector for start + VectorSubtract (r_origin, org1, diff); + VectorNormalizeFast (diff); + CrossProduct (normal, diff, right1); + + // calculate 'right' vector for end + VectorSubtract (r_origin, org2, diff); + VectorNormalizeFast (diff); + CrossProduct (normal, diff, right2); + + vert[ 0] = org1[0] + width * right1[0]; + vert[ 1] = org1[1] + width * right1[1]; + vert[ 2] = org1[2] + width * right1[2]; + vert[ 4] = org1[0] - width * right1[0]; + vert[ 5] = org1[1] - width * right1[1]; + vert[ 6] = org1[2] - width * right1[2]; + vert[ 8] = org2[0] - width * right2[0]; + vert[ 9] = org2[1] - width * right2[1]; + vert[10] = org2[2] - width * right2[2]; + vert[12] = org2[0] + width * right2[0]; + vert[13] = org2[1] + width * right2[1]; + vert[14] = org2[2] + width * right2[2]; +} diff --git a/render.h b/render.h index 720a4564..76400a72 100644 --- a/render.h +++ b/render.h @@ -172,5 +172,7 @@ void R_Stain (vec3_t origin, float radius, int cr1, int cg1, int cb1, int ca1, i void R_DrawCrosshair(void); +void R_CalcBeamVerts (float *vert, vec3_t org1, vec3_t org2, float width); + #endif -- 2.39.2