Ejemplo n.º 1
0
/*
   ===========
   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;
}
Ejemplo n.º 2
0
int ExportEntitiesMain( int argc, char **argv ){
        /* arg checking */
        if ( argc < 1 ) {
                Sys_Printf( "Usage: q3map -exportents [-v] <mapname>\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 );

        /* export the lightmaps */
        ExportEntities();

        /* return to sender */
        return 0;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
int AnalyzeBSP( int argc, char **argv )
{
	abspHeader_t			*header;
	int						size, i, version, offset, length, lumpInt, count;
	char					ident[ 5 ];
	void					*lump;
	float					lumpFloat;
	char					lumpString[ 1024 ], source[ 1024 ];
	qboolean				lumpSwap = qfalse;
	abspLumpTest_t			*lumpTest;
	static abspLumpTest_t	lumpTests[] =
							{
								{ sizeof( bspPlane_t ),			6,		"IBSP LUMP_PLANES" },
								{ sizeof( bspBrush_t ),			1,		"IBSP LUMP_BRUSHES" },
								{ 8,							6,		"IBSP LUMP_BRUSHSIDES" },
								{ sizeof( bspBrushSide_t ),		6,		"RBSP LUMP_BRUSHSIDES" },
								{ sizeof( bspModel_t ),			1,		"IBSP LUMP_MODELS" },
								{ sizeof( bspNode_t ),			2,		"IBSP LUMP_NODES" },
								{ sizeof( bspLeaf_t ),			1,		"IBSP LUMP_LEAFS" },
								{ 104,							3,		"IBSP LUMP_DRAWSURFS" },
								{ 44,							3,		"IBSP LUMP_DRAWVERTS" },
								{ 4,							6,		"IBSP LUMP_DRAWINDEXES" },
								{ 128 * 128 * 3,				1,		"IBSP LUMP_LIGHTMAPS" },
								{ 256 * 256 * 3,				1,		"IBSP LUMP_LIGHTMAPS (256 x 256)" },
								{ 512 * 512 * 3,				1,		"IBSP LUMP_LIGHTMAPS (512 x 512)" },
								{ 0, 0, NULL }
							};
	
	
	/* arg checking */
	if( argc < 1 )
	{
		Sys_Printf( "Usage: q3map -analyze [-lumpswap] [-v] <mapname>\n" );
		return 0;
	}
	
	/* process arguments */
	for( i = 1; i < (argc - 1); i++ )
	{
		/* -format map|ase|... */
		if( !strcmp( argv[ i ],  "-lumpswap" ) )
		{
			Sys_Printf( "Swapped lump structs enabled\n" );
 			lumpSwap = qtrue;
 		}
	}
	
	/* clean up map name */
	strcpy( source, ExpandArg( argv[ i ] ) );
	Sys_Printf( "Loading %s\n", source );
	
	/* load the file */
	size = LoadFile( source, (void**) &header );
	if( size == 0 || header == NULL )
	{
		Sys_Printf( "Unable to load %s.\n", source );
		return -1;
	}
	
	/* analyze ident/version */
	memcpy( ident, header->ident, 4 );
	ident[ 4 ] = '\0';
	version = LittleLong( header->version );
	
	Sys_Printf( "Identity:      %s\n", ident );
	Sys_Printf( "Version:       %d\n", version );
	Sys_Printf( "---------------------------------------\n" );
	
	/* analyze each lump */
	for( i = 0; i < 100; i++ )
	{
		/* call of duty swapped lump pairs */
		if( lumpSwap )
		{
			offset = LittleLong( header->lumps[ i ].length );
			length = LittleLong( header->lumps[ i ].offset );
		}
		
		/* standard lump pairs */
		else
		{
			offset = LittleLong( header->lumps[ i ].offset );
			length = LittleLong( header->lumps[ i ].length );
		}
		
		/* extract data */
		lump = (byte*) header + offset;
		lumpInt = LittleLong( (int) *((int*) lump) );
		lumpFloat = LittleFloat( (float) *((float*) lump) );
		memcpy( lumpString, (char*) lump, (length < 1024 ? length : 1024) );
		lumpString[ 1024 ] = '\0';
		
		/* print basic lump info */
		Sys_Printf( "Lump:          %d\n", i );
		Sys_Printf( "Offset:        %d bytes\n", offset );
		Sys_Printf( "Length:        %d bytes\n", length );
		
		/* only operate on valid lumps */
		if( length > 0 )
		{
			/* print data in 4 formats */
			Sys_Printf( "As hex:        %08X\n", lumpInt );
			Sys_Printf( "As int:        %d\n", lumpInt );
			Sys_Printf( "As float:      %f\n", lumpFloat );
			Sys_Printf( "As string:     %s\n", lumpString );
			
			/* guess lump type */
			if( lumpString[ 0 ] == '{' && lumpString[ 2 ] == '"' )
				Sys_Printf( "Type guess:    IBSP LUMP_ENTITIES\n" );
			else if( strstr( lumpString, "textures/" ) )
				Sys_Printf( "Type guess:    IBSP LUMP_SHADERS\n" );
			else
			{
				/* guess based on size/count */
				for( lumpTest = lumpTests; lumpTest->radix > 0; lumpTest++ )
				{
					if( (length % lumpTest->radix) != 0 )
						continue;
					count = length / lumpTest->radix;
					if( count < lumpTest->minCount )
						continue;
					Sys_Printf( "Type guess:    %s (%d x %d)\n", lumpTest->name, count, lumpTest->radix );
				}
			}
		}
		
		Sys_Printf( "---------------------------------------\n" );
		
		/* end of file */
		if( offset + length >= size )
			break;
	}
	
	/* last stats */
	Sys_Printf( "Lump count:    %d\n", i + 1 );
	Sys_Printf( "File size:     %d bytes\n", size );
	
	/* return to caller */
	return 0;
}
Ejemplo n.º 5
0
/*
============
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;
}
Ejemplo n.º 6
0
/*
===========
Vis_Main
===========
*/
int Vis_Main (int argc, char **argv)
{
	char	portalfile[1024];
	char	source[1024];
	char	name[1024];
	int		i;
	double	start, end;
	int		total_vis_time;
		
	Con_Print("---- VIS ----\n");

	verbose = false;
	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i], "-fast"))
		{
			Con_Print("fastvis = true\n");
			fastvis = true;
		}
		else if (!strcmp(argv[i], "-level"))
		{
			testlevel = atoi(argv[i+1]);
			Con_Print("testlevel = %i\n", testlevel);
			i++;
		}
		else if (!strcmp(argv[i], "-v"))
		{
			Con_Print("verbose = true\n");
			verbose = true;
		}
		else if (!strcmp (argv[i],"-nosort"))
		{
			Con_Print("nosort = true\n");
			nosort = true;
		}
		else if (!strcmp (argv[i],"-tmpin"))
			strcpy (inbase, "/tmp");
		else if (!strcmp (argv[i],"-tmpout"))
			strcpy (outbase, "/tmp");
		else if (argv[i][0] == '-')
			Con_Error("Unknown option \"%s\"\n", argv[i]);
		else
			break;
	}

	if (i != argc - 1)
		Con_Error("usage: q2map -vis [-level 0-4] [-fast] [-v] bspfile\n");

	start = I_FloatTime ();

	SetQdirFromPath (argv[i]);

	strcpy (source, ExpandArg(argv[i]));
	StripExtension (source);
	DefaultExtension (source, ".bsp");

	sprintf (name, "%s%s", inbase, source);
	Con_Print("reading %s\n", name);
	LoadBSPFile (name);
	if (numnodes == 0 || numfaces == 0)
		Con_Error("Empty map\n");

	sprintf (portalfile, "%s%s", inbase, ExpandArg(argv[i]));
	StripExtension (portalfile);
	strcat (portalfile, ".prt");
	
	Con_Print("reading %s\n", portalfile);
	LoadPortals (portalfile);
	
	CalcVis ();

	CalcPHS ();

	visdatasize = vismap_p - dvisdata;
	Con_Print("visdatasize:%i  compressed from %i\n", visdatasize, originalvismapsize*2);

	sprintf (name, "%s%s", outbase, source);
	Con_Print("writing %s\n", name);
	WriteBSPFile (name);	
	
	end = I_FloatTime ();
	total_vis_time = (int) ( end - start );
	Con_Print("\nVIS Time: ");
	if ( total_vis_time > 59 ) {
		Con_Print( "%d minutes ", total_vis_time / 60 );
	}
	Con_Print( "%d seconds\n", total_vis_time % 60 );

	return 0;
}
Ejemplo n.º 7
0
/*
==============
main
==============
*/
int main (int argc, char **argv)
{
	static	int		i;		// VC4.2 compiler bug if auto...
	char	path[1024];

	ExpandWildcards (&argc, &argv);

	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i], "-archive"))
		{
			// -archive f:/quake2/release/dump_11_30
			archive = true;
			strcpy (archivedir, argv[i+1]);
			printf ("Archiving source to: %s\n", archivedir);
			i++;
		}
		else if (!strcmp(argv[i], "-release"))
		{
			g_release = true;
			strcpy (g_releasedir, argv[i+1]);
			printf ("Copy output to: %s\n", g_releasedir);
			i++;
		}
		else if (!strcmp(argv[i], "-compress"))
		{
			g_compress_pak = true;
			printf ("Compressing pakfile\n");
		}
		else if (!strcmp(argv[i], "-pak"))
		{
			g_release = true;
			g_pak = true;
			printf ("Building pakfile: %s\n", argv[i+1]);
			BeginPak (argv[i+1]);
			i++;
		}
		else if (!strcmp(argv[i], "-only"))
		{
			strcpy (g_only, argv[i+1]);
			printf ("Only grabbing %s\n", g_only);
			i++;
		}
		else if (!strcmp(argv[i], "-3ds"))
		{
			do3ds = true;
			printf ("loading .3ds files\n");
		}
		else if (argv[i][0] == '-')
			Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i >= argc)
		Error ("usage: qgrab [-archive <directory>] [-release <directory>] [-only <model>] [-3ds] file.qgr");

	if (do3ds)
		trifileext = ext_3ds;
	else
		trifileext = ext_tri;

	for ( ; i<argc ; i++)
	{
		printf ("--------------- %s ---------------\n", argv[i]);
		// load the script
		strcpy (path, argv[i]);
		DefaultExtension (path, ".qdt");
		SetQdirFromPath (path);
		LoadScriptFile (ExpandArg(path));
		
		//
		// parse it
		//
		ParseScript ();

		// write out the last model
		FinishModel ();
		FinishSprite ();
	}

	if (g_pak)
		FinishPak ();

	return 0;
}
Ejemplo n.º 8
0
/*
ConvertBspToASE()
exports an 3d studio ase file from the bsp
*/
int ConvertBspToASE(int argc, char **argv)
{
	int             i;
	double          start, end;
	char            source[1024];
	char            dest[1024];

	Sys_Printf("---- convert map to ase ----\n");

	for(i = 1; i < argc; i++)
	{
		if(!strcmp(argv[i], "-threads"))
		{
			numthreads = atoi(argv[i + 1]);
			i++;
		}
		else if(!strcmp(argv[i], "-v"))
		{
			Sys_Printf("verbose = true\n");
			verbose = qtrue;
		}
		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 -bsp2ase [-<switch> [-<switch> ...]] <mapname.bsp>\n"
			  "\n" "Switches:\n" "   v              = verbose output\n");
		//"   quake1       = convert from QuakeWorld to XreaL\n"
		//"   quake2       = convert from Quake2 to XreaL\n"
		//"   quake3         = convert from Quake3 to XreaL\n"
		//"   quake4         = convert from Quake4 to XreaL\n");
	}

	start = I_FloatTime();

	ThreadSetDefault();

	SetQdirFromPath(argv[i]);

	strcpy(source, ExpandArg(argv[i]));
	StripExtension(source);
	DefaultExtension(source, ".bsp");

	// start from scratch
	LoadShaderInfo();

	Sys_Printf("reading %s\n", source);
	LoadBSPFile(source);

	ParseEntities();

	//
	strcpy(dest, ExpandArg(argv[i]));
	StripExtension(dest);
	strcat(dest, "_converted");
	DefaultExtension(dest, ".ase");

	WriteASEFile(dest);

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

	// shut down connection
	Broadcast_Shutdown();


	return 0;
}
Ejemplo n.º 9
0
Archivo: bsp.c Proyecto: 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;
}
Ejemplo n.º 10
0
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;
}
Ejemplo n.º 11
0
int ScaleBSPMain( int argc, char **argv ){
	int i, j;
	float f, a;
	vec3_t scale;
	vec3_t vec;
	char str[ 1024 ];
	int uniform, axis;
	qboolean texscale;
	float *old_xyzst = NULL;
	float spawn_ref = 0;


	/* arg checking */
	if ( argc < 3 ) {
		Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
		return 0;
	}

	texscale = qfalse;
	for ( i = 1; i < argc - 2; ++i )
	{
		if ( !strcmp( argv[i], "-tex" ) ) {
			texscale = qtrue;
		}
		else if ( !strcmp( argv[i], "-spawn_ref" ) ) {
			spawn_ref = atof( argv[i + 1] );
			++i;
		}
		else{
			break;
		}
	}

	/* get scale */
	// if(argc-2 >= i) // always true
	scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
	if ( argc - 3 >= i ) {
		scale[1] = scale[0] = atof( argv[ argc - 3 ] );
	}
	if ( argc - 4 >= i ) {
		scale[0] = atof( argv[ argc - 4 ] );
	}

	uniform = ( ( scale[0] == scale[1] ) && ( scale[1] == scale[2] ) );

	if ( scale[0] == 0.0f || scale[1] == 0.0f || scale[2] == 0.0f ) {
		Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <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 ] ) ) {
			if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
				vec[2] += spawn_ref;
			}
			vec[0] *= scale[0];
			vec[1] *= scale[1];
			vec[2] *= scale[2];
			if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
				vec[2] -= spawn_ref;
			}
			sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
			SetKeyValue( &entities[ i ], "origin", str );
		}

		a = FloatForKey( &entities[ i ], "angle" );
		if ( a == -1 || a == -2 ) { // z scale
			axis = 2;
		}
		else if ( fabs( sin( DEG2RAD( a ) ) ) < 0.707 ) {
			axis = 0;
		}
		else{
			axis = 1;
		}

		/* scale door lip */
		f = FloatForKey( &entities[ i ], "lip" );
		if ( f ) {
			f *= scale[axis];
			sprintf( str, "%f", f );
			SetKeyValue( &entities[ i ], "lip", str );
		}

		/* scale plat height */
		f = FloatForKey( &entities[ i ], "height" );
		if ( f ) {
			f *= scale[2];
			sprintf( str, "%f", f );
			SetKeyValue( &entities[ i ], "height", str );
		}

		// TODO maybe allow a definition file for entities to specify which values are scaled how?
	}

	/* scale models */
	for ( i = 0; i < numBSPModels; i++ )
	{
		bspModels[ i ].mins[0] *= scale[0];
		bspModels[ i ].mins[1] *= scale[1];
		bspModels[ i ].mins[2] *= scale[2];
		bspModels[ i ].maxs[0] *= scale[0];
		bspModels[ i ].maxs[1] *= scale[1];
		bspModels[ i ].maxs[2] *= scale[2];
	}

	/* scale nodes */
	for ( i = 0; i < numBSPNodes; i++ )
	{
		bspNodes[ i ].mins[0] *= scale[0];
		bspNodes[ i ].mins[1] *= scale[1];
		bspNodes[ i ].mins[2] *= scale[2];
		bspNodes[ i ].maxs[0] *= scale[0];
		bspNodes[ i ].maxs[1] *= scale[1];
		bspNodes[ i ].maxs[2] *= scale[2];
	}

	/* scale leafs */
	for ( i = 0; i < numBSPLeafs; i++ )
	{
		bspLeafs[ i ].mins[0] *= scale[0];
		bspLeafs[ i ].mins[1] *= scale[1];
		bspLeafs[ i ].mins[2] *= scale[2];
		bspLeafs[ i ].maxs[0] *= scale[0];
		bspLeafs[ i ].maxs[1] *= scale[1];
		bspLeafs[ i ].maxs[2] *= scale[2];
	}

	if ( texscale ) {
		Sys_Printf( "Using texture unlocking (and probably breaking texture alignment a lot)\n" );
		old_xyzst = safe_malloc( sizeof( *old_xyzst ) * numBSPDrawVerts * 5 );
		for ( i = 0; i < numBSPDrawVerts; i++ )
		{
			old_xyzst[5 * i + 0] = bspDrawVerts[i].xyz[0];
			old_xyzst[5 * i + 1] = bspDrawVerts[i].xyz[1];
			old_xyzst[5 * i + 2] = bspDrawVerts[i].xyz[2];
			old_xyzst[5 * i + 3] = bspDrawVerts[i].st[0];
			old_xyzst[5 * i + 4] = bspDrawVerts[i].st[1];
		}
	}

	/* scale drawverts */
	for ( i = 0; i < numBSPDrawVerts; i++ )
	{
		bspDrawVerts[i].xyz[0] *= scale[0];
		bspDrawVerts[i].xyz[1] *= scale[1];
		bspDrawVerts[i].xyz[2] *= scale[2];
		bspDrawVerts[i].normal[0] /= scale[0];
		bspDrawVerts[i].normal[1] /= scale[1];
		bspDrawVerts[i].normal[2] /= scale[2];
		VectorNormalize( bspDrawVerts[i].normal, bspDrawVerts[i].normal );
	}

	if ( texscale ) {
		for ( i = 0; i < numBSPDrawSurfaces; i++ )
		{
			switch ( bspDrawSurfaces[i].surfaceType )
			{
			case SURFACE_FACE:
			case SURFACE_META:
				if ( bspDrawSurfaces[i].numIndexes % 3 ) {
					Error( "Not a triangulation!" );
				}
				for ( j = bspDrawSurfaces[i].firstIndex; j < bspDrawSurfaces[i].firstIndex + bspDrawSurfaces[i].numIndexes; j += 3 )
				{
					int ia = bspDrawIndexes[j] + bspDrawSurfaces[i].firstVert, ib = bspDrawIndexes[j + 1] + bspDrawSurfaces[i].firstVert, ic = bspDrawIndexes[j + 2] + bspDrawSurfaces[i].firstVert;
					bspDrawVert_t *a = &bspDrawVerts[ia], *b = &bspDrawVerts[ib], *c = &bspDrawVerts[ic];
					float *oa = &old_xyzst[ia * 5], *ob = &old_xyzst[ib * 5], *oc = &old_xyzst[ic * 5];
					// extrapolate:
					//   a->xyz -> oa
					//   b->xyz -> ob
					//   c->xyz -> oc
					ExtrapolateTexcoords(
						&oa[0], &oa[3],
						&ob[0], &ob[3],
						&oc[0], &oc[3],
						a->xyz, a->st,
						b->xyz, b->st,
						c->xyz, c->st );
				}
				break;
			}
		}
	}

	/* scale planes */
	if ( uniform ) {
		for ( i = 0; i < numBSPPlanes; i++ )
		{
			bspPlanes[ i ].dist *= scale[0];
		}
	}
	else
	{
		for ( i = 0; i < numBSPPlanes; i++ )
		{
			bspPlanes[ i ].normal[0] /= scale[0];
			bspPlanes[ i ].normal[1] /= scale[1];
			bspPlanes[ i ].normal[2] /= scale[2];
			f = 1 / VectorLength( bspPlanes[i].normal );
			VectorScale( bspPlanes[i].normal, f, bspPlanes[i].normal );
			bspPlanes[ i ].dist *= f;
		}
	}

	/* scale gridsize */
	GetVectorForKey( &entities[ 0 ], "gridsize", vec );
	if ( ( vec[ 0 ] + vec[ 1 ] + vec[ 2 ] ) == 0.0f ) {
		VectorCopy( gridSize, vec );
	}
	vec[0] *= scale[0];
	vec[1] *= scale[1];
	vec[2] *= scale[2];
	sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
	SetKeyValue( &entities[ 0 ], "gridsize", str );

	/* inject command line parameters */
	InjectCommandLine( argv, 0, argc - 1 );

	/* write the bsp */
	UnparseEntities();
	StripExtension( source );
	DefaultExtension( source, "_s.bsp" );
	Sys_Printf( "Writing %s\n", source );
	WriteBSPFile( source );

	/* return to sender */
	return 0;
}
Ejemplo n.º 12
0
/*
==============
main
==============
*/
int main (int argc, char **argv)
{
	int			i;
	char		path[1024];
	char		*basedir;
	double		starttime, endtime;

	printf ("Qdata Plus : "__TIME__" "__DATE__"\n");

	starttime = I_FloatTime();
	basedir = NULL;

	TK_Init();
	ExpandWildcards (&argc, &argv);

	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i], "-archive"))
		{
			// -archive f:/quake2/release/dump_11_30
			archive = true;
			strcpy (archivedir, argv[i+1]);
			printf ("Archiving source to: %s\n", archivedir);
			i++;
		}
		else if (!strcmp(argv[i], "-release"))
		{
			g_release = true;
			strcpy (g_releasedir, argv[i+1]);
			printf ("Copy output to: %s\n", g_releasedir);
			i++;
		}
		else if (!strcmp(argv[i], "-base"))
		{
			i++;
			basedir = argv[i];
		}
		else if (!strcmp(argv[i], "-compress"))
		{
			g_compress_pak = true;
			printf ("Compressing pakfile\n");
		}
		else if (!strcmp(argv[i], "-pak"))
		{
			g_release = true;
			g_pak = true;
			printf ("Building pakfile: %s\n", argv[i+1]);
			BeginPak (argv[i+1]);
			i++;
		}
		else if (!strcmp(argv[i], "-only"))
		{
			strcpy (g_only, argv[i+1]);
			printf ("Only grabbing %s\n", g_only);
			i++;
		}
		else if (!strcmpi(argv[i], "-keypress"))
		{
			g_dokeypress = true;
		}
		else if (!strcmp(argv[i], "-3ds"))
		{
			do3ds = true;
			printf ("loading .3ds files\n");
		}
		else if (!strcmp(argv[i], "-materialfile"))
		{
			strcpy(g_materialFile, argv[i+1]);
			printf("Setting material file to %s\n", g_materialFile);
			i++;
		}
