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

Function DrawVisRainDrop

Descent3/viseffect.cpp:1083–1140  ·  view source on GitHub ↗

Draws a raindrop on the players windshield

Source from the content-addressed store, hash-verified

1081
1082// Draws a raindrop on the players windshield
1083void DrawVisRainDrop(vis_effect *vis) {
1084 float norm_time;
1085 float time_live = Gametime - vis->creation_time;
1086 float size = vis->size;
1087
1088 int visnum = vis - VisEffects;
1089 int bm_handle;
1090 fireball *fb = &Fireballs[vis->id];
1091
1092 norm_time = time_live / vis->lifetime;
1093
1094 if (norm_time >= 1)
1095 norm_time = .99999f; // don't go over!
1096
1097 size *= (1 - (norm_time / 2));
1098
1099 bm_handle = fb->bm_handle;
1100
1101 float val;
1102 if (norm_time > .5)
1103 val = 1.0 - ((norm_time - .5) / .5);
1104 else if (norm_time < .1)
1105 val = norm_time / .1;
1106 else
1107 val = 1.0;
1108
1109 rend_SetAlphaValue(val * .4 * 255);
1110 rend_SetOverlayType(OT_NONE);
1111 rend_SetWrapType(WT_CLAMP);
1112 rend_SetLighting(LS_NONE);
1113
1114 // Set position
1115 vector pos;
1116
1117 if (vis->id == RAINDROP_INDEX) {
1118 rend_SetZBufferState(0);
1119 rend_SetAlphaType(AT_SATURATE_TEXTURE);
1120 rend_SetAlphaValue(val * .4 * 255);
1121
1122 pos = Viewer_object->pos;
1123 pos += Viewer_object->orient.rvec * vis->pos.x;
1124 pos += Viewer_object->orient.uvec * vis->pos.y;
1125 pos += Viewer_object->orient.fvec * vis->pos.z;
1126 g3_DrawRotatedBitmap(&pos, 0, size, (size * bm_h(bm_handle, 0)) / bm_w(bm_handle, 0), bm_handle);
1127 rend_SetZBufferState(1);
1128 } else {
1129 rend_SetAlphaType(AT_SATURATE_TEXTURE);
1130 rend_SetAlphaValue(val * .2 * 255);
1131 rend_SetZBufferWriteMask(0);
1132 pos = vis->pos;
1133 ASSERT(!((vis->end_pos.x == 0.0) && (vis->end_pos.y == 0.0) && (vis->end_pos.z == 0.0)));
1134 g3_DrawPlanarRotatedBitmap(&pos, &vis->end_pos, 0, size, (size * bm_h(bm_handle, 0)) / bm_w(bm_handle, 0),
1135 bm_handle);
1136 rend_SetZBufferWriteMask(1);
1137 }
1138
1139 rend_SetWrapType(WT_WRAP);
1140}

Callers 1

DrawVisEffectFunction · 0.85

Calls 11

g3_DrawRotatedBitmapFunction · 0.85
bm_hFunction · 0.85
bm_wFunction · 0.85
rend_SetAlphaValueFunction · 0.50
rend_SetOverlayTypeFunction · 0.50
rend_SetWrapTypeFunction · 0.50
rend_SetLightingFunction · 0.50
rend_SetZBufferStateFunction · 0.50
rend_SetAlphaTypeFunction · 0.50
rend_SetZBufferWriteMaskFunction · 0.50

Tested by

no test coverage detected