Accurate local player positioning in minimap & radar views

other players needs to be checked

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6758 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Alejandro V. Garcia
2012-02-16 13:08:42 +00:00
parent 16c4b28914
commit 5e63720fb6
2 changed files with 54 additions and 24 deletions
+30 -6
View File
@@ -795,15 +795,23 @@ void drawminimap(int w, int h)
physent minicam;
camera1 = &minicam;
camera1->type = ENT_CAMERA;
camera1->o.x = mapdims[0] + mapdims[4]/2;
camera1->o.y = mapdims[1] + mapdims[5]/2;
int gdim = max(mapdims[4], mapdims[5]);
if(!gdim) gdim = ssize/2;
camera1->o.x = mapdims[0] + mapdims[4]/2.0f;
camera1->o.y = mapdims[1] + mapdims[5]/2.0f;
//float gdim = max(mapdims[4], mapdims[5])+2.0f; //make 1 cube smaller to give it a black edge
float gdim = max(mapdims[4], mapdims[5]); //no border
if(!gdim) gdim = ssize/2.0f;
camera1->o.z = mapdims[7] + 1;
camera1->pitch = -90;
camera1->yaw = 0;
int orthd = 2 + gdim/2;
glViewport(2, 2, size-4, size-4); // !not wsize here
//float orthd = 2 + gdim/2;
//glViewport(2, 2, size-4, size-4); // !not wsize here
float orthd = gdim/2.0f;
glViewport(0, 0, size, size); // !not wsize here
glClearDepth(0.0);
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // stencil added 2010jul22
@@ -830,6 +838,22 @@ void drawminimap(int w, int h)
resettmu(0);
float hf = hdr.waterlevel-0.3f;
renderwater(hf, 0, 0);
//draw a black border to prevent the minimap texture edges from bleeding in radarview
GLfloat prevLineWidth;
glGetFloatv(GL_LINE_WIDTH, &prevLineWidth);
glDisable(GL_BLEND);
glColor3f(0, 0, 0);
glLineWidth(2.0f);
glBegin(GL_LINE_LOOP);
glVertex3f(mapdims[0]+0.02f, mapdims[1]+0.02f, mapdims[7]);
glVertex3f(mapdims[0]+mapdims[4]-0.02f, mapdims[1]+0.02f, mapdims[7]);
glVertex3f(mapdims[0]+mapdims[4]-0.02f, mapdims[1]+mapdims[5]-0.02f, mapdims[7]);
glVertex3f(mapdims[0]+0.02f, mapdims[1]+mapdims[5]-0.02f, mapdims[7]);
glEnd();
glLineWidth(prevLineWidth);
glEnable(GL_BLEND);
camera1 = oldcam;
minimap = false;
glBindTexture(GL_TEXTURE_2D, minimaptex);
+24 -18
View File
@@ -404,17 +404,10 @@ VAR(showradarvalues, 0, 0, 1); // DEBUG
void drawradar_showmap(playerent *p, int w, int h)
{
int gdim = max(mapdims[4], mapdims[5]);
float radarviewsize = 3*min(VIRTW,VIRTH)/4;
float halfviewsize = radarviewsize/2.0f;
//float minimapviewsize = min(VIRTW,VIRTH); //minimapsize big size
float minimapviewsize = 3*min(VIRTW,VIRTH)/4; //minimap default size
float halfviewsize = minimapviewsize/2.0f;
float iconsize = radarentsize/0.2f;
int orthd = gdim/2;
int displace = radarviewsize/orthd;
float coordtrans = (radarviewsize-displace)/(gdim+3);
int offd = (abs(mapdims[5]-mapdims[4])/2)*coordtrans;
if(!gdim) { gdim = ssize/2; offd = 0; }
int offx = gdim==mapdims[5]?offd:0;
int offy = gdim==mapdims[4]?offd:0;
glColor3f(1.0f, 1.0f, 1.0f);
glPushMatrix();
extern GLuint minimaptex;
@@ -440,13 +433,25 @@ void drawradar_showmap(playerent *p, int w, int h)
}
glTranslatef(centerpos.x - halfviewsize, centerpos.y - halfviewsize , 0);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
quad(minimaptex, 0, 0, radarviewsize, 0.0f, 0.0f, 1.0f);
quad(minimaptex, 0, 0, minimapviewsize, 0.0f, 0.0f, 1.0f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_BLEND);
vec mdd(mapdims[0], mapdims[1], 0);
vec cod(offx+0.5f, offy+0.5f, 0);
vec ppv = vec(p->o).sub(mdd).mul(coordtrans).add(cod);
if(team_isactive(p->team)) drawradarent(ppv.x+displace, ppv.y+displace, p->yaw, p->state==CS_ALIVE ? (isattacking(p) ? 2 : 0) : 1, 2, iconsize, isattacking(p), "%s", colorname(p)); // local player
float gdim = max(mapdims[4], mapdims[5]); //no border
float orthd = gdim/2.0f;
float displace = (minimapviewsize/orthd)/2.0f;
float coordtrans = (minimapviewsize)/(gdim);
float offd = fabs(mapdims[5]-mapdims[4]) /2.0f;
if(!gdim) { gdim = ssize/2.0f; offd = 0; }
float offx = gdim==mapdims[5] ? offd : 0;
float offy = gdim==mapdims[4] ? offd : 0;
vec mdd = vec(mapdims[0]-offx, mapdims[1]-offy, 0);
vec cod(offx, offy, 0);
vec ppv = vec(p->o).sub(mdd).mul(coordtrans);
if(team_isactive(p->team)) drawradarent(ppv.x, ppv.y, p->yaw, p->state==CS_ALIVE ? (isattacking(p) ? 2 : 0) : 1, 2, iconsize, isattacking(p), "%s", colorname(p)); // local player
loopv(players) // other players
{
playerent *pl = players[i];
@@ -503,10 +508,10 @@ void drawradar_vicinity(playerent *p, int w, int h)
float radarviewsize = min(VIRTW,VIRTH)/5;
float halfviewsize = radarviewsize/2.0f;
float iconsize = radarentsize/0.4f; // Gibstick suggested: radarentsize*radarviewsize*0.015
float scaler = gdim/100.0f;
//float scaler = gdim/100.0f;
float scaleh = radarheight/(2.0f*gdim);
float scaled = radarviewsize/float(radarheight);
float offd = abs(mapdims[5]-mapdims[4])/2.0f;
float offd = fabs((mapdims[5]-mapdims[4]) /2.0f);
if(!gdim) { gdim = ssize/2; offd = 0; }
float offx = gdim==mapdims[5]?offd:0;
float offy = gdim==mapdims[4]?offd:0;
@@ -519,7 +524,8 @@ void drawradar_vicinity(playerent *p, int w, int h)
glTranslatef(centerpos.x, centerpos.y, 0);
glRotatef(-camera1->yaw, 0, 0, 1);
glTranslatef(-halfviewsize, -halfviewsize, 0);
vec d4rc = vec(p->o).sub(rsd).normalize().mul(scaler);
//vec d4rc = vec(p->o).sub(rsd).normalize().mul(scaler);
vec d4rc = vec(p->o).sub(rsd).normalize().mul(0); //Toca .mul(0) is still needed
vec usecenter = vec(p->o).sub(rtr).sub(d4rc);
if(showradarvalues)
{