From 1497c06cef8f484dbf9da4bb6e09c6f4433ce780 Mon Sep 17 00:00:00 2001 From: divverent Date: Mon, 27 Apr 2009 15:03:55 +0000 Subject: [PATCH] allow not keeping aspect git-svn-id: svn://svn.icculus.org/netradiant/trunk@345 61c419a2-8eb2-4b30-bcec-8cead039b335 --- tools/quake3/q3map2/game_darkplaces.h | 1 + tools/quake3/q3map2/game_dq.h | 1 + tools/quake3/q3map2/game_ef.h | 1 + tools/quake3/q3map2/game_etut.h | 1 + tools/quake3/q3map2/game_ja.h | 1 + tools/quake3/q3map2/game_jk2.h | 1 + tools/quake3/q3map2/game_nexuiz.h | 1 + tools/quake3/q3map2/game_prophecy.h | 1 + tools/quake3/q3map2/game_qfusion.h | 3 ++- tools/quake3/q3map2/game_quake3.h | 1 + tools/quake3/q3map2/game_quakelive.h | 1 + tools/quake3/q3map2/game_sof2.h | 1 + tools/quake3/q3map2/game_tenebrae.h | 1 + tools/quake3/q3map2/game_tremulous.h | 1 + tools/quake3/q3map2/game_wolf.h | 1 + tools/quake3/q3map2/game_wolfet.h | 1 + tools/quake3/q3map2/main.c | 38 ++++++++++++++++++--------- tools/quake3/q3map2/q3map2.h | 1 + 18 files changed, 44 insertions(+), 13 deletions(-) diff --git a/tools/quake3/q3map2/game_darkplaces.h b/tools/quake3/q3map2/game_darkplaces.h index 026b0ba2..ff936f9c 100644 --- a/tools/quake3/q3map2/game_darkplaces.h +++ b/tools/quake3/q3map2/game_darkplaces.h @@ -67,6 +67,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_dq.h b/tools/quake3/q3map2/game_dq.h index 86a1909c..5671266d 100644 --- a/tools/quake3/q3map2/game_dq.h +++ b/tools/quake3/q3map2/game_dq.h @@ -67,6 +67,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_ef.h b/tools/quake3/q3map2/game_ef.h index 9ee1e33d..a3b2950c 100644 --- a/tools/quake3/q3map2/game_ef.h +++ b/tools/quake3/q3map2/game_ef.h @@ -126,6 +126,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_etut.h b/tools/quake3/q3map2/game_etut.h index b876894b..e4dbc6bf 100644 --- a/tools/quake3/q3map2/game_etut.h +++ b/tools/quake3/q3map2/game_etut.h @@ -161,6 +161,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_ja.h b/tools/quake3/q3map2/game_ja.h index 4ff04520..69597b2b 100644 --- a/tools/quake3/q3map2/game_ja.h +++ b/tools/quake3/q3map2/game_ja.h @@ -80,6 +80,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "RBSP", /* bsp file prefix */ 1, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_jk2.h b/tools/quake3/q3map2/game_jk2.h index 338c018c..15cbf954 100644 --- a/tools/quake3/q3map2/game_jk2.h +++ b/tools/quake3/q3map2/game_jk2.h @@ -77,6 +77,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "RBSP", /* bsp file prefix */ 1, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_nexuiz.h b/tools/quake3/q3map2/game_nexuiz.h index 633b2a52..70258c44 100644 --- a/tools/quake3/q3map2/game_nexuiz.h +++ b/tools/quake3/q3map2/game_nexuiz.h @@ -76,6 +76,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 1.0f/66.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "../gfx/%s_mini.tga", /* minimap name format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_prophecy.h b/tools/quake3/q3map2/game_prophecy.h index 7fa4412c..2db39568 100644 --- a/tools/quake3/q3map2/game_prophecy.h +++ b/tools/quake3/q3map2/game_prophecy.h @@ -67,6 +67,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_qfusion.h b/tools/quake3/q3map2/game_qfusion.h index 5fedd571..7ce65bfa 100644 --- a/tools/quake3/q3map2/game_qfusion.h +++ b/tools/quake3/q3map2/game_qfusion.h @@ -126,8 +126,9 @@ game_t struct qfalse, /* compile deluxemaps */ 0, /* deluxemaps default mode */ 512, /* minimap size */ - 1.0f, /* minimap sharpener */ + 0.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qfalse, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "FBSP", /* bsp file prefix */ 1, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_quake3.h b/tools/quake3/q3map2/game_quake3.h index 4097a7e8..2236f12b 100644 --- a/tools/quake3/q3map2/game_quake3.h +++ b/tools/quake3/q3map2/game_quake3.h @@ -125,6 +125,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_quakelive.h b/tools/quake3/q3map2/game_quakelive.h index 91d9ca4b..34f56717 100644 --- a/tools/quake3/q3map2/game_quakelive.h +++ b/tools/quake3/q3map2/game_quakelive.h @@ -77,6 +77,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "IBSP", /* bsp file prefix */ 47, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_sof2.h b/tools/quake3/q3map2/game_sof2.h index ac11c792..1ef5e479 100644 --- a/tools/quake3/q3map2/game_sof2.h +++ b/tools/quake3/q3map2/game_sof2.h @@ -152,6 +152,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "RBSP", /* bsp file prefix */ 1, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_tenebrae.h b/tools/quake3/q3map2/game_tenebrae.h index caa13b50..d7677181 100644 --- a/tools/quake3/q3map2/game_tenebrae.h +++ b/tools/quake3/q3map2/game_tenebrae.h @@ -125,6 +125,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_tremulous.h b/tools/quake3/q3map2/game_tremulous.h index 642caf8f..6543d094 100644 --- a/tools/quake3/q3map2/game_tremulous.h +++ b/tools/quake3/q3map2/game_tremulous.h @@ -83,6 +83,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_wolf.h b/tools/quake3/q3map2/game_wolf.h index 53324659..816994a8 100644 --- a/tools/quake3/q3map2/game_wolf.h +++ b/tools/quake3/q3map2/game_wolf.h @@ -142,6 +142,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ diff --git a/tools/quake3/q3map2/game_wolfet.h b/tools/quake3/q3map2/game_wolfet.h index 20255946..d26a1734 100644 --- a/tools/quake3/q3map2/game_wolfet.h +++ b/tools/quake3/q3map2/game_wolfet.h @@ -79,6 +79,7 @@ game_t struct 512, /* minimap size */ 1.0f, /* minimap sharpener */ 0.0f, /* minimap border */ + qtrue, /* minimap keep aspect */ "%s.tga", /* minimap name format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ diff --git a/tools/quake3/q3map2/main.c b/tools/quake3/q3map2/main.c index 9d56d895..45d5ca51 100644 --- a/tools/quake3/q3map2/main.c +++ b/tools/quake3/q3map2/main.c @@ -293,7 +293,7 @@ static void MiniMapSharpen(int y) } } -void MiniMapMakeMinsMaxs(vec3_t mins_in, vec3_t maxs_in, float border) +void MiniMapMakeMinsMaxs(vec3_t mins_in, vec3_t maxs_in, float border, qboolean keepaspect) { vec3_t mins, maxs, extend; VectorCopy(mins_in, mins); @@ -302,17 +302,19 @@ void MiniMapMakeMinsMaxs(vec3_t mins_in, vec3_t maxs_in, float border) // line compatible to nexuiz mapinfo Sys_Printf("size %f %f %f %f %f %f\n", mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2]); - VectorSubtract(maxs, mins, extend); - - if(extend[1] > extend[0]) + if(keepaspect) { - mins[0] -= (extend[1] - extend[0]) * 0.5; - maxs[0] += (extend[1] - extend[0]) * 0.5; - } - else - { - mins[1] -= (extend[0] - extend[1]) * 0.5; - maxs[1] += (extend[0] - extend[1]) * 0.5; + VectorSubtract(maxs, mins, extend); + if(extend[1] > extend[0]) + { + mins[0] -= (extend[1] - extend[0]) * 0.5; + maxs[0] += (extend[1] - extend[0]) * 0.5; + } + else + { + mins[1] -= (extend[0] - extend[1]) * 0.5; + maxs[1] += (extend[0] - extend[1]) * 0.5; + } } /* border: amount of black area around the image */ @@ -535,6 +537,7 @@ int MiniMapBSPMain( int argc, char **argv ) int x, y; int i; vec3_t mins, maxs; + qboolean keepaspect; /* arg checking */ if( argc < 2 ) @@ -560,6 +563,7 @@ int MiniMapBSPMain( int argc, char **argv ) minimapSharpen = game->miniMapSharpen; minimap.width = minimap.height = game->miniMapSize; border = game->miniMapBorder; + keepaspect = game->miniMapKeepAspect; minimap.samples = 1; minimap.sample_offsets = NULL; @@ -604,6 +608,16 @@ int MiniMapBSPMain( int argc, char **argv ) i++; Sys_Printf( "Border set to %f\n", border ); } + else if( !strcmp( argv[ i ], "-keepaspect" ) ) + { + keepaspect = qtrue; + Sys_Printf( "Keeping aspect ratio by letterboxing\n", border ); + } + else if( !strcmp( argv[ i ], "-nokeepaspect" ) ) + { + keepaspect = qfalse; + Sys_Printf( "Not keeping aspect ratio\n", border ); + } else if( !strcmp( argv[ i ], "-o" ) ) { strcpy(minimapFilename, argv[i + 1]); @@ -623,7 +637,7 @@ int MiniMapBSPMain( int argc, char **argv ) } } - MiniMapMakeMinsMaxs(mins, maxs, border); + MiniMapMakeMinsMaxs(mins, maxs, border, keepaspect); if(!*minimapFilename) { diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 3756b2e5..c4c6a4bd 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -564,6 +564,7 @@ typedef struct game_s int miniMapSize; /* minimap size */ float miniMapSharpen; /* minimap sharpening coefficient */ float miniMapBorder; /* minimap border amount */ + qboolean miniMapKeepAspect; /* minimap keep aspect ratio by letterboxing */ char *miniMapNameFormat; /* minimap name format */ char *bspIdent; /* 4-letter bsp file prefix */ int bspVersion; /* bsp version to use */ -- 2.39.2