From d3c8df87bf415eaa4de0696999e8e9073b803931 Mon Sep 17 00:00:00 2001 From: Lucas GAUTHERON Date: Sat, 14 May 2011 12:12:28 +0000 Subject: [PATCH] map overview spectate mode ? git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6425 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/entity.h | 2 +- source/src/rendergl.cpp | 34 +++++++++++++++++++++++++++++++++- source/src/worldrender.cpp | 2 +- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/source/src/entity.h b/source/src/entity.h index 7c2f0251..be409a43 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -91,7 +91,7 @@ static inline const char *team_string(int t, bool abbr = false) { const char **n enum { ENT_PLAYER = 0, ENT_BOT, ENT_CAMERA, ENT_BOUNCE }; enum { CS_ALIVE = 0, CS_DEAD, CS_SPAWNING, CS_LAGGED, CS_EDITING, CS_SPECTATE }; enum { CR_DEFAULT = 0, CR_ADMIN }; -enum { SM_NONE = 0, SM_DEATHCAM, SM_FOLLOW1ST, SM_FOLLOW3RD, SM_FOLLOW3RD_TRANSPARENT, SM_FLY, SM_NUM }; +enum { SM_NONE = 0, SM_DEATHCAM, SM_FOLLOW1ST, SM_FOLLOW3RD, SM_FOLLOW3RD_TRANSPARENT, SM_FLY, SM_OVERVIEW, SM_NUM }; enum { FPCN_VOID = -3, FPCN_DEATHCAM = -2, FPCN_FLY = -1 }; class worldobject diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index f58da153..eeb11835 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -490,6 +490,27 @@ void recomputecamera() resetcamera(); camera1->eyeheight = 1.0f; break; + case SM_OVERVIEW: + { + // WIP, might not be released.. + // FIXME : bad feeling with walls ATM because of perspective + /*camera1->yaw = 0; + camera1->pitch = -90; + camera1->o.x = mapdims[0] + mapdims[4]/2; + camera1->o.y = mapdims[1] + mapdims[5]/2; + camera1->o.z = vec(mapdims[4]/2.0f, mapdims[5]/2.0f, 0.0f).magnitude() / tan( (spectfov - 10) * RAD /2.0f);*/ + // from drawminimap... + camera1->reset(); + camera1->type = ENT_CAMERA; + camera1->o.x = mapdims[0] + mapdims[4]/2; + camera1->o.y = mapdims[1] + mapdims[5]/2; + camera1->o.z = mapdims[7] + 1; + camera1->pitch = -90; + camera1->yaw = 0; + + disableraytable(); + break; + } case SM_FOLLOW1ST: { playerent *f = updatefollowplayer(); @@ -815,7 +836,17 @@ VARP(spechudgun, 0, 1, 1); void setperspective(float fovy, float aspect, float nearplane, float farplane) { GLdouble ydist = nearplane * tan(fovy/2*RAD), xdist = ydist * aspect; - glFrustum(-xdist, xdist, -ydist, ydist, nearplane, farplane); + if(player1->isspectating() && player1->spectatemode == SM_OVERVIEW) + { + int gdim = max(mapdims[4], mapdims[5]); + if(!gdim) gdim = ssize/2; + int orthd = 2 + gdim/2; + glOrtho(-orthd, orthd, -orthd, orthd, 0, (mapdims[7]-mapdims[6])+2); // depth of map +2 covered + } + else + { + glFrustum(-xdist, xdist, -ydist, ydist, nearplane, farplane); + } } void sethudgunperspective(bool on) @@ -975,6 +1006,7 @@ void gl_drawframe(int w, int h, float changelod, float curfps) renderstrips(); + xtraverts = 0; startmodelbatches(); diff --git a/source/src/worldrender.cpp b/source/src/worldrender.cpp index 3ef409f7..2d6b5959 100644 --- a/source/src/worldrender.cpp +++ b/source/src/worldrender.cpp @@ -270,7 +270,7 @@ void distlod(int &low, int &high, int angle, float widef) void render_world(float vx, float vy, float vh, float changelod, int yaw, int pitch, float fov, float fovy, int w, int h) { loopi(LARGEST_FACTOR) stats[i] = 0; - min_lod = minimap ? MAX_LOD : MIN_LOD+abs(pitch)/12; + min_lod = minimap || (player1->isspectating() && player1->spectatemode == SM_OVERVIEW) ? MAX_LOD : MIN_LOD+abs(pitch)/12; yaw = 360-yaw; float widef = fov/75.0f; int cdist = abs(yaw%90-45);