

I have a 3D game with a simple opengl game engine. Each object in the game has an X,Y,Z position.
I want to make a rotating map of an overview of the objects positions. I can make this work fine for a simple non rotating model.
I would like to rotate the 2D overview map as the player rotates but I don't seem to be able to get it correct.
Viewed from above the positions of the map points would be X and Z (Y is height in the game). The center point is 0 with negative values to the left.
The angle is 0 to 359 inclusive.
The 2D map (or angle=0) of the mapR() version give the fist "flat" image, but rotation gives the second image.
Can anyone see what I am doing wrong ?
Thanks,
Jon
C Source ...
Code:
void rotate2d(JSGEfloat angle, JSGEfloat* X, JSGEfloat* Y)
{
float ra;
ra = (angle/360) * (2*M_PI);
*X = *X * cos(ra) - *Y * sin(ra);
*Y = *Y * cos(ra) + *X * sin(ra);
}
Code:
void instr_mapR(JSGEfloat angle, JSGEfloat ox, JSGEfloat oy, int w, int h, int clearbackground, JSGEfloat bRf, JSGEfloat bGf, JSGEfloat bBf,
JSGEfloat xmin, JSGEfloat ymin, JSGEfloat xmax, JSGEfloat ymax)
{
int oi=0;
JSGEfloat X,Z;
if (clearbackground==TRUE)
draw_2d_line_pretend_rectange(ox, oy, w, h, -xmin*6, -ymin*6, xmax*6, ymax*6, bRf, bGf, bBf);
for (oi=0;oi<jsge_obj_top;oi++) // for all possible objects
{ // in use and not a star ?
if (sgeo[oi].inuse==TRUE && (sgeo[oi].visible==TRUE || sgeo[oi].tagnum==8000)) // Object active or the player itself
{
if (sgeo[oi].instr_map_show==TRUE)
{
X=sgeo[oi].posrot.X; // lr
//Y=sgeo[oi].posrot.Y; // ud
Z=sgeo[oi].posrot.Z; // fb
//printf("X=%f\tZ=%f\n",X,Z); fflush(stdout);
rotate2d(angle, &X, &Z);
draw_2d_cross_pretend_pixels(ox, oy, w, h, X*6, -Z*6,
sgeo[oi].instr_map_clr_Rf, sgeo[oi].instr_map_clr_Gf, sgeo[oi].instr_map_clr_Bf,
xmin, ymin, xmax, ymax);
}
}
}
}