]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
new modes for minimap: -black = black on transparent, -white = white on transparent...
authordivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Mon, 27 Apr 2009 16:57:55 +0000 (16:57 +0000)
committerdivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Mon, 27 Apr 2009 16:57:55 +0000 (16:57 +0000)
git-svn-id: svn://svn.icculus.org/netradiant/trunk@347 61c419a2-8eb2-4b30-bcec-8cead039b335

20 files changed:
tools/quake3/common/imagelib.c
tools/quake3/common/imagelib.h
tools/quake3/q3map2/game_darkplaces.h
tools/quake3/q3map2/game_dq.h
tools/quake3/q3map2/game_ef.h
tools/quake3/q3map2/game_etut.h
tools/quake3/q3map2/game_ja.h
tools/quake3/q3map2/game_jk2.h
tools/quake3/q3map2/game_nexuiz.h
tools/quake3/q3map2/game_prophecy.h
tools/quake3/q3map2/game_qfusion.h
tools/quake3/q3map2/game_quake3.h
tools/quake3/q3map2/game_quakelive.h
tools/quake3/q3map2/game_sof2.h
tools/quake3/q3map2/game_tenebrae.h
tools/quake3/q3map2/game_tremulous.h
tools/quake3/q3map2/game_wolf.h
tools/quake3/q3map2/game_wolfet.h
tools/quake3/q3map2/main.c
tools/quake3/q3map2/q3map2.h

index 5971d8101d69cc34d54f6ed8d67f4cf054d5c2c0..9e52f1ed1a74dbe24efa1ad9234b1a6e2ec371c3 100644 (file)
@@ -1181,6 +1181,26 @@ void WriteTGA (const char *filename, byte *data, int width, int height) {
        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);
+}
+
 /*
 ============================================================================
 
index 171332f74fbf12cefcd005e32e1af7ef82208da9..2371b48af4065bbe4c881b930c6b442272d8a44d 100644 (file)
@@ -39,6 +39,7 @@ void Save256Image (const char *name, byte *pixels, byte *palette,
 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 WriteTGA (const char *filename, byte *data, 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);
 
index ff936f9cd14aaaa1f9d7707e3b7f4d38616e8e99..04699d464db1c014620ca9c420eb22c0575b5e04 100644 (file)
@@ -68,6 +68,7 @@ game_t struct
        1.0f,               /* minimap sharpener */\r
        0.0f,               /* minimap border */\r
        qtrue,              /* minimap keep aspect */\r
+       MINIMAP_MODE_GRAY,  /* minimap mode */\r
        "%s.tga",           /* minimap name format */\r
        "IBSP",                         /* bsp file prefix */\r
        46,                                     /* bsp file version */\r
index 5671266d0a6636086d0a57949cda1dceb89333a0..d9f7fd542180865d26fbed4855851b91b4b955f2 100644 (file)
@@ -68,6 +68,7 @@ game_t struct
        1.0f,               /* minimap sharpener */\r
        0.0f,               /* minimap border */\r
        qtrue,              /* minimap keep aspect */\r
+       MINIMAP_MODE_GRAY,  /* minimap mode */\r
        "%s.tga",           /* minimap name format */\r
        "IBSP",                         /* bsp file prefix */\r
        46,                                     /* bsp file version */\r
index a3b2950c3e4353b20e10e939bd0ea8e13c2e7256..3617180120792146598135949c1d7c09b8c599b4 100644 (file)
@@ -127,6 +127,7 @@ game_t struct
        1.0f,               /* minimap sharpener */
        0.0f,               /* minimap border */
        qtrue,              /* minimap keep aspect */
+       MINIMAP_MODE_GRAY,  /* minimap mode */
        "%s.tga",           /* minimap name format */
        "IBSP",                         /* bsp file prefix */
        46,                                     /* bsp file version */
index e4dbc6bf75cdb82927edcf2492e516263c2f9470..8f2f29730aa705881ea1a9b6ee048ca0d0a628d6 100644 (file)
@@ -162,6 +162,7 @@ game_t struct
        1.0f,               /* minimap sharpener */
        0.0f,               /* minimap border */
        qtrue,              /* minimap keep aspect */
+       MINIMAP_MODE_GRAY,  /* minimap mode */
        "%s.tga",           /* minimap name format */
        "IBSP",                         /* bsp file prefix */
        46,                                     /* bsp file version */
index 69597b2b31c4025ebf140316342b9f4e82971b65..f63429dd3a0afb17f590508716748a10e460ca15 100644 (file)
@@ -81,6 +81,7 @@ game_t struct
        1.0f,               /* minimap sharpener */
        0.0f,               /* minimap border */
        qtrue,              /* minimap keep aspect */
+       MINIMAP_MODE_GRAY,  /* minimap mode */
        "%s.tga",           /* minimap name format */
        "RBSP",                         /* bsp file prefix */
        1,                                      /* bsp file version */
