]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote-tracking branch 'origin/master' into samual/orthoview
authorSamual Lenks <samual@xonotic.org>
Thu, 26 Dec 2013 07:23:54 +0000 (02:23 -0500)
committerSamual Lenks <samual@xonotic.org>
Thu, 26 Dec 2013 07:23:54 +0000 (02:23 -0500)
defaultXonotic.cfg
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/autocvars.qh

index dd16de9bc6ee4224b900bf576cfc86ff8e5fce20..1c69e121a8a5550e53bfd683f604f8b6e66e95c1 100644 (file)
@@ -141,6 +141,10 @@ set rpn_linear_to_sRGB "dup 1.0 2.4 div pow 1.055 mul 0.055 sub exch 12.92 mul d
 // q3map_skylight 9.32523632 3
 alias skybox_nosRGB_to_sRGB "rpn $3 402.123 $4 div div $rpn_sRGB_to_linear 402.123 $4 div mul /new_skylight: $3 402.123 $4 div div $1 256 div $2 0.017453 mul sin mul add $rpn_sRGB_to_linear $3 402.123 $4 div div $rpn_sRGB_to_linear sub 256 mul $2 0.017453 mul sin div /new_sunlight:"
 
+set cl_orthoview 0 "WARNING: WILL BREAK CONFIG!!! enable top-down view of the map- meant to be used for radar map images"
+set cl_orthoview_nofog 1 "disable fog while in orthoview"
+set cl_orthoview_distanceoverride 0 "set to a value other than 0 to force a different distance offset when in orthoview"
+
 // these settings determine how much the view is affected by movement/damage
 cl_smoothviewheight 0.05 // time of the averaging to the viewheight value so that it creates a smooth transition for crouching and such. 0 for instant transition
 cl_deathfade 0 // fade screen to dark red when dead, value represents how fast the fade is (higher is faster)
index a06eb5e6584e3ac96f48c489b762ee748ce9a127..f43f2da29d6fe04af5ad1ce2d76bd59de03616c6 100644 (file)
@@ -921,8 +921,10 @@ void Fog_Force()
 {
        // TODO somehow thwart prvm_globalset client ...
 
-       if(forcefog != "")
-               localcmd(strcat(notranslate_fogcmd1, forcefog, notranslate_fogcmd2));
+       if(autocvar_cl_orthoview && autocvar_cl_orthoview_nofog)
+               { localcmd("\nr_drawfog 0\n"); }
+       else if(forcefog != "")
+               { localcmd(strcat(notranslate_fogcmd1, forcefog, notranslate_fogcmd2)); }
 }
 
 void Gamemode_Init();
index 8c9d59dd91f9a77e421d746a0b8193a8c449fb0f..4a22c30aed6b3dab7e221df6d94b82be9d6eadba 100644 (file)
@@ -199,6 +199,17 @@ vector GetCurrentFov(float fov)
        return '1 0 0' * fovx + '0 1 0' * fovy;
 }
 
+vector GetOrthoviewFOV(vector ov_worldmin, vector ov_worldmax, vector ov_mid, vector ov_org)
+{
+       float fovx, fovy;
+       float width = (ov_worldmax_x - ov_worldmin_x);
+       float height = (ov_worldmax_y - ov_worldmin_y);
+       float distance_to_middle_of_world = vlen(ov_mid - ov_org);
+       fovx = atan2(width/2, distance_to_middle_of_world) / M_PI * 360.0;
+       fovy = atan2(height/2, distance_to_middle_of_world) / M_PI * 360.0;
+       return '1 0 0' * fovx + '0 1 0' * fovy;
+}
+
 // this function must match W_SetupShot!
 float zoomscript_caught;
 
