Пример #1
0
void CmdLib_InitCommandLine( int argc, char **argv )
{
	MathLib_Init( 1,1,1,0,false,true,true,true);
	CommandLine()->CreateCmdLine( argc, argv );
	CmdLib_InitFileSystem( argv[ 0 ] );
	InstallProgressReportHandler( PrintFReportHandler );

}
Пример #2
0
void main( int argc, char **argv )
{
	CommandLine()->CreateCmdLine( argc, argv );
	if( CommandLine()->ParmCount()!=2 )
	{
		printf( "usage : sptconvert <SPT file name>\n" );
		exit(0);
	}

	MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f, false, false, false, false );

	CmdLib_InitFileSystem( CommandLine()->GetParm(1) );

	CSpeedTreeRT speedTree;

	char treeName[MAX_PATH];
	_splitpath( argv[1], NULL, NULL, treeName, NULL );

	char smdFileName[MAX_PATH];
	sprintf( smdFileName, "%s.smd", treeName );

	char qcFileName[MAX_PATH];
	sprintf( qcFileName, "%s.qc", treeName );

	OutputQCFile( treeName );

	if( speedTree.LoadTree( argv[1] ) )
	{
		if( speedTree.Compute( NULL, 1, false ) )
		{
			CSpeedTreeRT::SGeometry sGeom;
			speedTree.GetGeometry( sGeom, SpeedTree_AllGeometry );

			OutputTreeGeometry( speedTree, sGeom, smdFileName );
		}
		else
		{
			// Trouble with compute
		}
	}
	else
	{
		// Trouble with load
	}
}
Пример #3
0
void InitFilesystem( const char *pPath )
{
	CmdLib_InitFileSystem( pPath );
	// This bit of hackery allows us to access files on the harddrive
	g_pFullFileSystem->AddSearchPath( "", "LOCAL", PATH_ADD_TO_HEAD ); 
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : argc - 
//			argv[] - 
// Output : int
//-----------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
	SpewOutputFunc( SpewFunc );
	SpewActivate( "unusedcontent", 2 );

	CommandLine()->CreateCmdLine( argc, argv );

	int i=1;
	for ( i ; i<argc ; i++)
	{
		if ( argv[ i ][ 0 ] == '-' )
		{
			switch( argv[ i ][ 1 ] )
			{
			case 'l':
				uselogfile = true;
				break;
			case 'v':
				verbose = true;
				break;
			case 'r':
				showreferencedfiles = true;
				break;
			case 'd':
				spewdeletions = true;
				break;
			case 'i':
				immediatedelete = true;
				break;
			case 'w':
				printwhitelist = true;
				break;
			case 'm':
				showmapfileusage = true;
				break;
			case 'g':
				// Just skip -game
				Assert( !Q_stricmp( argv[ i ], "-game" ) );
				++i;
				break;
			case 'f':
				// grab reslists folder
				{
					++i;
					Q_strncpy( g_szReslistDir, argv[ i ], sizeof( g_szReslistDir ) );
					Q_strlower( g_szReslistDir );
					Q_FixSlashes( g_szReslistDir );
					Q_AppendSlash( g_szReslistDir, sizeof( g_szReslistDir ) );
					
				}
				break;
			default:
				printusage();
				break;
			}
		}
	}

	if ( argc < 3 || ( i != argc ) )
	{
		PrintHeader();
		printusage();
		return 0;
	}

	CheckLogFile();

	PrintHeader();

	vprint( 0, "    Using reslist dir '%s'\n", g_szReslistDir );

	vprint( 0, "    Looking for extraneous content...\n" );

	char resfile[ 256 ];
	strcpy( resfile, argv[ i - 1 ] );

	vprint( 0, "    Comparing results of resfile (%s) with files under current directory...\n",	resfile );

	char workingdir[ 256 ];
	workingdir[0] = 0;
	Q_getwd( workingdir, sizeof( workingdir ) );

	// If they didn't specify -game on the command line, use VPROJECT.
	CmdLib_InitFileSystem( workingdir );

	filesystem = (IFileSystem *)(CmdLib_GetFileSystemFactory()( FILESYSTEM_INTERFACE_VERSION, NULL ));
	if ( !filesystem )
	{
		AssertMsg( 0, "Failed to create/get IFileSystem" );
		return 1;
	}

	g_pFullFileSystem->RemoveAllSearchPaths();
	g_pFullFileSystem->AddSearchPath(gamedir, "GAME");

	Q_strlower( gamedir );
	Q_FixSlashes( gamedir );

	//
	//ProcessMaterialsDirectory( vmtdir );

	// find out the mod dir name
	Q_strncpy( modname, gamedir, sizeof(modname) );
	modname[ strlen(modname) - 1] = 0;

	if ( strrchr( modname,  '\\' ) )
	{
		Q_strncpy( modname, strrchr( modname, '\\' ) + 1, sizeof(modname) );
	}
	else
	{
		Q_strncpy( modname, "", sizeof(modname) );
	}
	vprint( 1, "Mod Name:%s\n", modname);


	BuildCheckdirList();
	BuildWhiteList();

	vprint( 0, "Building aggregate file list from resfile output\n" );
	CUtlRBTree< ReferencedFile, int > referencedfiles( 0, 0, RefFileLessFunc );
	CUtlVector< UnusedContent::CUtlSymbol >	resfiles;

	BuildReferencedFileList( resfiles, referencedfiles, resfile );

	vprint( 0, "found %i files\n\n", referencedfiles.Count() );

	vprint( 0, "Building list of all game content files\n" );
	CUtlVector< FileEntry > contentfiles;
	CUtlVector< FileEntry > otherfiles;
	BuildFileList( 0, contentfiles, &otherfiles, "", 0 );
	vprint( 0, "found %i files in content tree\n\n", contentfiles.Count() );

	Correlate( referencedfiles, contentfiles, modname );

	// now output the files not referenced in the whitelist or general reslists
	filesystem->RemoveFile( CFmtStr( "%sunreferenced_files.lst", g_szReslistDir ), "GAME" );
	int c = otherfiles.Count();
	for ( i = 0; i < c; ++i )
	{
		FileEntry & entry = otherfiles[ i ];
		char const *name = g_Analysis.symbols.String( entry.sym );

		logprint( CFmtStr( "%sunreferenced_files.lst", g_szReslistDir ), "\"%s\\%s\"\n", modname, name );
	}

	// also include the files from deletions.bat, as we don't actually run that now
	c = contentfiles.Count();
	for ( i = 0; i < c; ++i )
	{
		FileEntry & entry = contentfiles[ i ];
		if ( entry.referenced != REFERENCED_NO )
			continue;

		char const *fn = g_Analysis.symbols.String( entry.sym );
		logprint( CFmtStr( "%sunreferenced_files.lst", g_szReslistDir ), "\"%s\\%s\"\n", modname, fn );
	}

	FileSystem_Term();

	return 0;
}
Пример #5
0
main (int argc, char *argv[])
{
	int i;
	CommandLine()->CreateCmdLine( argc, argv );
	SpewOutputFunc( HLFacePoserSpewFunc );
	MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f );
	CoInitialize(NULL);

	// make sure, we start in the right directory
	char szName[256];
	strcpy (szName, mx::getApplicationPath() );

	mx::init (argc, argv);

	sound->Init();

	FileSystem_Init( true );
	filesystem = (IFileSystem *)(FileSystem_GetFactory()( FILESYSTEM_INTERFACE_VERSION, NULL ));
	if ( !filesystem )
	{
		AssertMsg( 0, "Failed to create/get IFileSystem" );
		return 1;
	}

	char workingdir[ 256 ];
	workingdir[0] = 0;
	Q_getwd( workingdir );

	// If they didn't specify -game on the command line, use VPROJECT.
	CmdLib_InitFileSystem( workingdir, true );

	IFacePoserToolWindow::EnableToolRedraw( false );

	new MDLViewer ();

	g_MDLViewer->setMenuBar (g_MDLViewer->getMenuBar ());
	
	g_pStudioModel->Init();

	bool modelloaded = false;
	for ( i = 1; i < CommandLine()->ParmCount(); i++ )
	{
		if ( Q_stristr (CommandLine()->GetParm( i ), ".mdl") )
		{
			modelloaded = true;
			g_MDLViewer->LoadModelFile( CommandLine()->GetParm( i ) );
			break;
		}
	}

	models->LoadModelList();

	if ( models->Count() == 0 )
	{
		g_pFlexPanel->initFlexes( );
	}

	// Load expressions from last time
	int files = workspacefiles->GetNumStoredFiles( IWorkspaceFiles::EXPRESSION );
	for ( i = 0; i < files; i++ )
	{
		expressions->LoadClass( workspacefiles->GetStoredFile( IWorkspaceFiles::EXPRESSION, i ) );
	}

	IFacePoserToolWindow::EnableToolRedraw( true );

	int retval = mx::run();

	soundemitter->BaseShutdown();

	if (g_pStudioModel)
	{
		g_pStudioModel->Shutdown();
		g_pStudioModel = NULL;
	}

	if (g_pMaterialSystem)
	{
		g_pMaterialSystem->Shutdown();
		g_pMaterialSystem = NULL;
	}

	FileSystem_Term();

	CoUninitialize();

	return retval;
}
Пример #6
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;
}
Пример #7
0
int main(int argc, char* argv[])
{
    SpewOutputFunc( SceneManagerSpewFunc );

    //
    // make sure, we start in the right directory
    //
    char szName[256];

    strcpy (szName, mx::getApplicationPath ());

    if (argc > 1)
    {
        strcpy (cmdline, argv[1]);
        for (int i = 2; i < argc; i++)
        {
            strcat (cmdline, " ");
            strcat (cmdline, argv[i]);
        }
    }

    mx::init (argc, argv);

    FileSystem_Init( true );
    filesystem = (IFileSystem *)(FileSystem_GetFactory()( FILESYSTEM_INTERFACE_VERSION, NULL ));
    if ( !filesystem )
    {
        AssertMsg( 0, "Failed to create/get IFileSystem" );
        return 1;
    }

    char workingdir[ 256 ];
    workingdir[0] = 0;
    Q_getwd( workingdir );

    char *vproject = getenv("VPROJECT");
    if ( !vproject )
    {
        mxMessageBox( NULL, "You must set VPROJECT to run scenemanager.exe", "SceneManager", MB_OK );
        return -1;
    }

    // If they didn't specify -game on the command line, use VPROJECT.
    CmdLib_InitFileSystem( workingdir, true );

    sound->Init();

    CWorkspaceManager *sm = new CWorkspaceManager();

    bool workspace_loaded = false;
    for ( int i = 1; i < argc; i++ )
    {
        if ( !workspace_loaded && strstr (argv[i], ".vsw") )
        {
            workspace_loaded = true;

            // Strip game directory and slash
            char workspace_name[ 512 ];
            filesystem->FullPathToRelativePath( argv[ i ], workspace_name );

            sm->AutoLoad( workspace_name );
        }
    }

    if ( !workspace_loaded )
    {
        sm->AutoLoad( NULL );
    }

    int retval = mx::run ();

    sound->Shutdown();

    soundemitter->BaseShutdown();

    FileSystem_Term();

    return retval;
}
Пример #8
0
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;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input  : argc -
//			argv[] -
// Output : int
//-----------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
    SpewOutputFunc( SpewFunc );
    SpewActivate( "vcd_sound_check", 2 );

    int i=1;
    for ( i ; i<argc ; i++)
    {
        if ( argv[ i ][ 0 ] == '-' )
        {
            switch( argv[ i ][ 1 ] )
            {
            case 'l':
                uselogfile = true;
                break;
            case 'v':
                verbose = true;
                break;
            case 'm':
                spewmoveto = true;
                break;
            case 'o':
                vcdonly = true;
                break;
            default:
                printusage();
                break;
            }
        }
    }

    if ( argc < 3 || ( i != argc ) )
    {
        PrintHeader();
        printusage();
    }

    CheckLogFile();

    PrintHeader();

    vprint( 0, "    Looking for .wav files not referenced in .vcd files...\n" );

    char sounddir[ 256 ];
    char vcddir[ 256 ];
    strcpy( sounddir, argv[ i - 2 ] );
    strcpy( vcddir, argv[ i - 1 ] );
    if ( !strstr( sounddir, "sound" ) )
    {
        vprint( 0, "Sound dir %s looks invalid (format:  u:/tf2/hl2/sound/vo)\n", sounddir );
        return 0;
    }
    if ( !strstr( vcddir, "scenes" ) )
    {
        vprint( 0, ".vcd dir %s looks invalid (format:  u:/tf2/hl2/scenes)\n", vcddir );
        return 0;
    }

    char workingdir[ 256 ];
    workingdir[0] = 0;
    Q_getwd( workingdir, sizeof( workingdir ) );

    // If they didn't specify -game on the command line, use VPROJECT.
    CmdLib_InitFileSystem( workingdir );

    CSysModule *pSoundEmitterModule = g_pFullFileSystem->LoadModule( "soundemittersystem.dll" );
    if ( !pSoundEmitterModule )
    {
        vprint( 0, "Sys_LoadModule( soundemittersystem.dll ) failed!\n" );
        return 0;
    }

    CreateInterfaceFn hSoundEmitterFactory = Sys_GetFactory( pSoundEmitterModule );
    if ( !hSoundEmitterFactory )
    {
        vprint( 0, "Sys_GetFactory on soundemittersystem.dll failed!\n" );
        return 0;
    }

    soundemitter = ( ISoundEmitterSystemBase * )hSoundEmitterFactory( SOUNDEMITTERSYSTEM_INTERFACE_VERSION, NULL );
    if ( !soundemitter )
    {
        vprint( 0, "Couldn't get interface %s from soundemittersystem.dll!\n", SOUNDEMITTERSYSTEM_INTERFACE_VERSION );
        return 0;
    }

    filesystem = (IFileSystem *)(CmdLib_GetFileSystemFactory()( FILESYSTEM_INTERFACE_VERSION, NULL ));
    if ( !filesystem )
    {
        AssertMsg( 0, "Failed to create/get IFileSystem" );
        return 1;
    }

    Q_FixSlashes( gamedir );
    Q_strlower( gamedir );

    vprint( 0, "game dir %s\nsounds dir %s\nvcd dir %s\n\n",
            gamedir,
            sounddir,
            vcddir );

    Q_StripTrailingSlash( sounddir );
    Q_StripTrailingSlash( vcddir );


    filesystem->RemoveFile( "moveto.txt", "GAME" );
    //
    //ProcessMaterialsDirectory( vmtdir );

    vprint( 0, "Initializing sound emitter system\n" );
    soundemitter->Connect( FileSystem_GetFactory() );
    soundemitter->Init();

    vprint( 0, "Loaded %i sounds\n", soundemitter->GetSoundCount() );

    vprint( 0, "Building list of .vcd files\n" );
    CUtlVector< CUtlSymbol > vcdfiles;
    BuildFileList( vcdfiles, vcddir, ".vcd" );
    vprint( 0, "found %i .vcd files\n\n", vcdfiles.Count() );

    vprint( 0, "Building list of known .wav files\n" );
    CUtlVector< CUtlSymbol > wavfiles;
    BuildFileList( wavfiles, sounddir, ".wav" );
    vprint( 0, "found %i .wav files\n\n", wavfiles.Count() );

    CorrelateWavsAndVCDs( vcdfiles, wavfiles );

    soundemitter->Shutdown();
    soundemitter = 0;
    g_pFullFileSystem->UnloadModule( pSoundEmitterModule );

    FileSystem_Term();

    return 0;
}