示例#1
0
// run individual numbers function in same thread
void RunSameThreadOnIndividual(int workcnt, qboolean showpacifier, void(*func)(int))
{
	int	start, end;

	if( numthreads <= 0 )
		ThreadSetDefault();
	if( threaded == qtrue )
		Error("RunSameThreadOnIndividual: recursively entered!");

	start = I_FloatTime ();
	dispatch = 0;
	workcount = workcnt;
	oldf = -1;
	pacifier = showpacifier;
	workfunction = func;
	RunThreadsOnIndividualThread(0);
	end = I_FloatTime ();
	if (pacifier == qtrue)
	{
		while (oldf < 9)
		{
			oldf++;
			Sys_Printf ("%i...", oldf);
		}
		Sys_Printf (" (%i)\n", end-start);
	}
}
示例#2
0
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void RunThreadsOnIndividual (int workcnt, qboolean showpacifier, void(*func)(int))
{
	if (numthreads == -1)
		ThreadSetDefault ();
	workfunction = func;
	RunThreadsOn (workcnt, showpacifier, ThreadWorkerFunction);
} //end of the function RunThreadsOnIndividual
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )(int) ) {
	int threadid[MAX_THREADS];
	HANDLE threadhandle[MAX_THREADS];
	int i;
	int start, end;

	Log_Print( "Win32 multi-threading\n" );
	start = I_FloatTime();
	dispatch = 0;
	workcount = workcnt;
	oldf = -1;
	pacifier = showpacifier;
	threaded = true;

	if ( numthreads == -1 ) {
		ThreadSetDefault();
	}

	if ( numthreads < 1 || numthreads > MAX_THREADS ) {
		numthreads = 1;
	}
	//
	// run threads in parallel
	//
	InitializeCriticalSection( &crit );

	numwaitingthreads = 0;

	if ( numthreads == 1 ) { // use same thread
		func( 0 );
	} //end if
	else
	{
//		printf("starting %d threads\n", numthreads);
		for ( i = 0; i < numthreads; i++ )
		{
			threadhandle[i] = CreateThread(
				NULL,   // LPSECURITY_ATTRIBUTES lpsa,
				0,      // DWORD cbStack,
				(LPTHREAD_START_ROUTINE)func,   // LPTHREAD_START_ROUTINE lpStartAddr,
				(LPVOID)i,  // LPVOID lpvThreadParm,
				0,          //   DWORD fdwCreate,
				&threadid[i] );
//			printf("started thread %d\n", i);
		} //end for

		for ( i = 0; i < numthreads; i++ )
			WaitForSingleObject( threadhandle[i], INFINITE );
	} //end else
	DeleteCriticalSection( &crit );

	threaded = false;
	end = I_FloatTime();
	if ( pacifier ) {
		printf( " (%i)\n", end - start );
	}
} //end of the function RunThreadsOn
示例#4
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;
}
示例#5
0
// run threads on individual numbers
void RunThreadsOnIndividual(int workcnt, qboolean showpacifier, void(*func)(int))
{
	if( numthreads <= 0 )
		ThreadSetDefault();
	if ( threaded == qtrue )
		Error("RunThreadsOnIndividual: recursively entered!");

	workfunction = func;
	RunThreadsOn(workcnt, showpacifier, RunThreadsOnIndividualThread);
}
示例#6
0
void RunThreadsOn(int workcnt, qboolean showpacifier, void(*threadfunc)(int))
{
	if( numthreads <= 0 )
		ThreadSetDefault();
	if( threaded == qtrue )
		Error("RunThreadsOn: recursively entered!");

	threaded = qtrue;
	_RunThreadsOn(workcnt, showpacifier, threadfunc);
	threaded = qfalse;
}
示例#7
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;
}
示例#8
0
文件: convert_ase.c 项目: otty/cake3
/*
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;
}
示例#9
0
文件: qrad.c 项目: jpiolho/halflife
int main (int argc, char **argv)
{
	int		i;
	double		start, end;

	printf( "qrad.exe v 1.5 (%s)\n", __DATE__ );
	printf ("----- Radiosity ----\n");

	verbose = true;  // Originally FALSE
	smoothing_threshold = cos(45.0*(Q_PI/180)); // Originally zero.

	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i],"-dump"))
			dumppatches = true;
		else if (!strcmp(argv[i],"-bounce"))
		{
			if ( ++i < argc )
			{
				numbounce = atoi (argv[i]);
				if ( numbounce < 0 )
				{
					fprintf(stderr, "Error: expected non-negative value after '-bounce'\n" );
					return 1;
				}
			}
			else
			{
				fprintf( stderr, "Error: expected a value after '-bounce'\n" );
				return 1;
			}
		}
		else if (!strcmp(argv[i],"-verbose"))
		{
			verbose = true;
		}
		else if (!strcmp(argv[i],"-terse"))
		{
			verbose = false;
		}
		else if (!strcmp(argv[i],"-threads"))
		{
			if ( ++i < argc )
			{
				numthreads = atoi (argv[i]);
				if ( numthreads <= 0 )
				{
					fprintf(stderr, "Error: expected positive value after '-threads'\n" );
					return 1;
				}
			}
			else
			{
				fprintf( stderr, "Error: expected a value after '-threads'\n" );
				return 1;
			}
		}
		else if (!strcmp(argv[i],"-maxchop"))
		{
			if ( ++i < argc )
			{
				maxchop = (float)atof (argv[i]);
				if ( maxchop < 2 )
				{
					fprintf(stderr, "Error: expected positive value after '-maxchop'\n" );
					return 1;
				}
			}
			else
			{
				fprintf( stderr, "Error: expected a value after '-maxchop'\n" );
				return 1;
			}
		}
		else if (!strcmp(argv[i],"-chop"))
		{
			if ( ++i < argc )
			{
				minchop = (float)atof (argv[i]);
				if ( minchop < 1 )
				{
					fprintf(stderr, "Error: expected positive value after '-chop'\n" );
					return 1;
				}
				if ( minchop < 32 )
				{
					fprintf(stderr, "WARNING: Chop values below 32 are not recommended.  Use -extra instead.\n");
				}
			}
			else
			{
				fprintf( stderr, "Error: expected a value after '-chop'\n" );
				return 1;
			}
		}
		else if (!strcmp(argv[i],"-scale"))
		{
			if ( ++i < argc )
			{
				lightscale = (float)atof (argv[i]);
			}
			else
			{
				fprintf( stderr, "Error: expected a value after '-scale'\n" );
				return 1;
			}
		}
		else if (!strcmp(argv[i],"-ambient"))
		{
			if ( i+3 < argc )
			{
 				ambient[0] = (float)atof (argv[++i]) * 128;
 				ambient[1] = (float)atof (argv[++i]) * 128;
 				ambient[2] = (float)atof (argv[++i]) * 128;
			}
			else
			{
				fprintf( stderr, "Error: expected three color values after '-ambient'\n" );
				return 1;
			}
		}
		else if( !strcmp(argv[i], "-proj") )
		{
			if ( ++i < argc && *argv[i] )
				strcpy( qproject, argv[i] );
			else
			{
				fprintf(stderr, "Error: expected path name after '-proj'\n" );
				return 1;
			}
		}
		else if ( !strcmp(argv[i], "-maxlight") )
		{
			if ( ++i < argc && *argv[i] )
			{
				maxlight = (float)atof (argv[i]) * 128;
				if ( maxlight <= 0 )
				{
					fprintf(stderr, "Error: expected positive value after '-maxlight'\n" );
					return 1;
				}
			}
			else
			{
				fprintf( stderr, "Error: expected a value after '-maxlight'\n" );
				return 1;
			}
		}
		else if ( !strcmp(argv[i], "-lights" ) )
		{
			if ( ++i < argc && *argv[i] )
			{
				strcpy( designer_lights, argv[i] );
			}
			else
			{
				fprintf( stderr, "Error: expected a filepath after '-lights'\n" );
				return 1;
			}
		}
		else if ( !strcmp(argv[i], "-inc" ) )
		{
			incremental = true;
		} 
		else if (!strcmp(argv[i],"-gamma"))
		{
			if ( ++i < argc )
			{
				gamma = (float)atof (argv[i]);
			}
			else
			{
				fprintf( stderr, "Error: expected a value after '-gamma'\n" );
				return 1;
			}
		}
		else if (!strcmp(argv[i],"-dlight"))
		{
			if ( ++i < argc )
			{
				dlight_threshold = (float)atof (argv[i]);
			}
			else
			{
				fprintf( stderr, "Error: expected a value after '-dlight'\n" );
				return 1;
			}
		}
		else if (!strcmp(argv[i],"-extra"))
		{
			extra = true;
		}
		else if (!strcmp(argv[i],"-sky"))
		{
			if ( ++i < argc )
			{
				indirect_sun = (float)atof (argv[i]);
			}
			else
			{
				fprintf( stderr, "Error: expected a value after '-gamma'\n" );
				return 1;
			}
		}
		else if (!strcmp(argv[i],"-smooth"))
		{
			if ( ++i < argc )
			{
				smoothing_threshold = (float)cos(atof(argv[i])*(Q_PI/180.0));
			}
			else
			{
				fprintf( stderr, "Error: expected an angle after '-smooth'\n" );
				return 1;
			}
		}
		else if (!strcmp(argv[i],"-coring"))
		{
			if ( ++i < argc )
			{
				coring = (float)atof( argv[i] );
			}
			else
			{
				fprintf( stderr, "Error: expected a light threshold after '-coring'\n" );
				return 1;
			}
		}
		else if (!strcmp(argv[i],"-notexscale"))
		{
			texscale = false;
		}
		else
		{
			break;
		}
	}

	ThreadSetDefault ();

	if (maxlight > 255)
		maxlight = 255;

	if (i != argc - 1)
		Error ("usage: qrad [-dump] [-inc] [-bounce n] [-threads n] [-verbose] [-terse] [-chop n] [-maxchop n] [-scale n] [-ambient red green blue] [-proj file] [-maxlight n] [-threads n] [-lights file] [-gamma n] [-dlight n] [-extra] [-smooth n] [-coring n] [-notexscale] bspfile");

	start = I_FloatTime ();

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

	// Set the required global lights filename
	strcat( strcpy( global_lights, gamedir ), "lights.rad" );
	if ( _access( global_lights, 0x04) == -1 ) 
	{
		// try looking in qproject
		strcat( strcpy( global_lights, qproject ), "lights.rad" );
		if ( _access( global_lights, 0x04) == -1 ) 
		{
			// try looking in the directory we were run from
			GetModuleFileName( NULL, global_lights, sizeof( global_lights ) );
			ExtractFilePath( global_lights, global_lights );
			strcat( global_lights, "lights.rad" );
		}
	}

	// Set the optional level specific lights filename
	DefaultExtension( strcpy( level_lights, source ), ".rad" );
	if ( _access( level_lights, 0x04) == -1 ) *level_lights = 0;	

	ReadLightFile(global_lights);							// Required
	if ( *designer_lights ) ReadLightFile(designer_lights);	// Command-line
	if ( *level_lights )	ReadLightFile(level_lights);	// Optional & implied

	strcpy(incrementfile, source);
	DefaultExtension(incrementfile, ".r0");
	DefaultExtension(source, ".bsp");

	LoadBSPFile (source);
	ParseEntities ();

	if (!visdatasize)
	{
		printf ("No vis information, direct lighting only.\n");
		numbounce = 0;
		ambient[0] = ambient[1] = ambient[2] = 0.1f;
	}

	RadWorld ();

	if (verbose)
		PrintBSPFileSizes ();

	WriteBSPFile (source);

	if ( incremental )
	{
		if ( !IsIncremental(incrementfile) )
		{
			SaveIncremental(incrementfile);
		}
	}
	else
	{
		unlink(incrementfile);
	}

	end = I_FloatTime ();
	printf ("%5.0f seconds elapsed\n", end-start);
	
	return 0;
}
示例#10
0
文件: vvis.cpp 项目: chrizonix/RCBot2
int RunVVis( int argc, char **argv )
{
    char	portalfile[1024];
    char		source[1024];
    double		start, end;


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

    verbose = false;

    Q_StripExtension( argv[ argc - 1 ], source, sizeof( source ) );
    CmdLib_InitFileSystem( argv[ argc - 1 ] );

    Q_FileBase( source, source, sizeof( source ) );

    LoadCmdLineFromFile( argc, argv, source, "vvis" );
    int i = ParseCommandLine( argc, argv );

    // This part is just for VMPI. VMPI's file system needs the basedir in front of all filenames,
    // so we prepend qdir here.
    strcpy( source, ExpandPath( source ) );

    if (i != argc - 1)
    {
        PrintUsage( argc, argv );
        DeleteCmdLine( argc, argv );
        CmdLib_Exit( 1 );
    }

    start = Plat_FloatTime();


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

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

    ThreadSetDefault ();

    char	targetPath[1024];
    GetPlatformMapPath( source, targetPath, 0, 1024 );
    Msg ("reading %s\n", targetPath);
    LoadBSPFile (targetPath);
    if (numnodes == 0 || numfaces == 0)
        Error ("Empty map");
    ParseEntities ();

    // Check the VMF for a vis radius
    if (!g_bUseRadius)
    {
        float flRadius = DetermineVisRadius( );
        if (flRadius > 0.0f)
        {
            g_bUseRadius = true;
            g_VisRadius = flRadius * flRadius;
        }
    }

    if ( g_bUseRadius )
    {
        MarkLeavesAsRadial();
    }

    if ( inbase[0] == 0 )
    {
        strcpy( portalfile, source );
    }
    else
    {
        sprintf ( portalfile, "%s%s", inbase, argv[i] );
        Q_StripExtension( portalfile, portalfile, sizeof( portalfile ) );
    }
    strcat (portalfile, ".prt");

    Msg ("reading %s\n", portalfile);
    LoadPortals (portalfile);

    CalcVis ();
    CalcPAS ();

    // We need a mapping from cluster to leaves, since the PVS
    // deals with clusters for both CalcVisibleFogVolumes and
    BuildClusterTable();

    CalcVisibleFogVolumes();
    CalcDistanceFromLeavesToWater();

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

    Msg ("writing %s\n", targetPath);
    WriteBSPFile (targetPath);

    end = Plat_FloatTime();

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

    DeleteCmdLine( argc, argv );
    CmdLib_Cleanup();
    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
文件: convert_map.c 项目: otty/cake3
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;
}
示例#13
0
void ThreadStats (void)
{
	if( numthreads <= 0 )
		ThreadSetDefault();
	Sys_Printf (" %i threads\n", numthreads);
}
示例#14
0
文件: qbsp.c 项目: dommul/super8
/*
==================
main

==================
*/
int main (int argc, char **argv)
{
	int		i;
	double	start, end;

	myargc = argc;
	myargv = argv;

	//	malloc_debug (15);
	printf( "hmap2 by LordHavoc and Vic\n");
	printf( "based on id Software's quake qbsp, light and vis utilities source code\n" );
	printf( "\n" );

	//
	// check command line flags
	//

	if (argc == 1)
		goto error;

	// create all the filenames pertaining to this map
	strcpy(filename_map, argv[argc-1]);ReplaceExtension(filename_map, ".bsp", ".map", ".map");
	strcpy(filename_bsp, filename_map);ReplaceExtension(filename_bsp, ".map", ".bsp", ".bsp");
	strcpy(filename_prt, filename_bsp);ReplaceExtension(filename_prt, ".bsp", ".prt", ".prt");
	strcpy(filename_pts, filename_bsp);ReplaceExtension(filename_pts, ".bsp", ".pts", ".pts");
	strcpy(filename_lin, filename_bsp);ReplaceExtension(filename_lin, ".bsp", ".lin", ".lin");
	strcpy(filename_lit, filename_bsp);ReplaceExtension(filename_lit, ".bsp", ".lit", ".lit");
	strcpy(filename_dlit, filename_bsp);ReplaceExtension(filename_dlit, ".bsp", ".dlit", ".dlit");
	strcpy(filename_lights, filename_bsp);ReplaceExtension(filename_lights, ".bsp", ".lights", ".lights");

	if (!strcmp(filename_map, filename_bsp))
		Error("filename_map \"%s\" == filename_bsp \"%s\"\n", filename_map, filename_bsp);

	for (i = 0; i < argc; i++)
	{
		if (!strcmp(argv[i],"-threads"))
		{
			i++;
			if( i >= argc )
				Error( "no value was given to -numthreads\n" );
			numthreads = atoi (argv[i]);
		}
	}

	ThreadSetDefault ();

	i = 1;
	ismcbsp = false;
	if (!strcmp (argv[i], "-mc"))
	{
		printf ("Using Martial Concert bsp format\n");
		ismcbsp = true;
		i++;
	}

	if (argc == i)
		goto error;

	if (!strcmp (argv[i], "-bsp2prt"))
		return Bsp2Prt_Main (argc-i, argv+i);
	else if (!strcmp (argv[i], "-bspinfo"))
		return BspInfo_Main (argc-i, argv+i);
	else if (!strcmp (argv[i], "-vis"))
		return Vis_Main (argc-i, argv+i);
	else if (!strcmp (argv[i], "-light"))
		return Light_Main (argc-i, argv+i);

	nofill = false;
	notjunc = false;
	noclip = false;
	onlyents = false;
	verbose = true;
	allverbose = false;
	transwater = true;
	forcevis = true;
	waterlightmap = true;
	subdivide_size = 240;
	option_solidbmodels = false;

	for (; i < argc; i++)
	{
		if (argv[i][0] != '-')
			break;
		else if (!strcmp (argv[i],"-nowater"))
			transwater = false;
		else if (!strcmp (argv[i],"-notjunc"))
			notjunc = true;
		else if (!strcmp (argv[i],"-nofill"))
			nofill = true;
		else if (!strcmp (argv[i],"-noclip"))
			noclip = true;
		else if (!strcmp (argv[i],"-onlyents"))
			onlyents = true;
		else if (!strcmp (argv[i],"-verbose"))
			allverbose = true;
		else if (!strcmp (argv[i],"-nowaterlightmap"))
			waterlightmap = false;
		else if (!strcmp (argv[i],"-subdivide"))
		{
			subdivide_size = atoi(argv[i+1]);
			i++;
		}
		else if (!strcmp (argv[i],"-darkplaces"))
		{
			// produce 256x256 texel lightmaps
			subdivide_size = 4080;
		}
		else if (!strcmp (argv[i],"-noforcevis"))
			forcevis = false;
		else if (!strcmp (argv[i],"-solidbmodels"))
			option_solidbmodels = true;
		else if (!strcmp (argv[i],"-wadpath"))
			i++; // handled later in wad lookups
		else
			Error ("Unknown option '%s'", argv[i]);
	}

	if (i != argc - 1)
error:
		Error ("%s",
"usage: hmap2 [options] sourcefile\n"
"Compiles .map to .bsp, does not compile vis or lighting data\n"
"\n"
"other utilities available:\n"
"-bsp2prt    bsp2prt utility, run -bsp2prt as the first parameter for more\n"
"-bspinfo    bspinfo utility, run -bspinfo as the first parameter for more\n"
"-light      lighting utility, run -light as the first parameter for more\n"
"-vis        vis utility, run -vis as the first parameter for more\n"
"\n"
"What the options do:\n"
"-nowater    disable watervis; r_wateralpha in glquake will not work right\n"
"-notjunc    disable tjunction fixing; glquake will have holes between polygons\n"
"-nofill     disable sealing of map and vis, used for ammoboxes\n"
"-onlyents   patchs entities in existing .bsp, for relighting\n"
"-verbose    show more messages\n"
"-darkplaces allow really big polygons\n"
"-noforcevis don't make a .prt if the map leaks\n"
"-nowaterlightmap disable darkplaces lightmapped water feature\n"
"-notex      store blank textures instead of real ones, smaller bsp if zipped\n"
"-solidbmodels use qbsp behavior of making water/sky submodels solid\n"
		);

	printf("inputfile: %s\n", filename_map);
	printf("outputfile: %s\n", filename_bsp);

	// init memory
	Q_InitMem ();

	//
	// do it!
	//
	start = I_DoubleTime ();
	ProcessFile (filename_map, filename_bsp);
	end = I_DoubleTime ();
	printf ("%5.1f seconds elapsed\n\n", end-start);

	// print memory stats
	Q_PrintMem ();

	// free allocated memory
	Q_ShutdownMem ();

	return 0;
}
示例#15
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;
}
示例#16
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;
}
示例#17
0
int main(int argc,char **argv)
{
	int		i;
	double	start, end;

	printf("Katana Level (based on hmap2 by LordHavoc and Vic)\n");
	printf("Compiled: "__DATE__" "__TIME__"\n");
	printf("\n" );

	// Check command line flags
	if(argc == 1)
		goto STARTERROR;

	// create all the filenames pertaining to this map
	strcpy(filename_map, argv[argc - 1]);
	ReplaceExtension(filename_map,BSP_EXTENSION, ".map", ".map");
	strcpy(filename_bsp, filename_map);
	ReplaceExtension(filename_bsp, ".map",BSP_EXTENSION,BSP_EXTENSION);
	strcpy(filename_prt, filename_bsp);
	ReplaceExtension(filename_prt,BSP_EXTENSION, ".prt", ".prt");
	strcpy(filename_pts, filename_bsp);
	ReplaceExtension(filename_pts,BSP_EXTENSION, ".pts", ".pts");
	strcpy(cFilenameEntity, filename_pts);
	ReplaceExtension(cFilenameEntity, ".pts", ".entity", ".entity");

	if(!strcmp(filename_map, filename_bsp))
		Error("filename_map \"%s\" == filename_bsp \"%s\"\n", filename_map, filename_bsp);

/*	for (i = 0; i < argc; i++)
	{
		if (!strcmp(argv[i],"-threads"))
		{
			i++;
			if( i >= argc )
				Error( "no value was given to -numthreads\n" );
			numthreads = atoi (argv[i]);
		}
	}*/

	i = 1;
	if(argc == i)
		goto STARTERROR;

	if(!strcmp(argv[i],"-threads"))
	{
		if(i >= argc)
			Error("No value was given to -threads!\n");
		numthreads = atoi(argv[i+1]);
	}

	ThreadSetDefault();

	if (!strcmp (argv[i], "-bsp2prt"))
		return Bsp2Prt_Main (argc-i, argv+i);
	else if (!strcmp (argv[i], "-bspinfo"))
		return BspInfo_Main();
	else if (!strcmp (argv[i], "-vis"))
		return Vis_Main (argc-i, argv+i);
	else if (!strcmp (argv[i], "-light"))
		return Light_Main (argc-i, argv+i);

	nofill			= false;
	notjunc			= false;
	noclip			= false;
	onlyents		= false;
	verbose			= true;
	allverbose		= false;
	transwater		= true;
	forcevis		= true;
	waterlightmap	= true;
	subdivide_size	= 1024;

	for (; i < argc; i++)
	{
		if (argv[i][0] != '-')
			break;
		else if (!strcmp (argv[i],"-nowater"))
			transwater = false;
		else if (!strcmp (argv[i],"-notjunc"))
			notjunc = true;
		else if (!strcmp (argv[i],"-nofill"))
			nofill = true;
		else if (!strcmp (argv[i],"-noclip"))
			noclip = true;
		else if (!strcmp (argv[i],"-onlyents"))
			onlyents = true;
		else if (!strcmp (argv[i],"-verbose"))
			allverbose = true;
		else if (!strcmp (argv[i],"-nowaterlightmap"))
			waterlightmap = false;
		else if (!strcmp (argv[i],"-subdivide"))
		{
			subdivide_size = atoi(argv[i+1]);
			i++;
		}
		else if (!strcmp (argv[i],"-noforcevis"))
			forcevis = false;
		else if (!strcmp(argv[i], "-wadpath"))
		{ 
			sprintf(wadPath, "%s", argv[i + 1]);
			i++;
		}
		else
			Error("Unknown option '%s'",argv[i]);
	}

	if(i != argc-1)
STARTERROR:
		Error(	"%s",
				"usage: hmap2 [options] sourcefile\n"
				"Compiles .map to "BSP_EXTENSION", does not compile vis or lighting data\n"
				"\n"
				"other utilities available:\n"
				"-bsp2prt    bsp2prt utility, run -bsp2prt as the first parameter for more\n"
				"-bspinfo    bspinfo utility, run -bspinfo as the first parameter for more\n"
				"-light      lighting utility, run -light as the first parameter for more\n"
				"-vis        vis utility, run -vis as the first parameter for more\n"
				"\n"
				"What the options do:\n"
				"-wadpath (Sets the path to load WADs from.)\n"
				"-nowater			disable watervis; r_wateralpha in glquake will not work right\n"
				"-notjunc			disable tjunction fixing; glquake will have holes between polygons\n"
				"-nofill			disable sealing of map and vis, used for ammoboxes\n"
				"-onlyents			patchs entities in existing "BSP_EXTENSION", for relighting\n"
				"-verbose			show more messages\n"
				"-subdivide			allow really big polygons (e.g. -subdivide 1024)\n"
				"-noforcevis		don't make a .prt if the map leaks\n"
				"-nowaterlightmap	disable darkplaces lightmapped water feature\n"
				"-notex				store blank textures instead of real ones, smaller bsp if zipped\n");

	printf("Input:	%s\n", filename_map);
	printf("Output: %s\n", filename_bsp);

	// Init memory
	Q_InitMem ();

	// Do it!
	start = I_DoubleTime ();

	ProcessFile(filename_map);

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

	// Print memory stats
	Q_PrintMem();

	// Free allocated memory
	Q_ShutdownMem();

	return 0;
}
示例#18
0
int main( int argc, char **argv )
{
	int		i, r;
	double	start, end;
	
	
	/* we want consistent 'randomness' */
	srand( 0 );
	
	/* start timer */
	start = I_FloatTime();

	/* this was changed to emit version number over the network */
	printf( Q3MAP_VERSION "\n" );
	
	/* set exit call */
	atexit( ExitQ3Map );
	
	/* read general options first */
	for( i = 1; i < argc; i++ )
	{
		/* -connect */
		if( !strcmp( argv[ i ], "-connect" ) )
		{
			argv[ i ] = NULL;
			i++;
			Broadcast_Setup( argv[ i ] );
			argv[ i ] = NULL;
		}
		
		/* verbose */
		else if( !strcmp( argv[ i ], "-v" ) )
		{
			verbose = qtrue;
			argv[ i ] = NULL;
		}
		
		/* force */
		else if( !strcmp( argv[ i ], "-force" ) )
		{
			force = qtrue;
			argv[ i ] = NULL;
		}
		
		/* patch subdivisions */
		else if( !strcmp( argv[ i ], "-subdivisions" ) )
		{
			argv[ i ] = NULL;
			i++;
			patchSubdivisions = atoi( argv[ i ] );
			argv[ i ] = NULL;
			if( patchSubdivisions <= 0 )
				patchSubdivisions = 1;
		}
		
		/* threads */
		else if( !strcmp( argv[ i ], "-threads" ) )
		{
			argv[ i ] = NULL;
			i++;
			numthreads = atoi( argv[ i ] );
			argv[ i ] = NULL;
		}
	}
	
	/* init model library */
	PicoInit();
	PicoSetMallocFunc( safe_malloc );
	PicoSetFreeFunc( free );
	PicoSetPrintFunc( PicoPrintFunc );
	PicoSetLoadFileFunc( PicoLoadFileFunc );
	PicoSetFreeFileFunc( free );
	
	/* set number of threads */
	ThreadSetDefault();
	
	/* generate sinusoid jitter table */
	for( i = 0; i < MAX_JITTERS; i++ )
	{
		jitters[ i ] = sin( i * 139.54152147 );
		//%	Sys_Printf( "Jitter %4d: %f\n", i, jitters[ i ] );
	}
	
	/* we print out two versions, q3map's main version (since it evolves a bit out of GtkRadiant)
	   and we put the GtkRadiant version to make it easy to track with what version of Radiant it was built with */
	
	Sys_Printf( "Q3Map         - v1.0r (c) 1999 Id Software Inc.\n" );
	Sys_Printf( "Q3Map (ydnar) - v" Q3MAP_VERSION "\n" );
	Sys_Printf( "GtkRadiant    - v" RADIANT_VERSION " " __DATE__ " " __TIME__ "\n" );
	Sys_Printf( "%s\n", Q3MAP_MOTD );
	
	/* ydnar: new path initialization */
	InitPaths( &argc, argv );
	
	/* check if we have enough options left to attempt something */
	if( argc < 2 )
		Error( "Usage: %s [general options] [options] mapfile", argv[ 0 ] );
	
	/* fixaas */
	if( !strcmp( argv[ 1 ], "-fixaas" ) )
		r = FixAAS( argc - 1, argv + 1 );
	
	/* analyze */
	else if( !strcmp( argv[ 1 ], "-analyze" ) )
		r = AnalyzeBSP( argc - 1, argv + 1 );
	
	/* info */
	else if( !strcmp( argv[ 1 ], "-info" ) )
		r = BSPInfo( argc - 2, argv + 2 );
	
	/* vis */
	else if( !strcmp( argv[ 1 ], "-vis" ) )
		r = VisMain( argc - 1, argv + 1 );
	
	/* light */
	else if( !strcmp( argv[ 1 ], "-light" ) )
		r = LightMain( argc - 1, argv + 1 );
	
	/* vlight */
	else if( !strcmp( argv[ 1 ], "-vlight" ) )
	{
		Sys_Printf( "WARNING: VLight is no longer supported, defaulting to -light -fast instead\n\n" );
		argv[ 1 ] = "-fast";	/* eek a hack */
		r = LightMain( argc, argv );
	}
	
	/* ydnar: lightmap export */
	else if( !strcmp( argv[ 1 ], "-export" ) )
		r = ExportLightmapsMain( argc - 1, argv + 1 );
	
	/* ydnar: lightmap import */
	else if( !strcmp( argv[ 1 ], "-import" ) )
		r = ImportLightmapsMain( argc - 1, argv + 1 );
	
	/* ydnar: bsp scaling */
	else if( !strcmp( argv[ 1 ], "-scale" ) )
		r = ScaleBSPMain( argc - 1, argv + 1 );
	
	/* ydnar: bsp conversion */
	else if( !strcmp( argv[ 1 ], "-convert" ) )
		r = ConvertBSPMain( argc - 1, argv + 1 );
	
	/* ydnar: otherwise create a bsp */
	else
		r = BSPMain( argc, argv );
	
	/* emit time */
	end = I_FloatTime();
	Sys_Printf( "%9.0f seconds elapsed\n", end - start );
	
	/* shut down connection */
	Broadcast_Shutdown();
	
	/* return any error code */
	return r;
}
示例#19
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;
}
示例#20
0
//===========================================================================
// creates an .AAS file with the given name
// a MAP should be loaded before calling this
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_Create(char *aasfile)
{
	entity_t	*e;
	tree_t *tree;
	double start_time;

	//for a possible leak file
	strcpy(source, aasfile);
	StripExtension(source);
	//the time started
	start_time = I_FloatTime();
	//set the default number of threads (depends on number of processors)
	ThreadSetDefault();
	//set the global entity number to the world model
	entity_num = 0;
	//the world entity
	e = &entities[entity_num];
	//process the whole world
	tree = ProcessWorldBrushes(e->firstbrush, e->firstbrush + e->numbrushes);
	//if the conversion is cancelled
	if (cancelconversion)
	{
		Tree_Free(tree);
		return;
	} //end if
	//display BSP tree creation time
	Log_Print("BSP tree created in %5.0f seconds\n", I_FloatTime() - start_time);
	//prune the bsp tree
	Tree_PruneNodes(tree->headnode);
	//if the conversion is cancelled
	if (cancelconversion)
	{
		Tree_Free(tree);
		return;
	} //end if
	//create the tree portals
	MakeTreePortals(tree);
	//if the conversion is cancelled
	if (cancelconversion)
	{
		Tree_Free(tree);
		return;
	} //end if
	//Marks all nodes that can be reached by entites
	if (FloodEntities(tree))
	{
		//fill out nodes that can't be reached
		FillOutside(tree->headnode);
	} //end if
	else
	{
		LeakFile(tree);
		Error("**** leaked ****\n");
		return;
	} //end else
	//create AAS from the BSP tree
	//==========================================
	//initialize tmp aas
	AAS_InitTmpAAS();
	//create the convex areas from the leaves
	AAS_CreateAreas(tree->headnode);
	//free the BSP tree because it isn't used anymore
	if (freetree) Tree_Free(tree);
	//try to merge area faces
	AAS_MergeAreaFaces();
	//do gravitational subdivision
	AAS_GravitationalSubdivision();
	//merge faces if possible
	AAS_MergeAreaFaces();
	AAS_RemoveAreaFaceColinearPoints();
	//merge areas if possible
	AAS_MergeAreas();
	//NOTE: prune nodes directly after area merging
	AAS_PruneNodes();
	//flip shared faces so they are all facing to the same area
	AAS_FlipSharedFaces();
	AAS_RemoveAreaFaceColinearPoints();
	//merge faces if possible
	AAS_MergeAreaFaces();
	//merge area faces in the same plane
	AAS_MergeAreaPlaneFaces();
	//do ladder subdivision
	AAS_LadderSubdivision();
	//FIXME: melting is buggy
	AAS_MeltAreaFaceWindings();
	//remove tiny faces
	AAS_RemoveTinyFaces();
	//create area settings
	AAS_CreateAreaSettings();
	//check if the winding plane is equal to the face plane
	//AAS_CheckAreaWindingPlanes();
	//
	//AAS_CheckSharedFaces();
	//==========================================
	//if the conversion is cancelled
	if (cancelconversion)
	{
		Tree_Free(tree);
		AAS_FreeTmpAAS();
		return;
	} //end if
	//store the created AAS stuff in the AAS file format and write the file
	AAS_StoreFile(aasfile);
	//free the temporary AAS memory
	AAS_FreeTmpAAS();
	//display creation time
	Log_Print("\nAAS created in %5.0f seconds\n", I_FloatTime() - start_time);
} //end of the function AAS_Create
示例#21
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;
}
示例#22
0
文件: vis.c 项目: 6779660/halflife
/*
===========
main
===========
*/
int main (int argc, char **argv)
{
	char	portalfile[1024];
	char		source[1024];
	int		i;
	double		start, end;
		
	printf ("vis.exe v1.3 (%s)\n", __DATE__);
	printf ("---- vis ----\n");

	verbose = false;
	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i],"-threads"))
		{
			numthreads = atoi (argv[i+1]);
			i++;
		}
		else if (!strcmp(argv[i], "-fast"))
		{
			printf ("fastvis = true\n");
			fastvis = true;
		}
		else if (!strcmp(argv[i], "-v"))
		{
			printf ("verbose = true\n");
			verbose = true;
		}
		else if (argv[i][0] == '-')
			Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i != argc - 1)
		Error ("usage: vis [-threads #] [-level 0-4] [-fast] [-v] bspfile");

	start = I_FloatTime ();
	
	ThreadSetDefault ();

	printf ("%i thread(s)\n", numthreads);

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

	LoadBSPFile (source);
	
	strcpy (portalfile, argv[i]);
	StripExtension (portalfile);
	strcat (portalfile, ".prt");
	
	LoadPortals (portalfile);
	
	uncompressed = malloc(bitbytes*portalleafs);
	memset (uncompressed, 0, bitbytes*portalleafs);

	CalcVis ();

	qprintf ("c_chains: %i\n",c_chains);
	
	visdatasize = vismap_p - dvisdata;	
	printf ("visdatasize:%i  compressed from %i\n", visdatasize, originalvismapsize);
	
	CalcAmbientSounds ();

	WriteBSPFile (source);	
	