@@ -479,7 +490,7 @@ void CSQC_UpdateView(float w, float h)
        // event chase camera
        if(autocvar_chase_active <= 0) // greater than 0 means it's enabled manually, and this code is skipped
        {
-               if((spectatee_status >= 0 && (autocvar_cl_eventchase_death && is_dead)) || intermission)
+               if(((spectatee_status >= 0 && (autocvar_cl_eventchase_death && is_dead)) || intermission) && !autocvar_cl_orthoview)
                {
                        // make special vector since we can't use view_origin (It is one frame old as of this code, it gets set later with the results this code makes.)
                        vector current_view_origin = (csqcplayer ? csqcplayer.origin : pmove_org);
@@ -548,6 +559,61 @@ void CSQC_UpdateView(float w, float h)
        WarpZone_FixView();
        //WarpZone_FixPMove();
 
+       vector ov_org = '0 0 0';
+       vector ov_mid = '0 0 0';
+       vector ov_worldmin = '0 0 0';
+       vector ov_worldmax = '0 0 0';
+       if(autocvar_cl_orthoview)
+       {
+               #define FL2VEC(x,y,z) (('1 0 0' * x) + ('0 1 0' * y) + ('0 0 1' * z))
+
+               ov_worldmin = mi_picmin;
+               ov_worldmax = mi_picmax;
+               
+               float ov_width = (ov_worldmax_x - ov_worldmin_x);
+               float ov_height = (ov_worldmax_y - ov_worldmin_y);
+               float ov_distance = (512 * max(ov_width, ov_height));
+               if(autocvar_cl_orthoview_distanceoverride) { ov_distance = autocvar_cl_orthoview_distanceoverride; }
+               ov_mid = ((ov_worldmax + ov_worldmin) * 0.5);
+               ov_org = FL2VEC(ov_mid_x, ov_mid_y, (ov_mid_z + ov_distance));
+
+               float ov_nearest = vlen(ov_org - FL2VEC(
+                       bound(ov_worldmin_x, ov_org_x, ov_worldmax_x),
+                       bound(ov_worldmin_y, ov_org_y, ov_worldmax_y),
+                       bound(ov_worldmin_z, ov_org_z, ov_worldmax_z)
+               ));
+
+               float ov_furthest = 0;
+               float dist = 0;
+
+               if((dist = vlen(FL2VEC(ov_worldmin_x, ov_worldmin_y, ov_worldmin_z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
+               if((dist = vlen(FL2VEC(ov_worldmax_x, ov_worldmin_y, ov_worldmin_z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
+               if((dist = vlen(FL2VEC(ov_worldmin_x, ov_worldmax_y, ov_worldmin_z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
+               if((dist = vlen(FL2VEC(ov_worldmin_x, ov_worldmin_y, ov_worldmax_z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
+               if((dist = vlen(FL2VEC(ov_worldmax_x, ov_worldmax_y, ov_worldmin_z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
+               if((dist = vlen(FL2VEC(ov_worldmin_x, ov_worldmax_y, ov_worldmax_z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
+               if((dist = vlen(FL2VEC(ov_worldmax_x, ov_worldmin_y, ov_worldmax_z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
+               if((dist = vlen(FL2VEC(ov_worldmax_x, ov_worldmax_y, ov_worldmax_z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
+               
+               cvar_set("r_nearclip", ftos(ov_nearest));
+               cvar_set("r_farclip_base", ftos(ov_furthest));
+               cvar_set("r_farclip_world", "0");
+               cvar_set("r_useinfinitefarclip", "0");
+               
+               setproperty(VF_ORIGIN, ov_org);
+               setproperty(VF_ANGLES, '90 0 0');
+
+               /*if(autocvar_cl_orthoview_debug)
+               {
+                       print(sprintf("OrthoView: org = %s, angles = %s, distance = %f, nearest = %f, furthest = %f\n",
+                               vtos(ov_org),
+                               vtos(getpropertyvec(VF_ANGLES)),
+                               ov_distance,
+                               ov_nearest,
+                               ov_furthest));
+               }*/
+       }
+
        // Render the Scene
        view_origin = getpropertyvec(VF_ORIGIN);
        view_angles = getpropertyvec(VF_ANGLES);
@@ -689,7 +755,8 @@ void CSQC_UpdateView(float w, float h)
        vid_conheight = autocvar_vid_conheight;
        vid_pixelheight = autocvar_vid_pixelheight;
 
-       setproperty(VF_FOV, GetCurrentFov(fov));
+       if(autocvar_cl_orthoview) { setproperty(VF_FOV, GetOrthoviewFOV(ov_worldmin, ov_worldmax, ov_mid, ov_org)); }
+       else { setproperty(VF_FOV, GetCurrentFov(fov)); }
 
        // Camera for demo playback
        if(camera_active)
index 403792020ac7c7e08aa6a412f15abd5e98cffa9b..5ea1a65268b4e2298214381ba8756b2a018dd638 100644 (file)
@@ -54,6 +54,9 @@ float autocvar_cl_gunalign;
 float autocvar_cl_hidewaypoints;
 float autocvar_cl_lockview;
 float autocvar_cl_nogibs;
+float autocvar_cl_orthoview;
+float autocvar_cl_orthoview_nofog;
+float autocvar_cl_orthoview_distanceoverride;
 float autocvar_cl_particlegibs;
 float autocvar_cl_particles_oldnexbeam;
 float autocvar_cl_particles_quality;