/* ================= ProcessFile ================= */ void ProcessFile (char *sourcebase, char *bspfilename1) { // create filenames strcpy (bspfilename, bspfilename1); StripExtension (bspfilename); strcat (bspfilename, ".bsp"); strcpy (hullfilename, bspfilename1); StripExtension (hullfilename); strcat (hullfilename, ".h0"); strcpy (portfilename, bspfilename1); StripExtension (portfilename); strcat (portfilename, ".prt"); strcpy (pointfilename, bspfilename1); StripExtension (pointfilename); strcat (pointfilename, ".pts"); if (!onlyents) { remove (bspfilename); if (!usehulls) { hullfilename[strlen(hullfilename)-1] = '1'; remove (hullfilename); hullfilename[strlen(hullfilename)-1] = '2'; remove (hullfilename); } remove (portfilename); remove (pointfilename); } // load brushes and entities LoadMapFile (sourcebase); if (onlyents) { UpdateEntLump (); return; } // init the tables to be shared by all models BeginBSPFile (); // the clipping hulls will be written out to text files by forked processes CreateHulls (); ReadClipHull (1); ReadClipHull (2); WriteEntitiesToString(); FinishBSPFile (); }
/* ================= UpdateEntLump ================= */ void UpdateEntLump (void) { int m, entnum; char mod[80]; m = 1; for (entnum = 1 ; entnum < num_entities ; entnum++) { if (!entities[entnum].brushes) continue; sprintf (mod, "*%i", m); SetKeyValue (&entities[entnum], "model", mod); m++; } printf ("Updating entities lump...\n"); LoadBSPFile (bspfilename); WriteEntitiesToString(); WriteBSPFile (bspfilename); }
/* * ================== * 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 light modelfile ======== */ int main (int argc, char **argv) { int i; double start, end; char source[1024]; printf ("----- LightFaces ----\n"); 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; printf ("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 (argv[i][0] == '-') Error ("Unknown option \"%s\"", argv[i]); else break; } if (i != argc - 1) Error ("usage: light [-threads num] [-extra] bspfile"); InitThreads (); start = I_FloatTime (); strcpy (source, argv[i]); StripExtension (source); DefaultExtension (source, ".bsp"); LoadBSPFile (source); LoadEntities (); MakeTnodes (&dmodels[0]); LightWorld (); WriteEntitiesToString (); WriteBSPFile (source); end = I_FloatTime (); printf ("%5.1f seconds elapsed\n", end-start); return 0; }
/* ======== main light modelfile ======== */ int main (int argc, char **argv) { int i; int wantthreads; double start, end; char source[1024]; printf ("----- LightFaces ----\n"); ValidateByteorder (); wantthreads = 1; // default to single threaded for (i = 1 ; i < argc ; i++) { if (!strcmp(argv[i],"-threads")) { if (i >= argc - 1) COM_Error("Missing argument to \"%s\"", argv[i]); wantthreads = atoi (argv[++i]); } else if (!strcmp(argv[i],"-extra")) { extrasamples = true; printf ("extra sampling enabled\n"); } else if (!strcmp(argv[i],"-dist")) { if (i >= argc - 1) COM_Error("Missing argument to \"%s\"", argv[i]); scaledist = (float)atof (argv[++i]); } else if (!strcmp(argv[i],"-range")) { if (i >= argc - 1) COM_Error("Missing argument to \"%s\"", argv[i]); rangescale = (float)atof (argv[++i]); } else if (argv[i][0] == '-') COM_Error ("Unknown option \"%s\"", argv[i]); else break; } if (i != argc - 1) COM_Error ("usage: light [-threads num] [-extra] [-dist ?] [-range ?] bspfile"); InitThreads (wantthreads, 0); start = COM_GetTime (); strcpy (source, argv[i]); StripExtension (source); DefaultExtension (source, ".bsp", sizeof(source)); LoadBSPFile (source); LoadEntities (); MakeTnodes (&dmodels[0]); LightWorld (); WriteEntitiesToString (); WriteBSPFile (source); end = COM_GetTime (); printf ("%5.1f seconds elapsed\n", end-start); return 0; }
/* ================= ProcessFile ================= */ static void ProcessFile (char *sourcebase, char *bspfilename1) { int i; // FILE *FH; // char radfilename[1024]; // create filenames strcpy (bspfilename, bspfilename1); StripExtension (bspfilename); strcat (bspfilename, ".bsp"); strcpy (hullfilename, bspfilename1); StripExtension (hullfilename); strcat (hullfilename, ".h0"); strcpy (portfilename, bspfilename1); StripExtension (portfilename); strcat (portfilename, ".prt"); strcpy (pointfilename, bspfilename1); StripExtension (pointfilename); strcat (pointfilename, ".pts"); if (!onlyents) { remove (bspfilename); if (!usehulls && hullnum == 0) { hullfilename[strlen(hullfilename)-1] = '1'; remove (hullfilename); hullfilename[strlen(hullfilename)-1] = '2'; remove (hullfilename); hullfilename[strlen(hullfilename)-1] = '3'; remove (hullfilename); hullfilename[strlen(hullfilename)-1] = '4'; remove (hullfilename); hullfilename[strlen(hullfilename)-1] = '5'; remove (hullfilename); } remove (portfilename); remove (pointfilename); } // load brushes and entities LoadMapFile (sourcebase); if (onlyents) { UpdateEntLump (); return; } // init the tables to be shared by all models BeginBSPFile (); for (i = 0 ; i < MAX_MAP_CLIPNODES ; i++) LightValues[i] = -2; // the clipping hulls will be written out to text files by forked processes CreateHulls (); ReadClipHull (1); ReadClipHull (2); ReadClipHull (3); ReadClipHull (4); ReadClipHull (5); WriteEntitiesToString(); FinishBSPFile (); /* strcpy (radfilename, bspfilename1); StripExtension (radfilename); strcat (radfilename, ".rad"); FH = fopen(radfilename,"w"); for (i = 0 ; i < numfaces ; i++) fprintf(FH,"%d\n",LightValues[i]); fclose(FH); */ }
/* ======== main light modelfile ======== */ int main (int argc, char **argv) { int i, ModeCnt = 0, Val; char source[1024], *Option, *NextOption; float FVal; qboolean NoGlobRange = false; logfile = fopen (LOGFILENAME, "w"); logprintf ("----- Light 1.43 ---- Modified by Bengt Jardrup\n"); logprintf ("----- Release 2 ---- Coloured light and LIT support by MH\n\n"); for (i = 1; i < argc; i++) { Option = argv[i]; NextOption = i + 1 < argc ? argv[i + 1] : NULL; if (Option[0] != '-') break; ++Option; if (!stricmp (Option, "fast")) { FastLight = 2; if (NextOption != NULL && isdigit (NextOption[0]) && i + 2 < argc) { Val = atoi (NextOption); i++; if (Val > 2) FastLight = Val; } logprintf ("Fast light %d enabled\n", FastLight); } else if (!stricmp (Option, "soft")) { SoftLight = 0; if (NextOption != NULL && isdigit (NextOption[0]) && i + 2 < argc) { SoftLight = atoi (NextOption); i++; } } else if (!stricmp (Option, "softdist")) { SoftDist = GetArgument (Option, NextOption); i++; } else if (!stricmp (Option, "extra") || !stricmp (Option, "extra4")) { OverSample = Option[5] == '4' ? 4 : 2; logprintf ("Extra %dx%d sampling enabled\n", OverSample, OverSample); } else if (!stricmp (Option, "threads")) { numthreads = GetFloatArgument (Option, NextOption); i++; } else if (!stricmp (Option, "dist")) { scaledist = GetFloatArgument (Option, NextOption); i++; } else if (!stricmp (Option, "range")) { rangescale = GetFloatArgument (Option, NextOption); i++; } else if (!stricmp (Option, "globrange")) { GlobRange = true; logprintf ("Global range enabled\n"); } else if (!stricmp (Option, "noglobrange")) NoGlobRange = true; else if (!stricmp (Option, "light")) { worldminlight = GetArgument (Option, NextOption); i++; } else if (!stricmp (Option, "maxlight")) { worldmaxlight = GetArgument (Option, NextOption); i++; } else if (!stricmp (Option, "nolight")) { NoLight = true; logprintf ("Light entities disabled\n"); } else if (!stricmp (Option, "srclight")) { SrcLight = true; logprintf ("Unsourced light entities disabled\n"); } else if (!stricmp (Option, "sunlight")) { SunLight[0] = GetArgument (Option, NextOption); i++; } else if (!stricmp (Option, "sunlight2")) { SunLight[1] = GetArgument (Option, NextOption); i++; } else if (!stricmp (Option, "sunlight3")) { SunLight[1] = GetArgument (Option, NextOption); if (ShadowSense == -1) ShadowSense = SHADOWSENSE; i++; } else if (!stricmp (Option, "sunmangle")) { ChkArgument (Option, NextOption); if (sscanf (NextOption, "%d,%d", &SunMangleVal[0], &SunMangleVal[1]) != 2) Error ("Missing arguments for '%s'", Option); SunMangleVal[2] = 0; i++; } else if (!stricmp (Option, "nowarnings")) NoWarnings = true; else if (!stricmp (Option, "rate")) { ChkArgument (Option, NextOption); if (sscanf (NextOption, "%d,%f,%d,%d", &SecRate, &FVal, &NewLine, &TotTime) > 1) PercRate = (FVal + 0.05) * 10; // Fix roundoff AutoRate = false; i++; } else if (!stricmp (Option, "barpercent")) { SimpPercent = true; NumPercent = false; } else if (!stricmp (Option, "numpercent")) { SimpPercent = true; NumPercent = true; } else if (!stricmp (Option, "oldlight")) { OldLight = NoAnti = true; logprintf ("Oldlight mode enabled\n"); ++ModeCnt; } else if (!stricmp (Option, "tyrlite")) { TyrLiteMode = GlobRange = true; logprintf ("TyrLite mode enabled\n"); ++ModeCnt; } else if (!stricmp (Option, "tyrlite95")) { TyrLite95Mode = TyrLiteMode = GlobRange = true; logprintf ("TyrLite95 mode enabled\n"); ++ModeCnt; } else if (!stricmp (Option, "arghlite")) { ArghLiteMode = GlobRange = AddMinLight = true; logprintf ("ArghLite mode enabled\n"); ++ModeCnt; } else if (!stricmp (Option, "addmin")) { AddMinLight = true; logprintf ("Additive minlight enabled\n"); } else if (!stricmp (Option, "iklite")) { IKLiteMode = IKAngle = OldLight = NoAnti = true; logprintf ("IKLite mode enabled\n"); ++ModeCnt; } else if (!stricmp (Option, "ikangle")) { IKAngle = true; logprintf ("IKLite angle sensitivity enabled\n"); } else if (!stricmp (Option, "anglesense")) { FVal = GetFloatArgument (Option, NextOption); i++; if (FVal >= 0 && FVal <= 1 && FVal != scalecos) logprintf ("Angle sensitivity %g set\n", scalecos = FVal); } else if (!stricmp (Option, "shadowsense")) { FVal = GetFloatArgument (Option, NextOption); i++; if (FVal >= 0 && FVal <= 1) ShadowSense = FVal; } else if (!stricmp (Option, "gate")) { FVal = GetFloatArgument (Option, NextOption); i++; if (FVal >= 0 && FVal != GateVal) logprintf ("Fade Gate %g set\n", GateVal = FVal); } else if (!stricmp (Option, "dlx")) { LightDLXMode = OldLight = true; logprintf ("LightDLX mode enabled\n"); ++ModeCnt; } else if (!stricmp (Option, "kinn")) { KinnDelay = true; logprintf ("Kinn translation enabled\n"); } else if (!stricmp (Option, "solidsky")) { SolidSky = true; logprintf ("Solid sky brushes enabled\n"); } else if (!stricmp (Option, "unsup")) UnsupDetails = DetectKeys = true; else if (!stricmp (Option, "detect")) DetectKeys = true; else if (!stricmp (Option, "noskill")) NoSkillChk = true; else if (!stricmp (Option, "noflash")) NoFlash = true; else if (!stricmp (Option, "noanti")) NoAnti = NoAntiOption = true; else if (!stricmp (Option, "lightcap")) { Val = GetArgument (Option, NextOption); i++; if (Val >= 0 && Val != LightCap) logprintf ("LightCap %d enabled\n", LightCap = Val); } else if (!stricmp (Option, "onlyents")) OnlyEnts = true; else if (!stricmp (Option, "nowrite")) NoWrite = true; else if (!stricmp (Option, "norev")) NoReverse = true; else if (!stricmp (Option, "etp")) { EnhancedTP = true; logprintf ("Enhanced Texture Positioning enabled\n"); } else if (!stricmp (Option, "priority")) { SetQPriority (GetArgument (Option, NextOption)); i++; } else if (!stricmp (Option, "oldhformat")) OldHFormat = true; else if (!stricmp (Option, "?") || !stricmp (Option, "help")) PrintOptions (); else if (!stricmp (Option, "fakeGISun2")) { FakeGISunlight2 = true; logprintf ("Additive sunlight2 enabled\n"); } else if (!stricmp (Option, "fakeGIMode")) { FakeGIMode = true; logprintf ("FakeGI mode enabled\n"); } else Error ("Unknown option '%s'", Option); } if (i != argc - 1) PrintOptions (); if (GlobRange && NoGlobRange) { GlobRange = false; logprintf ("Global range disabled\n"); } if (ModeCnt > 1) Error ("Only one emulation mode allowed"); if (SoftLight >= 0) { if (SoftLight == 0) SoftLight = OverSample / 2 + 1; // Auto mode logprintf ("Soft light %d enabled\n", SoftLight); if (SoftDist != SOFTDIST) logprintf ("Soft distance %d set\n", SoftDist); } if (SoftLight > 0) { // Soft option is in charge SingleDist = -SoftDist; SkyDist = -SOFTDIST; } else { if (TyrLite95Mode) { SingleDist = 0; SkyDist = -ANGLE_EPSILON; } else SingleDist = SkyDist = 1; // Classic (no) soft distance } if (OverSample <= 2) { // Set compatibility modes GenCompatible = OldLight || TyrLiteMode || ArghLiteMode || IKLiteMode || LightDLXMode; ATCompatible = TyrLiteMode || ArghLiteMode; TyrCompatible = TyrLiteMode; } InitThreads (); if (!OnlyEnts && !NoWrite) start = I_FloatTime (); strcpy (source, argv[i]); StripExtension (source); DefaultExtension (source, ".bsp"); if (!NoWrite) WriteChk (source); logprintf ("File: %s\n", source); LoadBSPFile (source); LoadEntities (); if (OnlyEnts) logprintf ("Updating entities lump...\n"); else if (!NoWrite) { MakeTnodes (&dmodels[0]); FindFaceOffsets (); LightWorld (); } if (!NoWrite) { WriteEntitiesToString (); WriteBSPFile (source); } PrintFinish (); return 0; }