// Pattern generation. void GeneratePattern(galaxyData_t *galaxy) { // Vars int pattern = 0; int initial = TRUE; outputMapping_e currentOutputMap = MAP_FULL; long int timer = 0; #ifdef EMULATE unsigned char pause = FALSE; #endif /* EMULATE */ // Set the initial pixel state to all black. ColorAll(galaxy, PIXEL_BLACK); // Run the pattern loop. FOREVER { #ifdef EMULATE // Handle keyboard and window events. switch(HandleEvents()) { case DOEXIT: return; // Return to the main function for exit. case DONEXTPATTERN: // Pick a new pattern. pattern = rand() % PATTERN_COUNT; initial = TRUE; timer = 0; // printf("Pattern: %i\n", pattern); break; case DOPAUSE: pause = pause ? FALSE : TRUE; WindowTitle(pause ? 1000000 : delayMultiplier); // Kludge break; case DONOTHING: default: break; } // Write to the emulator output. UpdateEmuOutput(galaxy, currentOutputMap); // If paused, restart (continue) the FOREVER loop without further processing. if (pause) continue; #else /* EMULATE */ // Write to the serial port. WriteLights(galaxy, currentOutputMap); #endif /* EMULATE */ // Run the selected pattern from the patternFunctions array. patternList[pattern].patternFunction(galaxy, initial, ¤tOutputMap); // Set for the first pass when a new pattern is chosen, but can be unset now. initial = FALSE; // Have we run the pattern long enough? timer++; if (timer >= patternList[pattern].iterations) { // Timer expired. Choose a new pattern and set the initial flag. pattern = rand() % PATTERN_COUNT; initial = TRUE; timer = 0; } } // End of FOREVER Loop } // End GeneratePattern()
/* ======== 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; }