creates a full bsp + surfaces for the worldspawn entity
*/
-void ProcessWorldModel( void ){
+void ProcessWorldModel( const char *portalFilePath, const char *lineFilePath ){
int i, s;
entity_t *e;
tree_t *tree;
Sys_FPrintf( SYS_NOXML, "**********************\n" );
Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" );
Sys_FPrintf( SYS_NOXML, "**********************\n" );
- polyline = LeakFile( tree );
+ polyline = LeakFile( tree, lineFilePath );
leaknode = xmlNewNode( NULL, (xmlChar*)"message" );
xmlNodeSetContent( leaknode, (xmlChar*)"MAP LEAKED\n" );
xmlAddChild( leaknode, polyline );
/* save out information for visibility processing */
NumberClusters( tree );
if ( !leaked ) {
- WritePortalFile( tree );
+ WritePortalFile( tree, portalFilePath );
}
/* flood from entities */
process world + other models into the bsp
*/
-void ProcessModels( void ){
+void ProcessModels( const char *portalFilePath, const char *lineFilePath ){
qboolean oldVerbose;
entity_t *entity;
/* process the model */
Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
if ( mapEntityNum == 0 ) {
- ProcessWorldModel();
+ ProcessWorldModel(portalFilePath, lineFilePath);
}
else{
ProcessSubModel();
this is probably broken unless teamed with a radiant version that preserves entity order
*/
-void OnlyEnts( void ){
- char out[ 1024 ];
-
+void OnlyEnts( const char *BSPFilePath ){
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 );
+ LoadBSPFile( BSPFilePath );
ParseEntities();
p = ValueForKey( &entities[0], "_q3map2_cmdline" );
numBSPEntities = numEntities;
UnparseEntities();
- WriteBSPFile( out );
+ WriteBSPFile( BSPFilePath );
}
int i;
char path[ 1024 ], tempSource[ 1024 ];
qboolean onlyents = qfalse;
+ char BSPFilePath [ 1024 ];
+ char lineFilePath [ 1024 ];
+ char portalFilePath [ 1024 ];
+ char surfaceFilePath [ 1024 ];
+ BSPFilePath[0] = 0;
+ lineFilePath[0] = 0;
+ portalFilePath[0] = 0;
+ surfaceFilePath[0] = 0;
/* note it */
Sys_Printf( "Max Area face surface generation enabled\n" );
maxAreaFaceSurface = qtrue;
}
+ else if ( !strcmp( argv[ i ], "-bspfile" ) )
+ {
+ strcpy( BSPFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as bsp file\n", BSPFilePath );
+ }
+ else if ( !strcmp( argv[ i ], "-linfile" ) )
+ {
+ strcpy( lineFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as line file\n", lineFilePath );
+ }
+ else if ( !strcmp( argv[ i ], "-prtfile" ) )
+ {
+ strcpy( portalFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as portal file\n", portalFilePath );
+ }
+ else if ( !strcmp( argv[ i ], "-srffile" ) )
+ {
+ strcpy( surfaceFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as surface file\n", surfaceFilePath );
+ }
else if ( !strcmp( argv[ i ], "-bsp" ) ) {
Sys_Printf( "-bsp argument unnecessary\n" );
}
/* ydnar: set default sample size */
SetDefaultSampleSize( sampleSize );
+ if (!BSPFilePath[0]) {
+ sprintf( BSPFilePath, "%s.bsp", source );
+ }
+ if (!lineFilePath[0]) {
+ sprintf( lineFilePath, "%s.lin", source );
+ }
+ if (!portalFilePath[0]) {
+ sprintf( portalFilePath, "%s.prt", source );
+ }
+ if (!surfaceFilePath[0]) {
+ sprintf( surfaceFilePath, "%s.srf", source );
+ }
+
/* delete portal, line and surface files */
- sprintf( path, "%s.prt", source );
- remove( path );
- sprintf( path, "%s.lin", source );
- remove( path );
- //% sprintf( path, "%s.srf", source ); /* ydnar */
- //% remove( path );
+ remove( portalFilePath );
+ remove( lineFilePath );
+ //% remove( surfaceFilePath ) /* ydnar */
/* expand mapname */
strcpy( name, ExpandArg( argv[ i ] ) );
/* if onlyents, just grab the entites and resave */
if ( onlyents ) {
- OnlyEnts();
+ OnlyEnts( BSPFilePath );
return 0;
}
SetCloneModelNumbers();
/* process world and submodels */
- ProcessModels();
+ ProcessModels( portalFilePath, lineFilePath );
/* set light styles from targetted light entities */
SetLightStyles();
ProcessAdvertisements();
/* finish and write bsp */
- EndBSPFile( qtrue );
+ EndBSPFile( qtrue, BSPFilePath, surfaceFilePath );
/* remove temp map source file if appropriate */
if ( strlen( tempSource ) > 0 ) {
PseudoCompileBSP()
a stripped down ProcessModels
*/
-void PseudoCompileBSP( qboolean need_tree ){
+void PseudoCompileBSP( qboolean need_tree, const char *BSPFilePath, const char *surfaceFilePath ){
int models;
char modelValue[10];
entity_t *entity;
EmitBrushes( entity->brushes, &entity->firstBrush, &entity->numBrushes );
EndModel( entity, node );
}
- EndBSPFile( qfalse );
+ EndBSPFile( qfalse, BSPFilePath, surfaceFilePath );
}
/*
int ( *convertFunc )( char * );
game_t *convertGame;
char ext[1024];
+ char BSPFilePath [ 1024 ];
+ char surfaceFilePath [ 1024 ];
qboolean map_allowed, force_bsp, force_map;
DefaultExtension( source, ".map" );
Sys_Printf( "Loading %s\n", source );
LoadMapFile( source, qfalse, convertGame == NULL );
- PseudoCompileBSP( convertGame != NULL );
+ sprintf( BSPFilePath, "%s.bsp", source );
+ sprintf( surfaceFilePath, "%s.srf", source );
+ PseudoCompileBSP( convertGame != NULL, BSPFilePath, surfaceFilePath );
}
else
{
struct HelpOption bsp[] = {
{"-bsp <filename.map>", "Switch that enters this stage"},
{"-altsplit", "Alternate BSP tree splitting weights (should give more fps)"},
+ {"-bspfile <filename.bsp>", "BSP file to write"},
{"-celshader <shadername>", "Sets a global cel shader name"},
{"-custinfoparms", "Read scripts/custinfoparms.txt"},
{"-debuginset", "Push all triangle vertexes towards the triangle center"},
{"-flat", "Enable flat shading (good for combining with -celshader)"},
{"-fulldetail", "Treat detail brushes as structural ones"},
{"-leaktest", "Abort if a leak was found"},
+ {"-linefile <filename.lin>", "Line file to write"},
{"-meta", "Combine adjacent triangles of the same texture to surfaces (ALWAYS USE THIS)"},
{"-minsamplesize <N>", "Sets minimum lightmap resolution in luxels/qu"},
{"-mi <N>", "Sets the maximum number of indexes per surface"},
{"-np <A>", "Force all surfaces to be nonplanar with a given shade angle"},
{"-onlyents", "Only update entities in the BSP"},
{"-patchmeta", "Turn patches into triangle meshes for display"},
- {"-rename", "Append “bspâ€\9d suffix to miscmodel shaders (needed for SoF2)"},
+ {"-prtfile <filename.prt>", "Portal file to write"},
+ {"-rename", "Append suffix to miscmodel shaders (needed for SoF2)"},
{"-samplesize <N>", "Sets default lightmap resolution in luxels/qu"},
{"-skyfix", "Turn sky box into six surfaces to work around ATI problems"},
{"-snap <N>", "Snap brush bevel planes to the given number of units"},
+ {"-srffile <filename.srf>", "Surface file to write"},
{"-tempname <filename.map>", "Read the MAP file from the given file name"},
{"-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"},
{"-tmpout", "Write the BSP file to /tmp"},
{"-nopassage", "Just use PortalFlow vis (usually less fps)"},
{"-nosort", "Do not sort the portals before calculating vis (usually slower)"},
{"-passageOnly", "Just use PassageFlow vis (usually less fps)"},
- {"-saveprt", "Keep the PRT file after running vis (so you can run vis again)"},
+ {"-prtfile <filename.prt>", "Portal file to read"},
+ {"-saveprt", "Keep the Portal file after running vis (so you can run vis again)"},
{"-tmpin", "Use /tmp folder for input"},
{"-tmpout", "Use /tmp folder for output"},
};
{"-bounceonly", "Only compute radiosity"},
{"-bouncescale <F>", "Scaling factor for radiosity"},
{"-bounce <N>", "Number of bounces for radiosity"},
+ {"-bspfile <filename.bsp>", "BSP file to write"},
{"-cheapgrid", "Use `-cheap` style lighting for radiosity"},
{"-cheap", "Abort vertex light calculations when white is reached"},
{"-compensate <F>", "Lightmap compensate (darkening factor applied after everything else)"},
{"-shade", "Enable phong shading at default shade angle"},
{"-skyscale <F, `-sky` F>", "Scaling factor for sky and sun light"},
{"-smooth", "Deprecated alias for `-samples 2`"},
+ {"-srffile <filename.srf>", "Surface file to read"},
{"-style, -styles", "Enable support for light styles"},
{"-sunonly", "Only compute sun light"},
{"-super <N, `-supersample` N>", "Ordered grid supersampling quality"},
LEAK FILE GENERATION
- Save out name.line for qe3 to read
+ Save out name.lin for qe3 to read
==============================================================================
*/
TTimo: builds a polyline xml node
=============
*/
-xmlNodePtr LeakFile( tree_t *tree ){
+xmlNodePtr LeakFile( tree_t *tree, const char *filename ){
vec3_t mid;
FILE *linefile;
- char filename[1024];
node_t *node;
int count;
xmlNodePtr xml_node, point;
//
// write the points to the file
//
- sprintf( filename, "%s.lin", source );
linefile = fopen( filename, "w" );
if ( !linefile ) {
Error( "Couldn't open %s\n", filename );
does what it says...
*/
-void LightWorld( void ){
+void LightWorld( const char *BSPFilePath ){
vec3_t color;
float f;
int b, bt;
/* store off the bsp between bounces */
StoreSurfaceLightmaps();
UnparseEntities();
- Sys_Printf( "Writing %s\n", source );
- WriteBSPFile( source );
+ Sys_Printf( "Writing %s\n", BSPFilePath );
+ WriteBSPFile( BSPFilePath );
/* note it */
Sys_Printf( "\n--- Radiosity (bounce %d of %d) ---\n", b, bt );
int LightMain( int argc, char **argv ){
int i;
float f;
- char mapSource[ 1024 ];
+ char BSPFilePath[ 1024 ];
+ char surfaceFilePath[ 1024 ];
+ BSPFilePath[0] = 0;
+ surfaceFilePath[0] = 0;
const char *value;
int lightmapMergeSize = 0;
qboolean lightSamplesInsist = qfalse;
lightmapFill = qtrue;
Sys_Printf( "Filling lightmap colors from surrounding pixels to improve JPEG compression\n" );
}
+ else if ( !strcmp( argv[ i ], "-bspfile" ) )
+ {
+ strcpy( BSPFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as bsp file\n", BSPFilePath );
+ }
+ else if ( !strcmp( argv[ i ], "-srffile" ) )
+ {
+ strcpy( surfaceFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as surface file\n", surfaceFilePath );
+ }
/* unhandled args */
else
{
Sys_Printf( "Restricted lightmap searching enabled - block size adjusted to %d\n", lightmapSearchBlockSize );
}
- /* clean up map name */
strcpy( source, ExpandArg( argv[ i ] ) );
StripExtension( source );
- DefaultExtension( source, ".bsp" );
- strcpy( mapSource, ExpandArg( argv[ i ] ) );
- StripExtension( mapSource );
- DefaultExtension( mapSource, ".map" );
+ DefaultExtension( source, ".map" );
+
+ if (!BSPFilePath[0]) {
+ strcpy( BSPFilePath, ExpandArg( argv[ i ] ) );
+ StripExtension( BSPFilePath );
+ DefaultExtension( BSPFilePath, ".bsp" );
+ }
+
+ if (!surfaceFilePath[0]) {
+ strcpy( surfaceFilePath, ExpandArg( argv[ i ] ) );
+ StripExtension( surfaceFilePath );
+ DefaultExtension( surfaceFilePath, ".srf" );
+ }
/* ydnar: set default sample size */
SetDefaultSampleSize( sampleSize );
/* ydnar: handle shaders */
- BeginMapShaderFile( source );
+ BeginMapShaderFile( BSPFilePath );
LoadShaderInfo();
/* note loading */
Sys_Printf( "Loading %s\n", source );
/* ydnar: load surface file */
- LoadSurfaceExtraFile( source );
+ LoadSurfaceExtraFile( surfaceFilePath );
/* load bsp file */
- LoadBSPFile( source );
+ LoadBSPFile( BSPFilePath );
/* parse bsp entities */
ParseEntities();
/* load map file */
value = ValueForKey( &entities[ 0 ], "_keepLights" );
if ( value[ 0 ] != '1' ) {
- LoadMapFile( mapSource, qtrue, qfalse );
+ LoadMapFile( source, qtrue, qfalse );
}
/* set the entity/model origins and init yDrawVerts */
SetupTraceNodes();
/* light the world */
- LightWorld();
+ LightWorld( BSPFilePath );
/* ydnar: store off lightmaps */
StoreSurfaceLightmaps();
/* write out the bsp */
UnparseEntities();
- Sys_Printf( "Writing %s\n", source );
- WriteBSPFile( source );
+ Sys_Printf( "Writing %s\n", BSPFilePath );
+ WriteBSPFile( BSPFilePath );
/* ydnar: export lightmaps */
if ( exportLightmaps && !externalLightmaps ) {
WritePortalFile
================
*/
-void WritePortalFile( tree_t *tree ){
- char filename[1024];
+void WritePortalFile( tree_t *tree, const char *portalFilePath ){
Sys_FPrintf( SYS_VRB,"--- WritePortalFile ---\n" );
// write the file
- sprintf( filename, "%s.prt", source );
- Sys_Printf( "writing %s\n", filename );
- pf = fopen( filename, "w" );
+ Sys_Printf( "writing %s\n", portalFilePath );
+ pf = fopen( portalFilePath, "w" );
if ( !pf ) {
- Error( "Error opening %s", filename );
+ Error( "Error opening %s", portalFilePath );
}
fprintf( pf, "%s\n", PORTALFILE );
/* leakfile.c */
-xmlNodePtr LeakFile( tree_t *tree );
+xmlNodePtr LeakFile( tree_t *tree, const char *lineFilePath );
/* prtfile.c */
void NumberClusters( tree_t *tree );
-void WritePortalFile( tree_t *tree );
+void WritePortalFile( tree_t *tree, const char *portalFilePath );
/* writebsp.c */
int EmitShader( const char *shader, int *contentFlags, int *surfaceFlags );
void BeginBSPFile( void );
-void EndBSPFile( qboolean do_write );
+void EndBSPFile( qboolean do_write, const char *BSPFilePath, const char *surfaceFilePath );
void EmitBrushes( brush_t *brushes, int *firstBrush, int *numBrushes );
void EmitFogs( void );
float GetSurfaceExtraLongestCurve( int num );
void GetSurfaceExtraLightmapAxis( int num, vec3_t lightmapAxis );
-void WriteSurfaceExtraFile( const char *path );
-void LoadSurfaceExtraFile( const char *path );
+void WriteSurfaceExtraFile( const char *surfaceFilePath );
+void LoadSurfaceExtraFile( const char *surfaceFilePath );
/* decals.c */
writes out a surface info file (<map>.srf)
*/
-void WriteSurfaceExtraFile( const char *path ){
- char srfPath[ 1024 ];
+void WriteSurfaceExtraFile( const char *surfaceFilePath ){
FILE *sf;
surfaceExtra_t *se;
int i;
/* dummy check */
- if ( path == NULL || path[ 0 ] == '\0' ) {
+ if ( surfaceFilePath == NULL || surfaceFilePath[ 0 ] == '\0' ) {
return;
}
Sys_Printf( "--- WriteSurfaceExtraFile ---\n" );
/* open the file */
- strcpy( srfPath, path );
- StripExtension( srfPath );
- strcat( srfPath, ".srf" );
- Sys_Printf( "Writing %s\n", srfPath );
- sf = fopen( srfPath, "w" );
+ Sys_Printf( "Writing %s\n", surfaceFilePath );
+ sf = fopen( surfaceFilePath, "w" );
if ( sf == NULL ) {
- Error( "Error opening %s for writing", srfPath );
+ Error( "Error opening %s for writing", surfaceFilePath );
}
/* lap through the extras list */
reads a surface info file (<map>.srf)
*/
-void LoadSurfaceExtraFile( const char *path ){
- char srfPath[ 1024 ];
+void LoadSurfaceExtraFile( const char *surfaceFilePath ){
surfaceExtra_t *se;
int surfaceNum, size;
byte *buffer;
/* dummy check */
- if ( path == NULL || path[ 0 ] == '\0' ) {
+ if ( surfaceFilePath == NULL || surfaceFilePath[ 0 ] == '\0' ) {
return;
}
/* load the file */
- strcpy( srfPath, path );
- StripExtension( srfPath );
- strcat( srfPath, ".srf" );
- Sys_Printf( "Loading %s\n", srfPath );
- size = LoadFile( srfPath, (void**) &buffer );
+ Sys_Printf( "Loading %s\n", surfaceFilePath );
+ size = LoadFile( surfaceFilePath, (void**) &buffer );
if ( size <= 0 ) {
- Sys_Printf( "WARNING: Unable to find surface file %s, using defaults.\n", srfPath );
+ Sys_Printf( "WARNING: Unable to find surface file %s, using defaults.\n", surfaceFilePath );
return;
}
{
surfaceNum = atoi( token );
if ( surfaceNum < 0 || surfaceNum > MAX_MAP_DRAW_SURFS ) {
- Error( "ReadSurfaceExtraFile(): %s, line %d: bogus surface num %d", srfPath, scriptline, surfaceNum );
+ Error( "ReadSurfaceExtraFile(): %s, line %d: bogus surface num %d", surfaceFilePath, scriptline, surfaceNum );
}
while ( surfaceNum >= numSurfaceExtras )
se = AllocSurfaceExtra();
/* handle { } section */
if ( !GetToken( qtrue ) || strcmp( token, "{" ) ) {
- Error( "ReadSurfaceExtraFile(): %s, line %d: { not found", srfPath, scriptline );
+ Error( "ReadSurfaceExtraFile(): %s, line %d: { not found", surfaceFilePath, scriptline );
}
while ( 1 )
{
*/
void WriteFloat( FILE *f, vec_t v );
-void WritePortals( char *filename ){
+void WritePortals( char *portalpathfile ){
int i, j, num;
FILE *pf;
vportal_t *p;
fixedWinding_t *w;
// write the file
- pf = fopen( filename, "w" );
+ pf = fopen( portalpathfile, "w" );
if ( !pf ) {
- Error( "Error opening %s", filename );
+ Error( "Error opening %s", portalpathfile );
}
num = 0;
===========
*/
int VisMain( int argc, char **argv ){
- char portalfile[1024];
int i;
+ char portalFilePath[ 1024 ];
+ portalFilePath[0] = 0;
/* note it */
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 if ( !strcmp( argv[ i ], "-prtfile" ) )
+ {
+ strcpy( portalFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as portal file\n", portalFilePath );
+ }
else
{
}
if ( i != argc - 1 ) {
- Error( "usage: vis [-threads #] [-level 0-4] [-fast] [-v] bspfile" );
+ Error( "usage: vis [-threads #] [-level 0-4] [-fast] [-v] BSPFilePath" );
}
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 );
+ if (!portalFilePath[0]) {
+ sprintf( portalFilePath, "%s%s", inbase, ExpandArg( argv[ i ] ) );
+ StripExtension( portalFilePath );
+ strcat( portalFilePath, ".prt" );
+ Sys_Printf( "Loading %s\n", portalFilePath );
+ LoadPortals( portalFilePath );
+ }
/* ydnar: exit if no portals, hence no vis */
if ( numportals == 0 ) {
/* delete the prt file */
if ( !saveprt ) {
- remove( portalfile );
+ remove( portalFilePath );
}
/* write the bsp file */
finishes a new bsp and writes to disk
*/
-void EndBSPFile( qboolean do_write ){
- char path[ 1024 ];
-
+void EndBSPFile( qboolean do_write, const char *BSPFilePath, const char *surfaceFilePath ){
Sys_FPrintf( SYS_VRB, "--- EndBSPFile ---\n" );
if ( do_write ) {
/* write the surface extra file */
- WriteSurfaceExtraFile( source );
+ WriteSurfaceExtraFile( surfaceFilePath );
/* write the bsp */
- sprintf( path, "%s.bsp", source );
- Sys_Printf( "Writing %s\n", path );
- WriteBSPFile( path );
+ Sys_Printf( "Writing %s\n", BSPFilePath );
+ WriteBSPFile( BSPFilePath );
}
}