| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#include "q3map2.h" |
| 33 |
|
| 34 |
#if GDEF_OS_POSIX |
| 35 |
#include <sys/ioctl.h> |
| 36 |
#endif |
| 37 |
|
| 38 |
static unsigned terminalColumns = 80; |
| 39 |
|
| 40 |
struct HelpOption |
| 41 |
{ |
| 42 |
const char* name; |
| 43 |
const char* description; |
| 44 |
}; |
| 45 |
|
| 46 |
|
| 47 |
void HelpOptions(const char* group_name, int indentation, int width, struct HelpOption* options, int count) |
| 48 |
{ |
| 49 |
indentation *= 2; |
| 50 |
char* indent = malloc(indentation+1); |
| 51 |
memset(indent, ' ', indentation); |
| 52 |
indent[indentation] = 0; |
| 53 |
printf("%s%s:\n", indent, group_name); |
| 54 |
indentation += 2; |
| 55 |
indent = realloc(indent, indentation+1); |
| 56 |
memset(indent, ' ', indentation); |
| 57 |
indent[indentation] = 0; |
| 58 |
|
| 59 |
int i; |
| 60 |
for ( i = 0; i < count; i++ ) |
| 61 |
{ |
| 62 |
int printed = printf("%s%-24s ", indent, options[i].name); |
| 63 |
int descsz = strlen(options[i].description); |
| 64 |
int j = 0; |
| 65 |
while ( j < descsz && descsz-j > width - printed ) |
| 66 |
{ |
| 67 |
if ( j != 0 ) |
| 68 |
printf("%s%26c",indent,' '); |
| 69 |
int fragment = width - printed; |
| 70 |
while ( fragment > 0 && options[i].description[j+fragment-1] != ' ') |
| 71 |
fragment--; |
| 72 |
j += fwrite(options[i].description+j, sizeof(char), fragment, stdout); |
| 73 |
putchar('\n'); |
| 74 |
printed = indentation+26; |
| 75 |
} |
| 76 |
|
| 77 |
if ( j == 0 ) |
| 78 |
{ |
| 79 |
printf("%s\n",options[i].description+j); |
| 80 |
} |
| 81 |
else if ( j < descsz ) |
| 82 |
{ |
| 83 |
printf("%s%26c%s\n",indent,' ',options[i].description+j); |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
putchar('\n'); |
| 88 |
|
| 89 |
free(indent); |
| 90 |
} |
| 91 |
|
| 92 |
void HelpBsp() |
| 93 |
{ |
| 94 |
struct HelpOption bsp[] = { |
| 95 |
{"-bsp [options] <filename.map>", "Switch that enters this stage"}, |
| 96 |
{"-altsplit", "Alternate BSP tree splitting weights (should give more fps)"}, |
| 97 |
{"-bspfile <filename.bsp>", "BSP file to write"}, |
| 98 |
{"-celshader <shadername>", "Sets a global cel shader name"}, |
| 99 |
{"-custinfoparms", "Read scripts/custinfoparms.txt"}, |
| 100 |
{"-debuginset", "Push all triangle vertexes towards the triangle center"}, |
| 101 |
{"-debugportals", "Make BSP portals visible in the map"}, |
| 102 |
{"-debugsurfaces", "Color the vertexes according to the index of the surface"}, |
| 103 |
{"-deep", "Use detail brushes in the BSP tree, but at lowest priority (should give more fps)"}, |
| 104 |
{"-de <F>", "Distance epsilon for plane snapping etc."}, |
| 105 |
{"-fakemap", "Write fakemap.map containing all world brushes"}, |
| 106 |
{"-fastmeta", "Use small lightmap/surface verts/number maximum numbers (like Q3A), to be used with `-meta`"}, |
| 107 |
{"-flares", "Turn on support for flares"}, |
| 108 |
{"-flat", "Enable flat shading (good for combining with -celshader)"}, |
| 109 |
{"-fulldetail", "Treat detail brushes as structural ones"}, |
| 110 |
{"-keeplights", "Keep light entities in the BSP file after compile"}, |
| 111 |
{"-leaktest", "Abort if a leak was found"}, |
| 112 |
{"-linfile <filename.lin>", "Line file to write"}, |
| 113 |
{"-maxarea", "Use Max Area face surface generation"}, |
| 114 |
{"-maxlightmapvertices <N>", "Sets the maximum number of vertices per lightmapped surface"}, |
| 115 |
{"-maxsurfaceindexes <N>", "Sets the maximum number of indexes per surface"}, |
| 116 |
{"-maxsurfacevertices <N>", "Sets the maximum number of vertices per surface"}, |
| 117 |
{"-meta", "Combine adjacent triangles of the same texture to surfaces (ALWAYS USE THIS)"}, |
| 118 |
{"-metaadequatescore <N>", "Adequate score for adding triangles to meta surfaces"}, |
| 119 |
{"-metagoodscore <N>", "Good score for adding triangles to meta surfaces"}, |
| 120 |
{"-metamaxbboxdistance <F>", "Maximum bounding box distance for meta surfaces"}, |
| 121 |
{"-minsamplesize <N>", "Sets minimum lightmap resolution in luxels/qu"}, |
| 122 |
{"-mi <N>", "Deprecated alias for `-maxsurfaceindexes`"}, |
| 123 |
{"-mv <N>", "Deprecated alias for `-maxlightmapverts`"}, |
| 124 |
{"-ne <F>", "Normal epsilon for plane snapping etc."}, |
| 125 |
{"-nocurves", "Turn off support for patches"}, |
| 126 |
{"-nodetail", "Leave out detail brushes"}, |
| 127 |
{"-noflares", "Turn off support for flares"}, |
| 128 |
{"-nofog", "Turn off support for fog volumes"}, |
| 129 |
{"-nohint", "Turn off support for hint brushes"}, |
| 130 |
{"-nosRGB", "Treat colors and textures as linear colorspace"}, |
| 131 |
{"-nosRGBcolor", "Treat shader and light entity colors as linear colorspace"}, |
| 132 |
{"-nosRGBtex", "Treat textures as linear colorspace"}, |
| 133 |
{"-nosubdivide", "Turn off support for `q3map_tessSize` (breaks water vertex deforms)"}, |
| 134 |
{"-notjunc", "Do not fix T-junctions (causes cracks between triangles, do not use)"}, |
| 135 |
{"-nowater", "Turn off support for water, slime or lava (Stef, this is for you)"}, |
| 136 |
{"-np <A>", "Force all surfaces to be nonplanar with a given shade angle"}, |
| 137 |
{"-onlyents", "Only update entities in the BSP"}, |
| 138 |
{"-patchmeta", "Turn patches into triangle meshes for display"}, |
| 139 |
{"-prtfile <filename.prt>", "Portal file to write"}, |
| 140 |
{"-rename", "Append suffix to miscmodel shaders (needed for SoF2)"}, |
| 141 |
{"-samplesize <N>", "Sets default lightmap resolution in luxels/qu"}, |
| 142 |
{"-skyfix", "Turn sky box into six surfaces to work around ATI problems"}, |
| 143 |
{"-snap <N>", "Snap brush bevel planes to the given number of units"}, |
| 144 |
{"-srffile <filename.srf>", "Surface file to write"}, |
| 145 |
{"-sRGBcolor", "Treat shader and light entity colors as sRGB colorspace"}, |
| 146 |
{"-sRGBtex", "Treat textures as sRGB colorspace"}, |
| 147 |
{"-tempname <filename.map>", "Read the MAP file from the given file name"}, |
| 148 |
{"-texrange <N>", "Limit per-surface texture range to the given number of units, and subdivide surfaces like with `q3map_tessSize` if this is not met"}, |
| 149 |
{"-tmpout", "Write the BSP file to /tmp"}, |
| 150 |
{"-verboseentities", "Enable `-v` only for map entities, not for the world"}, |
| 151 |
}; |
| 152 |
|
| 153 |
HelpOptions("BSP Stage", 0, terminalColumns, bsp, sizeof(bsp)/sizeof(struct HelpOption)); |
| 154 |
} |
| 155 |
|
| 156 |
void HelpVis() |
| 157 |
{ |
| 158 |
struct HelpOption vis[] = { |
| 159 |
{"-vis [options] <filename.map>", "Switch that enters this stage"}, |
| 160 |
{"-fast", "Very fast and crude vis calculation"}, |
| 161 |
{"-hint", "Merge all but hint portals"}, |
| 162 |
{"-mergeportals", "The less crude half of `-merge`, makes vis sometimes much faster but doesn't hurt fps usually"}, |
| 163 |
{"-merge", "Faster but still okay vis calculation"}, |
| 164 |
{"-nopassage", "Just use PortalFlow vis (usually less fps)"}, |
| 165 |
{"-nosort", "Do not sort the portals before calculating vis (usually slower)"}, |
| 166 |
{"-passageOnly", "Just use PassageFlow vis (usually less fps)"}, |
| 167 |
{"-prtfile <filename.prt>", "Portal file to read"}, |
| 168 |
{"-saveprt", "Keep the Portal file after running vis (so you can run vis again)"}, |
| 169 |
{"-tmpin", "Use /tmp folder for input"}, |
| 170 |
{"-tmpout", "Use /tmp folder for output"}, |
| 171 |
{"-v -v", "Extra verbose mode for cluster debug"}, |
| 172 |
}; |
| 173 |
|
| 174 |
HelpOptions("VIS Stage", 0, terminalColumns, vis, sizeof(vis)/sizeof(struct HelpOption)); |
| 175 |
} |
| 176 |
|
| 177 |
void HelpLight() |
| 178 |
{ |
| 179 |
struct HelpOption light[] = { |
| 180 |
{"-light [options] <filename.map>", "Switch that enters this stage"}, |
| 181 |
{"-vlight [options] <filename.map>", "Deprecated alias for `-light -fast` ... filename.map"}, |
| 182 |
{"-approx <N>", "Vertex light approximation tolerance (never use in conjunction with deluxemapping)"}, |
| 183 |
{"-areascale <F, `-area` F>", "Scaling factor for area lights (surfacelight)"}, |
| 184 |
{"-backsplash <Fscale Fdistance>", "scale area lights backsplash fraction + set distance globally; (distance < -900 to omit distance setting); default = 1 23; real area lights have no backsplash (scale = 0); q3map_backsplash shader keyword overrides this setting"}, |
| 185 |
{"-backsplashpoint", "Use point light as backsplash light (default)"}, |
| 186 |
{"-backsplasharea", "Use area light as backsplash light"}, |
| 187 |
{"-border", "Add a red border to lightmaps for debugging"}, |
| 188 |
{"-bouncegrid", "Also compute radiosity on the light grid"}, |
| 189 |
{"-bounceonly", "Only compute radiosity"}, |
| 190 |
{"-bouncescale <F>", "Scaling factor for radiosity"}, |
| 191 |
{"-bounce <N>", "Number of bounces for radiosity"}, |
| 192 |
{"-bspfile <filename.bsp>", "BSP file to write"}, |
| 193 |
{"-cheapgrid", "Use `-cheap` style lighting for radiosity"}, |
| 194 |
{"-cheap", "Abort vertex light calculations when white is reached"}, |
| 195 |
{"-compensate <F>", "Lightmap compensate (darkening factor applied after everything else)"}, |
| 196 |
{"-cpma", "CPMA vertex lighting mode"}, |
| 197 |
{"-custinfoparms", "Read scripts/custinfoparms.txt"}, |
| 198 |
{"-dark", "Darken lightmap seams"}, |
| 199 |
{"-debugaxis", "Color the lightmaps according to the lightmap axis"}, |
| 200 |
{"-debugcluster", "Color the lightmaps according to the index of the cluster"}, |
| 201 |
{"-debugdeluxe", "Show deluxemaps on the lightmap"}, |
| 202 |
{"-debugnormals", "Color the lightmaps according to the direction of the surface normal"}, |
| 203 |
{"-debugorigin", "Color the lightmaps according to the origin of the luxels"}, |
| 204 |
{"-debugsurfaces, -debugsurface", "Color the lightmaps according to the index of the surface"}, |
| 205 |
{"-debugunused", "This option does nothing"}, |
| 206 |
{"-debug", "Mark the lightmaps according to the cluster: unmapped clusters get yellow, occluded ones get pink, flooded ones get blue overlay color, otherwise red"}, |
| 207 |
{"-deluxemode 0", "Use modelspace deluxemaps (DarkPlaces)"}, |
| 208 |
{"-deluxemode 1", "Use tangentspace deluxemaps"}, |
| 209 |
{"-deluxe, -deluxemap", "Enable deluxemapping (light direction maps)"}, |
| 210 |
{"-dirtdebug, -debugdirt", "Store the dirtmaps as lightmaps for debugging"}, |
| 211 |
{"-dirtdepth", "Dirtmapping depth"}, |
| 212 |
{"-dirtgain", "Dirtmapping exponent"}, |
| 213 |
{"-dirtmode 0", "Ordered direction dirtmapping"}, |
| 214 |
{"-dirtmode 1", "Randomized direction dirtmapping"}, |
| 215 |
{"-dirtscale", "Dirtmapping scaling factor"}, |
| 216 |
{"-dirty", "Enable dirtmapping"}, |
| 217 |
{"-dump", "Dump radiosity from `-bounce` into numbered MAP file prefabs"}, |
| 218 |
{"-export", "Export lightmaps when compile finished (like `-export` mode)"}, |
| 219 |
{"-exposure <F>", "Lightmap exposure to better support overbright spots"}, |
| 220 |
{"-external", "Force external lightmaps even if at size of internal lightmaps"}, |
| 221 |
{"-externalnames", "Write lightstyle shader using external lightmap names"}, |
| 222 |
{"-extradist <F>", "Extra distance for lights in map units"}, |
| 223 |
{"-extravisnudge", "Broken feature to nudge the luxel origin to a better vis cluster"}, |
| 224 |
{"-extrawide", "Deprecated alias for `-super 2 -filter`"}, |
| 225 |
{"-extra", "Deprecated alias for `-super 2`"}, |
| 226 |
{"-fastallocate", "Trade lightmap size against packing time (useful with hi res lightmaps on large maps: reduce allocation time from days to minutes for only some extra bytes)"}, |
| 227 |
{"-fastbounce", "Use `-fast` style lighting for radiosity"}, |
| 228 |
{"-faster", "Use a faster falloff curve for lighting; also implies `-fast`"}, |
| 229 |
{"-fastgrid", "Use `-fast` style lighting for the light grid"}, |
| 230 |
{"-fastlightmapsearch", "Deprecated alias for `-fastallocate`"}, |
| 231 |
{"-fast", "Ignore tiny light contributions"}, |
| 232 |
{"-fill", "Fill lightmap colors from surrounding pixels to improve JPEG compression"}, |
| 233 |
{"-filter", "Lightmap filtering, doesn't play nice with some other effects, don't use it, use `-samples` instead"}, |
| 234 |
{"-floodlight", "Enable floodlight (zero-effort somewhat decent lighting)"}, |
| 235 |
{"-gamma <F>", "Lightmap gamma"}, |
| 236 |
{"-gridambientdirectionality <F>", "Ambient directional lighting received (default: 0.0)"}, |
| 237 |
{"-gridambientscale <F>", "Scaling factor for the light grid ambient components only"}, |
| 238 |
{"-griddirectionality <F>", "Directional lighting received (default: 1.0)"}, |
| 239 |
{"-gridscale <F>", "Scaling factor for the light grid only"}, |
| 240 |
{"-lightanglehl 0", "Disable half lambert light angle attenuation"}, |
| 241 |
{"-lightanglehl 1", "Enable half lambert light angle attenuation"}, |
| 242 |
{"-lightmapdir <directory>", "Directory to store external lightmaps (default: same as map name without extension)"}, |
| 243 |
{"-lightmapsearchblocksize <N>", "Restrict lightmap search to block size <N>"}, |
| 244 |
{"-lightmapsearchpower <N>", "Optimize for lightmap merge power <N>"}, |
| 245 |
{"-lightmapsize <N>", "Size of lightmaps to generate (must be a power of two)"}, |
| 246 |
{"-lightsubdiv <N>", "Size of light emitting shader subdivision"}, |
| 247 |
{"-lomem", "Low memory but slower lighting mode"}, |
| 248 |
{"-lowquality", "Low quality floodlight (appears to currently break floodlight)"}, |
| 249 |
{"-minsamplesize <N>", "Sets minimum lightmap resolution in luxels/qu"}, |
| 250 |
{"-nobouncestore", "Do not store BSP, lightmap and shader files between bounces"}, |
| 251 |
{"-nocollapse", "Do not collapse identical lightmaps"}, |
| 252 |
{"-nodeluxe, -nodeluxemap", "Disable deluxemapping"}, |
| 253 |
{"-nofastpoint", "Disable fast point light calculation"}, |
| 254 |
{"-nogrid", "Disable grid light calculation (makes all entities fullbright)"}, |
| 255 |
{"-nolightmapsearch", "Do not optimize lightmap packing for GPU memory usage (as doing so costs fps)"}, |
| 256 |
{"-normalmap", "Color the lightmaps according to the direction of the surface normal (TODO is this identical to `-debugnormals`?)"}, |
| 257 |
{"-nosRGB", "Treat colors, textures, and lightmaps as linear colorspace"}, |
| 258 |
{"-nosRGBcolor", "Treat shader and light entity colors as linear colorspace"}, |
| 259 |
{"-nosRGBlight", "Write lightmaps as linear colorspace"}, |
| 260 |
{"-nosRGBtex", "Treat textures as linear colorspace"}, |
| 261 |
{"-nostyle, -nostyles", "Disable support for light styles"}, |
| 262 |
{"-nosurf", "Disable tracing against surfaces (only uses BSP nodes then)"}, |
| 263 |
{"-notrace", "Disable shadow occlusion"}, |
| 264 |
{"-novertex", "Disable vertex lighting"}, |
| 265 |
{"-patchshadows", "Cast shadows from patches"}, |
| 266 |
{"-pointscale <F, `-point` F>", "Scaling factor for spherical and spot point lights (light entities)"}, |
| 267 |
{"-q3", "Use nonlinear falloff curve by default (like Q3A)"}, |
| 268 |
{"-randomsamples", "Use random sampling for lightmaps"}, |
| 269 |
{"-rawlightmapsizelimit <N>", "Sets maximum lightmap resolution in luxels/qu (only affects patches if used -patchmeta in BSP stage)"}, |
| 270 |
{"-samplescale <F>", "Scales all lightmap resolutions"}, |
| 271 |
{"-samplesize <N>", "Sets default lightmap resolution in luxels/qu"}, |
| 272 |
{"-samplessearchboxsize <N>", "Search box size (1 to 4) for lightmap adaptive supersampling"}, |
| 273 |
{"-samples <N>", "Adaptive supersampling quality"}, |
| 274 |
{"-scale <F>", "Scaling factor for all light types"}, |
| 275 |
{"-shadeangle <A>", "Angle for phong shading"}, |
| 276 |
{"-shade", "Enable phong shading at default shade angle"}, |
| 277 |
{"-skyscale <F, `-sky` F>", "Scaling factor for sky and sun light"}, |
| 278 |
{"-slowallocate", "Use old (a bit more careful, but much slower) lightmaps packing algorithm (default)"}, |
| 279 |
{"-smooth", "Deprecated alias for `-samples 2`"}, |
| 280 |
{"-sphericalscale <F, `-spherical` F>", "Scaling factor for spherical point light entities"}, |
| 281 |
{"-spotscale <F, `-spot` F>", "Scaling factor for spot point light entities"}, |
| 282 |
{"-srffile <filename.srf>", "Surface file to read"}, |
| 283 |
{"-sRGB", "Treat colors, textures, and lightmaps as sRGB colorspace"}, |
| 284 |
{"-sRGBcolor", "Treat shader and light entity colors as sRGB colorspace"}, |
| 285 |
{"-sRGBlight", "Write lightmaps as sRGB colorspace"}, |
| 286 |
{"-sRGBtex", "Treat textures as sRGB colorspace"}, |
| 287 |
{"-style, -styles", "Enable support for light styles"}, |
| 288 |
{"-sunonly", "Only compute sun light"}, |
| 289 |
{"-super <N, `-supersample` N>", "Ordered grid supersampling quality, much slower than `-samples`"}, |
| 290 |
{"-thresh <F>", "Triangle subdivision threshold"}, |
| 291 |
{"-trianglecheck", "Broken check that should ensure luxels apply to the right triangle"}, |
| 292 |
{"-trisoup", "Convert brush faces to triangle soup"}, |
| 293 |
{"-wolf", "Use linear falloff curve by default (like W:ET)"}, |
| 294 |
}; |
| 295 |
|
| 296 |
HelpOptions("Light Stage", 0, terminalColumns, light, sizeof(light)/sizeof(struct HelpOption)); |
| 297 |
} |
| 298 |
|
| 299 |
void HelpAnalyze() |
| 300 |
{ |
| 301 |
struct HelpOption analyze[] = { |
| 302 |
{"-analyze [options] <filename.bsp>", "Switch that enters this mode"}, |
| 303 |
{"-lumpswap", "Swap byte order in the lumps"}, |
| 304 |
}; |
| 305 |
|
| 306 |
HelpOptions("Analyzing BSP-like file structure", 0, terminalColumns, analyze, sizeof(analyze)/sizeof(struct HelpOption)); |
| 307 |
} |
| 308 |
|
| 309 |
void HelpScale() |
| 310 |
{ |
| 311 |
struct HelpOption scale[] = { |
| 312 |
{"-scale [options] <S filename.bsp>", "Scale uniformly"}, |
| 313 |
{"-scale [options] <SX SY SZ filename.bsp>", "Scale non-uniformly"}, |
| 314 |
{"-tex", "Scale without texture lock"}, |
| 315 |
{"-spawn_ref <F>", "Vertical offset for info_player_* entities (adds spawn_ref, scales, subtracts spawn_ref)"}, |
| 316 |
}; |
| 317 |
|
| 318 |
HelpOptions("Scaling", 0, terminalColumns, scale, sizeof(scale)/sizeof(struct HelpOption)); |
| 319 |
} |
| 320 |
|
| 321 |
void HelpConvert() |
| 322 |
{ |
| 323 |
struct HelpOption convert[] = { |
| 324 |
{"-convert [options] <filename.bsp>", "Switch that enters this mode"}, |
| 325 |
{"-deluxemapsastexcoord", "Save deluxemap names and texcoords instead of textures (only when writing ase and obj)"}, |
| 326 |
{"-de <F>", "Distance epsilon for the conversion (only when reading map)"}, |
| 327 |
{"-format <converter>", "Select the converter, default ase (available: map, map_bp, ase, obj, or game names)"}, |
| 328 |
{"-lightmapsastexcoord", "Save lightmap names and texcoords instead of textures (only when writing ase and obj)"}, |
| 329 |
{"-meta", "Combine adjacent triangles of the same texture to surfaces (only when reading map)"}, |
| 330 |
{"-ne <F>", "Normal epsilon for the conversion (only when reading map)"}, |
| 331 |
{"-patchmeta", "Turn patches into triangle meshes for display (only when reading map)"}, |
| 332 |
{"-readbsp", "Force converting bsp to selected format"}, |
| 333 |
{"-readmap", "Force converting map to selected format"}, |
| 334 |
{"-shadersasbitmap", "Save shader names as bitmap names in the model so it works as a prefab (only when writing ase and obj)"}, |
| 335 |
}; |
| 336 |
|
| 337 |
HelpOptions("Converting & Decompiling", 0, terminalColumns, convert, sizeof(convert)/sizeof(struct HelpOption)); |
| 338 |
} |
| 339 |
|
| 340 |
void HelpExport() |
| 341 |
{ |
| 342 |
struct HelpOption exportl[] = { |
| 343 |
{"-export <filename.bsp>", "Copies lightmaps from the BSP to `filename/lightmap_0000.tga`"} |
| 344 |
}; |
| 345 |
|
| 346 |
HelpOptions("Exporting lightmaps", 0, terminalColumns, exportl, sizeof(exportl)/sizeof(struct HelpOption)); |
| 347 |
} |
| 348 |
|
| 349 |
void HelpExportEnts() |
| 350 |
{ |
| 351 |
struct HelpOption exportents[] = { |
| 352 |
{"-exportents <filename.bsp>", "Exports the entities to a text file (.ent)"}, |
| 353 |
}; |
| 354 |
HelpOptions("ExportEnts Stage", 0, terminalColumns, exportents, sizeof(exportents)/sizeof(struct HelpOption)); |
| 355 |
} |
| 356 |
|
| 357 |
void HelpFixaas() |
| 358 |
{ |
| 359 |
struct HelpOption fixaas[] = { |
| 360 |
{"-fixaas <filename.bsp>", "Switch that enters this mode"}, |
| 361 |
}; |
| 362 |
|
| 363 |
HelpOptions("Fixing AAS checksum", 0, terminalColumns, fixaas, sizeof(fixaas)/sizeof(struct HelpOption)); |
| 364 |
} |
| 365 |
|
| 366 |
void HelpInfo() |
| 367 |
{ |
| 368 |
struct HelpOption info[] = { |
| 369 |
{"-info <filename.bsp>", "Switch that enters this mode"}, |
| 370 |
}; |
| 371 |
|
| 372 |
HelpOptions("Get info about BSP file", 0, terminalColumns, info, sizeof(info)/sizeof(struct HelpOption)); |
| 373 |
} |
| 374 |
|
| 375 |
void HelpImport() |
| 376 |
{ |
| 377 |
struct HelpOption import[] = { |
| 378 |
{"-import <filename.bsp>", "Copies lightmaps from `filename/lightmap_0000.tga` ff into the BSP"}, |
| 379 |
}; |
| 380 |
|
| 381 |
HelpOptions("Importing lightmaps", 0, terminalColumns, import, sizeof(import)/sizeof(struct HelpOption)); |
| 382 |
} |
| 383 |
|
| 384 |
void HelpMinimap() |
| 385 |
{ |
| 386 |
struct HelpOption minimap[] = { |
| 387 |
{"-minimap [options] <filename.bsp>", "Creates a minimap of the BSP, by default writes to `../gfx/filename_mini.tga`"}, |
| 388 |
{"-autolevel", "Automatically level brightness and contrast"}, |
| 389 |
{"-black", "Write the minimap as a black-on-transparency RGBA32 image"}, |
| 390 |
{"-boost <F>", "Sets the contrast boost value (higher values make a brighter image); contrast boost is somewhat similar to gamma, but continuous even at zero"}, |
| 391 |
{"-border <F>", "Sets the amount of border pixels relative to the total image size"}, |
| 392 |
{"-brightness <F>", "Sets brightness value to add to minimap values"}, |
| 393 |
{"-contrast <F>", "Sets contrast value to scale minimap values (doesn't affect brightness)"}, |
| 394 |
{"-gray", "Write the minimap as a white-on-black GRAY8 image"}, |
| 395 |
{"-keepaspect", "Ensure the aspect ratio is kept (the minimap is then letterboxed to keep aspect)"}, |
| 396 |
{"-minmax <xmin ymin zmin xmax ymax zmax>", "Forces specific map dimensions (note: the minimap actually uses these dimensions, scaled to the target size while keeping aspect with centering, and 1/64 of border appended to all sides)"}, |
| 397 |
{"-noautolevel", "Do not automatically level brightness and contrast"}, |
| 398 |
{"-nokeepaspect", "Do not ensure the aspect ratio is kept (makes it easier to use the image in your code, but looks bad together with sharpening)"}, |
| 399 |
{"-o <filename.tga>", "Sets the output file name"}, |
| 400 |
{"-random <N>", "Sets the randomized supersampling count (cannot be combined with `-samples`)"}, |
| 401 |
{"-samples <N>", "Sets the ordered supersampling count (cannot be combined with `-random`)"}, |
| 402 |
{"-sharpen <F>", "Sets the sharpening coefficient"}, |
| 403 |
{"-size <N>", "Sets the width and height of the output image"}, |
| 404 |
{"-white", "Write the minimap as a white-on-transparency RGBA32 image"}, |
| 405 |
}; |
| 406 |
|
| 407 |
HelpOptions("MiniMap", 0, terminalColumns, minimap, sizeof(minimap)/sizeof(struct HelpOption)); |
| 408 |
} |
| 409 |
|
| 410 |
void HelpCommon() |
| 411 |
{ |
| 412 |
struct HelpOption common[] = { |
| 413 |
{"-connect <address>", "Talk to a " RADIANT_NAME " instance using a specific XML based protocol"}, |
| 414 |
{"-force", "Allow reading some broken/unsupported BSP files e.g. when decompiling, may also crash"}, |
| 415 |
{"-fs_basepath <path>", "Sets the given path as main directory of the game (can be used more than once to look in multiple paths)"}, |
| 416 |
{"-fs_forbiddenpath <pattern>", "Pattern to ignore directories, pk3, and pk3dir; example pak?.pk3 (can be used more than once to look for multiple patterns)"}, |
| 417 |
{"-fs_game <gamename>", "Sets a different game directory name (default for Q3A: baseq3, can be used more than once)"}, |
| 418 |
{"-fs_home <dir>", "Specifies where the user home directory is on Linux"}, |
| 419 |
{"-fs_homebase <dir>", "Specifies game home directory relative to user home directory on Linux (default for Q3A: .q3a)"}, |
| 420 |
{"-fs_homepath <path>", "Sets the given path as the game home directory name (fs_home + fs_homebase)"}, |
| 421 |
{"-fs_nobasepath", "Do not load base paths in VFS, imply -fs_nomagicpath"}, |
| 422 |
{"-fs_nomagicpath", "Do not try to guess base path magically"}, |
| 423 |
{"-fs_nohomepath", "Do not load home path in VFS"}, |
| 424 |
{"-fs_pakpath <path>", "Specify a package directory (can be used more than once to look in multiple paths)"}, |
| 425 |
{"-game <gamename>", "Load settings for the given game (default: quake3)"}, |
| 426 |
{"-subdivisions <F>", "Multiplier for patch subdivisions quality"}, |
| 427 |
{"-threads <N>", "Number of threads to use"}, |
| 428 |
{"-v", "Verbose mode"}, |
| 429 |
{"-werror", "Make all warnings into errors"} |
| 430 |
}; |
| 431 |
|
| 432 |
HelpOptions("Common Options", 0, terminalColumns, common, sizeof(common)/sizeof(struct HelpOption)); |
| 433 |
} |
| 434 |
|
| 435 |
void HelpGames() |
| 436 |
{ |
| 437 |
printf("Games:\n"); |
| 438 |
qboolean begin = qtrue; |
| 439 |
|
| 440 |
|
| 441 |
for ( unsigned i = 0, length = 0; games[ i ].arg != NULL; i++ ) |
| 442 |
{ |
| 443 |
|
| 444 |
if ( length + 3 + strlen( games[ i ].arg ) > terminalColumns ) |
| 445 |
{ |
| 446 |
printf(",\n"); |
| 447 |
length = 0; |
| 448 |
begin = qtrue; |
| 449 |
} |
| 450 |
|
| 451 |
if ( begin ) |
| 452 |
{ |
| 453 |
printf(" %s", games[ i ].arg ); |
| 454 |
begin = qfalse; |
| 455 |
} |
| 456 |
else |
| 457 |
{ |
| 458 |
printf(", %s", games[ i ].arg ); |
| 459 |
} |
| 460 |
|
| 461 |
length += 2 + strlen( games[ i ].arg ); |
| 462 |
} |
| 463 |
|
| 464 |
printf("\n\n"); |
| 465 |
} |
| 466 |
|
| 467 |
void HelpMain(const char* arg) |
| 468 |
{ |
| 469 |
printf("Usage: q3map2 [stage] [common options...] [stage options...] [stage source file]\n"); |
| 470 |
printf(" q3map2 -help [stage]\n"); |
| 471 |
printf(" q3map2 -help all\n\n"); |
| 472 |
|
| 473 |
#if GDEF_OS_POSIX |
| 474 |
struct winsize ws; |
| 475 |
ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); |
| 476 |
if (ws.ws_col > 60) { |
| 477 |
terminalColumns = ws.ws_col; |
| 478 |
} |
| 479 |
#endif |
| 480 |
|
| 481 |
HelpCommon(); |
| 482 |
|
| 483 |
HelpGames(); |
| 484 |
|
| 485 |
struct HelpOption stages[] = { |
| 486 |
{"-bsp", "BSP Stage"}, |
| 487 |
{"-vis", "VIS Stage"}, |
| 488 |
{"-light", "Light Stage"}, |
| 489 |
{"-analyze", "Analyzing BSP-like file structure"}, |
| 490 |
{"-scale", "Scaling"}, |
| 491 |
{"-convert", "Converting & Decompiling"}, |
| 492 |
{"-export", "Exporting lightmaps"}, |
| 493 |
{"-exportents", "Exporting entities"}, |
| 494 |
{"-fixaas", "Fixing AAS checksum"}, |
| 495 |
{"-info", "Get info about BSP file"}, |
| 496 |
{"-import", "Importing lightmaps"}, |
| 497 |
{"-minimap", "MiniMap"}, |
| 498 |
}; |
| 499 |
|
| 500 |
void(*help_funcs[])() = { |
| 501 |
HelpBsp, |
| 502 |
HelpVis, |
| 503 |
HelpLight, |
| 504 |
HelpAnalyze, |
| 505 |
HelpScale, |
| 506 |
HelpConvert, |
| 507 |
HelpExport, |
| 508 |
HelpExportEnts, |
| 509 |
HelpFixaas, |
| 510 |
HelpInfo, |
| 511 |
HelpImport, |
| 512 |
HelpMinimap, |
| 513 |
}; |
| 514 |
|
| 515 |
if ( arg && strlen(arg) > 0 ) |
| 516 |
{ |
| 517 |
if ( arg[0] == '-' ) |
| 518 |
{ |
| 519 |
arg++; |
| 520 |
} |
| 521 |
|
| 522 |
if ( strcmp(arg, "all") == 0 ) |
| 523 |
{ |
| 524 |
HelpOptions("Stages", 0, terminalColumns, stages, sizeof(stages)/sizeof(struct HelpOption)); |
| 525 |
|
| 526 |
for ( unsigned i = 0; i < sizeof(stages)/sizeof(struct HelpOption); i++ ) |
| 527 |
{ |
| 528 |
help_funcs[i](); |
| 529 |
} |
| 530 |
return; |
| 531 |
} |
| 532 |
|
| 533 |
for ( unsigned i = 0; i < sizeof(stages)/sizeof(struct HelpOption); i++ ) |
| 534 |
{ |
| 535 |
if ( strcmp(arg, stages[i].name+1) == 0 ) |
| 536 |
{ |
| 537 |
help_funcs[i](); |
| 538 |
return; |
| 539 |
} |
| 540 |
} |
| 541 |
} |
| 542 |
|
| 543 |
HelpOptions("Stages", 0, terminalColumns, stages, sizeof(stages)/sizeof(struct HelpOption)); |
| 544 |
} |