mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2025-01-10 03:51:18 +00:00
new modes for minimap: -black = black on transparent, -white = white on transparent, -gray = white on black
git-svn-id: svn://svn.icculus.org/netradiant/trunk@347 61c419a2-8eb2-4b30-bcec-8cead039b335
This commit is contained in:
parent
75ba6b77ec
commit
0375a83f2b
17 changed files with 117 additions and 21 deletions
|
@ -1169,6 +1169,26 @@ void WriteTGA( const char *filename, byte *data, int width, int height ) {
|
||||||
free( buffer );
|
free( buffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WriteTGAGray (const char *filename, byte *data, int width, int height) {
|
||||||
|
byte buffer[18];
|
||||||
|
int i;
|
||||||
|
int c;
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
|
memset (buffer, 0, 18);
|
||||||
|
buffer[2] = 3; // uncompressed type
|
||||||
|
buffer[12] = width&255;
|
||||||
|
buffer[13] = width>>8;
|
||||||
|
buffer[14] = height&255;
|
||||||
|
buffer[15] = height>>8;
|
||||||
|
buffer[16] = 8; // pixel size
|
||||||
|
|
||||||
|
f = fopen (filename, "wb");
|
||||||
|
fwrite (buffer, 1, 18, f);
|
||||||
|
fwrite (data, 1, width * height, f);
|
||||||
|
fclose (f);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
============================================================================
|
============================================================================
|
||||||
|
|
||||||
|
|
|
@ -40,5 +40,6 @@ void LoadTGA( const char *filename, byte **pixels, int *width, int *height );
|
||||||
void LoadTGABuffer( const byte *buffer, const byte* enddata, byte **pic, int *width, int *height );
|
void LoadTGABuffer( const byte *buffer, const byte* enddata, byte **pic, int *width, int *height );
|
||||||
void WriteTGA( const char *filename, byte *data, int width, int height );
|
void WriteTGA( const char *filename, byte *data, int width, int height );
|
||||||
int LoadJPGBuff( void *src_buffer, int src_size, unsigned char **pic, int *width, int *height );
|
int LoadJPGBuff( void *src_buffer, int src_size, unsigned char **pic, int *width, int *height );
|
||||||
|
void WriteTGAGray (const char *filename, byte *data, int width, int height);
|
||||||
|
|
||||||
void Load32BitImage( const char *name, unsigned **pixels, int *width, int *height );
|
void Load32BitImage( const char *name, unsigned **pixels, int *width, int *height );
|
||||||
|
|
|
@ -118,6 +118,7 @@
|
||||||
1.0f, /* minimap sharpener */
|
1.0f, /* minimap sharpener */
|
||||||
0.0f, /* minimap border */
|
0.0f, /* minimap border */
|
||||||
qtrue, /* minimap keep aspect */
|
qtrue, /* minimap keep aspect */
|
||||||
|
MINIMAP_MODE_GRAY, /* minimap mode */
|
||||||
"%s.tga", /* minimap name format */
|
"%s.tga", /* minimap name format */
|
||||||
"IBSP", /* bsp file prefix */
|
"IBSP", /* bsp file prefix */
|
||||||
46, /* bsp file version */
|
46, /* bsp file version */
|
||||||
|
|
|
@ -153,6 +153,7 @@
|
||||||
1.0f, /* minimap sharpener */
|
1.0f, /* minimap sharpener */
|
||||||
0.0f, /* minimap border */
|
0.0f, /* minimap border */
|
||||||
qtrue, /* minimap keep aspect */
|
qtrue, /* minimap keep aspect */
|
||||||
|
MINIMAP_MODE_GRAY, /* minimap mode */
|
||||||
"%s.tga", /* minimap name format */
|
"%s.tga", /* minimap name format */
|
||||||
"IBSP", /* bsp file prefix */
|
"IBSP", /* bsp file prefix */
|
||||||
47, /* bsp file version */
|
47, /* bsp file version */
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
1.0f, /* minimap sharpener */
|
1.0f, /* minimap sharpener */
|
||||||
0.0f, /* minimap border */
|
0.0f, /* minimap border */
|
||||||
qtrue, /* minimap keep aspect */
|
qtrue, /* minimap keep aspect */
|
||||||
|
MINIMAP_MODE_GRAY, /* minimap mode */
|
||||||
"%s.tga", /* minimap name format */
|
"%s.tga", /* minimap name format */
|
||||||
"RBSP", /* bsp file prefix */
|
"RBSP", /* bsp file prefix */
|
||||||
1, /* bsp file version */
|
1, /* bsp file version */
|
||||||
|
|
|
@ -69,6 +69,7 @@
|
||||||
1.0f, /* minimap sharpener */
|
1.0f, /* minimap sharpener */
|
||||||
0.0f, /* minimap border */
|
0.0f, /* minimap border */
|
||||||
qtrue, /* minimap keep aspect */
|
qtrue, /* minimap keep aspect */
|
||||||
|
MINIMAP_MODE_GRAY, /* minimap mode */
|
||||||
"%s.tga", /* minimap name format */
|
"%s.tga", /* minimap name format */
|
||||||
"RBSP", /* bsp file prefix */
|
"RBSP", /* bsp file prefix */
|
||||||
1, /* bsp file version */
|
1, /* bsp file version */
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
1.0f, /* minimap sharpener */
|
1.0f, /* minimap sharpener */
|
||||||
1.0f/66.0f, /* minimap border */
|
1.0f/66.0f, /* minimap border */
|
||||||
qtrue, /* minimap keep aspect */
|
qtrue, /* minimap keep aspect */
|
||||||
|
MINIMAP_MODE_GRAY, /* minimap mode */
|
||||||
"../gfx/%s_mini.tga", /* minimap name format */
|
"../gfx/%s_mini.tga", /* minimap name format */
|
||||||
"IBSP", /* bsp file prefix */
|
"IBSP", /* bsp file prefix */
|
||||||
46, /* bsp file version */
|
46, /* bsp file version */
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
0.0f, /* minimap sharpener */
|
0.0f, /* minimap sharpener */
|
||||||
0.0f, /* minimap border */
|
0.0f, /* minimap border */
|
||||||
qfalse, /* minimap keep aspect */
|
qfalse, /* minimap keep aspect */
|
||||||
|
MINIMAP_MODE_WHITE, /* minimap mode */
|
||||||
"../minimaps/%s.tga", /* minimap name format */
|
"../minimaps/%s.tga", /* minimap name format */
|
||||||
"FBSP", /* bsp file prefix */
|
"FBSP", /* bsp file prefix */
|
||||||
1, /* bsp file version */
|
1, /* bsp file version */
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
1.0f, /* minimap sharpener */
|
1.0f, /* minimap sharpener */
|
||||||
0.0f, /* minimap border */
|
0.0f, /* minimap border */
|
||||||
qtrue, /* minimap keep aspect */
|
qtrue, /* minimap keep aspect */
|
||||||
|
MINIMAP_MODE_GRAY, /* minimap mode */
|
||||||
"%s.tga", /* minimap name format */
|
"%s.tga", /* minimap name format */
|
||||||
"IBSP", /* bsp file prefix */
|
"IBSP", /* bsp file prefix */
|
||||||
46, /* bsp file version */
|
46, /* bsp file version */
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
1.0f, /* minimap sharpener */
|
1.0f, /* minimap sharpener */
|
||||||
0.0f, /* minimap border */
|
0.0f, /* minimap border */
|
||||||
qtrue, /* minimap keep aspect */
|
qtrue, /* minimap keep aspect */
|
||||||
|
MINIMAP_MODE_GRAY, /* minimap mode */
|
||||||
"%s.tga", /* minimap name format */
|
"%s.tga", /* minimap name format */
|
||||||
"IBSP", /* bsp file prefix */
|
"IBSP", /* bsp file prefix */
|
||||||
47, /* bsp file version */
|
47, /* bsp file version */
|
||||||
|
|
|
@ -144,6 +144,7 @@
|
||||||
1.0f, /* minimap sharpener */
|
1.0f, /* minimap sharpener */
|
||||||
0.0f, /* minimap border */
|
0.0f, /* minimap border */
|
||||||
qtrue, /* minimap keep aspect */
|
qtrue, /* minimap keep aspect */
|
||||||
|
MINIMAP_MODE_GRAY, /* minimap mode */
|
||||||
"%s.tga", /* minimap name format */
|
"%s.tga", /* minimap name format */
|
||||||
"RBSP", /* bsp file prefix */
|
"RBSP", /* bsp file prefix */
|
||||||
1, /* bsp file version */
|
1, /* bsp file version */
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
1.0f, /* minimap sharpener */
|
1.0f, /* minimap sharpener */
|
||||||
0.0f, /* minimap border */
|
0.0f, /* minimap border */
|
||||||
qtrue, /* minimap keep aspect */
|
qtrue, /* minimap keep aspect */
|
||||||
|
MINIMAP_MODE_GRAY, /* minimap mode */
|
||||||
"%s.tga", /* minimap name format */
|
"%s.tga", /* minimap name format */
|
||||||
"IBSP", /* bsp file prefix */
|
"IBSP", /* bsp file prefix */
|
||||||
46, /* bsp file version */
|
46, /* bsp file version */
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
1.0f, /* minimap sharpener */
|
1.0f, /* minimap sharpener */
|
||||||
0.0f, /* minimap border */
|
0.0f, /* minimap border */
|
||||||
qtrue, /* minimap keep aspect */
|
qtrue, /* minimap keep aspect */
|
||||||
|
MINIMAP_MODE_GRAY, /* minimap mode */
|
||||||
"%s.tga", /* minimap name format */
|
"%s.tga", /* minimap name format */
|
||||||
"IBSP", /* bsp file prefix */
|
"IBSP", /* bsp file prefix */
|
||||||
46, /* bsp file version */
|
46, /* bsp file version */
|
||||||
|
|
|
@ -134,6 +134,7 @@
|
||||||
1.0f, /* minimap sharpener */
|
1.0f, /* minimap sharpener */
|
||||||
0.0f, /* minimap border */
|
0.0f, /* minimap border */
|
||||||
qtrue, /* minimap keep aspect */
|
qtrue, /* minimap keep aspect */
|
||||||
|
MINIMAP_MODE_GRAY, /* minimap mode */
|
||||||
"%s.tga", /* minimap name format */
|
"%s.tga", /* minimap name format */
|
||||||
"IBSP", /* bsp file prefix */
|
"IBSP", /* bsp file prefix */
|
||||||
47, /* bsp file version */
|
47, /* bsp file version */
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
1.0f, /* minimap sharpener */
|
1.0f, /* minimap sharpener */
|
||||||
0.0f, /* minimap border */
|
0.0f, /* minimap border */
|
||||||
qtrue, /* minimap keep aspect */
|
qtrue, /* minimap keep aspect */
|
||||||
|
MINIMAP_MODE_GRAY, /* minimap mode */
|
||||||
"%s.tga", /* minimap name format */
|
"%s.tga", /* minimap name format */
|
||||||
"IBSP", /* bsp file prefix */
|
"IBSP", /* bsp file prefix */
|
||||||
47, /* bsp file version */
|
47, /* bsp file version */
|
||||||
|
|
|
@ -94,8 +94,6 @@ static void ExitQ3Map( void ){
|
||||||
|
|
||||||
/* minimap stuff */
|
/* minimap stuff */
|
||||||
|
|
||||||
/* borrowed from light.c */
|
|
||||||
void WriteTGA24( char *filename, byte *data, int width, int height, qboolean flip );
|
|
||||||
typedef struct minimap_s
|
typedef struct minimap_s
|
||||||
{
|
{
|
||||||
bspModel_t *model;
|
bspModel_t *model;
|
||||||
|
@ -560,10 +558,11 @@ int MiniMapBSPMain( int argc, char **argv )
|
||||||
char relativeMinimapFilename[1024];
|
char relativeMinimapFilename[1024];
|
||||||
float minimapSharpen;
|
float minimapSharpen;
|
||||||
float border;
|
float border;
|
||||||
byte *data3b, *p;
|
byte *data4b, *p;
|
||||||
float *q;
|
float *q;
|
||||||
int x, y;
|
int x, y;
|
||||||
int i;
|
int i;
|
||||||
|
miniMapMode_t mode;
|
||||||
vec3_t mins, maxs;
|
vec3_t mins, maxs;
|
||||||
qboolean keepaspect;
|
qboolean keepaspect;
|
||||||
|
|
||||||
|
@ -592,6 +591,7 @@ int MiniMapBSPMain( int argc, char **argv )
|
||||||
minimap.width = minimap.height = game->miniMapSize;
|
minimap.width = minimap.height = game->miniMapSize;
|
||||||
border = game->miniMapBorder;
|
border = game->miniMapBorder;
|
||||||
keepaspect = game->miniMapKeepAspect;
|
keepaspect = game->miniMapKeepAspect;
|
||||||
|
mode = game->miniMapMode;
|
||||||
|
|
||||||
minimap.samples = 1;
|
minimap.samples = 1;
|
||||||
minimap.sample_offsets = NULL;
|
minimap.sample_offsets = NULL;
|
||||||
|
@ -663,6 +663,21 @@ int MiniMapBSPMain( int argc, char **argv )
|
||||||
i += 6;
|
i += 6;
|
||||||
Sys_Printf( "Map mins/maxs overridden\n" );
|
Sys_Printf( "Map mins/maxs overridden\n" );
|
||||||
}
|
}
|
||||||
|
else if( !strcmp( argv[ i ], "-gray" ) )
|
||||||
|
{
|
||||||
|
mode = MINIMAP_MODE_GRAY;
|
||||||
|
Sys_Printf( "Writing as white-on-black image\n" );
|
||||||
|
}
|
||||||
|
else if( !strcmp( argv[ i ], "-black" ) )
|
||||||
|
{
|
||||||
|
mode = MINIMAP_MODE_BLACK;
|
||||||
|
Sys_Printf( "Writing as black alpha image\n" );
|
||||||
|
}
|
||||||
|
else if( !strcmp( argv[ i ], "-white" ) )
|
||||||
|
{
|
||||||
|
mode = MINIMAP_MODE_WHITE;
|
||||||
|
Sys_Printf( "Writing as white alpha image\n" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MiniMapMakeMinsMaxs(mins, maxs, border, keepaspect);
|
MiniMapMakeMinsMaxs(mins, maxs, border, keepaspect);
|
||||||
|
@ -675,6 +690,8 @@ int MiniMapBSPMain( int argc, char **argv )
|
||||||
MergeRelativePath(minimapFilename, path, relativeMinimapFilename);
|
MergeRelativePath(minimapFilename, path, relativeMinimapFilename);
|
||||||
Sys_Printf("Output file name automatically set to %s\n", minimapFilename);
|
Sys_Printf("Output file name automatically set to %s\n", minimapFilename);
|
||||||
}
|
}
|
||||||
|
ExtractFilePath(minimapFilename, path);
|
||||||
|
Q_mkdir(path);
|
||||||
|
|
||||||
if(minimapSharpen >= 0)
|
if(minimapSharpen >= 0)
|
||||||
{
|
{
|
||||||
|
@ -683,7 +700,7 @@ int MiniMapBSPMain( int argc, char **argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
minimap.data1f = safe_malloc(minimap.width * minimap.height * sizeof(*minimap.data1f));
|
minimap.data1f = safe_malloc(minimap.width * minimap.height * sizeof(*minimap.data1f));
|
||||||
data3b = safe_malloc(minimap.width * minimap.height * 3);
|
data4b = safe_malloc(minimap.width * minimap.height * 4);
|
||||||
if(minimapSharpen >= 0)
|
if(minimapSharpen >= 0)
|
||||||
minimap.sharpendata1f = safe_malloc(minimap.width * minimap.height * sizeof(*minimap.data1f));
|
minimap.sharpendata1f = safe_malloc(minimap.width * minimap.height * sizeof(*minimap.data1f));
|
||||||
|
|
||||||
|
@ -720,24 +737,61 @@ int MiniMapBSPMain( int argc, char **argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
Sys_Printf( "\nConverting...");
|
Sys_Printf( "\nConverting...");
|
||||||
p = data3b;
|
|
||||||
for(y = 0; y < minimap.height; ++y)
|
|
||||||
for(x = 0; x < minimap.width; ++x)
|
|
||||||
{
|
|
||||||
byte b;
|
|
||||||
float v = *q++;
|
|
||||||
if(v < 0) v = 0;
|
|
||||||
if(v > 255.0/256.0) v = 255.0/256.0;
|
|
||||||
b = v * 256;
|
|
||||||
*p++ = b;
|
|
||||||
*p++ = b;
|
|
||||||
*p++ = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
Sys_Printf( " writing to %s...", minimapFilename );
|
switch(mode)
|
||||||
ExtractFilePath(minimapFilename, path);
|
{
|
||||||
Q_mkdir(path);
|
case MINIMAP_MODE_GRAY:
|
||||||
WriteTGA24(minimapFilename, data3b, minimap.width, minimap.height, qfalse);
|
p = data4b;
|
||||||
|
for(y = 0; y < minimap.height; ++y)
|
||||||
|
for(x = 0; x < minimap.width; ++x)
|
||||||
|
{
|
||||||
|
byte b;
|
||||||
|
float v = *q++;
|
||||||
|
if(v < 0) v = 0;
|
||||||
|
if(v > 255.0/256.0) v = 255.0/256.0;
|
||||||
|
b = v * 256;
|
||||||
|
*p++ = b;
|
||||||
|
}
|
||||||
|
Sys_Printf( " writing to %s...", minimapFilename );
|
||||||
|
WriteTGAGray(minimapFilename, data4b, minimap.width, minimap.height);
|
||||||
|
break;
|
||||||
|
case MINIMAP_MODE_BLACK:
|
||||||
|
p = data4b;
|
||||||
|
for(y = 0; y < minimap.height; ++y)
|
||||||
|
for(x = 0; x < minimap.width; ++x)
|
||||||
|
{
|
||||||
|
byte b;
|
||||||
|
float v = *q++;
|
||||||
|
if(v < 0) v = 0;
|
||||||
|
if(v > 255.0/256.0) v = 255.0/256.0;
|
||||||
|
b = v * 256;
|
||||||
|
*p++ = 0;
|
||||||
|
*p++ = 0;
|
||||||
|
*p++ = 0;
|
||||||
|
*p++ = b;
|
||||||
|
}
|
||||||
|
Sys_Printf( " writing to %s...", minimapFilename );
|
||||||
|
WriteTGA(minimapFilename, data4b, minimap.width, minimap.height);
|
||||||
|
break;
|
||||||
|
case MINIMAP_MODE_WHITE:
|
||||||
|
p = data4b;
|
||||||
|
for(y = 0; y < minimap.height; ++y)
|
||||||
|
for(x = 0; x < minimap.width; ++x)
|
||||||
|
{
|
||||||
|
byte b;
|
||||||
|
float v = *q++;
|
||||||
|
if(v < 0) v = 0;
|
||||||
|
if(v > 255.0/256.0) v = 255.0/256.0;
|
||||||
|
b = v * 256;
|
||||||
|
*p++ = 255;
|
||||||
|
*p++ = 255;
|
||||||
|
*p++ = 255;
|
||||||
|
*p++ = b;
|
||||||
|
}
|
||||||
|
Sys_Printf( " writing to %s...", minimapFilename );
|
||||||
|
WriteTGA(minimapFilename, data4b, minimap.width, minimap.height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Sys_Printf( " done.\n" );
|
Sys_Printf( " done.\n" );
|
||||||
|
|
||||||
|
|
|
@ -549,6 +549,13 @@ typedef struct surfaceParm_s
|
||||||
}
|
}
|
||||||
surfaceParm_t;
|
surfaceParm_t;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
MINIMAP_MODE_GRAY,
|
||||||
|
MINIMAP_MODE_BLACK,
|
||||||
|
MINIMAP_MODE_WHITE
|
||||||
|
}
|
||||||
|
miniMapMode_t;
|
||||||
|
|
||||||
typedef struct game_s
|
typedef struct game_s
|
||||||
{
|
{
|
||||||
|
@ -570,6 +577,7 @@ typedef struct game_s
|
||||||
float miniMapSharpen; /* minimap sharpening coefficient */
|
float miniMapSharpen; /* minimap sharpening coefficient */
|
||||||
float miniMapBorder; /* minimap border amount */
|
float miniMapBorder; /* minimap border amount */
|
||||||
qboolean miniMapKeepAspect; /* minimap keep aspect ratio by letterboxing */
|
qboolean miniMapKeepAspect; /* minimap keep aspect ratio by letterboxing */
|
||||||
|
miniMapMode_t miniMapMode; /* minimap mode */
|
||||||
char *miniMapNameFormat; /* minimap name format */
|
char *miniMapNameFormat; /* minimap name format */
|
||||||
char *bspIdent; /* 4-letter bsp file prefix */
|
char *bspIdent; /* 4-letter bsp file prefix */
|
||||||
int bspVersion; /* bsp version to use */
|
int bspVersion; /* bsp version to use */
|
||||||
|
|
Loading…
Reference in a new issue