index 15cbf9544499c975c3abc1c761a8c621ea6bd653..0ce673ecd498c1133305b736dd5f785bec282521 100644 (file)
@@ -78,6 +78,7 @@ game_t struct
        1.0f,               /* minimap sharpener */
        0.0f,               /* minimap border */
        qtrue,              /* minimap keep aspect */
+       MINIMAP_MODE_GRAY,  /* minimap mode */
        "%s.tga",           /* minimap name format */
        "RBSP",                         /* bsp file prefix */
        1,                                      /* bsp file version */
index 70258c440c9caab6bf2550bcda780b93b1c62bb7..2e205d2af56b03336dbafe8a460184c5587d92a3 100644 (file)
@@ -77,6 +77,7 @@ game_t struct
        1.0f,               /* minimap sharpener */
        1.0f/66.0f,         /* minimap border */
        qtrue,              /* minimap keep aspect */
+       MINIMAP_MODE_GRAY,  /* minimap mode */
        "../gfx/%s_mini.tga", /* minimap name format */
        "IBSP",                         /* bsp file prefix */
        46,                                     /* bsp file version */
index 2db39568f964b993fbd7d98526677b8177f80a14..f16a515eec6c2cfd5993734a50d00940f824821e 100644 (file)
@@ -68,6 +68,7 @@ game_t struct
        1.0f,               /* minimap sharpener */\r
        0.0f,               /* minimap border */\r
        qtrue,              /* minimap keep aspect */\r
+       MINIMAP_MODE_GRAY,  /* minimap mode */\r
        "%s.tga",           /* minimap name format */\r
        "IBSP",                         /* bsp file prefix */\r
        46,                                     /* bsp file version */\r
index cf4a99c00cd07d0ce6de6819e66bb6575dc73325..5b5b2df290e6063afd35c030464672fa36e90da9 100644 (file)
@@ -129,6 +129,7 @@ game_t struct
        0.0f,               /* minimap sharpener */
        0.0f,               /* minimap border */
        qfalse,             /* minimap keep aspect */
+       MINIMAP_MODE_WHITE, /* minimap mode */
        "../minimaps/%s.tga", /* minimap name format */
        "FBSP",                         /* bsp file prefix */
        1,                                      /* bsp file version */
index 2236f12bcded8fd31cf1bf134f40dda6020f4e90..949cffdd9efaab213813bb4b994aeeaa9c1494d8 100644 (file)
@@ -126,6 +126,7 @@ game_t struct
        1.0f,               /* minimap sharpener */
        0.0f,               /* minimap border */
        qtrue,              /* minimap keep aspect */
+       MINIMAP_MODE_GRAY,  /* minimap mode */
        "%s.tga",           /* minimap name format */
        "IBSP",                         /* bsp file prefix */
        46,                                     /* bsp file version */
index 34f56717228e8c7e8f73ef35b909c949eeaac0b5..0a0e48c17e4aa327aca194975652265127f8f6d7 100644 (file)
@@ -78,6 +78,7 @@ game_t struct
        1.0f,               /* minimap sharpener */
        0.0f,               /* minimap border */
        qtrue,              /* minimap keep aspect */
+       MINIMAP_MODE_GRAY,  /* minimap mode */
        "%s.tga",           /* minimap name format */
        "IBSP",                         /* bsp file prefix */
        47,                                     /* bsp file version */
index 1ef5e479a0a21cd84d61f0f9e40165c50b85ae4f..db96aa5161d57d64eba88b0cc683c4bce77fedd6 100644 (file)
@@ -153,6 +153,7 @@ game_t struct
        1.0f,               /* minimap sharpener */
        0.0f,               /* minimap border */
        qtrue,              /* minimap keep aspect */
+       MINIMAP_MODE_GRAY,  /* minimap mode */
        "%s.tga",           /* minimap name format */
        "RBSP",                                 /* bsp file prefix */
        1,                                              /* bsp file version */
index d76771818d1920057bb4f3625b97f955d64b7708..e6d6637b51bd4c55c0a4687cf764be99b8a0f160 100644 (file)
@@ -126,6 +126,7 @@ game_t struct
        1.0f,               /* minimap sharpener */
        0.0f,               /* minimap border */
        qtrue,              /* minimap keep aspect */
+       MINIMAP_MODE_GRAY,  /* minimap mode */
        "%s.tga",           /* minimap name format */
        "IBSP",                         /* bsp file prefix */
        46,                                     /* bsp file version */
index 6543d094725dadde6deb8066a78c749376234830..3228d64e1f4088d16d2677b2f11c22076f905c80 100644 (file)
@@ -84,6 +84,7 @@ game_t struct
        1.0f,               /* minimap sharpener */
        0.0f,               /* minimap border */
        qtrue,              /* minimap keep aspect */
