]> git.rm.cloudns.org Git - voretournament/voretournament.git/commitdiff
Colorize the screen when inside water or other fluids (code ported back from Xonotic)
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 25 Feb 2011 20:35:40 +0000 (22:35 +0200)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 25 Feb 2011 20:35:40 +0000 (22:35 +0200)
data/defaultVoretournament.cfg
data/qcsrc/client/View.qc

index 5a2a208d68a573fc95b04e718856042fc22658e5..0c88250b4a84c91e154d3593100358628afaff03 100644 (file)
@@ -1059,6 +1059,17 @@ con_chatwidth 0.6
 con_notifysize 10\r
 con_notifyalign 0\r
 \r
+seta hud_contents 1 "an improved version of gl_polyblend for liquids such as water/lava/slime, draw a filler when inside the liquid"\r
+seta hud_contents_factor 1 "factor at which to multiply the current faded value."\r
+seta hud_contents_fadeintime 0.02 "factor of time it takes for the alpha level to reach normal value when entering the liquid"\r
+seta hud_contents_fadeouttime 0.1 "factor of time it takes for the alpha level to reach normal value when leaving the liquid"\r
+seta hud_contents_lava_alpha 0.7 "alpha of the lava color blend when inside it"\r
+seta hud_contents_lava_color "0.8 0.1 0" \r
+seta hud_contents_slime_alpha 0.7 "alpha of the slime color blend when inside it"\r
+seta hud_contents_slime_color "0 0.4 0.1"\r
+seta hud_contents_water_alpha 0.5 "alpha of the water color blend when inside it"\r
+seta hud_contents_water_color "0.4 0.3 0.3"\r
+\r
 sbar_info_pos 50\r
 seta sbar_alpha_bg 0.8 "alpha value of the HUD background"\r
 seta sbar_alpha_fg 1 "alpha value of the HUD foreground items"\r
index 9ae5a03b4ab6b1a2afdd22d3126003213a2e12d4..37090311ca38342258b94c9451e20733d5f00eb9 100644 (file)
@@ -253,6 +253,8 @@ float camera_mode;
 float chase_active_old;\r
 float artwork_fade;\r
 float pickup_crosshair_time, pickup_crosshair_size;\r
+float contentavgalpha, liquidalpha_prev;\r
+vector liquidcolor_prev;\r
 string artwork_image;\r
 string intermission_song;\r
 string NextFrameCommand;\r
@@ -451,6 +453,54 @@ void CSQC_UpdateView(float w, float h)
        // next R_RenderScene call\r
        drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0);\r
 \r
+       if(cvar("hud_contents"))\r
+       {\r
+               float contentalpha_temp, incontent, liquidalpha, contentfadetime;\r
+               vector liquidcolor;\r
+               \r
+               switch(pointcontents(view_origin))\r
+               {\r
+                       case CONTENT_WATER:\r
+                               liquidalpha = cvar("hud_contents_water_alpha");\r
+                               liquidcolor = stov(cvar_string("hud_contents_water_color"));\r
+                               incontent = 1;\r
+                               break;\r
+                               \r
+                       case CONTENT_LAVA:\r
+                               liquidalpha = cvar("hud_contents_lava_alpha");\r
+                               liquidcolor = stov(cvar_string("hud_contents_lava_color"));\r
+                               incontent = 1;\r
+                               break;  \r
+                                                       \r
+                       case CONTENT_SLIME:\r
+                               liquidalpha = cvar("hud_contents_slime_alpha");\r
+                               liquidcolor = stov(cvar_string("hud_contents_slime_color"));\r
+                               incontent = 1;\r
+                               break;\r
+                               \r
+                       default:\r
+                               liquidalpha = 0;\r
+                               liquidcolor = '0 0 0';\r
+                               incontent = 0;\r
+                               break;\r
+               }\r
+               \r
+               if(incontent) // fade in/out at different speeds so you can do e.g. instant fade when entering water and slow when leaving it.\r
+               { // also lets delcare previous values for blending properties, this way it isn't reset until after you have entered a different content\r
+                       contentfadetime = cvar("hud_contents_fadeintime");\r
+                       liquidalpha_prev = liquidalpha;\r
+                       liquidcolor_prev = liquidcolor;\r
+               }\r
+               else\r
+                       contentfadetime = cvar("hud_contents_fadeouttime");\r
+                       \r
+               contentalpha_temp = bound(0, drawframetime / max(0.0001, contentfadetime), 1);\r
+               contentavgalpha = contentavgalpha * (1 - contentalpha_temp) + incontent * contentalpha_temp;\r
+               \r
+               if(contentavgalpha)\r
+                       drawfill('0 0 0', '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, liquidcolor_prev, contentavgalpha * liquidalpha_prev, DRAWFLAG_NORMAL);\r
+       }\r
+\r
        // Draw the mouse cursor\r
        // NOTE: drawpic must happen after R_RenderScene for some reason\r
        //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);\r