1 /* -------------------------------------------------------------------------------
3 Copyright (C) 1999-2007 id Software, Inc. and contributors.
4 For a list of contributors, see the accompanying CONTRIBUTORS file.
6 This file is part of GtkRadiant.
8 GtkRadiant is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 GtkRadiant is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GtkRadiant; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 -------------------------------------------------------------------------------
24 This code has been altered significantly from its original form, to support
25 several games based on the Quake III Arena engine, in the form of "Q3Map2."
27 ------------------------------------------------------------------------------- */
39 const char* description;
42 void HelpOptions(const char* group_name, int indentation, int width, struct HelpOption* options, int count)
45 char* indent = malloc(indentation+1);
46 memset(indent, ' ', indentation);
47 indent[indentation] = 0;
48 printf("%s%s:\n", indent, group_name);
50 indent = realloc(indent, indentation+1);
51 memset(indent, ' ', indentation);
52 indent[indentation] = 0;
55 for ( i = 0; i < count; i++ )
57 int printed = printf("%s%-24s ", indent, options[i].name);
58 int descsz = strlen(options[i].description);
60 while ( j < descsz && descsz-j > width - printed )
63 printf("%s%26c",indent,' ');
64 int fragment = width - printed;
65 while ( fragment > 0 && options[i].description[j+fragment-1] != ' ')
67 j += fwrite(options[i].description+j, sizeof(char), fragment, stdout);
69 printed = indentation+26;
73 printf("%s\n",options[i].description+j);
75 else if ( j < descsz )
77 printf("%s%26c%s\n",indent,' ',options[i].description+j);
88 struct HelpOption bsp[] = {
89 {"-bsp <filename.map>", "Switch that enters this stage"},
90 {"-altsplit", "Alternate BSP tree splitting weights (should give more fps)"},
91 {"-celshader <shadername>", "Sets a global cel shader name"},
92 {"-custinfoparms", "Read scripts/custinfoparms.txt"},
93 {"-debuginset", "Push all triangle vertexes towards the triangle center"},
94 {"-debugportals", "Make BSP portals visible in the map"},
95 {"-debugsurfaces", "Color the vertexes according to the index of the surface"},
96 {"-deep", "Use detail brushes in the BSP tree, but at lowest priority (should give more fps)"},
97 {"-de <F>", "Distance epsilon for plane snapping etc."},
98 {"-fakemap", "Write fakemap.map containing all world brushes"},
99 {"-flares", "Turn on support for flares (TEST?)"},
100 {"-flat", "Enable flat shading (good for combining with -celshader)"},
101 {"-fulldetail", "Treat detail brushes as structural ones"},
102 {"-leaktest", "Abort if a leak was found"},
103 {"-meta", "Combine adjacent triangles of the same texture to surfaces (ALWAYS USE THIS)"},
104 {"-minsamplesize <N>", "Sets minimum lightmap resolution in luxels/qu"},
105 {"-mi <N>", "Sets the maximum number of indexes per surface"},
106 {"-mv <N>", "Sets the maximum number of vertices of a lightmapped surface"},
107 {"-ne <F>", "Normal epsilon for plane snapping etc."},
108 {"-nocurves", "Turn off support for patches"},
109 {"-nodetail", "Leave out detail brushes"},
110 {"-noflares", "Turn off support for flares"},
111 {"-nofog", "Turn off support for fog volumes"},
112 {"-nohint", "Turn off support for hint brushes"},
113 {"-nosubdivide", "Turn off support for `q3map_tessSize` (breaks water vertex deforms)"},
114 {"-notjunc", "Do not fix T-junctions (causes cracks between triangles, do not use)"},
115 {"-nowater", "Turn off support for water, slime or lava (Stef, this is for you)"},
116 {"-np <A>", "Force all surfaces to be nonplanar with a given shade angle"},
117 {"-onlyents", "Only update entities in the BSP"},
118 {"-patchmeta", "Turn patches into triangle meshes for display"},
119 {"-rename", "Append “bspâ€
\9d suffix to miscmodel shaders (needed for SoF2)"},
120 {"-samplesize <N>", "Sets default lightmap resolution in luxels/qu"},
121 {"-skyfix", "Turn sky box into six surfaces to work around ATI problems"},
122 {"-snap <N>", "Snap brush bevel planes to the given number of units"},
123 {"-tempname <filename.map>", "Read the MAP file from the given file name"},
124 {"-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"},
125 {"-tmpout", "Write the BSP file to /tmp"},
126 {"-verboseentities", "Enable `-v` only for map entities, not for the world"},
128 HelpOptions("BSP Stage", 0, 80, bsp, sizeof(bsp)/sizeof(struct HelpOption));
132 struct HelpOption vis[] = {
133 {"-vis <filename.map>", "Switch that enters this stage"},
134 {"-fast", "Very fast and crude vis calculation"},
135 {"-mergeportals", "The less crude half of `-merge`, makes vis sometimes much faster but doesn't hurt fps usually"},
136 {"-merge", "Faster but still okay vis calculation"},
137 {"-nopassage", "Just use PortalFlow vis (usually less fps)"},
138 {"-nosort", "Do not sort the portals before calculating vis (usually slower)"},
139 {"-passageOnly", "Just use PassageFlow vis (usually less fps)"},
140 {"-saveprt", "Keep the PRT file after running vis (so you can run vis again)"},
141 {"-tmpin", "Use /tmp folder for input"},
142 {"-tmpout", "Use /tmp folder for output"},
144 HelpOptions("VIS Stage", 0, 80, vis, sizeof(vis)/sizeof(struct HelpOption));
148 struct HelpOption light[] = {
149 {"-light <filename.map>", "Switch that enters this stage"},
150 {"-vlight <filename.map>", "Deprecated alias for `-light -fast` ... filename.map"},
151 {"-approx <N>", "Vertex light approximation tolerance (never use in conjunction with deluxemapping)"},
152 {"-areascale <F, `-area` F>", "Scaling factor for area lights (surfacelight)"},
153 {"-border", "Add a red border to lightmaps for debugging"},
154 {"-bouncegrid", "Also compute radiosity on the light grid"},
155 {"-bounceonly", "Only compute radiosity"},
156 {"-bouncescale <F>", "Scaling factor for radiosity"},
157 {"-bounce <N>", "Number of bounces for radiosity"},
158 {"-cheapgrid", "Use `-cheap` style lighting for radiosity"},
159 {"-cheap", "Abort vertex light calculations when white is reached"},
160 {"-compensate <F>", "Lightmap compensate (darkening factor applied after everything else)"},
161 {"-cpma", "CPMA vertex lighting mode"},
162 {"-custinfoparms", "Read scripts/custinfoparms.txt"},
163 {"-dark", "Darken lightmap seams"},
164 {"-debugaxis", "Color the lightmaps according to the lightmap axis"},
165 {"-debugcluster", "Color the lightmaps according to the index of the cluster"},
166 {"-debugdeluxe", "Show deluxemaps on the lightmap"},
167 {"-debugnormals", "Color the lightmaps according to the direction of the surface normal"},
168 {"-debugorigin", "Color the lightmaps according to the origin of the luxels"},
169 {"-debugsurfaces, -debugsurface", "Color the lightmaps according to the index of the surface"},
170 {"-debugunused", "This option does nothing"},
171 {"-debug", "Mark the lightmaps according to the cluster: unmapped clusters get yellow, occluded ones get pink, flooded ones get blue overlay color, otherwise red"},
172 {"-deluxemode 0", "Use modelspace deluxemaps (DarkPlaces)"},
173 {"-deluxemode 1", "Use tangentspace deluxemaps"},
174 {"-deluxe, -deluxemap", "Enable deluxemapping (light direction maps)"},
175 {"-dirtdebug, -debugdirt", "Store the dirtmaps as lightmaps for debugging"},
176 {"-dirtdepth", "Dirtmapping depth"},
177 {"-dirtgain", "Dirtmapping exponent"},
178 {"-dirtmode 0", "Ordered direction dirtmapping"},
179 {"-dirtmode 1", "Randomized direction dirtmapping"},
180 {"-dirtscale", "Dirtmapping scaling factor"},
181 {"-dirty", "Enable dirtmapping"},
182 {"-dump", "Dump radiosity from `-bounce` into numbered MAP file prefabs"},
183 {"-export", "Export lightmaps when compile finished (like `-export` mode)"},
184 {"-exposure <F>", "Lightmap exposure to better support overbright spots"},
185 {"-external", "Force external lightmaps even if at size of internal lightmaps"},
186 {"-extravisnudge", "Broken feature to nudge the luxel origin to a better vis cluster"},
187 {"-extrawide", "Deprecated alias for `-super 2 -filter`"},
188 {"-extra", "Deprecated alias for `-super 2`"},
189 {"-fastbounce", "Use `-fast` style lighting for radiosity"},
190 {"-faster", "Use a faster falloff curve for lighting; also implies `-fast`"},
191 {"-fastgrid", "Use `-fast` style lighting for the light grid"},
192 {"-fast", "Ignore tiny light contributions"},
193 {"-filter", "Lightmap filtering"},
194 {"-floodlight", "Enable floodlight (zero-effort somewhat decent lighting)"},
195 {"-gamma <F>", "Lightmap gamma"},
196 {"-gridambientscale <F>", "Scaling factor for the light grid ambient components only"},
197 {"-gridscale <F>", "Scaling factor for the light grid only"},
198 {"-keeplights", "Keep light entities in the BSP file after compile"},
199 {"-lightmapdir <directory>", "Directory to store external lightmaps (default: same as map name without extension)"},
200 {"-lightmapsize <N>", "Size of lightmaps to generate (must be a power of two)"},
201 {"-lomem", "Low memory but slower lighting mode"},
202 {"-lowquality", "Low quality floodlight (appears to currently break floodlight)"},
203 {"-minsamplesize <N>", "Sets minimum lightmap resolution in luxels/qu"},
204 {"-nocollapse", "Do not collapse identical lightmaps"},
205 {"-nodeluxe, -nodeluxemap", "Disable deluxemapping"},
206 {"-nogrid", "Disable grid light calculation (makes all entities fullbright)"},
207 {"-nolightmapsearch", "Do not optimize lightmap packing for GPU memory usage (as doing so costs fps)"},
208 {"-normalmap", "Color the lightmaps according to the direction of the surface normal (TODO is this identical to `-debugnormals`?)"},
209 {"-nostyle, -nostyles", "Disable support for light styles"},
210 {"-nosurf", "Disable tracing against surfaces (only uses BSP nodes then)"},
211 {"-notrace", "Disable shadow occlusion"},
212 {"-novertex", "Disable vertex lighting"},
213 {"-patchshadows", "Cast shadows from patches"},
214 {"-pointscale <F, `-point` F>", "Scaling factor for point lights (light entities)"},
215 {"-q3", "Use nonlinear falloff curve by default (like Q3A)"},
216 {"-samplescale <F>", "Scales all lightmap resolutions"},
217 {"-samplesize <N>", "Sets default lightmap resolution in luxels/qu"},
218 {"-samples <N>", "Adaptive supersampling quality"},
219 {"-scale <F>", "Scaling factor for all light types"},
220 {"-shadeangle <A>", "Angle for phong shading"},
221 {"-shade", "Enable phong shading at default shade angle"},
222 {"-skyscale <F, `-sky` F>", "Scaling factor for sky and sun light"},
223 {"-smooth", "Deprecated alias for `-samples 2`"},
224 {"-style, -styles", "Enable support for light styles"},
225 {"-sunonly", "Only compute sun light"},
226 {"-super <N, `-supersample` N>", "Ordered grid supersampling quality"},
227 {"-thresh <F>", "Triangle subdivision threshold"},
228 {"-trianglecheck", "Broken check that should ensure luxels apply to the right triangle"},
229 {"-trisoup", "Convert brush faces to triangle soup"},
230 {"-wolf", "Use linear falloff curve by default (like W:ET)"},
233 HelpOptions("Light Stage", 0, 80, light, sizeof(light)/sizeof(struct HelpOption));
238 struct HelpOption analize[] = {
239 {"-analyze <filename.bsp>", "Switch that enters this mode"},
240 {"-lumpswap", "Swap byte order in the lumps"},
243 HelpOptions("Analyzing BSP-like file structure", 0, 80, analize, sizeof(analize)/sizeof(struct HelpOption));
247 struct HelpOption scale[] = {
248 {"-scale <S filename.bsp>", "Scale uniformly"},
249 {"-scale <SX SY SZ filename.bsp>", "Scale non-uniformly"},
250 {"-scale -tex <S filename.bsp>", "Scale uniformly without texture lock"},
251 {"-scale -tex <SX SY SZ filename.bsp>", "Scale non-uniformly without texture lock"},
253 HelpOptions("Scaling", 0, 80, scale, sizeof(scale)/sizeof(struct HelpOption));
257 struct HelpOption convert[] = {
258 {"-convert <filename.bsp>", "Switch that enters this mode"},
259 {"-de <number>", "Distance epsilon for the conversion"},
260 {"-format <converter>", "Select the converter (available: map, ase, or game names)"},
261 {"-ne <F>", "Normal epsilon for the conversion"},
262 {"-shadersasbitmap", "(only for ase) use the shader names as \\*BITMAP key so they work as prefabs"},
265 HelpOptions("Converting & Decompiling", 0, 80, convert, sizeof(convert)/sizeof(struct HelpOption));
270 struct HelpOption exportl[] = {
271 {"-export <filename.bsp>", "Copies lightmaps from the BSP to `filename/lightmap_0000.tga` ff"}
274 HelpOptions("Exporting lightmaps", 0, 80, exportl, sizeof(exportl)/sizeof(struct HelpOption));
279 struct HelpOption fixaas[] = {
280 {"-fixaas <filename.bsp>", "Switch that enters this mode"},
283 HelpOptions("Fixing AAS checksum", 0, 80, fixaas, sizeof(fixaas)/sizeof(struct HelpOption));
288 struct HelpOption info[] = {
289 {"-info <filename.bsp>", "Switch that enters this mode"},
292 HelpOptions("Get info about BSP file", 0, 80, info, sizeof(info)/sizeof(struct HelpOption));
297 struct HelpOption import[] = {
298 {"-import <filename.bsp>", "Copies lightmaps from `filename/lightmap_0000.tga` ff into the BSP"},
301 HelpOptions("Importing lightmaps", 0, 80, import, sizeof(import)/sizeof(struct HelpOption));
306 struct HelpOption minimap[] = {
307 {"-minimap <filename.bsp>", "Creates a minimap of the BSP, by default writes to `../gfx/filename_mini.tga`"},
308 {"-black", "Write the minimap as a black-on-transparency RGBA32 image"},
309 {"-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"},
310 {"-border <F>", "Sets the amount of border pixels relative to the total image size"},
311 {"-gray", "Write the minimap as a white-on-black GRAY8 image"},
312 {"-keepaspect", "Ensure the aspect ratio is kept (the minimap is then letterboxed to keep aspect)"},
313 {"-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)"},
314 {"-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)"},
315 {"-o <filename.tga>", "Sets the output file name"},
316 {"-random <N>", "Sets the randomized supersampling count (cannot be combined with `-samples`)"},
317 {"-samples <N>", "Sets the ordered supersampling count (cannot be combined with `-random`)"},
318 {"-sharpen <F>", "Sets the sharpening coefficient"},
319 {"-size <N>", "Sets the width and height of the output image"},
320 {"-white", "Write the minimap as a white-on-transparency RGBA32 image"},
323 HelpOptions("MiniMap", 0, 80, minimap, sizeof(minimap)/sizeof(struct HelpOption));
328 struct HelpOption common[] = {
329 {"-connect <address>", "Talk to a NetRadiant instance using a specific XML based protocol"},
330 {"-force", "Allow reading some broken/unsupported BSP files e.g. when decompiling, may also crash"},
331 {"-fs_basepath <path>", "Sets the given path as main directory of the game (can be used more than once to look in multiple paths)"},
332 {"-fs_game <gamename>", "Sets a different game directory name (default for Q3A: baseq3)"},
333 {"-fs_homebase <dir>", "Specifies where the user home directory name is on Linux (default for Q3A: .q3a)"},
334 {"-game <gamename>", "Load settings for the given game (default: quake3)"},
335 {"-subdivisions <F>", "multiplier for patch subdivisions quality"},
336 {"-threads <N>", "number of threads to use"},
337 {"-v", "Verbose mode"}
340 HelpOptions("Common Options", 0, 80, common, sizeof(common)/sizeof(struct HelpOption));
344 void HelpMain(const char* arg)
346 printf("Usage: q3map2 [stage] [common options...] [stage options...] [stage source file]\n");
347 printf(" q3map2 -help [stage]\n\n");
351 struct HelpOption stages[] = {
352 {"-bsp", "BSP Stage"},
353 {"-vis", "VIS Stage"},
354 {"-light", "Light Stage"},
355 {"-analize", "Analyzing BSP-like file structure"},
356 {"-scale", "Scaling"},
357 {"-convert", "Converting & Decompiling"},
358 {"-export", "Exporting lightmaps"},
359 {"-fixaas", "Fixing AAS checksum"},
360 {"-info", "Get info about BSP file"},
361 {"-import", "Importing lightmaps"},
362 {"-minimap", "MiniMap"},
364 void(*help_funcs[])() = {
378 if ( arg && strlen(arg) > 0 )
384 for ( i = 0; i < sizeof(stages)/sizeof(struct HelpOption); i++ )
385 if ( strcmp(arg, stages[i].name+1) == 0 )
392 HelpOptions("Stages", 0, 80, stages, sizeof(stages)/sizeof(struct HelpOption));