-/* -------------------------------------------------------------------------------
+/* -------------------------------------------------------------------------------;
Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
/* 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;
float *sample_offsets;
float sharpen_boxmult;
float sharpen_centermult;
+ float boost;
float *data1f;
float *sharpendata1f;
vec3_t mins, size;
}
}
-void MiniMapMakeMinsMaxs(vec3_t mins_in, vec3_t maxs_in, float border)
+static void MiniMapContrastBoost(int y)
+{
+ int x;
+ float *q = &minimap.data1f[y * minimap.width];
+ for(x = 0; x < minimap.width; ++x)
+ {
+ *q = *q * minimap.boost / ((minimap.boost - 1) * *q + 1);
+ ++q;
+ }
+}
+
+void MiniMapMakeMinsMaxs(vec3_t mins_in, vec3_t maxs_in, float border, qboolean keepaspect)
{
vec3_t mins, maxs, extend;
VectorCopy(mins_in, mins);
// 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])
- {
- mins[0] -= (extend[1] - extend[0]) * 0.5;
- maxs[0] += (extend[1] - extend[0]) * 0.5;
- }
- else
+ if(keepaspect)
{
- 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 */
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;
/* arg checking */
if( argc < 2 )
minimapSharpen = game->miniMapSharpen;
minimap.width = minimap.height = game->miniMapSize;
border = game->miniMapBorder;
+ keepaspect = game->miniMapKeepAspect;
+ mode = game->miniMapMode;
minimap.samples = 1;
minimap.sample_offsets = NULL;
+ minimap.boost = 1.0;
/* process arguments */
for( i = 1; i < (argc - 1); i++ )
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]);
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" );
+ }
+ else if( !strcmp( argv[ i ], "-boost" ) )
+ {
+ minimap.boost = atof(argv[i + 1]);
+ i++;
+ Sys_Printf( "Contrast boost set to %f\n", minimap.boost );
+ }
}
- MiniMapMakeMinsMaxs(mins, maxs, border);
+ MiniMapMakeMinsMaxs(mins, maxs, border, keepaspect);
if(!*minimapFilename)
{
MergeRelativePath(minimapFilename, path, relativeMinimapFilename);
Sys_Printf("Output file name automatically set to %s\n", minimapFilename);
}
+ ExtractFilePath(minimapFilename, path);
+ Q_mkdir(path);
if(minimapSharpen >= 0)
{
}
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));
}
}
+ if(minimap.boost != 1.0)
+ {
+ Sys_Printf( "\n--- MiniMapContrastBoost (%d) ---\n", minimap.height );
+ RunThreadsOnIndividual(minimap.height, qtrue, MiniMapContrastBoost);
+ }
+
if(minimap.sharpendata1f)
{
Sys_Printf( "\n--- MiniMapSharpen (%d) ---\n", minimap.height );
}
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 );
- 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" );
int uniform, axis;
qboolean texscale;
float *old_xyzst = NULL;
+ float spawn_ref = 0;
/* arg checking */
if( argc < 3 )
{
- Sys_Printf( "Usage: q3map [-v] -scale [-tex] <value> <mapname>\n" );
+ Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
return 0;
}
+ texscale = qfalse;
+ for(i = 1; i < argc-2; ++i)
+ {
+ if(!strcmp(argv[i], "-tex"))
+ {
+ texscale = qtrue;
+ }
+ else if(!strcmp(argv[i], "-spawn_ref"))
+ {
+ spawn_ref = atof(argv[i+1]);
+ ++i;
+ }
+ else
+ break;
+ }
+
/* get scale */
- scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
- if(argc >= 4)
+ // if(argc-2 >= i) // always true
+ scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
+ if(argc-3 >= i)
scale[1] = scale[0] = atof( argv[ argc - 3 ] );
- if(argc >= 5)
+ if(argc-4 >= i)
scale[0] = atof( argv[ argc - 4 ] );
- texscale = !strcmp(argv[1], "-tex");
-
uniform = ((scale[0] == scale[1]) && (scale[1] == scale[2]));
if( scale[0] == 0.0f || scale[1] == 0.0f || scale[2] == 0.0f )
{
- Sys_Printf( "Usage: q3map [-v] -scale [-tex] <value> <mapname>\n" );
+ Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
Sys_Printf( "Non-zero scale value required.\n" );
return 0;
}
GetVectorForKey( &entities[ i ], "origin", vec );
if( (vec[ 0 ] || vec[ 1 ] || vec[ 2 ]) )
{
+ if(!strncmp(ValueForKey(&entities[i], "classname"), "info_player_", 12))
+ vec[2] += spawn_ref;
vec[0] *= scale[0];
vec[1] *= scale[1];
vec[2] *= scale[2];
+ if(!strncmp(ValueForKey(&entities[i], "classname"), "info_player_", 12))
+ vec[2] -= spawn_ref;
sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
SetKeyValue( &entities[ i ], "origin", str );
}
argv[ i ] = NULL;
}
}
-
+
/* init model library */
PicoInit();
PicoSetMallocFunc( safe_malloc );