/* * ================== * main * light modelfile * ================== */ int main(int argc, const char **argv) { int i, bsp_version; double start; double end; char source[1024]; init_log("light.log"); logprint("----- TyrLight v0.99e -----\n" #if 0 "** Beta version " __DATE__ " " __TIME__ "\n" #endif ); numthreads = GetDefaultThreads(); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-threads")) { numthreads = atoi(argv[i + 1]); i++; } else if (!strcmp(argv[i], "-extra")) { extrasamples = true; logprint("extra sampling enabled\n"); } else if (!strcmp(argv[i], "-dist")) { scaledist = atof(argv[i + 1]); i++; } else if (!strcmp(argv[i], "-range")) { rangescale = atof(argv[i + 1]); i++; } else if (!strcmp(argv[i], "-light")) { worldminlight = atof(argv[i + 1]); i++; } else if (!strcmp(argv[i], "-compress")) { compress_ents = true; logprint("light entity compression enabled\n"); } else if (!strcmp(argv[i], "-colored") || !strcmp(argv[i], "-coloured")) { colored = true; } else if (!strcmp(argv[i], "-bsp30")) { bsp30 = true; } else if (!strcmp(argv[i], "-lit")) { litfile = true; } else if (!strcmp(argv[i], "-nominlimit")) { nominlimit = true; } else if (argv[i][0] == '-') Error("Unknown option \"%s\"", argv[i]); else break; } if (numthreads > 1) logprint("running with %d threads\n", numthreads); // Switch on colored flag if specifying -lit or -bsp30 if (bsp30 || litfile) colored = true; // Check the colored options if (colored) { if (!bsp30 && !litfile) { logprint("colored output format not specified -> using bsp 30\n"); bsp30 = true; } else if (bsp30 && litfile) { Error("Two colored output formats specified"); } else if (litfile) { logprint("colored output format: lit\n"); } else if (bsp30) { logprint("colored output format: bsp30\n"); } } if (i != argc - 1) Error("usage: light [-threads num] [-light num] [-extra]\n" " [-colored] [-bsp30] [-lit]\n" " [-nocount] [-compress] [-nominlimit] bspfile\n"); start = I_FloatTime(); strcpy(source, argv[i]); StripExtension(source); DefaultExtension(source, ".bsp"); bsp_version = LoadBSPFile(source); LoadEntities(); MakeTnodes(); FindFaceOffsets(); LightWorld(); WriteEntitiesToString(); if (colored && bsp30) WriteBSPFile(source, 30); else WriteBSPFile(source, bsp_version); if (colored && litfile) WriteLitFile(source, LIT_VERSION); end = I_FloatTime(); logprint("%5.1f seconds elapsed\n", end - start); close_log(); return 0; }
/* =========== main =========== */ int main(int argc, char **argv) { bspdata_t bspdata; bsp2_t *const bsp = &bspdata.data.bsp2; int32_t loadversion; int i; init_log("vis.log"); logprint("---- vis / TyrUtils " stringify(TYRUTILS_VERSION) " ----\n"); LowerProcessPriority(); numthreads = GetDefaultThreads(); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-threads")) { numthreads = atoi(argv[i + 1]); i++; } else if (!strcmp(argv[i], "-fast")) { logprint("fastvis = true\n"); fastvis = true; } else if (!strcmp(argv[i], "-level")) { testlevel = atoi(argv[i + 1]); i++; } else if (!strcmp(argv[i], "-v")) { logprint("verbose = true\n"); verbose = 1; } else if (!strcmp(argv[i], "-vv")) { logprint("verbose = extra\n"); verbose = 2; } else if (!strcmp(argv[i], "-noambientsky")) { logprint("ambient sky sounds disabled\n"); ambientsky = false; } else if (!strcmp(argv[i], "-noambientwater")) { logprint("ambient water sounds disabled\n"); ambientwater = false; } else if (!strcmp(argv[i], "-noambientslime")) { logprint("ambient slime sounds disabled\n"); ambientslime = false; } else if (!strcmp(argv[i], "-noambientlava")) { logprint("ambient lava sounds disabled\n"); ambientlava = false; } else if (!strcmp(argv[i], "-noambient")) { logprint("ambient sound calculation disabled\n"); ambientsky = false; ambientwater = false; ambientslime = false; ambientlava = false; } else if (argv[i][0] == '-') Error("Unknown option \"%s\"", argv[i]); else break; } if (i != argc - 1) { printf("usage: vis [-threads #] [-level 0-4] [-fast] [-v|-vv] " "[-credits] bspfile\n"); exit(1); } logprint("running with %d threads\n", numthreads); logprint("testlevel = %i\n", testlevel); stateinterval = 300; /* 5 minutes */ starttime = statetime = I_FloatTime(); strcpy(sourcefile, argv[i]); StripExtension(sourcefile); DefaultExtension(sourcefile, ".bsp"); LoadBSPFile(sourcefile, &bspdata); loadversion = bspdata.version; if (loadversion != BSP2VERSION) ConvertBSPFormat(BSP2VERSION, &bspdata); strcpy(portalfile, argv[i]); StripExtension(portalfile); strcat(portalfile, ".prt"); LoadPortals(portalfile, bsp); strcpy(statefile, sourcefile); StripExtension(statefile); DefaultExtension(statefile, ".vis"); strcpy(statetmpfile, sourcefile); StripExtension(statetmpfile); DefaultExtension(statetmpfile, ".vi0"); uncompressed = malloc(leafbytes_real * portalleafs_real); memset(uncompressed, 0, leafbytes_real * portalleafs_real); // CalcPassages (); CalcVis(bsp); logprint("c_noclip: %i\n", c_noclip); logprint("c_chains: %lu\n", c_chains); bsp->visdatasize = vismap_p - bsp->dvisdata; logprint("visdatasize:%i compressed from %i\n", bsp->visdatasize, originalvismapsize); CalcAmbientSounds(bsp); /* Convert data format back if necessary */ if (loadversion != BSP2VERSION) ConvertBSPFormat(loadversion, &bspdata); WriteBSPFile(sourcefile, &bspdata); // unlink (portalfile); endtime = I_FloatTime(); logprint("%5.1f seconds elapsed\n", endtime - starttime); close_log(); return 0; }