MCPcopy Create free account
hub / github.com/demoth/jake2 / R_DrawBeam

Method R_DrawBeam

client/src/main/java/jake2/client/render/fast/Main.java:1481–1544  ·  view source on GitHub ↗

R_DrawBeam

(entity_t e)

Source from the content-addressed store, hash-verified

1479 * R_DrawBeam
1480 */
1481 void R_DrawBeam(entity_t e) {
1482 oldorigin[0] = e.oldorigin[0];
1483 oldorigin[1] = e.oldorigin[1];
1484 oldorigin[2] = e.oldorigin[2];
1485
1486 origin[0] = e.origin[0];
1487 origin[1] = e.origin[1];
1488 origin[2] = e.origin[2];
1489
1490 normalized_direction[0] = direction[0] = oldorigin[0] - origin[0];
1491 normalized_direction[1] = direction[1] = oldorigin[1] - origin[1];
1492 normalized_direction[2] = direction[2] = oldorigin[2] - origin[2];
1493
1494 if (Math3D.VectorNormalize(normalized_direction) == 0.0f)
1495 return;
1496
1497 Math3D.PerpendicularVector(perpvec, normalized_direction);
1498 Math3D.VectorScale(perpvec, e.frame / 2, perpvec);
1499
1500 for (int i = 0; i < 6; i++) {
1501 Math3D.RotatePointAroundVector(
1502 start_points[i],
1503 normalized_direction,
1504 perpvec,
1505 (360.0f / NUM_BEAM_SEGS) * i);
1506
1507 Math3D.VectorAdd(start_points[i], origin, start_points[i]);
1508 Math3D.VectorAdd(start_points[i], direction, end_points[i]);
1509 }
1510
1511 gl.glDisable(GL_TEXTURE_2D);
1512 gl.glEnable(GL_BLEND);
1513 gl.glDepthMask(false);
1514
1515 float r = (d_8to24table[e.skinnum & 0xFF]) & 0xFF;
1516 float g = (d_8to24table[e.skinnum & 0xFF] >> 8) & 0xFF;
1517 float b = (d_8to24table[e.skinnum & 0xFF] >> 16) & 0xFF;
1518
1519 r *= 1 / 255.0f;
1520 g *= 1 / 255.0f;
1521 b *= 1 / 255.0f;
1522
1523 gl.glColor4f(r, g, b, e.alpha);
1524
1525 gl.glBegin(GL_TRIANGLE_STRIP);
1526
1527 float[] v;
1528
1529 for (int i = 0; i < NUM_BEAM_SEGS; i++) {
1530 v = start_points[i];
1531 gl.glVertex3f(v[0], v[1], v[2]);
1532 v = end_points[i];
1533 gl.glVertex3f(v[0], v[1], v[2]);
1534 v = start_points[(i + 1) % NUM_BEAM_SEGS];
1535 gl.glVertex3f(v[0], v[1], v[2]);
1536 v = end_points[(i + 1) % NUM_BEAM_SEGS];
1537 gl.glVertex3f(v[0], v[1], v[2]);
1538 }

Callers 1

R_DrawEntitiesOnListMethod · 0.95

Calls 12

VectorNormalizeMethod · 0.95
PerpendicularVectorMethod · 0.95
VectorScaleMethod · 0.95
VectorAddMethod · 0.95
glDisableMethod · 0.65
glEnableMethod · 0.65
glDepthMaskMethod · 0.65
glColor4fMethod · 0.65
glBeginMethod · 0.65
glVertex3fMethod · 0.65
glEndMethod · 0.65

Tested by

no test coverage detected