コード例 #1
0
ファイル: qbsp.c プロジェクト: darkshade9/aq2w
/*
 * 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;
}
コード例 #2
0
ファイル: graphprocess.cpp プロジェクト: Bradeskojest/qminer
TGraphCascade::TGraphCascade(const PJsonVal& Params) {
    // build graph and node name-id maps
    PJsonVal Dag = Params->GetObjKey("dag");
    GenGraph(Dag);
    // read enabled (ignore the ones missing from the graph)
    PJsonVal EnabledNodeIdH = Params->GetObjKey("enabledNodes");
    ProcessEnabled(EnabledNodeIdH);
    PruneGraph();
    InitTimestamps();
    // read models
    PJsonVal NodeModels = Params->GetObjKey("nodeModels");
    ProcessModels(NodeModels);
    TimeUnit = Params->GetObjInt("timeUnit", 1000);
    Rnd.PutSeed(Params->GetObjInt("randSeed", 0));
}
コード例 #3
0
ファイル: qbsp.c プロジェクト: jayschwa/quake2world
/*
 * @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;
}
コード例 #4
0
void QSceneDisplay::ProcessSelection( int xPos,int yPos )
{
	GLfloat aspect;
	GLuint selectBuff[BUFFER_LENGTH];
	GLint hits,viewport[4];

	glSelectBuffer(BUFFER_LENGTH,selectBuff);
	glGetIntegerv(GL_VIEWPORT,viewport);

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();

	glRenderMode(GL_SELECT);
	glLoadIdentity();
	gluPickMatrix(xPos,viewport[3]-yPos,2,2,viewport);

	glOrtho(plane[0],plane[1],plane[2],plane[3],-10000,10000);
	gluLookAt(eye[0],eye[1],eye[2],scene->bsphere.center[0],scene->bsphere.center[1],scene->bsphere.center[2],up[0],up[1],up[2]);

	DrawScene();

	hits=glRenderMode(GL_RENDER);

	if(hits>0)
		ProcessModels(selectBuff);
	else
	{
		selectModel=-1;
		 updateGL();
	}

	glMatrixMode(GL_PROJECTION);
	glPopMatrix();

	glMatrixMode(GL_MODELVIEW);
}
コード例 #5
0
ファイル: dmap.cpp プロジェクト: 0culus/Doom3-for-MacOSX-
/*
============
Dmap
============
*/
void Dmap( const idCmdArgs &args ) {
	int			i;
	int			start, end;
	char		path[1024];
	idStr		passedName;
	bool		leaked = false;
	bool		noCM = false;
	bool		noAAS = false;

	ResetDmapGlobals();

	if ( args.Argc() < 2 ) {
		DmapHelp();
		return;
	}

	common->Printf("---- dmap ----\n");

	dmapGlobals.fullCarve = true;
	dmapGlobals.shadowOptLevel = SO_MERGE_SURFACES;		// create shadows by merging all surfaces, but no super optimization
//	dmapGlobals.shadowOptLevel = SO_CLIP_OCCLUDERS;		// remove occluders that are completely covered
//	dmapGlobals.shadowOptLevel = SO_SIL_OPTIMIZE;
//	dmapGlobals.shadowOptLevel = SO_CULL_OCCLUDED;

	dmapGlobals.noLightCarve = true;

	for ( i = 1 ; i < args.Argc() ; i++ ) {
		const char *s;

		s = args.Argv(i);
		if ( s[0] == '-' ) {
			s++;
			if ( s[0] == '\0' ) {
				continue;
			}
		}

		if ( !idStr::Icmp( s,"glview" ) ) {
			dmapGlobals.glview = true;
		} else if ( !idStr::Icmp( s, "v" ) ) {
			common->Printf( "verbose = true\n" );
			dmapGlobals.verbose = true;
		} else if ( !idStr::Icmp( s, "draw" ) ) {
			common->Printf( "drawflag = true\n" );
			dmapGlobals.drawflag = true;
		} else if ( !idStr::Icmp( s, "noFlood" ) ) {
			common->Printf( "noFlood = true\n" );
			dmapGlobals.noFlood = true;
		} else if ( !idStr::Icmp( s, "noLightCarve" ) ) {
			common->Printf( "noLightCarve = true\n" );
			dmapGlobals.noLightCarve = true;
		} else if ( !idStr::Icmp( s, "lightCarve" ) ) {
			common->Printf( "noLightCarve = false\n" );
			dmapGlobals.noLightCarve = false;
		} else if ( !idStr::Icmp( s, "noOpt" ) ) {
			common->Printf( "noOptimize = true\n" );
			dmapGlobals.noOptimize = true;
		} else if ( !idStr::Icmp( s, "verboseentities" ) ) {
			common->Printf( "verboseentities = true\n");
			dmapGlobals.verboseentities = true;
		} else if ( !idStr::Icmp( s, "noCurves" ) ) {
			common->Printf( "noCurves = true\n");
			dmapGlobals.noCurves = true;
		} else if ( !idStr::Icmp( s, "noModels" ) ) {
			common->Printf( "noModels = true\n" );
			dmapGlobals.noModelBrushes = true;
		} else if ( !idStr::Icmp( s, "noClipSides" ) ) {
			common->Printf( "noClipSides = true\n" );
			dmapGlobals.noClipSides = true;
		} else if ( !idStr::Icmp( s, "noCarve" ) ) {
			common->Printf( "noCarve = true\n" );
			dmapGlobals.fullCarve = false;
		} else if ( !idStr::Icmp( s, "shadowOpt" ) ) {
			dmapGlobals.shadowOptLevel = (shadowOptLevel_t)atoi( args.Argv( i+1 ) );
			common->Printf( "shadowOpt = %i\n",dmapGlobals.shadowOptLevel );
			i += 1;
		} else if ( !idStr::Icmp( s, "noTjunc" ) ) {
			// triangle optimization won't work properly without tjunction fixing
			common->Printf ("noTJunc = true\n" );
			dmapGlobals.noTJunc = true;
			dmapGlobals.noOptimize = true;
			common->Printf ("forcing noOptimize = true\n" );
		} else if ( !idStr::Icmp( s, "noCM" ) ) {
			noCM = true;
			common->Printf( "noCM = true\n" );
		} else if ( !idStr::Icmp( s, "noAAS" ) ) {
			noAAS = true;
			common->Printf( "noAAS = true\n" );
		} else if ( !idStr::Icmp( s, "editorOutput" ) ) {
#ifdef _WIN32
			com_outputMsg = true;
#endif
		} else {
			break;
		}
	}

	if ( i >= args.Argc() ) {
		common->Error( "usage: dmap [options] mapfile" );
	}

	passedName = args.Argv(i);		// may have an extension
	passedName.BackSlashesToSlashes();
	if ( passedName.Icmpn( "maps/", 4 ) != 0 ) {
		passedName = "maps/" + passedName;
	}

	idStr stripped = passedName;
	stripped.StripFileExtension();
	idStr::Copynz( dmapGlobals.mapFileBase, stripped, sizeof(dmapGlobals.mapFileBase) );

	bool region = false;
	// if this isn't a regioned map, delete the last saved region map
	if ( passedName.Right( 4 ) != ".reg" ) {
		sprintf( path, "%s.reg", dmapGlobals.mapFileBase );
		fileSystem->RemoveFile( path );
	} else {
		region = true;
	}


	passedName = stripped;

	// delete any old line leak files
	sprintf( path, "%s.lin", dmapGlobals.mapFileBase );
	fileSystem->RemoveFile( path );


	//
	// start from scratch
	//
	start = Sys_Milliseconds();

	if ( !LoadDMapFile( passedName ) ) {
		return;
	}

	if ( ProcessModels() ) {
		WriteOutputFile();
	} else {
		leaked = true;
	}

	FreeDMapFile();

	common->Printf( "%i total shadow triangles\n", dmapGlobals.totalShadowTriangles );
	common->Printf( "%i total shadow verts\n", dmapGlobals.totalShadowVerts );

	end = Sys_Milliseconds();
	common->Printf( "-----------------------\n" );
	common->Printf( "%5.0f seconds for dmap\n", ( end - start ) * 0.001f );

	if ( !leaked ) {

		if ( !noCM ) {

			// make sure the collision model manager is not used by the game
			cmdSystem->BufferCommandText( CMD_EXEC_NOW, "disconnect" );

			// create the collision map
			start = Sys_Milliseconds();

			collisionModelManager->LoadMap( dmapGlobals.dmapFile );
			collisionModelManager->FreeMap();

			end = Sys_Milliseconds();
			common->Printf( "-------------------------------------\n" );
			common->Printf( "%5.0f seconds to create collision map\n", ( end - start ) * 0.001f );
		}

		if ( !noAAS && !region ) {
			// create AAS files
			RunAAS_f( args );
		}
	}

	// free the common .map representation
	delete dmapGlobals.dmapFile;

	// clear the map plane list
	dmapGlobals.mapPlanes.Clear();

#ifdef _WIN32
	if ( com_outputMsg && com_hwndMsg != NULL ) {
		unsigned int msg = ::RegisterWindowMessage( DMAP_DONE );
		::PostMessage( com_hwndMsg, msg, 0, 0 );
	}
#endif
}
コード例 #6
0
ファイル: bsp.c プロジェクト: Teivaz/nebula2
int BSPMain( int argc, char **argv )
{
    int            i;
    char        path[ 1024 ], tempSource[ 1024 ];
    qboolean    onlyents = qfalse;
    
    
    /* note it */
    Sys_Printf( "--- BSP ---\n" );
    
    SetDrawSurfacesBuffer();
    mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
    memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
    numMapDrawSurfs = 0;
    
    tempSource[ 0 ] = '\0';
    
    /* set standard game flags */
    maxSurfaceVerts = game->maxSurfaceVerts;
    maxSurfaceIndexes = game->maxSurfaceIndexes;
    emitFlares = game->emitFlares;
    
    /* process arguments */
    for( i = 1; i < (argc - 1); i++ )
    {
        if( !strcmp( argv[ i ], "-onlyents" ) )
        {
            Sys_Printf( "Running entity-only compile\n" );
            onlyents = qtrue;
        }
        else if( !strcmp( argv[ i ], "-tempname" ) )
            strcpy( tempSource, argv[ ++i ] );
        else if( !strcmp( argv[ i ], "-tmpout" ) )
            strcpy( outbase, "/tmp" );
        else if( !strcmp( argv[ i ],  "-nowater" ) )
        {
            Sys_Printf( "Disabling water\n" );
            nowater = qtrue;
        }
        else if( !strcmp( argv[ i ],  "-nodetail" ) )
        {
            Sys_Printf( "Ignoring detail brushes\n") ;
            nodetail = qtrue;
        }
        else if( !strcmp( argv[ i ],  "-fulldetail" ) )
        {
            Sys_Printf( "Turning detail brushes into structural brushes\n" );
            fulldetail = qtrue;
        }
        else if( !strcmp( argv[ i ],  "-nofog" ) )
        {
            Sys_Printf( "Fog volumes disabled\n" );
            nofog = qtrue;
        }
        else if( !strcmp( argv[ i ],  "-nosubdivide" ) )
        {
            Sys_Printf( "Disabling brush face subdivision\n" );
            nosubdivide = qtrue;
        }
        else if( !strcmp( argv[ i ],  "-leaktest" ) )
        {
            Sys_Printf( "Leaktest enabled\n" );
            leaktest = qtrue;
        }
        else if( !strcmp( argv[ i ],  "-verboseentities" ) )
        {
            Sys_Printf( "Verbose entities enabled\n" );
            verboseEntities = qtrue;
        }
        else if( !strcmp( argv[ i ], "-nocurves" ) )
        {
            Sys_Printf( "Ignoring curved surfaces (patches)\n" );
            noCurveBrushes = qtrue;
        }
        else if( !strcmp( argv[ i ], "-notjunc" ) )
        {
            Sys_Printf( "T-junction fixing disabled\n" );
            notjunc = qtrue;
        }
        else if( !strcmp( argv[ i ], "-fakemap" ) )
        {
            Sys_Printf( "Generating fakemap.map\n" );
            fakemap = qtrue;
        }
        else if( !strcmp( argv[ i ],  "-samplesize" ) )
         {
            sampleSize = atoi( argv[ i + 1 ] );
            if( sampleSize < 1 )
                sampleSize = 1;
             i++;
            Sys_Printf( "Lightmap sample size set to %dx%d units\n", sampleSize, sampleSize );
         }
        else if( !strcmp( argv[ i ],  "-custinfoparms") )
        {
            Sys_Printf( "Custom info parms enabled\n" );
            useCustomInfoParms = qtrue;
        }
        
        /* sof2 args */
        else if( !strcmp( argv[ i ], "-rename" ) )
        {
            Sys_Printf( "Appending _bsp suffix to misc_model shaders (SOF2)\n" );
            renameModelShaders = qtrue;
        }
        
        /* ydnar args */
        else if( !strcmp( argv[ i ],  "-ne" ) )
         {
            normalEpsilon = atof( argv[ i + 1 ] );
             i++;
            Sys_Printf( "Normal epsilon set to %f\n", normalEpsilon );
         }
        else if( !strcmp( argv[ i ],  "-de" ) )
         {
            distanceEpsilon = atof( argv[ i + 1 ] );
             i++;
            Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon );
         }
        else if( !strcmp( argv[ i ],  "-mv" ) )
         {
            maxLMSurfaceVerts = atoi( argv[ i + 1 ] );
            if( maxLMSurfaceVerts < 3 )
                maxLMSurfaceVerts = 3;
            if( maxLMSurfaceVerts > maxSurfaceVerts )
                maxSurfaceVerts = maxLMSurfaceVerts;
             i++;
            Sys_Printf( "Maximum lightmapped surface vertex count set to %d\n", maxLMSurfaceVerts );
         }
        else if( !strcmp( argv[ i ],  "-mi" ) )
         {
            maxSurfaceIndexes = atoi( argv[ i + 1 ] );
            if( maxSurfaceIndexes < 3 )
                maxSurfaceIndexes = 3;
             i++;
            Sys_Printf( "Maximum per-surface index count set to %d\n", maxSurfaceIndexes );
         }
        else if( !strcmp( argv[ i ], "-np" ) )
        {
            npDegrees = atof( argv[ i + 1 ] );
            if( npDegrees < 0.0f )
                shadeAngleDegrees = 0.0f;
            else if( npDegrees > 0.0f )
                Sys_Printf( "Forcing nonplanar surfaces with a breaking angle of %f degrees\n", npDegrees );
            i++;
        }
        else if( !strcmp( argv[ i ],  "-snap" ) )
         {
            bevelSnap = atoi( argv[ i + 1 ]);
            if( bevelSnap < 0 )
                bevelSnap = 0;
             i++;
            if( bevelSnap > 0 )
                Sys_Printf( "Snapping brush bevel planes to %d units\n", bevelSnap );
         }
        else if( !strcmp( argv[ i ],  "-texrange" ) )
         {
            texRange = atoi( argv[ i + 1 ]);
            if( texRange < 0 )
                texRange = 0;
             i++;
            Sys_Printf( "Limiting per-surface texture range to %d texels\n", texRange );
         }
        else if( !strcmp( argv[ i ], "-nohint" ) )
        {
            Sys_Printf( "Hint brushes disabled\n" );
            noHint = qtrue;
        }
        else if( !strcmp( argv[ i ], "-flat" ) )
        {
            Sys_Printf( "Flatshading enabled\n" );
            flat = qtrue;
        }
        else if( !strcmp( argv[ i ], "-meta" ) )
        {
            Sys_Printf( "Creating meta surfaces from brush faces\n" );
            meta = qtrue;
        }
        else if( !strcmp( argv[ i ], "-patchmeta" ) )
        {
            Sys_Printf( "Creating meta surfaces from patches\n" );
            patchMeta = qtrue;
        }
        else if( !strcmp( argv[ i ], "-flares" ) )
        {
            Sys_Printf( "Flare surfaces enabled\n" );
            emitFlares = qtrue;
        }
        else if( !strcmp( argv[ i ], "-noflares" ) )
        {
            Sys_Printf( "Flare surfaces disabled\n" );
            emitFlares = qfalse;
        }
        else if( !strcmp( argv[ i ], "-skyfix" ) )
        {
            Sys_Printf( "GL_CLAMP sky fix/hack/workaround enabled\n" );
            skyFixHack = qtrue;
        }
        else if( !strcmp( argv[ i ], "-debugsurfaces" ) )
        {
            Sys_Printf( "emitting debug surfaces\n" );
            debugSurfaces = qtrue;
        }
        else if( !strcmp( argv[ i ], "-debuginset" ) )
        {
            Sys_Printf( "Debug surface triangle insetting enabled\n" );
            debugInset = qtrue;
        }
        else if( !strcmp( argv[ i ], "-debugportals" ) )
        {
            Sys_Printf( "Debug portal surfaces enabled\n" );
            debugPortals = qtrue;
        }
        else if( !strcmp( argv[ i ], "-bsp" ) )
            Sys_Printf( "-bsp argument unnecessary\n" );
        else
            Sys_Printf( "WARNING: Unknown option \"%s\"\n", argv[ i ] );
    }
    
    /* fixme: print more useful usage here */
    if( i != (argc - 1) )
        Error( "usage: q3map [options] mapfile" );
    
    /* copy source name */
    strcpy( source, ExpandArg( argv[ i ] ) );
    StripExtension( source );
    
    /* ydnar: set default sample size */
    SetDefaultSampleSize( sampleSize );
    
    /* 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 );
    
    /* expand mapname */
    strcpy( name, ExpandArg( argv[ i ] ) );    
    if( strcmp( name + strlen( name ) - 4, ".reg" ) )
    {
        /* if we are doing a full map, delete the last saved region map */
        sprintf( path, "%s.reg", source );
        remove( path );
        DefaultExtension( name, ".map" );    /* might be .reg */
    }
    
    /* if onlyents, just grab the entites and resave */
    if( onlyents )
    {
        OnlyEnts();
        return 0;
    }
    
    /* load shaders */
    LoadShaderInfo();
    
    /* load original file from temp spot in case it was renamed by the editor on the way in */
    if( strlen( tempSource ) > 0 )
        LoadMapFile( tempSource, qfalse );
    else
        LoadMapFile( name, qfalse );
    
    /* ydnar: decal setup */
    ProcessDecals();
    
    /* ydnar: cloned brush model entities */
    SetCloneModelNumbers();
    
    /* process world and submodels */
    ProcessModels();
    
    /* set light styles from targetted light entities */
    SetLightStyles();
    
    /* finish and write bsp */
    EndBSPFile();
    
    /* remove temp map source file if appropriate */
    if( strlen( tempSource ) > 0)
        remove( tempSource );
    
    /* return to sender */
    return 0;
}
コード例 #7
0
ファイル: qbsp3.c プロジェクト: hypov8/quake2_texture_fix
/*
============
main
============
*/
int main (int argc, char **argv)
{
	int		i;
	double		start, end;
	char		path[1024];
#ifndef FIXTEXONLY
	printf ("---- qbsp3 ----\n");
#else
	printf("---- Map Fix Texture Capitals ----\n");
#endif

	for (i=1 ; i<argc ; i++)
	{
#ifndef FIXTEXONLY
		if (!strcmp(argv[i],"-threads"))
		{
			numthreads = atoi (argv[i+1]);
			i++;
		}
		else if (!strcmp(argv[i],"-glview"))
		{
			glview = true;
		}
		else if (!strcmp(argv[i], "-v"))
		{
			printf ("verbose = true\n");
			verbose = true;
		}
		else if (!strcmp(argv[i], "-draw"))
		{
			printf ("drawflag = true\n");
			drawflag = true;
		}
		else if (!strcmp(argv[i], "-noweld"))
		{
			printf ("noweld = true\n");
			noweld = true;
		}
		else if (!strcmp(argv[i], "-nocsg"))
		{
			printf ("nocsg = true\n");
			nocsg = true;
		}
		else if (!strcmp(argv[i], "-noshare"))
		{
			printf ("noshare = true\n");
			noshare = true;
		}
		else if (!strcmp(argv[i], "-notjunc"))
		{
			printf ("notjunc = true\n");
			notjunc = true;
		}
		else if (!strcmp(argv[i], "-nowater"))
		{
			printf ("nowater = true\n");
			nowater = true;
		}
		else if (!strcmp(argv[i], "-noopt"))
		{
			printf ("noopt = true\n");
			noopt = true;
		}
		else if (!strcmp(argv[i], "-noprune"))
		{
			printf ("noprune = true\n");
			noprune = true;
		}
		else if (!strcmp(argv[i], "-nofill"))
		{
			printf ("nofill = true\n");
			nofill = true;
		}
		else if (!strcmp(argv[i], "-nomerge"))
		{
			printf ("nomerge = true\n");
			nomerge = true;
		}
		else if (!strcmp(argv[i], "-nosubdiv"))
		{
			printf ("nosubdiv = true\n");
			nosubdiv = true;
		}
		else if (!strcmp(argv[i], "-nodetail"))
		{
			printf ("nodetail = true\n");
			nodetail = true;
		}
		else if (!strcmp(argv[i], "-fulldetail"))
		{
			printf ("fulldetail = true\n");
			fulldetail = true;
		}
		else if (!strcmp(argv[i], "-onlyents"))
		{
			printf ("onlyents = true\n");
			onlyents = true;
		}
//hypo
		else 
#endif

			if (!strcmp(argv[i], "-onlytextures"))
		{
			printf("onlytextures = true\n");
			onlytextures = true;
		}
//hypo end
#ifndef FIXTEXONLY
		else if (!strcmp(argv[i], "-micro"))
		{
			microvolume = atof(argv[i+1]);
			printf ("microvolume = %f\n", microvolume);
			i++;
		}
		else if (!strcmp(argv[i], "-leaktest"))
		{
			printf ("leaktest = true\n");
			leaktest = true;
		}
		else if (!strcmp(argv[i], "-verboseentities"))
		{
			printf ("verboseentities = true\n");
			verboseentities = true;
		}
		else if (!strcmp(argv[i], "-chop"))
		{
			subdivide_size = atof(argv[i+1]);
			printf ("subdivide_size = %f\n", subdivide_size);
			i++;
		}
		else if (!strcmp(argv[i], "-block"))
		{
			block_xl = block_xh = atoi(argv[i+1]);
			block_yl = block_yh = atoi(argv[i+2]);
			printf ("block: %i,%i\n", block_xl, block_yl);
			i+=2;
		}
		else if (!strcmp(argv[i], "-blocks"))
		{
			block_xl = atoi(argv[i+1]);
			block_yl = atoi(argv[i+2]);
			block_xh = atoi(argv[i+3]);
			block_yh = atoi(argv[i+4]);
			printf ("blocks: %i,%i to %i,%i\n", 
				block_xl, block_yl, block_xh, block_yh);
			i+=4;
		}
		else if (!strcmp (argv[i],"-tmpout"))
		{
			strcpy (outbase, "/tmp");
		}
#endif
		else if (argv[i][0] == '-')
			Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i != argc - 1)
		Error ("usage: qbsp3 [options] mapfile");

	start = I_FloatTime ();

	ThreadSetDefault ();
	numthreads = 1;		// multiple threads aren't helping...

//hypo
	if (onlytextures)
	{
		strcpy(source, ExpandArg(argv[i]));
		StripExtension(source);
		mapHasCapitals = 0;
	}
#ifndef FIXTEXONLY
	else
	//hypo end
	{
		SetQdirFromPath(argv[i]);

		strcpy(source, ExpandArg(argv[i]));
		StripExtension(source);

		// delete portal and line files
		sprintf(path, "%s.prt", source);
		remove(path);
		sprintf(path, "%s.lin", source);
		remove(path);

		strcpy(name, ExpandArg(argv[i]));
		DefaultExtension(name, ".map");	// might be .reg
	}
#endif
	//
	// if onlyents, just grab the entites and resave
	//
#ifndef FIXTEXONLY
	if (onlyents)
	{
		char out[1024];

		sprintf (out, "%s.bsp", source);
		LoadBSPFile (out);
		num_entities = 0;

		LoadMapFile (name);
		SetModelNumbers ();
		SetLightStyles ();

		UnparseEntities ();

		WriteBSPFile (out);
	}
//hypo write textures
	else 
#endif		
		if (onlytextures)
	{
		char out[1024];
		char mapFix[1024];

		sprintf(out, "%s.bsp", source);
		LoadBSPFile(out);

		if (mapHasCapitals)
		{	
			StripExtension(out);
			sprintf(mapFix, "%s_fix.bsp", out);

			printf("map has %i capitals. Writing... %s\n", mapHasCapitals, mapFix);

			WriteBSPFile(mapFix);
		}
		else
			printf("map is fine\n");

	}
//hypo end
#ifndef FIXTEXONLY
	else
	{
		//
		// start from scratch
		//
		LoadMapFile (name);
		SetModelNumbers ();
		SetLightStyles ();

		ProcessModels ();
	}


	end = I_FloatTime ();
	printf ("%5.0f seconds elapsed\n", end-start);

#endif
	return 0;
}
コード例 #8
0
ファイル: vbsp.cpp プロジェクト: Adidasman1/source-sdk-2013
int RunVBSP( int argc, char **argv )
{
	int		i;
	double		start, end;
	char		path[1024];

	CommandLine()->CreateCmdLine( argc, argv );
	MathLib_Init( 2.2f, 2.2f, 0.0f, OVERBRIGHT, false, false, false, false );
	InstallSpewFunction();
	SpewActivate( "developer", 1 );
	
	CmdLib_InitFileSystem( argv[ argc-1 ] );

	Q_StripExtension( ExpandArg( argv[ argc-1 ] ), source, sizeof( source ) );
	Q_FileBase( source, mapbase, sizeof( mapbase ) );
	strlwr( mapbase );

	LoadCmdLineFromFile( argc, argv, mapbase, "vbsp" );

	Msg( "Valve Software - vbsp.exe (%s)\n", __DATE__ );

	for (i=1 ; i<argc ; i++)
	{
		if (!stricmp(argv[i],"-threads"))
		{
			numthreads = atoi (argv[i+1]);
			i++;
		}
		else if (!Q_stricmp(argv[i],"-glview"))
		{
			glview = true;
		}
		else if ( !Q_stricmp(argv[i], "-v") || !Q_stricmp(argv[i], "-verbose") )
		{
			Msg("verbose = true\n");
			verbose = true;
		}
		else if (!Q_stricmp(argv[i], "-noweld"))
		{
			Msg ("noweld = true\n");
			noweld = true;
		}
		else if (!Q_stricmp(argv[i], "-nocsg"))
		{
			Msg ("nocsg = true\n");
			nocsg = true;
		}
		else if (!Q_stricmp(argv[i], "-noshare"))
		{
			Msg ("noshare = true\n");
			noshare = true;
		}
		else if (!Q_stricmp(argv[i], "-notjunc"))
		{
			Msg ("notjunc = true\n");
			notjunc = true;
		}
		else if (!Q_stricmp(argv[i], "-nowater"))
		{
			Msg ("nowater = true\n");
			nowater = true;
		}
		else if (!Q_stricmp(argv[i], "-noopt"))
		{
			Msg ("noopt = true\n");
			noopt = true;
		}
		else if (!Q_stricmp(argv[i], "-noprune"))
		{
			Msg ("noprune = true\n");
			noprune = true;
		}
		else if (!Q_stricmp(argv[i], "-nomerge"))
		{
			Msg ("nomerge = true\n");
			nomerge = true;
		}
		else if (!Q_stricmp(argv[i], "-nomergewater"))
		{
			Msg ("nomergewater = true\n");
			nomergewater = true;
		}
		else if (!Q_stricmp(argv[i], "-nosubdiv"))
		{
			Msg ("nosubdiv = true\n");
			nosubdiv = true;
		}
		else if (!Q_stricmp(argv[i], "-nodetail"))
		{
			Msg ("nodetail = true\n");
			nodetail = true;
		}
		else if (!Q_stricmp(argv[i], "-fulldetail"))
		{
			Msg ("fulldetail = true\n");
			fulldetail = true;
		}
		else if (!Q_stricmp(argv[i], "-onlyents"))
		{
			Msg ("onlyents = true\n");
			onlyents = true;
		}
		else if (!Q_stricmp(argv[i], "-onlyprops"))
		{
			Msg ("onlyprops = true\n");
			onlyprops = true;
		}
		else if (!Q_stricmp(argv[i], "-micro"))
		{
			microvolume = atof(argv[i+1]);
			Msg ("microvolume = %f\n", microvolume);
			i++;
		}
		else if (!Q_stricmp(argv[i], "-leaktest"))
		{
			Msg ("leaktest = true\n");
			leaktest = true;
		}
		else if (!Q_stricmp(argv[i], "-verboseentities"))
		{
			Msg ("verboseentities = true\n");
			verboseentities = true;
		}
		else if (!Q_stricmp(argv[i], "-snapaxial"))
		{
			Msg ("snap axial = true\n");
			g_snapAxialPlanes = true;
		}
#if 0
		else if (!Q_stricmp(argv[i], "-maxlightmapdim"))
		{
			g_maxLightmapDimension = atof(argv[i+1]);
			Msg ("g_maxLightmapDimension = %f\n", g_maxLightmapDimension);
			i++;
		}
#endif
		else if (!Q_stricmp(argv[i], "-block"))
		{
			block_xl = block_xh = atoi(argv[i+1]);
			block_yl = block_yh = atoi(argv[i+2]);
			Msg ("block: %i,%i\n", block_xl, block_yl);
			i+=2;
		}
		else if (!Q_stricmp(argv[i], "-blocks"))
		{
			block_xl = atoi(argv[i+1]);
			block_yl = atoi(argv[i+2]);
			block_xh = atoi(argv[i+3]);
			block_yh = atoi(argv[i+4]);
			Msg ("blocks: %i,%i to %i,%i\n", 
				block_xl, block_yl, block_xh, block_yh);
			i+=4;
		}
		else if ( !Q_stricmp( argv[i], "-dumpcollide" ) )
		{
			Msg("Dumping collision models to collideXXX.txt\n" );
			dumpcollide = true;
		}
		else if ( !Q_stricmp( argv[i], "-dumpstaticprop" ) )
		{
			Msg("Dumping static props to staticpropXXX.txt\n" );
			g_DumpStaticProps = true;
		}
		else if ( !Q_stricmp( argv[i], "-forceskyvis" ) )
		{
			Msg("Enabled vis in 3d skybox\n" );
			g_bSkyVis = true;
		}
		else if (!Q_stricmp (argv[i],"-tmpout"))
		{
			strcpy (outbase, "/tmp");
		}
#if 0
		else if( !Q_stricmp( argv[i], "-defaultluxelsize" ) )
		{
			g_defaultLuxelSize = atof( argv[i+1] );
			i++;
		}
#endif
		else if( !Q_stricmp( argv[i], "-luxelscale" ) )
		{
			g_luxelScale = atof( argv[i+1] );
			i++;
		}
		else if( !strcmp( argv[i], "-minluxelscale" ) )
		{
			g_minLuxelScale = atof( argv[i+1] );
			if (g_minLuxelScale < 1)
				g_minLuxelScale = 1;
			i++;
		}
		else if( !Q_stricmp( argv[i], "-dxlevel" ) )
		{
			g_nDXLevel = atoi( argv[i+1] );
			Msg( "DXLevel = %d\n", g_nDXLevel );
			i++;
		}
		else if( !Q_stricmp( argv[i], "-bumpall" ) )
		{
			g_BumpAll = true;
		}
		else if( !Q_stricmp( argv[i], "-low" ) )
		{
			g_bLowPriority = true;
		}
		else if( !Q_stricmp( argv[i], "-lightifmissing" ) )
		{
			g_bLightIfMissing = true;
		}
		else if ( !Q_stricmp( argv[i], CMDLINEOPTION_NOVCONFIG ) )
		{
		}
		else if ( !Q_stricmp( argv[i], "-allowdebug" ) || !Q_stricmp( argv[i], "-steam" ) )
		{
			// nothing to do here, but don't bail on this option
		}
		else if ( !Q_stricmp( argv[i], "-vproject" ) || !Q_stricmp( argv[i], "-game" ) )
		{
			++i;
		}
		else if ( !Q_stricmp( argv[i], "-keepstalezip" ) )
		{
			g_bKeepStaleZip = true;
		}
		else if ( !Q_stricmp( argv[i], "-xbox" ) )
		{
			// enable mandatory xbox extensions
			g_NodrawTriggers = true;
			g_DisableWaterLighting = true;
		}
		else if ( !Q_stricmp( argv[i], "-allowdetailcracks"))
		{
			g_bAllowDetailCracks = true;
		}
		else if ( !Q_stricmp( argv[i], "-novirtualmesh"))
		{
			g_bNoVirtualMesh = true;
		}
		else if ( !Q_stricmp( argv[i], "-replacematerials" ) )
		{
			g_ReplaceMaterials = true;
		}
		else if ( !Q_stricmp(argv[i], "-nodrawtriggers") )
		{
			g_NodrawTriggers = true;
		}
		else if ( !Q_stricmp( argv[i], "-FullMinidumps" ) )
		{
			EnableFullMinidumps( true );
		}
		else if (argv[i][0] == '-')
		{
			Warning("VBSP: Unknown option \"%s\"\n\n", argv[i]);
			i = 100000;	// force it to print the usage
			break;
		}
		else
			break;
	}

	if (i != argc - 1)
	{
		PrintCommandLine( argc, argv );

		Warning(	
			"usage  : vbsp [options...] mapfile\n"
			"example: vbsp -onlyents c:\\hl2\\hl2\\maps\\test\n"
			"\n"
			"Common options (use -v to see all options):\n"
			"\n"
			"  -v (or -verbose): Turn on verbose output (also shows more command\n"
			"                    line options).\n"
			"\n"
			"  -onlyents   : This option causes vbsp only import the entities from the .vmf\n"
			"                file. -onlyents won't reimport brush models.\n"
			"  -onlyprops  : Only update the static props and detail props.\n"
			"  -glview     : Writes .gl files in the current directory that can be viewed\n"
			"                with glview.exe. If you use -tmpout, it will write the files\n"
			"                into the \\tmp folder.\n"
			"  -nodetail   : Get rid of all detail geometry. The geometry left over is\n"
			"                what affects visibility.\n"
			"  -nowater    : Get rid of water brushes.\n"
			"  -low        : Run as an idle-priority process.\n"
			"\n"
			"  -vproject <directory> : Override the VPROJECT environment variable.\n"
			"  -game <directory>     : Same as -vproject.\n"
			"\n" );

		if ( verbose )
		{
			Warning(
				"Other options  :\n"
				"  -novconfig   : Don't bring up graphical UI on vproject errors.\n"
				"  -threads     : Control the number of threads vbsp uses (defaults to the # of\n"
				"                 processors on your machine).\n"
				"  -verboseentities: If -v is on, this disables verbose output for submodels.\n"
				"  -noweld      : Don't join face vertices together.\n"
				"  -nocsg       : Don't chop out intersecting brush areas.\n"
				"  -noshare     : Emit unique face edges instead of sharing them.\n"
				"  -notjunc     : Don't fixup t-junctions.\n"
				"  -noopt       : By default, vbsp removes the 'outer shell' of the map, which\n"
				"                 are all the faces you can't see because you can never get\n"
				"                 outside the map. -noopt disables this behaviour.\n"
				"  -noprune     : Don't prune neighboring solid nodes.\n"
				"  -nomerge     : Don't merge together chopped faces on nodes.\n"
				"  -nomergewater: Don't merge together chopped faces on water.\n"
				"  -nosubdiv    : Don't subdivide faces for lightmapping.\n"
				"  -micro <#>   : vbsp will warn when brushes are output with a volume less\n"
				"                 than this number (default: 1.0).\n"
				"  -fulldetail  : Mark all detail geometry as normal geometry (so all detail\n"
				"                 geometry will affect visibility).\n"
				"  -leaktest    : Stop processing the map if a leak is detected. Whether or not\n"
				"                 this flag is set, a leak file will be written out at\n"
				"                 <vmf filename>.lin, and it can be imported into Hammer.\n"
				"  -bumpall     : Force all surfaces to be bump mapped.\n"
				"  -snapaxial   : Snap axial planes to integer coordinates.\n"
				"  -block # #      : Control the grid size mins that vbsp chops the level on.\n"
				"  -blocks # # # # : Enter the mins and maxs for the grid size vbsp uses.\n"
				"  -dumpstaticprops: Dump static props to staticprop*.txt\n"
				"  -dumpcollide    : Write files with collision info.\n"
				"  -forceskyvis	   : Enable vis calculations in 3d skybox leaves\n"
				"  -luxelscale #   : Scale all lightmaps by this amount (default: 1.0).\n"
				"  -minluxelscale #: No luxel scale will be lower than this amount (default: 1.0).\n"
				"  -lightifmissing : Force lightmaps to be generated for all surfaces even if\n"
				"                    they don't need lightmaps.\n"
				"  -keepstalezip   : Keep the BSP's zip files intact but regenerate everything\n"
				"                    else.\n"
				"  -virtualdispphysics : Use virtual (not precomputed) displacement collision models\n"
				"  -xbox           : Enable mandatory xbox options\n"
				"  -x360		   : Generate Xbox360 version of vsp\n"
				"  -nox360		   : Disable generation Xbox360 version of vsp (default)\n"
				"  -replacematerials : Substitute materials according to materialsub.txt in content\\maps\n"
				"  -FullMinidumps  : Write large minidumps on crash.\n"
				);
			}

		DeleteCmdLine( argc, argv );
		CmdLib_Cleanup();
		CmdLib_Exit( 1 );
	}

	start = Plat_FloatTime();

	// Run in the background?
	if( g_bLowPriority )
	{
		SetLowPriority();
	}

	if( ( g_nDXLevel != 0 ) && ( g_nDXLevel < 80 ) )
	{
		g_BumpAll = false;
	}

	if( g_luxelScale == 1.0f )
	{
		if ( g_nDXLevel == 70 )
		{
			g_luxelScale = 4.0f;
		}
	}

	ThreadSetDefault ();
	numthreads = 1;		// multiple threads aren't helping...

	// Setup the logfile.
	char logFile[512];
	_snprintf( logFile, sizeof(logFile), "%s.log", source );
	SetSpewFunctionLogFile( logFile );

	LoadPhysicsDLL();
	LoadSurfaceProperties();

#if 0
	Msg( "qdir: %s  This is the the path of the initial source file \n", qdir );
	Msg( "gamedir: %s This is the base engine + mod-specific game dir (e.g. d:/tf2/mytfmod/) \n", gamedir );
	Msg( "basegamedir: %s This is the base engine + base game directory (e.g. e:/hl2/hl2/, or d:/tf2/tf2/ )\n", basegamedir );
#endif

	sprintf( materialPath, "%smaterials", gamedir );
	InitMaterialSystem( materialPath, CmdLib_GetFileSystemFactory() );
	Msg( "materialPath: %s\n", materialPath );
	
	// delete portal and line files
	sprintf (path, "%s.prt", source);
	remove (path);
	sprintf (path, "%s.lin", source);
	remove (path);

	strcpy (name, ExpandArg (argv[i]));	

	const char *pszExtension = V_GetFileExtension( name );
	if ( !pszExtension )
	{
		V_SetExtension( name, ".vmm", sizeof( name ) );
		if ( !FileExists( name ) )
		{
			V_SetExtension( name, ".vmf", sizeof( name ) );
		}
	}

	char platformBSPFileName[1024];
	GetPlatformMapPath( source, platformBSPFileName, g_nDXLevel, 1024 );
	
	// if we're combining materials, load the script file
	if ( g_ReplaceMaterials )
	{
		LoadMaterialReplacementKeys( gamedir, mapbase );
	}

	//
	// if onlyents, just grab the entites and resave
	//
	if (onlyents)
	{
		LoadBSPFile (platformBSPFileName);
		num_entities = 0;
		// Clear out the cubemap samples since they will be reparsed even with -onlyents
		g_nCubemapSamples = 0;

		// Mark as stale since the lighting could be screwed with new ents.
		AddBufferToPak( GetPakFile(), "stale.txt", "stale", strlen( "stale" ) + 1, false );

		LoadMapFile (name);
		SetModelNumbers ();
		SetLightStyles ();

		// NOTE: If we ever precompute lighting for static props in
		// vrad, EmitStaticProps should be removed here

		// Emit static props found in the .vmf file
		EmitStaticProps();

		// NOTE: Don't deal with detail props here, it blows away lighting

		// Recompute the skybox
		ComputeBoundsNoSkybox();

		// Make sure that we have a water lod control eneity if we have water in the map.
		EnsurePresenceOfWaterLODControlEntity();

		// Make sure the func_occluders have the appropriate data set
		FixupOnlyEntsOccluderEntities();

		// Doing this here because stuff abov may filter out entities
		UnparseEntities ();

		WriteBSPFile (platformBSPFileName);
	}
	else if (onlyprops)
	{
		// In the only props case, deal with static + detail props only
		LoadBSPFile (platformBSPFileName);

		LoadMapFile(name);
		SetModelNumbers();
		SetLightStyles();

		// Emit static props found in the .vmf file
		EmitStaticProps();

		// Place detail props found in .vmf and based on material properties
		LoadEmitDetailObjectDictionary( gamedir );
		EmitDetailObjects();

		WriteBSPFile (platformBSPFileName);
	}
	else
	{
		//
		// start from scratch
		//

		// Load just the file system from the bsp
		if( g_bKeepStaleZip && FileExists( platformBSPFileName ) )
		{
			LoadBSPFile_FileSystemOnly (platformBSPFileName);
			// Mark as stale since the lighting could be screwed with new ents.
			AddBufferToPak( GetPakFile(), "stale.txt", "stale", strlen( "stale" ) + 1, false );
		}

		LoadMapFile (name);
		WorldVertexTransitionFixup();
		if( ( g_nDXLevel == 0 ) || ( g_nDXLevel >= 70 ) )
		{
			Cubemap_FixupBrushSidesMaterials();
			Cubemap_AttachDefaultCubemapToSpecularSides();
			Cubemap_AddUnreferencedCubemaps();
		}
		SetModelNumbers ();
		SetLightStyles ();
		LoadEmitDetailObjectDictionary( gamedir );
		ProcessModels ();
	}

	end = Plat_FloatTime();
	
	char str[512];
	GetHourMinuteSecondsString( (int)( end - start ), str, sizeof( str ) );
	Msg( "%s elapsed\n", str );

	DeleteCmdLine( argc, argv );
	ReleasePakFileLumps();
	DeleteMaterialReplacementKeys();
	ShutdownMaterialSystem();
	CmdLib_Cleanup();
	return 0;
}
コード例 #9
0
ファイル: bsp.c プロジェクト: kingtiger01/OpenMOHAA
int main (int argc, char **argv) {
	int		i;
	double		start, end;
	char		path[1024];

	_printf ("Q3Map v1.0s (c) 1999 Id Software Inc.\n");
  	_printf ("OMmap (su44) - v0.1\n");

	if ( argc < 2 ) {
		Error ("usage: q3map [options] mapfile");
	}

	// check for general program options
	if (!strcmp(argv[1], "-info")) {
		Bspinfo( argc - 2, argv + 2 );
		return 0;
	}
	if (!strcmp(argv[1], "-light")) {
		LightMain( argc - 1, argv + 1 );
		return 0;
	}
	if (!strcmp(argv[1], "-vlight")) {
		VLightMain( argc - 1, argv + 1 );
		return 0;
	}
	if (!strcmp(argv[1], "-vsound")) {
		VSoundMain( argc - 1, argv + 1 );
		return 0;
	}
	if (!strcmp(argv[1], "-vis")) {
		VisMain( argc - 1, argv + 1 );
		return 0;
	}

	// do a bsp if nothing else was specified

	_printf ("---- q3map ----\n");

  tempsource[0] = '\0';

	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i],"-tempname"))
    {
      strcpy(tempsource, argv[++i]);
    }
		else if (!strcmp(argv[i],"-threads"))
		{
			numthreads = atoi (argv[i+1]);
			i++;
		}
		else if (!strcmp(argv[i],"-glview"))
		{
			glview = qtrue;
		}
		else if (!strcmp(argv[i], "-v"))
		{
			_printf ("verbose = true\n");
			verbose = qtrue;
		}
		else if (!strcmp(argv[i], "-draw"))
		{
			_printf ("drawflag = true\n");
			drawflag = qtrue;
		}
		else if (!strcmp(argv[i], "-nowater"))
		{
			_printf ("nowater = true\n");
			nowater = qtrue;
		}
		else if (!strcmp(argv[i], "-noopt"))
		{
			_printf ("noopt = true\n");
			noopt = qtrue;
		}
		else if (!strcmp(argv[i], "-nofill"))
		{
			_printf ("nofill = true\n");
			nofill = qtrue;
		}
		else if (!strcmp(argv[i], "-nodetail"))
		{
			_printf ("nodetail = true\n");
			nodetail = qtrue;
		}
		else if (!strcmp(argv[i], "-fulldetail"))
		{
			_printf ("fulldetail = true\n");
			fulldetail = qtrue;
		}
		else if (!strcmp(argv[i], "-onlyents"))
		{
			_printf ("onlyents = true\n");
			onlyents = qtrue;
		}
		else if (!strcmp(argv[i], "-onlytextures"))
		{
			_printf ("onlytextures = true\n");	// FIXME: make work again!
			onlytextures = qtrue;
		}
		else if (!strcmp(argv[i], "-micro"))
		{
			microvolume = atof(argv[i+1]);
			_printf ("microvolume = %f\n", microvolume);
			i++;
		}
		else if (!strcmp(argv[i], "-nofog"))
		{
			_printf ("nofog = true\n");
			nofog = qtrue;
		}
		else if (!strcmp(argv[i], "-nosubdivide"))
		{
			_printf ("nosubdivide = true\n");
			nosubdivide = qtrue;
		}
		else if (!strcmp(argv[i], "-leaktest"))
		{
			_printf ("leaktest = true\n");
			leaktest = qtrue;
		}
		else if (!strcmp(argv[i], "-verboseentities"))
		{
			_printf ("verboseentities = true\n");
			verboseentities = qtrue;
		}
		else if (!strcmp(argv[i], "-nocurves"))
		{
			noCurveBrushes = qtrue;
			_printf ("no curve brushes\n");
		}
		else if (!strcmp(argv[i], "-notjunc"))
		{
			notjunc = qtrue;
			_printf ("no tjunction fixing\n");
		}
		else if (!strcmp(argv[i], "-expand"))
		{
			testExpand = qtrue;
			_printf ("Writing expanded.map.\n");
		}
		else if (!strcmp(argv[i], "-showseams"))
		{
			showseams = qtrue;
			_printf ("Showing seams on terrain.\n");
		}
		else if (!strcmp (argv[i],"-tmpout"))
		{
			strcpy (outbase, "/tmp");
		}
		else if (!strcmp (argv[i],"-fakemap"))
		{
			fakemap = qtrue;
			_printf( "will generate fakemap.map\n");
		}
		else if (!strcmp(argv[i], "-samplesize"))
		{
			samplesize = atoi(argv[i+1]);
			if (samplesize < 1) samplesize = 1;
			i++;
			_printf("lightmap sample size is %dx%d units\n", samplesize, samplesize);
		}
		else if (argv[i][0] == '-')
			Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i != argc - 1)
		Error ("usage: q3map [options] mapfile");

	start = I_FloatTime ();

	ThreadSetDefault ();
	//numthreads = 1;		// multiple threads aren't helping because of heavy malloc use
	SetQdirFromPath (argv[i]);

