Example #1
0
File: qbsp.c Project: 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;
}
Example #2
0
/*
========
Light_Main

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

	extrasamplesbit = 0;
	lightvis = true;
	relight = false;
	globallightscale = 1.0;
	globallightradiusscale = 1.0;
	minlight = 0;
	ambientlight = 0;
	defaultlighttype = LIGHTTYPE_MINUSX;
	overridelighttypes = false;

	for( i = 1; i < argc; i++ ) {
		if( !strcmp( argv[i],"-extra" ) ) {
			extrasamplesbit = 1;
			printf( "2x2 sampling enabled (tip: -extra4x4 is even higher quality)\n" );
		} else if( !strcmp( argv[i],"-extra4x4" ) ) {
			extrasamplesbit = 2;
			printf( "4x4 sampling enabled\n" );
		} else if( !strcmp( argv[i],"-extra8x8" ) ) {
			extrasamplesbit = 3;
			printf( "8x8 sampling enabled\n" );
		} else if( !strcmp( argv[i],"-nolightvis" ) ) {
			printf( "use of vis data to optimize lighting disabled\n" );
			lightvis = false;
		} else if( !strcmp( argv[i],"-relight" ) ) {
			if (ismcbsp)
				printf( "-relight is not valid with Martial Concert bsp format, ignoring\n" );
			else
			{
				printf( "relighting map to create .lit file without modifying .bsp\n" );
				relight = true;
			}
		} else if( !strcmp( argv[i],"-intensity" ) ) {
			i++;
			if( i >= argc )
				Error( "no value was given to -intensity\n" );
			globallightscale = atof( argv[i] );
			if( globallightscale < 0.01 )
				globallightscale = 0.01;
		} else if( !strcmp( argv[i],"-radiusscale" ) ) {
			i++;
			if( i >= argc )
				Error( "no value was given to -radiusscale\n" );
			globallightradiusscale = atof( argv[i] );
			if( globallightradiusscale < 0.01 )
				globallightradiusscale = 0.01;
		} else if( !strcmp( argv[i],"-minlight" ) ) {
			i++;
			if( i >= argc )
				Error( "no value was given to -minlight\n" );
			minlight = atof( argv[i] );
			if( minlight < 0 )
				minlight = 0;
		} else if( !strcmp( argv[i], "-ambientlight" ) ) {
			i++;
			if( i >= argc )
				Error( "no value was given to -ambientlight\n" );
			ambientlight = atof( argv[i] );
			if( ambientlight < 0 )
				ambientlight = 0;
		} else if( !strcmp( argv[i],"-defaulttype" ) ) {
			i++;
			if( i >= argc )
				Error( "no value was given to -defaulttype\n" );
			defaultlighttype = atoi( argv[i] );
			if( defaultlighttype < 0 || defaultlighttype >= LIGHTTYPE_TOTAL )
				Error( "invalid value given to -defaulttype\n" );
		} else if( !strcmp( argv[i],"-overridetypes" ) ) {
			printf( "overriding all light types with current default\n" );
			overridelighttypes = true;
		}
		else if( !strcmp( argv[i],"-harshshade" ) )
		{
			harshshade = 1;
			printf( "harsh shading enabled\n" );
		}
		else if( argv[i][0] == '-' )
			Error( "Unknown option \"%s\"", argv[i] );
		else
			break;
	}

	extrasamplesscale = 1.0f / (1 << (extrasamplesbit * 2));

	if( i != argc - 1 )
		Error( "%s",
"usage: hmap2 [-mc] -light [options] bspfile\n"
"Compiles lighting data in a .bsp and also makes .lit colored lighting data\n"
"\n"
"Quick usage notes for entities: (place these in key/value pairs)\n"
"wait - falloff rate: 1.0 default, 0.5 = double radius, 2 = half radius\n"
"_color - red green blue, specifies color of light, example 1 0.6 0.3 is orange\n"
"_lightradius - forces light to be this radius (useful with 1/ types)\n"
"delay - light type: (x = distance of surface from light, r = radius)\n"
"0: 1-(x/r)    fast, quake lighting, the default, tyrlite compatible\n"
"1: 1/(x)      slow, tyrlite compatible\n"
"2: 1/(x*x)    slow, realistic, tyrlite compatible\n"
"3: 1          fast, no fade, useful for sky lights, tyrlite compatible\n"
"4: sun        slow, directional sunlight, uses target direction like spotlights\n"
"5: 1-x/r*x/r  fast, looks like darkplaces/tenebrae lights\n"
"\n"
"-mc           uses \"Martial Concert\" format bsp\n"
"\n"
"What the options do:\n"
"-extra        antialiased lighting, takes much longer, higher quality\n"
"-extra4x4     antialiased lighting, even slower and better than -extra\n"
"-extra8x8     antialiased lighting, even slower and better than -extra4x4\n"
"-nolightvis   disables use of visibility data to optimize lighting\n"
"-relight      make a .lit file for an existing .bsp without modifying the .bsp\n"
"-harshshade   harsh shading rather than the normal soft shading\n"
"Options from here on are incompatible with darkplaces realtime lighting mode\n"
"(it does not know if these options are used, and will require manual rtlights\n"
" editing to look good)\n"
"-intensity    scales brightness of all lights\n"
"-radiusscale  scales size of all lights (including 1/ types)\n"
"-defaulttype <number> sets default light type by number, see delay above\n"
"-overridetypes forces all lights to use the -defaulttype setting\n"
"-minlight     raises darkest areas of the map to this light level (0-255)\n"
"-ambientlight raises all of the map by this light level (0-255)\n"
		);

	// init memory
	Q_InitMem ();

	printf( "----- LightFaces ----\n" );

//	InitThreads ();

	start = I_DoubleTime ();

	LoadBSPFile( filename_bsp );

	memset( dlightdata, 0, sizeof( dlightdata ) );
	memset( drgblightdata, 0, sizeof( drgblightdata ) );

	if( !visdatasize ) {
		printf( "no visibility data found (run -vis before -light to compile faster)\n" );
		lightvis = false;
	}

	ParseEntities ();
	printf( "%i entities read\n", num_entities );

	ParseLightEntities ();

	LightWorld ();

#ifdef WRITE_LIGHTSFILE
	WriteLights ();
#endif

	UnparseEntities ();

	WriteBSPFile( filename_bsp, relight );

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

	// print memory stats
	Q_PrintMem ();

#if _MSC_VER && _DEBUG
	printf( "press any key\n" );
	getchar();
#endif

	// free allocated memory
	Q_ShutdownMem ();

	return 0;
}
Example #3
0
File: vis.c Project: qbism/super8
/*
===========
Vis_Main
===========
*/
int Vis_Main( int argc, char **argv )
{
    int			i;
    double		start, end;

    printf ("---- vis ----\n");

    fastvis = false;
    verbose = false;
    rvis = true;
    noambientslime = true;
    noreuse = false;
    farplane = 0;

    if (ismcbsp)
        noambient = true;

    for (i=1 ; i<argc ; i++)
    {
        if (!strcmp(argv[i], "-norvis"))
        {
            rvis = false;
            printf ("rvis optimization disabled\n");
        }
        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], "-noreuse"))
        {
            printf ("vis rows reusage disabled\n");
            noreuse = true;
        }
        else if (!strcmp(argv[i], "-noambient"))
        {
            noambient = true;
            printf ("all ambient sounds disabled\n");
        }
        else if (!strcmp(argv[i], "-noambientwater"))
        {
            noambientwater = true;
            printf ("ambient water sounds disabled\n");
        }
        else if (!strcmp(argv[i], "-ambientslime"))
        {
            noambientslime = false;
            printf ("ambient slime sounds enabled\n");
        }
        else if (!strcmp(argv[i], "-noambientlava"))
        {
            noambientlava = true;
            printf ("ambient lava sounds disabled\n");
        }
        else if (!strcmp(argv[i], "-noambientsky"))
        {
            noambientsky = true;
            printf ("ambient sky sounds disabled\n");
        }
        else if (!strcmp(argv[i], "-farplane"))
        {
            farplane = atoi (argv[i+1]);
            printf ("farplane = %f\n", farplane);
            i++;
        }
        else if (argv[i][0] == '-')
            Error ("Unknown option \"%s\"", argv[i]);
        else
            break;
    }

    if (i != argc - 1)
    {
        Error ("%s",
               "usage: hmap2 -vis [options] bspfile\n"
               "Compiles visibility data in a .bsp, needs a .prt file\n"
               "\n"
               "What the options do:\n"
               "-level 0-4      quality, default 4\n"
               "-fast           fast but bad quality vis\n"
               "-v              verbose\n"
               "-norvis         disable rvis optimization, 0.001% better quality and 30% slower\n"
               "-ambientslime   do not convert slime channel to water (requires engine support)\n"
               "-noambient      disable ambient sounds (water bubbling, wind, etc)\n"
               "-noambientwater disable ambient water sounds (water)\n"
               "-noambientslime disable ambient slime sounds (water, or -ambientslime)\n"
               "-noambientlava  disable ambient lava sounds (unused by quake)\n"
               "-noambientsky   disable ambient sky sounds (wind)\n"
               "-noreuse        disable merging of identical vis data (less compression)\n"
               "-farplane       limit visible distance (warning: not a good idea without fog)\n"
              );
    }

    // init memory
    Q_InitMem ();

    start = I_DoubleTime ();

    LoadBSPFile (filename_bsp);
    LoadPortals (filename_prt);

    uncompressed = qmalloc(bitlongs*portalleafs*sizeof(long));
    memset (uncompressed, 0, bitlongs*portalleafs*sizeof(long));

//	CalcPassages ();

    CalcVis ();

    printf ("row size: %i\n",bitbytes);
    printf ("c_reused: %i\n",c_reused);
    printf ("c_chains: %i\n",c_chains);

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

    if (!noambient)
        CalcAmbientSounds ();

    WriteBSPFile (filename_bsp, false);

//	unlink (portalfile);

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

    // print memory stats
    Q_PrintMem ();

    // free allocated memory
    Q_ShutdownMem ();

    return 0;
}
Example #4
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;
}