/*		else if (!strcmpi(argv[i], "-newgen"))
		{
			if (i < argc-4)
			{
				printf("run new triangle grouping routine here\n");
				NewGen(argv[i+1],argv[i+2],atoi(argv[i+3]),atoi(argv[i+4]));
			}
			else
			{
				printf("qdata -newskin <base.hrc> <skin.pcx> width height\n");
			}
			return 0;
		}
*/		else if (!strcmpi(argv[i], "-genskin"))
		{
			i++;
			if (i < argc-3)
			{
				GenSkin(argv[i],argv[i+1],atol(argv[i+2]),atol(argv[i+3]));
			}
			else
			{
				printf("qdata -genskin <base.hrc> <skin.pcx> <desired width> <desired height>\n");
			}
			return 0;
			
		}
		else if (!strcmpi(argv[i], "-noopts"))
		{
			g_no_opimizations = true;
			printf("not performing optimizations\n");
		}
		else if (!strcmpi(argv[i], "-md2"))
		{
			g_forcemodel = MODEL_MD2;
		}
		else if (!strcmpi(argv[i], "-fm"))
		{
			g_forcemodel = MODEL_FM;
		}
		else if (!strcmpi(argv[i], "-verbose"))
		{
			g_verbose = true;
		}
		else if (!strcmpi(argv[i], "-oldskin"))
		{
			g_allow_newskin = false;
		}
		else if (!strcmpi(argv[i], "-ignoreUV"))
		{
			g_ignoreTriUV = true;
		}
		else if (!strcmpi(argv[i], "-publish"))
		{
			g_publishOutput = true;
		}
		else if (!strcmpi(argv[i], "-nomkdir"))
		{
			g_nomkdir = true;
		}
		else if (argv[i][0] == '-')
			Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i >= argc)
	{
		Error ("usage: qdata [-archive <directory>]\n"
			"             [-release <directory>]\n"
			"             [-base <directory>]\n"
			"             [-compress]\n"
			"             [-pak <file>]\n"
			"             [-only <model>]\n"
			"             [-keypress]\n"
			"             [-3ds]\n"
			"             [-materialfile <file>]\n"
			"             [-noopts]\n"
			"             [-md2]\n"
			"             [-fm]\n"
			"             [-verbose]\n"
			"             [-ignoreUV]\n"
			"             [-oldskin]\n"
			"             [-publish]\n"
			"             [-nomkdir]\n"
			"             file.qdt\n"
			"or\n"
			"       qdata -genskin <base.hrc> <skin.pcx> <desired width> <desired height>");
	}

	if (do3ds)
		trifileext = ext_3ds;
	else
		trifileext = ext_tri;

	for ( ; i<argc ; i++)
	{
		printf ("--------------- %s ---------------\n", argv[i]);
		// load the script
		strcpy (path, argv[i]);
		DefaultExtension (path, ".qdt");
		DefaultExtension(g_materialFile, ".mat");
		SetQdirFromPath (path);

		printf("workingdir='%s'\n", gamedir);
		if (basedir)
		{
			qdir[0] = 0;
			g_outputDir = basedir;
		}

		printf("outputdir='%s'\n", g_outputDir);

		QFile_ReadMaterialTypes(g_materialFile);
		LoadScriptFile (ExpandArg(path));
		
		//
		// parse it
		//
		ParseScript ();

		// write out the last model
		FinishModel ();
		FMFinishModel ();
		FinishSprite ();
	}

	if (total_textures)
	{
		printf("\n");
		printf("Total textures processed: %d\n",total_textures);
		printf("Average size: %d x %d\n",total_x / total_textures, total_y / total_textures);
	}

	if (g_pak)
		FinishPak ();

	endtime = I_FloatTime();
	printf("Time elapsed:  %f\n", endtime-starttime);
	
	if (g_dokeypress)
	{
		printf("Success! ... Hit a key: ");
		getchar();
	}

	return 0;
}
Ejemplo n.º 13
0
Archivo: bsp.c Proyecto: 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;
}
Ejemplo n.º 14
0
int ConvertMapToMap(int argc, char **argv)
{
	int             i;
	double          start, end;
	char            source[1024];
	char            name[1024];
	char            save[1024];

	Sys_Printf("---- convert map to map ----\n");

	for(i = 1; i < argc; i++)
	{
		if(!strcmp(argv[i], "-threads"))
		{
			numthreads = atoi(argv[i + 1]);
			i++;
		}
		else if(!strcmp(argv[i], "-v"))
		{
			Sys_Printf("verbose = true\n");
			verbose = qtrue;
		}
		else if(!strcmp(argv[i], "-quake3"))
		{
			convertType = CONVERT_QUAKE3;
			Sys_Printf("converting from Quake3 to XreaL\n");
		}
		else if(!strcmp(argv[i], "-quake4"))
		{
			convertType = CONVERT_QUAKE4;
			Sys_Printf("converting from Quake4 to XreaL\n");
		}
		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 -map2map [-<switch> [-<switch> ...]] <mapname.map>\n"
			  "\n" "Switches:\n" "   v              = verbose output\n"
			  //"   quake1       = convert from QuakeWorld to XreaL\n"
			  //"   quake2       = convert from Quake2 to XreaL\n"
			  "   quake3         = convert from Quake3 to XreaL\n" "   quake4         = convert from Quake4 to XreaL\n");
	}

	start = I_FloatTime();

	ThreadSetDefault();

	SetQdirFromPath(argv[i]);

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

	strcpy(name, ExpandArg(argv[i]));
	DefaultExtension(name, ".map");

	// start from scratch
	LoadShaderInfo();

	LoadMapFile(name);

	//
	strcpy(save, ExpandArg(argv[i]));
	StripExtension(save);
	strcat(save, "_converted");
	DefaultExtension(save, ".map");

	WriteMapFile(save);

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

	// shut down connection
	Broadcast_Shutdown();

	return 0;
}
Ejemplo n.º 15
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 );
}
Ejemplo n.º 16
0
int FixAAS( int argc, char **argv )
{
	int			length, checksum;
	void		*buffer;
	FILE		*file;
	char		aas[ 1024 ], **ext;
	char		*exts[] =
				{
					".aas",
					"_b0.aas",
					"_b1.aas",
					NULL
				};
	
	
	/* arg checking */
	if( argc < 2 )
	{
		Sys_Printf( "Usage: q3map -fixaas [-v] <mapname>\n" );
		return 0;
	}
	
	/* do some path mangling */
	strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
	StripExtension( source );
	DefaultExtension( source, ".bsp" );
	
	/* note it */
	Sys_Printf( "--- FixAAS ---\n" );
	
	/* load the bsp */
	Sys_Printf( "Loading %s\n", source );
	length = LoadFile( source, &buffer );
	
	/* create bsp checksum */
	Sys_Printf( "Creating checksum...\n" );
	checksum = LittleLong( MD4BlockChecksum( buffer, length ) );
	
	/* write checksum to aas */
	ext = exts;
	while( *ext )
	{
		/* mangle name */
		strcpy( aas, source );
		StripExtension( aas );
		strcat( aas, *ext );
		Sys_Printf( "Trying %s\n", aas );
		ext++;
		
		/* fix it */
		file = fopen( aas, "r+b" );
		if( !file )
			continue;
		if( fwrite( &checksum, 4, 1, file ) != 1 )
			Error( "Error writing checksum to %s", aas );
		fclose( file );
	}
	
	/* return to sender */
	return 0;
}
Ejemplo n.º 17
0
/*
===========
main
===========
*/
int main (int argc, char **argv)
{
	char	portalfile[1024];
	char		source[1024];
	char		name[1024];
	int		i;
	double		start, end;
		
	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], "-level"))
		{
			testlevel = atoi(argv[i+1]);
			printf ("testlevel = %i\n", testlevel);
			i++;
		}
		else if (!strcmp(argv[i], "-v"))
		{
			printf ("verbose = true\n");
			verbose = true;
		}
		else if (!strcmp (argv[i],"-nosort"))
		{
			printf ("nosort = true\n");
			nosort = true;
		}
		else if (!strcmp (argv[i],"-tmpin"))
			strcpy (inbase, "/tmp");
		else if (!strcmp (argv[i],"-tmpout"))
			strcpy (outbase, "/tmp");
		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 ();

	strcpy (source, argv[i]);
	StripExtension (source);
	DefaultExtension (source, ".bsp");

	sprintf (name, "%s%s", inbase, source);
	printf ("reading %s\n", name);
	LoadBSPFile (name);
	if (numnodes == 0 || numfaces == 0)
		Error ("Empty map");

	sprintf (portalfile, "%s%s", inbase, ExpandArg(argv[i]));
	StripExtension (portalfile);
	strcat (portalfile, ".prt");
	
	printf ("reading %s\n", portalfile);
	LoadPortals (portalfile);
	
	CalcVis ();

	CalcPHS ();

	visdatasize = vismap_p - dvisdata;	
	printf ("visdatasize:%i  compressed from %i\n", visdatasize, originalvismapsize*2);

	sprintf (name, "%s%s", outbase, source);
	printf ("writing %s\n", name);
	WriteBSPFile (name);	
	
	end = I_FloatTime ();
	printf ("%5.1f seconds elapsed\n", end-start);

	return 0;
}
Ejemplo n.º 18
0
int main( int argc, char *argv[] )
{
	if ( argc < 2 )
	{
		Msg("Usage:\nmakephx [options] <FILESPEC>\ne.g. makephx [-r] *.phy\n");
		return 0;
	}

	CommandLine()->CreateCmdLine( argc, argv );
	g_bRecursive = CommandLine()->FindParm("-r") > 0 ? true : false;
	g_bQuiet = CommandLine()->FindParm("-quiet") > 0 ? true : false;
	InitFilesystem( "*.*" );
	InitVPhysics();
	// disable automatic packing, we want to do this ourselves.
	physcollision->SetPackOnLoad( false );
	MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f, false, false, false, false );
	InstallSpewFunction();

	g_pModelConfig = new KeyValues("config");
	g_pModelConfig->LoadFromFile( g_pFullFileSystem, "phx.cfg", "GAME" );
	g_TotalOut = 0;
	g_TotalCompress = 0;
	FileFindHandle_t handle;
	char fullpath[1024], currentFile[1024], dirName[1024], nameext[256];
	strcpy( fullpath, argv[argc-1] );
	strcpy( fullpath, ExpandPath( fullpath ) );
	strcpy( fullpath, ExpandArg( fullpath ) );
	Q_strncpy(dirName, fullpath, sizeof(dirName));
	Q_StripFilename(dirName);
	Q_strncpy(nameext, fullpath + strlen(dirName)+1, sizeof(nameext));
	CUtlVector< const char * > directoryList;
	directoryList.AddToTail( strdup(dirName) );
	int current = 0;
	int count = 0;
	do 
	{
		if ( g_bRecursive )
		{
			MakeFilename( currentFile, sizeof(currentFile), directoryList[current], "*.*" );
			const char *pFilename = g_pFullFileSystem->FindFirst( currentFile, &handle );
			while ( pFilename )
			{
				if ( pFilename[0] != '.' && g_pFullFileSystem->FindIsDirectory( handle ) )
				{
					MakeDirname( currentFile, sizeof(currentFile), directoryList[current], pFilename );
					directoryList.AddToTail(strdup(currentFile));
				}
				pFilename = g_pFullFileSystem->FindNext( handle );
			}
			g_pFullFileSystem->FindClose( handle );
		}

		MakeFilename(currentFile, sizeof(currentFile), directoryList[current], nameext);
		const char *pFilename = g_pFullFileSystem->FindFirst( currentFile, &handle );
		while ( pFilename )
		{
			phyfile_t phy;
			MakeFilename(currentFile, sizeof(currentFile), directoryList[current], pFilename);
			LoadPHYFile( &phy, currentFile );
			if ( phy.collide.isPacked || phy.collide.solidCount < 1 )
			{
				Msg("%s is not a valid PHY file\n", currentFile );
			}
			else
			{
				WritePHXFile( currentFile, phy );
				count++;
			}
			UnloadPHYFile( &phy );
			pFilename = g_pFullFileSystem->FindNext( handle );
		}
		g_pFullFileSystem->FindClose( handle );
		current++;
	} while( current < directoryList.Count() );

	if ( count )
	{
		if (!g_bQuiet)
		{
			Msg("\n------\nTotal %s, %s\nSaved %s\n", Q_pretifymem( g_TotalOut ), Q_pretifymem( g_TotalCompress ), Q_pretifymem( g_TotalOut - g_TotalCompress ) );
			Msg("%.2f%% savings\n", ((float)(g_TotalOut-g_TotalCompress) / (float)g_TotalOut) * 100.0f );
		}
	}
	else
	{
		Msg("No files found in %s!\n", directoryList[current] );
	}

	return 0;
}
Ejemplo n.º 19
0
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;
}
Ejemplo n.º 20
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;
}
Ejemplo n.º 21
0
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;
}
Ejemplo n.º 22
0
/*
==============
main
==============
*/
int main (int argc, char **argv)
{
	static	int		i;		// VC4.2 compiler bug if auto...
	char	path[1024];

  // using GtkRadiant's versioning next to Id's versioning
  printf ("Q3Data      - (c) 1999 Id Software Inc.\n");
  printf ("GtkRadiant  - v" RADIANT_VERSION " " __DATE__ "\n");

	ExpandWildcards (&argc, &argv);

	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i], "-archive"))
		{
			archive = qtrue;
			strcpy (archivedir, argv[i+1]);
			printf ("Archiving source to: %s\n", archivedir);
			i++;
		}
		else if (!strcmp(argv[i], "-release"))
		{
			g_release = qtrue;
			strcpy (g_releasedir, argv[i+1]);
			printf ("Copy output to: %s\n", g_releasedir);
			i++;
		}
		else if ( !strcmp( argv[i], "-nostrips" ) )
		{
			g_stripify = qfalse;
			printf( "Not optimizing for strips\n" );
		}
		else if ( !strcmp( argv[i], "-writedir" ) )
		{
			strcpy( writedir, argv[i+1] );
			printf( "Write output to: %s\n", writedir );
			i++;
		}
		else if ( !strcmp( argv[i], "-verbose" ) )
		{
			g_verbose = qtrue;
		}
		else if ( !strcmp( argv[i], "-dump" ) )
		{
			printf( "Dumping contents of: '%s'\n", argv[i+1] );
			if ( strstr( argv[i+1], ".md3" ) )
			{
				MD3_Dump( argv[i+1] );
			}
			else
			{
				Error( "Do not know how to dump the contents of '%s'\n", argv[i+1] );
			}
			i++;
		}
		else if ( !strcmp( argv[i], "-3dsconvert" ) )
		{
      // NOTE TTimo this is broken, tried on a sample .3ds
      // what happens .. it calls the Convert3DStoMD3,
      // which calls the scriptlib function in non initialized state .. and crashes
			printf( "Converting %s.3DS to %s.MD3\n", argv[i+1], argv[i+1] );
			SetQdirFromPath( argv[i+1] );
      vfsInitDirectory( gamedir );
			Convert3DStoMD3( argv[i+1] );
			i++;
		}
		else if (!strcmp(argv[i], "-only"))
		{
			strcpy (g_only, argv[i+1]);
			printf ("Only grabbing %s\n", g_only);
			i++;
		}
		else if (!strcmp(argv[i], "-gamedir"))
		{
			strcpy(gamedir, argv[i+1]);
			i++;
		}
		else if (argv[i][0] == '-')
			Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i == argc)
		Error ("usage: q3data [-archive <directory>] [-dump <file.md3>] [-release <directory>] [-only <model>] [-3dsconvert <file.3ds>] [-verbose] [file.qdt]");

	for ( ; i<argc ; i++)
	{
		printf ("--------------- %s ---------------\n", argv[i]);
		// load the script
		strcpy (path, argv[i]);
		DefaultExtension (path, ".qdt");
		if(!gamedir[0])
			SetQdirFromPath (path);
    // NOTE TTimo
    // q3data went through a partial conversion to use the vfs
    // it was never actually tested before 1.1.1
    // the code is still mostly using direct file access calls
    vfsInitDirectory( gamedir );
		LoadScriptFile (ExpandArg(path), -1);
		
		//
		// parse it
		//
		ParseScript ();

		// write out the last model
		FinishModel ( TYPE_UNKNOWN );
	}

	return 0;
}
Ejemplo n.º 23
0
int ConvertBSPMain( int argc, char **argv ){
	int i;
	int ( *convertFunc )( char * );
	game_t  *convertGame;
	char ext[1024];
	char BSPFilePath [ 1024 ];
	char surfaceFilePath [ 1024 ];
	qboolean map_allowed, force_bsp, force_map;


	/* set default */
	convertFunc = ConvertBSPToASE;
	convertGame = NULL;
	map_allowed = qfalse;
	force_bsp = qfalse;
	force_map = qfalse;

	/* arg checking */
	if ( argc < 1 ) {
		Sys_Printf( "Usage: q3map -convert [-format <ase|obj|map_bp|map>] [-shadersasbitmap|-lightmapsastexcoord|-deluxemapsastexcoord] [-readbsp|-readmap [-meta|-patchmeta]] [-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;
				map_allowed = qfalse;
			}
			else if ( !Q_stricmp( argv[ i ], "obj" ) ) {
				convertFunc = ConvertBSPToOBJ;
				map_allowed = qfalse;
			}
			else if ( !Q_stricmp( argv[ i ], "map_bp" ) ) {
				convertFunc = ConvertBSPToMap_BP;
				map_allowed = qtrue;
			}
			else if ( !Q_stricmp( argv[ i ], "map" ) ) {
				convertFunc = ConvertBSPToMap;
				map_allowed = qtrue;
			}
			else
			{
				convertGame = GetGame( argv[ i ] );
				map_allowed = qfalse;
				if ( convertGame == NULL ) {
					Sys_FPrintf( SYS_WRN, "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] );
				}
			}
		}
		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 ],  "-shaderasbitmap" ) || !strcmp( argv[ i ],  "-shadersasbitmap" ) ) {
			shadersAsBitmap = qtrue;
		}
		else if ( !strcmp( argv[ i ],  "-lightmapastexcoord" ) || !strcmp( argv[ i ],  "-lightmapsastexcoord" ) ) {
			lightmapsAsTexcoord = qtrue;
		}
		else if ( !strcmp( argv[ i ],  "-deluxemapastexcoord" ) || !strcmp( argv[ i ],  "-deluxemapsastexcoord" ) ) {
			lightmapsAsTexcoord = qtrue;
			deluxemap = qtrue;
		}
		else if ( !strcmp( argv[ i ],  "-readbsp" ) ) {
			force_bsp = qtrue;
		}
		else if ( !strcmp( argv[ i ],  "-readmap" ) ) {
			force_map = qtrue;
		}
		else if ( !strcmp( argv[ i ],  "-meta" ) ) {
			meta = qtrue;
		}
		else if ( !strcmp( argv[ i ],  "-patchmeta" ) ) {
			meta = qtrue;
			patchMeta = qtrue;
		}
	}

	LoadShaderInfo();

	/* clean up map name */
	strcpy( source, ExpandArg( argv[i] ) );
	ExtractFileExtension( source, ext );

	if ( !map_allowed && !force_map ) {
		force_bsp = qtrue;
	}

	if ( force_map || ( !force_bsp && !Q_stricmp( ext, "map" ) && map_allowed ) ) {
		if ( !map_allowed ) {
			Sys_FPrintf( SYS_WRN, "WARNING: the requested conversion should not be done from .map files. Compile a .bsp first.\n" );
		}
		StripExtension( source );
		DefaultExtension( source, ".map" );
		Sys_Printf( "Loading %s\n", source );
		LoadMapFile( source, qfalse, convertGame == NULL );
		sprintf( BSPFilePath, "%s.bsp", source );
		sprintf( surfaceFilePath, "%s.srf", source );
		PseudoCompileBSP( convertGame != NULL, BSPFilePath, surfaceFilePath );
	}
	else
	{
		StripExtension( source );
		DefaultExtension( source, ".bsp" );
		Sys_Printf( "Loading %s\n", source );
		LoadBSPFile( source );
		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 );
}