]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Better perspective effect for SPR_OVERHEAD, added global xy scale for them.
authorvortex <vortex@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 2 Jan 2011 16:48:22 +0000 (16:48 +0000)
committervortex <vortex@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 2 Jan 2011 16:48:22 +0000 (16:48 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10689 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c
r_sprites.c

index 6dd046ededd7a1b88417564f0948fd2a50f7e42e..1ec229b7564ce6948e43fb5dfab7d8048ad05fe4 100644 (file)
@@ -189,8 +189,10 @@ cvar_t r_track_sprites = {CVAR_SAVE, "r_track_sprites", "1", "track SPR_LABEL* s
 cvar_t r_track_sprites_flags = {CVAR_SAVE, "r_track_sprites_flags", "1", "1: Rotate sprites accodringly, 2: Make it a continuous rotation"};
 cvar_t r_track_sprites_scalew = {CVAR_SAVE, "r_track_sprites_scalew", "1", "width scaling of tracked sprites"};
 cvar_t r_track_sprites_scaleh = {CVAR_SAVE, "r_track_sprites_scaleh", "1", "height scaling of tracked sprites"};
-cvar_t r_overheadsprites_perspective = {CVAR_SAVE, "r_overheadsprites_perspective", "0.15", "fake perspective effect for SPR_OVERHEAD sprites"};
-cvar_t r_overheadsprites_pushback = {CVAR_SAVE, "r_overheadsprites_pushback", "16", "how far to pull the SPR_OVERHEAD sprites toward the eye (used to avoid intersections with 3D models)"};
+cvar_t r_overheadsprites_perspective = {CVAR_SAVE, "r_overheadsprites_perspective", "5", "fake perspective effect for SPR_OVERHEAD sprites"};
+cvar_t r_overheadsprites_pushback = {CVAR_SAVE, "r_overheadsprites_pushback", "15", "how far to pull the SPR_OVERHEAD sprites toward the eye (used to avoid intersections with 3D models)"};
+cvar_t r_overheadsprites_scalex = {CVAR_SAVE, "r_overheadsprites_scalex", "1", "additional scale for overhead sprites for x axis"};
+cvar_t r_overheadsprites_scaley = {CVAR_SAVE, "r_overheadsprites_scaley", "1", "additional scale for overhead sprites for y axis"};
 
 cvar_t r_glsl_saturation = {CVAR_SAVE, "r_glsl_saturation", "1", "saturation multiplier (only working in glsl!)"};
 cvar_t r_glsl_saturation_redcompensate = {CVAR_SAVE, "r_glsl_saturation_redcompensate", "0", "a 'vampire sight' addition to desaturation effect, does compensation for red color, r_glsl_restart is required"};
@@ -7450,6 +7452,8 @@ void GL_Main_Init(void)
        Cvar_RegisterVariable(&r_track_sprites_scaleh);
        Cvar_RegisterVariable(&r_overheadsprites_perspective);
        Cvar_RegisterVariable(&r_overheadsprites_pushback);
+       Cvar_RegisterVariable(&r_overheadsprites_scalex);
+       Cvar_RegisterVariable(&r_overheadsprites_scaley);
 }
 
 extern void R_Textures_Init(void);
index 02348b373c73b308e78365f50f41254f07c18941..8f416b47b6e665d430c15da4fb879ff315ba8815 100644 (file)
@@ -10,6 +10,8 @@ extern cvar_t r_track_sprites_scalew;
 extern cvar_t r_track_sprites_scaleh;
 extern cvar_t r_overheadsprites_perspective;
 extern cvar_t r_overheadsprites_pushback;
+extern cvar_t r_overheadsprites_scalex;
+extern cvar_t r_overheadsprites_scaley;
 
 #define TSF_ROTATE 1
 #define TSF_ROTATE_CONTINOUSLY 2
@@ -356,20 +358,22 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r
                up[2] = mup[0] * r_refdef.view.forward[2] + mup[1] * r_refdef.view.left[2] + mup[2] * r_refdef.view.up[2];
                break;
        case SPR_OVERHEAD:
-               VectorScale(r_refdef.view.left, ent->scale, left);
-               VectorScale(r_refdef.view.up, ent->scale, up);
-               // offset
-               VectorCopy(r_refdef.view.up, up);
-               up[2] = up[2] + r_overheadsprites_perspective.value; VectorNormalize(up); // some rotation
-               VectorScale(up, ent->scale, up);
-               // offset (move nearer to player, yz is camera plane)
-               VectorSubtract(r_refdef.view.origin, org, middle);
+               // Overhead games sprites, have some special hacks to look good
+               VectorScale(r_refdef.view.left, ent->scale * r_overheadsprites_scalex.value, left);
+               VectorScale(r_refdef.view.up, ent->scale * r_overheadsprites_scaley.value, up);
+               VectorSubtract(org, r_refdef.view.origin, middle);
                VectorNormalize(middle);
-               org[0] = org[0] + middle[0]*r_overheadsprites_pushback.value;
-               org[1] = org[1] + middle[1]*r_overheadsprites_pushback.value;
-               org[2] = org[2] + middle[2]*r_overheadsprites_pushback.value;
-                // simlulate a bit of perspective effect
-               up[2] = up[2] + r_overheadsprites_perspective.value;
+               // offset and rotate
+               dir_angle = r_overheadsprites_perspective.value * (1 - fabs(DotProduct(middle, r_refdef.view.forward)));
+               up[2] = up[2] + dir_angle;
+               VectorNormalize(up);
+               VectorScale(up, ent->scale * r_overheadsprites_scaley.value, up);
+               // offset (move nearer to player, yz is camera plane)
+               org[0] = org[0] - middle[0]*r_overheadsprites_pushback.value;
+               org[1] = org[1] - middle[1]*r_overheadsprites_pushback.value;
+               org[2] = org[2] - middle[2]*r_overheadsprites_pushback.value;
+               // little perspective effect
+               up[2] = up[2] + dir_angle * 0.3;
                break;
        }
 
@@ -383,7 +387,7 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r
                        RSurf_ActiveCustomEntity(&identitymatrix, &identitymatrix, ent->flags, 0, ent->colormod[0], ent->colormod[1], ent->colormod[2], ent->alpha * ent->frameblend[i].lerp, 4, vertex3f, spritetexcoord2f, NULL, NULL, NULL, NULL, 2, polygonelement3i, polygonelement3s, false, false);
                        frame = model->sprite.sprdata_frames + ent->frameblend[i].subframe;
                        texture = R_GetCurrentTexture(model->data_textures + ent->frameblend[i].subframe);
-
+               
                        // lit sprite by lightgrid if it is not fullbright, lit only ambient
                        if (!(texture->currentmaterialflags & MATERIALFLAG_FULLBRIGHT))
                                VectorAdd(ent->modellight_ambient, ent->modellight_diffuse, rsurface.modellight_ambient); // sprites dont use lightdirection