+       MINIMAP_MODE_GRAY,  /* minimap mode */
        "%s.tga",           /* minimap name format */
        "IBSP",                         /* bsp file prefix */
        46,                                     /* bsp file version */
index 816994a89b057ce47a7111428530d25cd27a5567..2e7baf461708e0cab8e495a467aae6c26435a290 100644 (file)
@@ -143,6 +143,7 @@ game_t struct
        1.0f,               /* minimap sharpener */
        0.0f,               /* minimap border */
        qtrue,              /* minimap keep aspect */
+       MINIMAP_MODE_GRAY,  /* minimap mode */
        "%s.tga",           /* minimap name format */
        "IBSP",                         /* bsp file prefix */
        46,                                     /* bsp file version */
index d26a173416e885914c1915c0c7d1cfeb1709c813..12173d33a5b2a0038577f2a996354138a4dd4eb0 100644 (file)
@@ -80,6 +80,7 @@ game_t struct
        1.0f,               /* minimap sharpener */
        0.0f,               /* minimap border */
        qtrue,              /* minimap keep aspect */
+       MINIMAP_MODE_GRAY,  /* minimap mode */
        "%s.tga",           /* minimap name format */
        "IBSP",                         /* bsp file prefix */
        46,                                     /* bsp file version */
index 7e9f3b20d8fdc1ddad3ebdeb373c3faeb20cb101..057a549ace85e1787d9a9d88fd0193793182f92c 100644 (file)
@@ -66,8 +66,6 @@ static void ExitQ3Map( void )
 
 /* minimap stuff */
 
-/* borrowed from light.c */
-void WriteTGA24( char *filename, byte *data, int width, int height, qboolean flip );
 typedef struct minimap_s
 {
        bspModel_t *model;
@@ -532,10 +530,11 @@ int MiniMapBSPMain( int argc, char **argv )
        char relativeMinimapFilename[1024];
        float minimapSharpen;
        float border;
-       byte *data3b, *p;
+       byte *data4b, *p;
        float *q;
        int x, y;
        int i;
+       miniMapMode_t mode;
        vec3_t mins, maxs;
        qboolean keepaspect;
 
@@ -564,6 +563,7 @@ int MiniMapBSPMain( int argc, char **argv )
        minimap.width = minimap.height = game->miniMapSize;
        border = game->miniMapBorder;
        keepaspect = game->miniMapKeepAspect;
+       mode = game->miniMapMode;
 
        minimap.samples = 1;
        minimap.sample_offsets = NULL;
@@ -635,6 +635,21 @@ int MiniMapBSPMain( int argc, char **argv )
                        i += 6;
                        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);
@@ -647,6 +662,8 @@ int MiniMapBSPMain( int argc, char **argv )
                MergeRelativePath(minimapFilename, path, relativeMinimapFilename);
                Sys_Printf("Output file name automatically set to %s\n", minimapFilename);
        }
+       ExtractFilePath(minimapFilename, path);
+       Q_mkdir(path);
 
        if(minimapSharpen >= 0)
        {
@@ -655,7 +672,7 @@ int MiniMapBSPMain( int argc, char **argv )
        }
 
        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)
                minimap.sharpendata1f = safe_malloc(minimap.width * minimap.height * sizeof(*minimap.data1f));
 
@@ -692,24 +709,61 @@ int MiniMapBSPMain( int argc, char **argv )
        }
 
        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 );
-       ExtractFilePath(minimapFilename, path);
-       Q_mkdir(path);
-       WriteTGA24(minimapFilename, data3b, minimap.width, minimap.height, qfalse);
+       switch(mode)
+       {
+               case MINIMAP_MODE_GRAY:
+                       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" );
 
index c4c6a4bd1d08e94787077606b9c0d6862ba3da59..e47bf798962b7eda75b196c5aff654981af735e4 100644 (file)
@@ -535,6 +535,13 @@ typedef struct surfaceParm_s
 }
 surfaceParm_t;
 
+typedef enum
+{
+       MINIMAP_MODE_GRAY,
+       MINIMAP_MODE_BLACK,
+       MINIMAP_MODE_WHITE
+}
+miniMapMode_t;
 
 typedef struct game_s
 {
@@ -565,6 +572,7 @@ typedef struct game_s
        float               miniMapSharpen;                 /* minimap sharpening coefficient */
        float               miniMapBorder;                  /* minimap border amount */
        qboolean            miniMapKeepAspect;              /* minimap keep aspect ratio by letterboxing */
+       miniMapMode_t       miniMapMode;                    /* minimap mode */
        char                *miniMapNameFormat;             /* minimap name format */
        char                            *bspIdent;                                              /* 4-letter bsp file prefix */
        int                                     bspVersion;                                             /* bsp version to use */