/* ================== BspInfo_PrintInfo ================== */ static void Bsp_Convert( const char *filename ) { convert_bsp = true; LoadBSPFile( filename_bsp ); WriteBSPFile( filename_bsp, false ); }
/* ================= ProcessFile ================= */ void ProcessFile (char *sourcebase, char *filename_bsp1) { if (!onlyents) { remove (filename_bsp); remove (filename_prt); remove (filename_pts); remove (filename_lin); remove (filename_lit); remove (filename_dlit); remove (filename_lights); } // load brushes and entities LoadMapFile (sourcebase); if (onlyents) { LoadBSPFile (filename_bsp); UpdateEntLump (); WriteBSPFile (filename_bsp, false); 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 (); UpdateEntLump (); WriteMiptex (); FinishBSPFile (); }
int main (int argc, char **argv) { double start, stop; dstring_t *portalfile = dstring_new (); QFile *f; start = Sys_DoubleTime (); this_program = argv[0]; DecodeArgs (argc, argv); if (!options.bspfile) { usage (1); Sys_Error ("%s: no bsp file specified.", this_program); } QFS_SetExtension (options.bspfile, ".bsp"); f = Qopen (options.bspfile->str, "rb"); if (!f) Sys_Error ("couldn't open %s for reading.", options.bspfile->str); bsp = LoadBSPFile (f, Qfilesize (f)); Qclose (f); visdata = dstring_new (); dstring_copystr (portalfile, options.bspfile->str); QFS_SetExtension (portalfile, ".prt"); LoadPortals (portalfile->str); uncompressed = calloc (bitbytes_l, portalclusters); CalcVis (); if (options.verbosity >= 0) printf ("c_chains: %i%s\n", c_chains, options.threads > 1 ? " (not reliable)" :""); BSP_AddVisibility (bsp, (byte *) visdata->str, visdata->size); if (options.verbosity >= 0) printf ("visdatasize:%ld compressed from %ld\n", (long) bsp->visdatasize, (long) originalvismapsize); CalcAmbientSounds (); f = Qopen (options.bspfile->str, "wb"); if (!f) Sys_Error ("couldn't open %s for writing.", options.bspfile->str); WriteBSPFile (bsp, f); Qclose (f); stop = Sys_DoubleTime (); if (options.verbosity >= 0) printf ("%5.1f seconds elapsed\n", stop - start); return 0; }
/* ============ EndBSPFile ============ */ void EndBSPFile( void ){ char path[1024]; #if 0 int len; byte *buf; #endif EmitBrushes(); EmitPlanes(); UnparseEntities(); // load the pop #if 0 sprintf( path, "%s/pics/pop.lmp", gamedir ); len = LoadFile( path, &buf ); memcpy( dpop, buf, sizeof( dpop ) ); free( buf ); #endif // write the map sprintf( path, "%s.bsp", source ); Sys_Printf( "Writing %s\n", path ); WriteBSPFile( path ); }
/* =========== main =========== */ int VIS_Main(){ char portalfile[1024]; char source[1024]; char name[1024]; double start, end; int total_vis_time; Sys_Printf( "\n----- VIS ----\n\n" ); //if (i != argc - 1) // Error ("usage: vis [-threads #] [-level 0-4] [-fast] [-v] bspfile"); start = I_FloatTime(); ThreadSetDefault(); SetQdirFromPath( mapname ); strcpy( source, ExpandArg( mapname ) ); StripExtension( source ); DefaultExtension( source, ".bsp" ); sprintf( name, "%s%s", inbase, source ); Sys_Printf( "reading %s\n", name ); LoadBSPFile( name ); if ( numnodes == 0 || numfaces == 0 ) { Error( "Empty map" ); } sprintf( portalfile, "%s%s", inbase, ExpandArg( mapname ) ); StripExtension( portalfile ); strcat( portalfile, ".prt" ); Sys_Printf( "reading %s\n", portalfile ); LoadPortals( portalfile ); CalcVis(); CalcPHS(); visdatasize = vismap_p - dvisdata; Sys_Printf( "visdatasize:%i compressed from %i\n", visdatasize, originalvismapsize * 2 ); sprintf( name, "%s%s", outbase, source ); Sys_Printf( "writing %s\n", name ); WriteBSPFile( name ); end = I_FloatTime(); total_vis_time = (int) ( end - start ); Sys_Printf( "\nVIS Time: " ); if ( total_vis_time > 59 ) { Sys_Printf( "%d Minutes ", total_vis_time / 60 ); } Sys_Printf( "%d Seconds\n", total_vis_time % 60 ); return 0; }
void FinishBSPFile( void ) { printf( "--- BSP file information ---\n" ); PrintBSPFileSizes (); qprintf( "--- WriteBSPFile: %s ---\n", filename_bsp ); WriteBSPFile(filename_bsp); qfree( planemapping ); }
/* ================== FinishBSPFile ================== */ void FinishBSPFile (void) { int i; qprintf ("--- FinishBSPFile ---\n"); if (verbose) PrintBSPFileSizes (); WriteBSPFile (bspfilename); }
/** * @brief Finishes a new bsp and writes to disk * @sa BeginBSPFile */ void EndBSPFile (const char* filename) { EmitBrushes(); EmitPlanes(); UnparseEntities(); /* write the map */ Verb_Printf(VERB_LESS, "Writing %s\n", filename); WriteBSPFile(filename); }
/* ================== FinishBSPFile ================== */ void FinishBSPFile (void) { printf ("--- FinishBSPFile ---\n"); printf ("WriteBSPFile: %s\n", bspfilename); WriteMiptex (); PrintBSPFileSizes (); WriteBSPFile (bspfilename); }
/* ============ EndBSPFile ============ */ void EndBSPFile (void) { // Mark noshadow faces. MarkNoShadowFaces(); EmitBrushes (); EmitPlanes (); // stick flat normals at the verts SaveVertexNormals(); // Figure out lightmap extents for all faces. UpdateAllFaceLightmapExtents(); // Generate geometry and lightmap alpha for displacements. EmitDispLMAlphaAndNeighbors(); // Emit overlay data. Overlay_EmitOverlayFaces(); OverlayTransition_EmitOverlayFaces(); // phys collision needs dispinfo to operate (needs to generate phys collision for displacement surfs) EmitPhysCollision(); // We can't calculate this properly until vvis (since we need vis to do this), so we set // to zero everywhere by default. ClearDistToClosestWater(); // Emit static props found in the .vmf file EmitStaticProps(); // Place detail props found in .vmf and based on material properties EmitDetailObjects(); // Compute bounds after creating disp info because we need to reference it ComputeBoundsNoSkybox(); // Make sure that we have a water lod control eneity if we have water in the map. EnsurePresenceOfWaterLODControlEntity(); // Doing this here because stuff about may filter out entities UnparseEntities (); // remove unused texinfos CompactTexinfos(); // Figure out which faces want macro textures. DiscoverMacroTextures(); char fileName[1024]; V_strncpy( fileName, source, sizeof( fileName ) ); V_DefaultExtension( fileName, ".bsp", sizeof( fileName ) ); Msg ("Writing %s\n", fileName); WriteBSPFile (fileName); }
/* ============ EndBSPFile ============ */ void EndBSPFile( void ) { char path[1024]; EmitPlanes (); UnparseEntities (); // write the map sprintf (path, "%s.bsp", source); _printf ("Writing %s\n", path); WriteBSPFile (path); }
/* * BSP_Main */ int BSP_Main(void){ time_t start, end; char base[MAX_OSPATH]; int total_bsp_time; #ifdef _WIN32 char title[MAX_OSPATH]; sprintf(title, "Q2WMap [Compiling BSP]"); SetConsoleTitle(title); #endif Com_Print("\n----- BSP -----\n\n"); start = time(NULL); StripExtension(map_name, base); // clear the whole bsp structure memset(&d_bsp, 0, sizeof(d_bsp)); // delete portal and line files remove(va("%s.prt", base)); remove(va("%s.lin", base)); // if onlyents, just grab the entities and re-save if(onlyents){ LoadBSPFile(bsp_name); num_entities = 0; LoadMapFile(map_name); SetModelNumbers(); UnparseEntities(); WriteBSPFile(bsp_name); } else { // start from scratch LoadMapFile(map_name); SetModelNumbers(); ProcessModels(); } end = time(NULL); total_bsp_time = (int)(end - start); Com_Print("\nBSP Time: "); if(total_bsp_time > 59) Com_Print("%d Minutes ", total_bsp_time / 60); Com_Print("%d Seconds\n", total_bsp_time % 60); return 0; }
/* * @brief */ void EndBSPFile(void) { EmitBrushes(); EmitPlanes(); EmitAreaPortals(); UnparseEntities(); // now that the verts have been resolved, align the normals count d_bsp.num_normals = d_bsp.num_vertexes; // write the map Com_Verbose("Writing %s\n", bsp_name); WriteBSPFile(bsp_name); }
/* ============ OnlyEnts ============ */ void OnlyEnts( void ) { char out[1024]; sprintf (out, "%s.bsp", source); LoadBSPFile (out); num_entities = 0; LoadMapFile (name); SetModelNumbers (); SetLightStyles (); UnparseEntities (); WriteBSPFile (out); }
/* ============ WriteBSP ============ */ void WriteBSP (char *name) { char path[1024]; strcpy (path, name); DefaultExtension (path, ".bsp"); SetModelNumbers (); SetLightStyles (); UnparseEntities (); if ( !onlyents ) WriteMiptex (); WriteBSPFile (path); }
void EndBSPFile( void ){ char path[ 1024 ]; EmitPlanes(); numBSPEntities = numEntities; UnparseEntities(); /* write the surface extra file */ WriteSurfaceExtraFile( source ); /* write the bsp */ sprintf( path, "%s.bsp", source ); Sys_Printf( "Writing %s\n", path ); WriteBSPFile( path ); }
void OnlyEnts( void ){ char out[ 1024 ]; char save_cmdline[1024], save_version[1024], save_gridsize[1024]; const char *p; /* note it */ Sys_Printf( "--- OnlyEnts ---\n" ); sprintf( out, "%s.bsp", source ); LoadBSPFile( out ); ParseEntities(); p = ValueForKey( &entities[0], "_q3map2_cmdline" ); strncpy( save_cmdline, p, sizeof( save_cmdline ) ); save_cmdline[sizeof( save_cmdline ) - 1] = 0; p = ValueForKey( &entities[0], "_q3map2_version" ); strncpy( save_version, p, sizeof( save_version ) ); save_version[sizeof( save_version ) - 1] = 0; p = ValueForKey( &entities[0], "gridsize" ); strncpy( save_gridsize, p, sizeof( save_gridsize ) ); save_gridsize[sizeof( save_gridsize ) - 1] = 0; numEntities = 0; LoadShaderInfo(); LoadMapFile( name, qfalse, qfalse ); SetModelNumbers(); SetLightStyles(); if ( *save_cmdline ) { SetKeyValue( &entities[0], "_q3map2_cmdline", save_cmdline ); } if ( *save_version ) { SetKeyValue( &entities[0], "_q3map2_version", save_version ); } if ( *save_gridsize ) { SetKeyValue( &entities[0], "gridsize", save_gridsize ); } numBSPEntities = numEntities; UnparseEntities(); WriteBSPFile( out ); }
/* * @brief */ int32_t BSP_Main(void) { char base[MAX_OSPATH]; Com_Print("\n----- BSP -----\n\n"); const time_t start = time(NULL); StripExtension(map_name, base); // clear the whole bsp structure memset(&d_bsp, 0, sizeof(d_bsp)); // delete portal and line files remove(va("%s.prt", base)); remove(va("%s.lin", base)); // if onlyents, just grab the entities and re-save if (onlyents) { LoadBSPFile(bsp_name); num_entities = 0; LoadMapFile(map_name); SetModelNumbers(); UnparseEntities(); WriteBSPFile(bsp_name); } else { // start from scratch LoadMapFile(map_name); SetModelNumbers(); ProcessModels(); } const time_t end = time(NULL); const time_t duration = end - start; Com_Print("\nBSP Time: "); if (duration > 59) Com_Print("%d Minutes ", (int32_t) (duration / 60)); Com_Print("%d Seconds\n", (int32_t) (duration % 60)); return 0; }
/* ============ OnlyTextures ============ */ void OnlyTextures( void ) { // FIXME!!! char out[1024]; int i; Error( "-onlytextures isn't working now..." ); sprintf (out, "%s.bsp", source); LoadMapFile (name); LoadBSPFile (out); // replace all the drawsurface shader names for ( i = 0 ; i < numDrawSurfaces ; i++ ) { } WriteBSPFile (out); }
/* ================= 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); }
void EndBSPFile( qboolean do_write ){ char path[ 1024 ]; Sys_FPrintf( SYS_VRB, "--- EndBSPFile ---\n" ); EmitPlanes(); numBSPEntities = numEntities; UnparseEntities(); if ( do_write ) { /* write the surface extra file */ WriteSurfaceExtraFile( source ); /* write the bsp */ sprintf( path, "%s.bsp", source ); Sys_Printf( "Writing %s\n", path ); WriteBSPFile( path ); } }
void OnlyEnts( void ){ char out[ 1024 ]; /* note it */ Sys_Printf( "--- OnlyEnts ---\n" ); sprintf( out, "%s.bsp", source ); LoadBSPFile( out ); numEntities = 0; LoadShaderInfo(); LoadMapFile( name, qfalse ); SetModelNumbers(); SetLightStyles(); numBSPEntities = numEntities; UnparseEntities(); WriteBSPFile( out ); }
/* * @brief */ int32_t VIS_Main(void) { char portal_file[MAX_OSPATH]; Com_Print("\n----- VIS -----\n\n"); const time_t start = time(NULL); LoadBSPFile(bsp_name); if (d_bsp.num_nodes == 0 || d_bsp.num_faces == 0) Com_Error(ERR_FATAL, "Empty map\n"); StripExtension(map_name, portal_file); strcat(portal_file, ".prt"); LoadPortals(portal_file); CalcVis(); CalcPHS(); d_bsp.vis_data_size = map_vis.pointer - d_bsp.vis_data; Com_Print("VIS data: %d bytes (compressed from %u bytes)\n", d_bsp.vis_data_size, (uint32_t) (map_vis.uncompressed_size * 2)); WriteBSPFile(bsp_name); const time_t end = time(NULL); const time_t duration = end - start; Com_Print("\nVIS Time: "); if (duration > 59) Com_Print("%d Minutes ", (int32_t) (duration / 60)); Com_Print("%d Seconds\n", (int32_t) (duration % 60)); return 0; }
void EndBSPFile( void ){ char path[ 1024 ]; Sys_FPrintf( SYS_VRB, "--- EndBSPFile ---\n" ); EmitPlanes(); numBSPEntities = numEntities; UnparseEntities(); /* write the surface extra file */ WriteSurfaceExtraFile( source ); #ifdef SMOKINGUNS //only create tex file if it is the first compile WriteTexFile (source); #endif /* write the bsp */ sprintf( path, "%s.bsp", source ); Sys_Printf( "Writing %s\n", path ); WriteBSPFile( path ); }
/* =========== main =========== */ int main (int argc, char **argv) { char portalfile[1024]; char source[1024]; int i; double start, end; printf ("vis.exe v1.3 (%s)\n", __DATE__); printf ("---- vis ----\n"); verbose = false; for (i=1 ; i<argc ; i++) { if (!strcmp(argv[i],"-threads")) { numthreads = atoi (argv[i+1]); i++; } else if (!strcmp(argv[i], "-fast")) { printf ("fastvis = true\n"); fastvis = true; } else if (!strcmp(argv[i], "-v")) { printf ("verbose = true\n"); verbose = true; } else if (argv[i][0] == '-') Error ("Unknown option \"%s\"", argv[i]); else break; } if (i != argc - 1) Error ("usage: vis [-threads #] [-level 0-4] [-fast] [-v] bspfile"); start = I_FloatTime (); ThreadSetDefault (); printf ("%i thread(s)\n", numthreads); strcpy (source, argv[i]); StripExtension (source); DefaultExtension (source, ".bsp"); LoadBSPFile (source); strcpy (portalfile, argv[i]); StripExtension (portalfile); strcat (portalfile, ".prt"); LoadPortals (portalfile); uncompressed = malloc(bitbytes*portalleafs); memset (uncompressed, 0, bitbytes*portalleafs); CalcVis (); qprintf ("c_chains: %i\n",c_chains); visdatasize = vismap_p - dvisdata; printf ("visdatasize:%i compressed from %i\n", visdatasize, originalvismapsize); CalcAmbientSounds (); WriteBSPFile (source); // unlink (portalfile); end = I_FloatTime (); printf ("%5.1f seconds elapsed\n", end-start); free(uncompressed); return 0; }
int main (int argc, char **argv) { int i; double start, end; printf( "qrad.exe v 1.5 (%s)\n", __DATE__ ); printf ("----- Radiosity ----\n"); verbose = true; // Originally FALSE smoothing_threshold = cos(45.0*(Q_PI/180)); // Originally zero. for (i=1 ; i<argc ; i++) { if (!strcmp(argv[i],"-dump")) dumppatches = true; else if (!strcmp(argv[i],"-bounce")) { if ( ++i < argc ) { numbounce = atoi (argv[i]); if ( numbounce < 0 ) { fprintf(stderr, "Error: expected non-negative value after '-bounce'\n" ); return 1; } } else { fprintf( stderr, "Error: expected a value after '-bounce'\n" ); return 1; } } else if (!strcmp(argv[i],"-verbose")) { verbose = true; } else if (!strcmp(argv[i],"-terse")) { verbose = false; } else if (!strcmp(argv[i],"-threads")) { if ( ++i < argc ) { numthreads = atoi (argv[i]); if ( numthreads <= 0 ) { fprintf(stderr, "Error: expected positive value after '-threads'\n" ); return 1; } } else { fprintf( stderr, "Error: expected a value after '-threads'\n" ); return 1; } } else if (!strcmp(argv[i],"-maxchop")) { if ( ++i < argc ) { maxchop = (float)atof (argv[i]); if ( maxchop < 2 ) { fprintf(stderr, "Error: expected positive value after '-maxchop'\n" ); return 1; } } else { fprintf( stderr, "Error: expected a value after '-maxchop'\n" ); return 1; } } else if (!strcmp(argv[i],"-chop")) { if ( ++i < argc ) { minchop = (float)atof (argv[i]); if ( minchop < 1 ) { fprintf(stderr, "Error: expected positive value after '-chop'\n" ); return 1; } if ( minchop < 32 ) { fprintf(stderr, "WARNING: Chop values below 32 are not recommended. Use -extra instead.\n"); } } else { fprintf( stderr, "Error: expected a value after '-chop'\n" ); return 1; } } else if (!strcmp(argv[i],"-scale")) { if ( ++i < argc ) { lightscale = (float)atof (argv[i]); } else { fprintf( stderr, "Error: expected a value after '-scale'\n" ); return 1; } } else if (!strcmp(argv[i],"-ambient")) { if ( i+3 < argc ) { ambient[0] = (float)atof (argv[++i]) * 128; ambient[1] = (float)atof (argv[++i]) * 128; ambient[2] = (float)atof (argv[++i]) * 128; } else { fprintf( stderr, "Error: expected three color values after '-ambient'\n" ); return 1; } } else if( !strcmp(argv[i], "-proj") ) { if ( ++i < argc && *argv[i] ) strcpy( qproject, argv[i] ); else { fprintf(stderr, "Error: expected path name after '-proj'\n" ); return 1; } } else if ( !strcmp(argv[i], "-maxlight") ) { if ( ++i < argc && *argv[i] ) { maxlight = (float)atof (argv[i]) * 128; if ( maxlight <= 0 ) { fprintf(stderr, "Error: expected positive value after '-maxlight'\n" ); return 1; } } else { fprintf( stderr, "Error: expected a value after '-maxlight'\n" ); return 1; } } else if ( !strcmp(argv[i], "-lights" ) ) { if ( ++i < argc && *argv[i] ) { strcpy( designer_lights, argv[i] ); } else { fprintf( stderr, "Error: expected a filepath after '-lights'\n" ); return 1; } } else if ( !strcmp(argv[i], "-inc" ) ) { incremental = true; } else if (!strcmp(argv[i],"-gamma")) { if ( ++i < argc ) { gamma = (float)atof (argv[i]); } else { fprintf( stderr, "Error: expected a value after '-gamma'\n" ); return 1; } } else if (!strcmp(argv[i],"-dlight")) { if ( ++i < argc ) { dlight_threshold = (float)atof (argv[i]); } else { fprintf( stderr, "Error: expected a value after '-dlight'\n" ); return 1; } } else if (!strcmp(argv[i],"-extra")) { extra = true; } else if (!strcmp(argv[i],"-sky")) { if ( ++i < argc ) { indirect_sun = (float)atof (argv[i]); } else { fprintf( stderr, "Error: expected a value after '-gamma'\n" ); return 1; } } else if (!strcmp(argv[i],"-smooth")) { if ( ++i < argc ) { smoothing_threshold = (float)cos(atof(argv[i])*(Q_PI/180.0)); } else { fprintf( stderr, "Error: expected an angle after '-smooth'\n" ); return 1; } } else if (!strcmp(argv[i],"-coring")) { if ( ++i < argc ) { coring = (float)atof( argv[i] ); } else { fprintf( stderr, "Error: expected a light threshold after '-coring'\n" ); return 1; } } else if (!strcmp(argv[i],"-notexscale")) { texscale = false; } else { break; } } ThreadSetDefault (); if (maxlight > 255) maxlight = 255; if (i != argc - 1) Error ("usage: qrad [-dump] [-inc] [-bounce n] [-threads n] [-verbose] [-terse] [-chop n] [-maxchop n] [-scale n] [-ambient red green blue] [-proj file] [-maxlight n] [-threads n] [-lights file] [-gamma n] [-dlight n] [-extra] [-smooth n] [-coring n] [-notexscale] bspfile"); start = I_FloatTime (); strcpy (source, argv[i]); StripExtension (source); SetQdirFromPath (source); // Set the required global lights filename strcat( strcpy( global_lights, gamedir ), "lights.rad" ); if ( _access( global_lights, 0x04) == -1 ) { // try looking in qproject strcat( strcpy( global_lights, qproject ), "lights.rad" ); if ( _access( global_lights, 0x04) == -1 ) { // try looking in the directory we were run from GetModuleFileName( NULL, global_lights, sizeof( global_lights ) ); ExtractFilePath( global_lights, global_lights ); strcat( global_lights, "lights.rad" ); } } // Set the optional level specific lights filename DefaultExtension( strcpy( level_lights, source ), ".rad" ); if ( _access( level_lights, 0x04) == -1 ) *level_lights = 0; ReadLightFile(global_lights); // Required if ( *designer_lights ) ReadLightFile(designer_lights); // Command-line if ( *level_lights ) ReadLightFile(level_lights); // Optional & implied strcpy(incrementfile, source); DefaultExtension(incrementfile, ".r0"); DefaultExtension(source, ".bsp"); LoadBSPFile (source); ParseEntities (); if (!visdatasize) { printf ("No vis information, direct lighting only.\n"); numbounce = 0; ambient[0] = ambient[1] = ambient[2] = 0.1f; } RadWorld (); if (verbose) PrintBSPFileSizes (); WriteBSPFile (source); if ( incremental ) { if ( !IsIncremental(incrementfile) ) { SaveIncremental(incrementfile); } } else { unlink(incrementfile); } end = I_FloatTime (); printf ("%5.0f seconds elapsed\n", end-start); return 0; }
/* =========== VisMain =========== */ int VisMain(int argc, char **argv) { char portalfile[1024]; int i; /* note it */ Sys_Printf("--- Vis ---\n"); /* process arguments */ for(i = 1; i < (argc - 1); i++) { if(!strcmp(argv[i], "-fast")) { Sys_Printf("fastvis = true\n"); fastvis = qtrue; } else if(!strcmp(argv[i], "-merge")) { Sys_Printf("merge = true\n"); mergevis = qtrue; } else if(!strcmp(argv[i], "-mergeportals")) { Sys_Printf("mergeportals = true\n"); mergevisportals = qtrue; } else if(!strcmp(argv[i], "-nopassage")) { Sys_Printf("nopassage = true\n"); noPassageVis = qtrue; } else if(!strcmp(argv[i], "-passageOnly")) { Sys_Printf("passageOnly = true\n"); passageVisOnly = qtrue; } else if(!strcmp(argv[i], "-nosort")) { Sys_Printf("nosort = true\n"); nosort = qtrue; } else if(!strcmp(argv[i], "-v")) { debugCluster = qtrue; Sys_Printf("Extra verbose mode enabled\n"); } else if(!strcmp(argv[i], "-tmpin")) { strcpy(inbase, "/tmp"); } else if(!strcmp(argv[i], "-tmpout")) { strcpy(outbase, "/tmp"); } /* ydnar: -hint to merge all but hint portals */ else if(!strcmp(argv[i], "-hint")) { Sys_Printf("hint = true\n"); hint = qtrue; mergevis = qtrue; } else { Sys_Printf("WARNING: Unknown option \"%s\"\n", argv[i]); } } if(i != argc - 1) Error("usage: vis [-threads #] [-level 0-4] [-fast] [-v] bspfile"); /* load the bsp */ sprintf(source, "%s%s", inbase, ExpandArg(argv[i])); StripExtension(source); strcat(source, ".bsp"); Sys_Printf("Loading %s\n", source); LoadBSPFile(source); /* load the portal file */ sprintf(portalfile, "%s%s", inbase, ExpandArg(argv[i])); StripExtension(portalfile); strcat(portalfile, ".prt"); Sys_Printf("Loading %s\n", portalfile); LoadPortals(portalfile); /* ydnar: exit if no portals, hence no vis */ if(numportals == 0) { Sys_Printf("No portals means no vis, exiting.\n"); return 0; } /* ydnar: for getting far plane */ ParseEntities(); /* inject command line parameters */ InjectCommandLine(argv, 0, argc - 1); UnparseEntities(); if(mergevis) MergeLeaves(); if(mergevis || mergevisportals) MergeLeafPortals(); CountActivePortals(); /* WritePortals( "maps/hints.prs" ); */ Sys_Printf("visdatasize:%i\n", numBSPVisBytes); CalcVis(); /* write the bsp file */ Sys_Printf("Writing %s\n", source); WriteBSPFile(source); return 0; }
int ScaleBSPMain( int argc, char **argv ) { int i; float f, scale; vec3_t vec; char str[ 1024 ]; /* arg checking */ if( argc < 2 ) { Sys_Printf( "Usage: q3map -scale <value> [-v] <mapname>\n" ); return 0; } /* get scale */ scale = atof( argv[ argc - 2 ] ); if( scale == 0.0f ) { Sys_Printf( "Usage: q3map -scale <value> [-v] <mapname>\n" ); Sys_Printf( "Non-zero scale value required.\n" ); return 0; } /* do some path mangling */ strcpy( source, ExpandArg( argv[ argc - 1 ] ) ); StripExtension( source ); DefaultExtension( source, ".bsp" ); /* load the bsp */ Sys_Printf( "Loading %s\n", source ); LoadBSPFile( source ); ParseEntities(); /* note it */ Sys_Printf( "--- ScaleBSP ---\n" ); Sys_FPrintf( SYS_VRB, "%9d entities\n", numEntities ); /* scale entity keys */ for( i = 0; i < numBSPEntities && i < numEntities; i++ ) { /* scale origin */ GetVectorForKey( &entities[ i ], "origin", vec ); if( (vec[ 0 ] + vec[ 1 ] + vec[ 2 ]) ) { VectorScale( vec, scale, vec ); sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] ); SetKeyValue( &entities[ i ], "origin", str ); } /* scale door lip */ f = FloatForKey( &entities[ i ], "lip" ); if( f ) { f *= scale; sprintf( str, "%f", f ); SetKeyValue( &entities[ i ], "lip", str ); } } /* scale models */ for( i = 0; i < numBSPModels; i++ ) { VectorScale( bspModels[ i ].mins, scale, bspModels[ i ].mins ); VectorScale( bspModels[ i ].maxs, scale, bspModels[ i ].maxs ); } /* scale nodes */ for( i = 0; i < numBSPNodes; i++ ) { VectorScale( bspNodes[ i ].mins, scale, bspNodes[ i ].mins ); VectorScale( bspNodes[ i ].maxs, scale, bspNodes[ i ].maxs ); } /* scale leafs */ for( i = 0; i < numBSPLeafs; i++ ) { VectorScale( bspLeafs[ i ].mins, scale, bspLeafs[ i ].mins ); VectorScale( bspLeafs[ i ].maxs, scale, bspLeafs[ i ].maxs ); } /* scale drawverts */ for( i = 0; i < numBSPDrawVerts; i++ ) VectorScale( bspDrawVerts[ i ].xyz, scale, bspDrawVerts[ i ].xyz ); /* scale planes */ for( i = 0; i < numBSPPlanes; i++ ) bspPlanes[ i ].dist *= scale; /* scale gridsize */ GetVectorForKey( &entities[ 0 ], "gridsize", vec ); if( (vec[ 0 ] + vec[ 1 ] + vec[ 2 ]) == 0.0f ) VectorCopy( gridSize, vec ); VectorScale( vec, scale, vec ); sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] ); SetKeyValue( &entities[ 0 ], "gridsize", str ); /* write the bsp */ UnparseEntities(); StripExtension( source ); DefaultExtension( source, "_s.bsp" ); Sys_Printf( "Writing %s\n", source ); WriteBSPFile( source ); /* return to sender */ return 0; }
/* * ================== * 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; }
int ConvertBSPMain( int argc, char **argv ) { int i; int (*convertFunc)( char * ); game_t *convertGame; /* set default */ convertFunc = ConvertBSPToASE; convertGame = NULL; /* arg checking */ if( argc < 1 ) { Sys_Printf( "Usage: q3map -scale <value> [-v] <mapname>\n" ); return 0; } /* process arguments */ for( i = 1; i < (argc - 1); i++ ) { /* -format map|ase|... */ if( !strcmp( argv[ i ], "-format" ) ) { i++; if( !Q_stricmp( argv[ i ], "ase" ) ) convertFunc = ConvertBSPToASE; else if( !Q_stricmp( argv[ i ], "map" ) ) convertFunc = ConvertBSPToMap; else { convertGame = GetGame( argv[ i ] ); if( convertGame == NULL ) Sys_Printf( "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] ); } } } /* clean up map name */ strcpy( source, ExpandArg( argv[ i ] ) ); StripExtension( source ); DefaultExtension( source, ".bsp" ); LoadShaderInfo(); Sys_Printf( "Loading %s\n", source ); /* ydnar: load surface file */ //% LoadSurfaceExtraFile( source ); LoadBSPFile( source ); /* parse bsp entities */ ParseEntities(); /* bsp format convert? */ if( convertGame != NULL ) { /* set global game */ game = convertGame; /* write bsp */ StripExtension( source ); DefaultExtension( source, "_c.bsp" ); Sys_Printf( "Writing %s\n", source ); WriteBSPFile( source ); /* return to sender */ return 0; } /* normal convert */ return convertFunc( source ); }