//	unlink (portalfile);

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

	return 0;
}
示例#23
0
/*
========
main

light modelfile
========
*/
int main (int argc, char **argv)
{
	int		i;
	double		start, end;
	char		source[1024];

	printf("Light.exe Version 1.3 Id Software and valve (%s)\n", __DATE__ );
	printf ("----- LightFaces ----\n");

	// default to 24-bit light info
	hicolor = true;

	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i],"-threads"))
		{
			numthreads = atoi (argv[i+1]);
			i++;
		}
		else if (!strcmp(argv[i],"-extra"))
		{
			extrasamples = true;
			printf ("extra sampling enabled\n");
		}
		else if (!strcmp(argv[i],"-dist"))
		{
			scaledist = atof (argv[i+1]);
			i++;
		}
		else if (!strcmp(argv[i],"-range"))
		{
			rangescale = atof (argv[i+1]);
			i++;
		}
		else if (!strcmp(argv[i],"-lowcolor"))
		{
			hicolor = false;
		}
		else if (!strcmp( argv[ i ], "-noclamp" ) )
		{
			clamp192 = false;
		}
		else if (argv[i][0] == '-')
			Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i != argc - 1)
		Error ("usage: light [-threads num] [-extra] [-lowcolor] bspfile");

	ThreadSetDefault ();

	start = I_FloatTime ();

	strcpy (source, argv[i]);
	StripExtension (source);
	DefaultExtension (source, ".bsp");
	
	LoadBSPFile (source);
	LoadEntities ();
		
	MakeTnodes (&dmodels[0]);

	LightWorld ();

	WriteBSPFile (source);

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