MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DrawThrusterEffect

Function DrawThrusterEffect

model/newstyle.cpp:624–674  ·  view source on GitHub ↗

Draws a glowing cone of light that represents thrusters

Source from the content-addressed store, hash-verified

622
623// Draws a glowing cone of light that represents thrusters
624void DrawThrusterEffect(vector *pos, float r, float g, float b, vector *norm, float size, float length) {
625 vector cur_pos = *pos;
626 float cur_length = 0;
627 vector glow_pos[MAX_PARTS];
628 float glow_size[MAX_PARTS];
629 int total_parts = 0;
630
631 if (length < .1)
632 return;
633
634 int num_divs = length * 3;
635 if (num_divs > MAX_PARTS)
636 num_divs = MAX_PARTS;
637
638 float size_change = size / num_divs;
639 float pos_change = length / num_divs;
640
641 if (!UseHardware)
642 return; // No software stuff here!
643
644 rend_SetZBufferWriteMask(0);
645 rend_SetAlphaType(AT_SATURATE_TEXTURE);
646 rend_SetAlphaValue(.3 * 255);
647
648 rend_SetLighting(LS_GOURAUD);
649 rend_SetColorModel(CM_RGB);
650
651 ddgr_color color = GR_RGB(r * 255, g * 255, b * 255);
652 int bm_handle = Fireballs[GRADIENT_BALL_INDEX].bm_handle;
653 int t;
654
655 // We must draw the small ones first, but we're starting the iteration from the
656 // large one. Consequently, we must store our variables so we can draw in reverse order
657 for (t = 0; t < num_divs && size > .05; t++) {
658 glow_pos[t] = cur_pos;
659 glow_size[t] = size;
660
661 size -= size_change;
662 cur_pos += ((*norm) * pos_change);
663
664 total_parts++;
665 }
666
667 for (t = total_parts - 1; t >= 0; t--) {
668 rend_SetZBias(-glow_size[t]);
669 g3_DrawBitmap(&glow_pos[t], glow_size[t], (glow_size[t] * bm_h(bm_handle, 0)) / bm_w(bm_handle, 0), bm_handle,
670 color);
671 }
672 rend_SetZBias(0.0);
673 rend_SetZBufferWriteMask(1);
674}
675
676// Draws a glowing cone of light
677void DrawGlowEffect(vector *pos, float r, float g, float b, vector *norm, float size) {

Callers 1

RenderSubmodelFunction · 0.85

Calls 10

g3_DrawBitmapFunction · 0.85
bm_hFunction · 0.85
bm_wFunction · 0.85
rend_SetZBufferWriteMaskFunction · 0.50
rend_SetAlphaTypeFunction · 0.50
rend_SetAlphaValueFunction · 0.50
rend_SetLightingFunction · 0.50
rend_SetColorModelFunction · 0.50
GR_RGBFunction · 0.50
rend_SetZBiasFunction · 0.50

Tested by

no test coverage detected