#ifdef _WIN32
  InitPakFile(gamedir, NULL);
#endif

	strcpy (source, ExpandArg (argv[i]));
	StripExtension (source);

	// delete portal and line files
	sprintf (path, "%s.prt", source);
	remove (path);
	sprintf (path, "%s.lin", source);
	remove (path);

	strcpy (name, ExpandArg (argv[i]));	
	if ( strcmp(name + strlen(name) - 4, ".reg" ) ) {
		// if we are doing a full map, delete the last saved region map
		sprintf (path, "%s.reg", source);
		remove (path);

		DefaultExtension (name, ".map");	// might be .reg
	}

	//
	// if onlyents, just grab the entites and resave
	//
	if ( onlyents ) {
		OnlyEnts();
		return 0;
	}

	//
	// if onlytextures, just grab the textures and resave
	//
	if ( onlytextures ) {
		OnlyTextures();
		return 0;
	}

	//
	// start from scratch
	//
	LoadShaderInfo();

  // load original file from temp spot in case it was renamed by the editor on the way in
  if (strlen(tempsource) > 0) {
	  LoadMapFile (tempsource);
  } else {
	  LoadMapFile (name);
  }

	SetModelNumbers ();
	SetLightStyles ();

	ProcessModels ();

	EndBSPFile();

	end = I_FloatTime ();
	_printf ("%5.0f seconds elapsed\n", end-start);

  // remove temp name if appropriate
  if (strlen(tempsource) > 0) {
    remove(tempsource);
  }

	return 0;
}
コード例 #10
0
ファイル: qcsg.c プロジェクト: 6779660/halflife
int main (int argc, char **argv)
{
	int		i, j;
	int		hull;
	entity_t	*ent;
	char	source[1024];
	char	name[1024];
	double		start, end;

	printf( "qcsg.exe v2.8 (%s)\n", __DATE__ );
	printf ("---- qcsg ----\n" );

	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i],"-threads"))
		{
			numthreads = atoi (argv[i+1]);
			i++;
		}
		else if (!strcmp(argv[i],"-glview"))
		{
			glview = true;
		}
		else if (!strcmp(argv[i], "-v"))
		{
			printf ("verbose = true\n");
			verbose = true;
		}
		else if (!strcmp(argv[i], "-draw"))
		{
			printf ("drawflag = true\n");
			drawflag = true;
		}
		else if (!strcmp(argv[i], "-noclip"))
		{
			printf ("noclip = true\n");
			noclip = true;
		}
		else if (!strcmp(argv[i], "-onlyents"))
		{
			printf ("onlyents = true\n");
			onlyents = true;
		}
		else if (!strcmp(argv[i], "-nowadtextures"))
		{
			printf ("wadtextures = false\n");
			wadtextures = false;
		}
		else if (!strcmp(argv[i], "-wadinclude"))
		{
			pszWadInclude[nWadInclude++] = strdup( argv[i + 1] );
			i++;
		}
		else if( !strcmp( argv[ i ], "-proj" ) )
		{
			strcpy( qproject, argv[ i + 1 ] );
			i++;
		}
		else if (!strcmp(argv[i], "-hullfile"))
		{
			hullfile = true;
			strcpy( qhullfile, argv[i + 1] );
			i++;
		}
		else if (argv[i][0] == '-')
			Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i != argc - 1)
		Error ("usage: qcsg [-nowadtextures] [-wadinclude <name>] [-draw] [-glview] [-noclip] [-onlyents] [-proj <name>] [-threads #] [-v] [-hullfile <name>] mapfile");

	SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_ABOVE_NORMAL);
	start = I_FloatTime ();

	CheckHullFile( hullfile, qhullfile );

	ThreadSetDefault ();
	SetQdirFromPath (argv[i]);

	strcpy (source, ExpandArg (argv[i]));
	COM_FixSlashes(source);
	StripExtension (source);

	strcpy (name, ExpandArg (argv[i]));	
	DefaultExtension (name, ".map");	// might be .reg

	//
	// if onlyents, just grab the entites and resave
	//
	if (onlyents  && !glview)
	{
		char out[1024];
		int	old_entities;
		sprintf (out, "%s.bsp", source);
		LoadBSPFile (out);

		// Get the new entity data from the map file
		LoadMapFile (name);

		// Write it all back out again.
		WriteBSP (source);

		end = I_FloatTime ();
		printf ("%5.0f seconds elapsed\n", end-start);
		return 0;
	}

	//
	// start from scratch
	//
	LoadMapFile (name);

	RunThreadsOnIndividual (nummapbrushes, true, CreateBrush);

	BoundWorld ();

	qprintf ("%5i map planes\n", nummapplanes);

	for (i=0 ; i<NUM_HULLS ; i++)
	{
		char	name[1024];

		if (glview)
			sprintf (name, "%s.gl%i",source, i);
		else
			sprintf (name, "%s.p%i",source, i);
		out[i] = fopen (name, "w");
		if (!out[i])
			Error ("Couldn't open %s",name);
	}

	ProcessModels ();

	qprintf ("%5i csg faces\n", c_csgfaces);
	qprintf ("%5i used faces\n", c_outfaces);
	qprintf ("%5i tiny faces\n", c_tiny);
	qprintf ("%5i tiny clips\n", c_tiny_clip);

	for (i=0 ; i<NUM_HULLS ; i++)
		fclose (out[i]);

	if (!glview)
	{
		EmitPlanes ();
		WriteBSP (source);
	}

	end = I_FloatTime ();
	printf ("%5.0f seconds elapsed\n", end-start);

	return 0;
}
コード例 #11
0
ファイル: bsp.c プロジェクト: otty/cake3
int BspMain(int argc, char **argv)
{
	int             i;
	double          start, end;
	char            path[1024];

	Sys_Printf("---- bsp ----\n");

	for(i = 1; i < argc; i++)
	{
		if(!strcmp(argv[i], "-threads"))
		{
			numthreads = atoi(argv[i + 1]);
			i++;
		}
		else if(!strcmp(argv[i], "-glview"))
		{
			glview = qtrue;
		}
		else if(!strcmp(argv[i], "-v"))
		{
			Sys_Printf("verbose = true\n");
			verbose = qtrue;
		}
		else if(!strcmp(argv[i], "-draw"))
		{
			Sys_Printf("drawflag = true\n");
			drawFlag = qtrue;
		}
		else if(!strcmp(argv[i], "-debugsurfaces"))
		{
			Sys_Printf("emitting debug surfaces\n");
			debugSurfaces = qtrue;
		}
		else if(!strcmp(argv[i], "-nowater"))
		{
			Sys_Printf("nowater = true\n");
			noliquids = qtrue;
		}
		else if(!strcmp(argv[i], "-nodetail"))
		{
			Sys_Printf("nodetail = true\n");
			nodetail = qtrue;
		}
		else if(!strcmp(argv[i], "-fulldetail"))
		{
			Sys_Printf("fulldetail = true\n");
			fulldetail = qtrue;
		}
		else if(!strcmp(argv[i], "-onlyents"))
		{
			Sys_Printf("onlyents = true\n");
			onlyents = qtrue;
		}
		else if(!strcmp(argv[i], "-onlytextures"))
		{
			Sys_Printf("onlytextures = true\n");	// FIXME: make work again!
			onlytextures = qtrue;
		}
		else if(!strcmp(argv[i], "-micro"))
		{
			microvolume = atof(argv[i + 1]);
			Sys_Printf("microvolume = %f\n", microvolume);
			i++;
		}
		else if(!strcmp(argv[i], "-nofog"))
		{
			Sys_Printf("nofog = true\n");
			nofog = qtrue;
		}
		else if(!strcmp(argv[i], "-nosubdivide"))
		{
			Sys_Printf("nosubdivide = true\n");
			nosubdivide = qtrue;
		}
		else if(!strcmp(argv[i], "-leaktest"))
		{
			Sys_Printf("leaktest = true\n");
			leaktest = qtrue;
		}
		else if(!strcmp(argv[i], "-nocurves"))
		{
			nocurves = qtrue;
			Sys_Printf("no curve brushes\n");
		}
		else if(!strcmp(argv[i], "-nodoors"))
		{
			nodoors = qtrue;
			Sys_Printf("no door entities\n");
		}
		else if(!strcmp(argv[i], "-notjunc"))
		{
			notjunc = qtrue;
			Sys_Printf("no tjunction fixing\n");
		}
		else if(!strcmp(argv[i], "-expand"))
		{
			testExpand = qtrue;
			Sys_Printf("Writing expanded.map.\n");
		}
		else if(!strcmp(argv[i], "-showseams"))
		{
			showseams = qtrue;
			Sys_Printf("Showing seams on terrain.\n");
		}
		else if(!strcmp(argv[i], "-tmpout"))
		{
			strcpy(outbase, "/tmp");
		}
		else if(!strcmp(argv[i], "-fakemap"))
		{
			fakemap = qtrue;
			Sys_Printf("will generate fakemap.map\n");
		}
		else if(!strcmp(argv[i], "-samplesize"))
		{
			samplesize = atoi(argv[i + 1]);
			if(samplesize < 1)
				samplesize = 1;
			i++;
			Sys_Printf("lightmap sample size is %dx%d units\n", samplesize, samplesize);
		}
		else if(!strcmp(argv[i], "-connect"))
		{
			Broadcast_Setup(argv[++i]);
		}
		else if(argv[i][0] == '-')
			Error("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if(i != argc - 1)
	{
		Error("usage: xmap -map2bsp [-<switch> [-<switch> ...]] <mapname.map>\n"
			  "\n"
			  "Switches:\n"
			  "   v              = verbose output\n"
			  "   threads <X>    = set number of threads to X\n"
			  "   nocurves       = don't emit bezier surfaces\n" "   nodoors        = disable door entities\n"
			  //"   breadthfirst   = breadth first bsp building\n"
			  //"   nobrushmerge   = don't merge brushes\n"
			  "   noliquids      = don't write liquids to map\n"
			  //"   nocsg                                = disables brush chopping\n"
			  //"   glview     = output a GL view\n"
			  "   draw           = enables mini BSP viewer\n"
			  //"   noweld     = disables weld\n"
			  //"   noshare    = disables sharing\n"
			  "   notjunc        = disables juncs\n" "   nowater        = disables water brushes\n"
			  //"   noprune    = disables node prunes\n"
			  //"   nomerge    = disables face merging\n"
			  "   nofog          = disables fogs\n"
			  "   nosubdivide    = disables subdivision of draw surfaces\n"
			  "   nodetail       = disables detail brushes\n"
			  "   fulldetail     = enables full detail\n"
			  "   onlyents       = only compile entities with bsp\n"
			  "   micro <volume>\n"
			  "                  = sets the micro volume to the given float\n" "   leaktest       = perform a leak test\n"
			  //"   chop <subdivide_size>\n"
			  //"              = sets the subdivide size to the given float\n"
			  "   samplesize <N> = set the lightmap pixel size to NxN units\n");
	}

	start = I_FloatTime();

	ThreadSetDefault();

	SetQdirFromPath(argv[i]);

	strcpy(source, ExpandArg(argv[i]));
	StripExtension(source);

	// delete portal and line files
	sprintf(path, "%s.prt", source);
	remove(path);
	sprintf(path, "%s.lin", source);
	remove(path);

	strcpy(name, ExpandArg(argv[i]));
	if(strcmp(name + strlen(name) - 4, ".reg"))
	{
		// if we are doing a full map, delete the last saved region map
		sprintf(path, "%s.reg", source);
		remove(path);

		DefaultExtension(name, ".map");	// might be .reg
	}

	// if onlyents, just grab the entites and resave
	if(onlyents)
	{
		OnlyEnts();

		// shut down connection
		Broadcast_Shutdown();

		return 0;
	}

	// if onlytextures, just grab the textures and resave
	if(onlytextures)
	{
		OnlyTextures();

		// shut down connection
		Broadcast_Shutdown();

		return 0;
	}

	// start from scratch
	LoadShaderInfo();

	LoadMapFile(name);

	ProcessModels();

	SetModelNumbers();

	EndBSPFile();

	end = I_FloatTime();
	Sys_Printf("%5.0f seconds elapsed\n", end - start);

	// shut down connection
	Broadcast_Shutdown();

	return 0;
}
コード例 #12
0
ファイル: dmap.cpp プロジェクト: Deepfreeze32/idtech4cdk
/*
============
Dmap
============
*/
void Dmap( const idCmdArgs &args ) {
	int			i;
	int			start, end;
	char		path[1024];
	idStr		passedName;
	bool		leaked = false;
	bool		noCM = false;
	bool		noAAS = false;

	ResetDmapGlobals();

	if ( args.Argc() < 2 ) {
		DmapHelp();
		return;
	}

	common->Printf("---- World Builder ----\n");
	common->Printf("Processing compile options\n");

	//dmapGlobals.fullCarve = true;
	dmapGlobals.shadowOptLevel = SO_MERGE_SURFACES;		// create shadows by merging all surfaces, but no super optimization
//	dmapGlobals.shadowOptLevel = SO_CLIP_OCCLUDERS;		// remove occluders that are completely covered
//	dmapGlobals.shadowOptLevel = SO_SIL_OPTIMIZE;
//	dmapGlobals.shadowOptLevel = SO_CULL_OCCLUDED;
	dmapGlobals.mapCompileError = "";
	dmapGlobals.noLightCarve = true;

	for ( i = 1 ; i < args.Argc() ; i++ ) {
		const char *s;

		s = args.Argv(i);
		if ( s[0] == '-' ) {
			s++;
			if ( s[0] == '\0' ) {
				continue;
			}
		}

		if ( !idStr::Icmp( s,"glview" ) ) {
			dmapGlobals.glview = true;
		} else if ( !idStr::Icmp( s, "v" ) ) {
			common->Printf( "verbose = true\n" );
			dmapGlobals.verbose = true;
		} else if ( !idStr::Icmp( s, "draw" ) ) {
			common->Printf( "drawflag = true\n" );
			dmapGlobals.drawflag = true;
		} else if ( !idStr::Icmp( s, "noFlood" ) ) {
			common->Printf( "noFlood = true\n" );
			dmapGlobals.noFlood = true;
		} else if ( !idStr::Icmp( s, "noLightCarve" ) ) {
			common->Printf( "noLightCarve = true\n" );
			dmapGlobals.noLightCarve = true;
		} else if ( !idStr::Icmp( s, "lightCarve" ) ) {
			common->Printf( "noLightCarve = false\n" );
			dmapGlobals.noLightCarve = false;
		} else if ( !idStr::Icmp( s, "noOpt" ) ) {
			common->Printf( "noOptimize = true\n" );
			dmapGlobals.noOptimize = true;
		} else if ( !idStr::Icmp( s, "verboseentities" ) ) {
			common->Printf( "verboseentities = true\n");
			dmapGlobals.verboseentities = true;
		} else if ( !idStr::Icmp( s, "noCurves" ) ) {
			common->Printf( "noCurves = true\n");
			dmapGlobals.noCurves = true;
		} else if ( !idStr::Icmp( s, "noModels" ) ) {
			common->Printf( "noModels = true\n" );
			dmapGlobals.noModelBrushes = true;
		} else if ( !idStr::Icmp( s, "noClipSides" ) ) {
			common->Printf( "noClipSides = true\n" );
			dmapGlobals.noClipSides = true;
		} else if ( !idStr::Icmp( s, "noCarve" ) ) {
			common->Printf( "noCarve = true\n" );
			dmapGlobals.fullCarve = false;
		} else if ( !idStr::Icmp( s, "shadowOpt" ) ) {
			dmapGlobals.shadowOptLevel = (shadowOptLevel_t)atoi( args.Argv( i+1 ) );
			common->Printf( "shadowOpt = %i\n",dmapGlobals.shadowOptLevel );
			i += 1;
		} else if ( !idStr::Icmp( s, "noTjunc" ) ) {
			// triangle optimization won't work properly without tjunction fixing
			common->Printf ("noTJunc = true\n" );
			dmapGlobals.noTJunc = true;
			dmapGlobals.noOptimize = true;
			common->Printf ("forcing noOptimize = true\n" );
		} else if ( !idStr::Icmp( s, "noCM" ) ) {
			noCM = true;
			common->Printf( "noCM = true\n" );
		} else if ( !idStr::Icmp( s, "noAAS" ) ) {
			noAAS = true;
			common->Printf( "noAAS = true\n" );
// jmarshall
		} else if ( !idStr::Icmp( s, "novtupdate" ) ) {
			dmapGlobals.novtupdate = true;
		} else if ( !idStr::Icmp( s, "updateents" ) ) {
			dmapGlobals.onlyEntities = true;
		} 
// jmarshall end
		else {
			break;
		}
	}
	dmapGlobals.noOptimize = true;
	if ( i >= args.Argc() ) {
		common->Error( "usage: dmap [options] mapfile" );
	}
// jmarshall - ensure bsp_inlinemesh_maxfacespertri cvar has good to go values.
	if(bsp_inlinemesh_maxfacespertri.GetInteger() > 0 && (bsp_inlinemesh_maxfacespertri.GetInteger() % 3) != 0) {
		common->Warning( "CVar bsp_inlinemesh_maxfacespertri has a invalid value, must be multiples of 3!\n");
		return;
	}

	if(bsp_inlinemesh_maxfacespertri.GetInteger() <= 0) {
		common->Warning( "InlineMesh face seperation is disabled! This will affect the quality of the UV map generation\n");
	}
	dmapGlobals.noOptimize = true;
	//dmapGlobals.noLightCarve = true;

	passedName = args.Argv(i);		// may have an extension
	passedName.BackSlashesToSlashes();
	if ( passedName.Icmpn( "maps/", 4 ) != 0 ) {
		passedName = "maps/" + passedName;
	}

	idStr stripped = passedName;
	stripped.StripFileExtension();
	idStr::Copynz( dmapGlobals.mapFileBase, stripped, sizeof(dmapGlobals.mapFileBase) );

	bool region = false;
	// if this isn't a regioned map, delete the last saved region map
	if ( passedName.Right( 4 ) != ".reg" ) {
		sprintf( path, "%s.reg", dmapGlobals.mapFileBase );
		fileSystem->RemoveFile( path );
	} else {
		region = true;
	}


	passedName = stripped;

	// delete any old line leak files
	sprintf( path, "%s.lin", dmapGlobals.mapFileBase );
	fileSystem->RemoveFile( path );


	//
	// start from scratch
	//
	start = sys->Milliseconds();

	if ( !LoadDMapFile( passedName ) ) {
		return;
	}


	if(dmapGlobals.onlyEntities) {
		dmapGlobals.dmapFile->WriteGameEntities( dmapGlobals.mapFileBase, WORLD_ENTITIES_FILE_EXT );
		noCM = true;
	}
	else
	{
		if ( ProcessModels() ) {
			WriteOutputFile();
		} else {
			leaked = true;
		}
	}
// jmarshall end

	common->Printf("Cleaning up temporary memory...\n");
	FreeDMapFile();


	end = sys->Milliseconds();
	common->Printf( "-----------------------\n" );
	common->Printf( "%5.0f seconds for dmap\n", ( end - start ) * 0.001f );

	if ( !leaked ) {

		if ( !noCM ) {

			// make sure the collision model manager is not used by the game
			cmdSystem->BufferCommandText( CMD_EXEC_NOW, "disconnect" );

			// create the collision map
			start = sys->Milliseconds();

			collisionModelManager->LoadMap( dmapGlobals.dmapFile );
			collisionModelManager->FreeMap();

			end = sys->Milliseconds();
			common->Printf( "-------------------------------------\n" );
			common->Printf( "%5.0f seconds to create collision map\n", ( end - start ) * 0.001f );
		}

		if ( !noAAS && !region ) {
			// create AAS files
			RunAAS_f( args );
		}
	}

	// free the common .map representation
	delete dmapGlobals.dmapFile;
	

	// clear the map plane list
	dmapGlobals.mapPlanes.Clear();
// jmarshall
	if(dmapGlobals.mapCompileError.Length() > 0) {
		common->Warning("There was a problem building the world! The build process completed but it may not be complete/accurate\n");
		common->Warning(dmapGlobals.mapCompileError.c_str());
		dmapGlobals.mapCompileError = "";
	}
// jmarshall end

	// jmarshall
/*
#ifdef _WIN32
	if ( com_outputMsg && com_hwndMsg != NULL ) {
		unsigned int msg = ::RegisterWindowMessage( DMAP_DONE );
		::PostMessage( com_hwndMsg, msg, 0, 0 );
	}
#endif
*/
	// jmarshall end
}