home *** CD-ROM | disk | FTP | other *** search
/ Freelog 34 / Freelog034.iso / Graphisme3D / City / CITY.MCR < prev    next >
Encoding:
Text File  |  1999-02-01  |  7.2 KB  |  127 lines

  1. /*************************************************************************
  2.       DEFAULT CITY GENERATOR MACRO FILE FOR PERSISTENCE OF VISION 3.x
  3. **************************************************************************
  4.  
  5. Created by Chris Colefax, 1 February 1999
  6. NOTE: This file is designed for use with City.inc; see City.htm for
  7.       more information
  8.  
  9. *************************************************************************/
  10.  
  11. // CHECK OPTIONS AND ASSIGN DEFAULTS
  12.    #ifndef (city_seed) #local city_seed = 0; #end
  13.    #declare _CT_rand1 = seed(city_seed); // For traffic
  14.    #declare _CT_rand2 = seed(city_seed); // For pavement objects
  15.    #declare _CT_rand3 = seed(city_seed); // For buildings
  16.    #declare _CT_rand4 = seed(city_seed); // For building levels
  17.  
  18.    #ifndef (building_width) #declare building_width = 25; #end
  19.    #ifndef (min_building_height) #declare min_building_height = building_width * .5; #end
  20.    #ifndef (max_building_height) #declare max_building_height = building_width * 2; #end
  21.    #ifndef (building_height_falloff) #declare building_height_falloff = 2; #end
  22.    #ifndef (building_height_turb) #declare building_height_turb = .5; #end
  23.  
  24.    #ifndef (pavement_height) #declare pavement_height = .15; #end
  25.    #ifndef (traffic_spacing) #declare traffic_spacing = 10; #end
  26.    #ifndef (traffic_lanes) #declare traffic_lanes = 1; #end
  27.    #ifndef (traffic_width) #declare traffic_width = 3; #end
  28.    #declare street_width = traffic_width*2*(traffic_lanes + .5);
  29.  
  30.    #ifndef (city_default_objects) #declare city_default_objects = true; #end
  31.    #ifndef (building_types) #declare building_types = 0; #end
  32.  
  33.    #if (city_default_objects) 
  34.       #include "DEFAULT.OBJ"
  35.       #if (traffic_spacing > 0) #include "VEHICLES.OBJ" #end
  36.       #include "HOTELS.OBJ" #include "FLATS.OBJ" #include "OFFICES.OBJ"
  37.    #end
  38.  
  39. // CITY CREATION MACROS
  40.    #macro city_base (Corner1, Corner2)
  41.       #declare _CT_extents = (abs(city_corner1.x) + abs(city_corner1.z)) / 2;
  42.       plane {y, 0 hollow
  43.          clipped_by {box {<Corner1.x, -.1, Corner1.z>, <Corner2.x, .1, Corner2.z>}}
  44.          texture {street_texture}}
  45.    #end
  46.  
  47.    #macro city_pavement (Corner1, Corner2)
  48.       box {Corner1, Corner2 + y*pavement_height texture {pavement_texture}}
  49.  
  50.       #ifdef (pavement_object) #local PSize = Corner2 - Corner1;
  51.       #local V = 0; #while (V < dimension_size(pavement_object, 1))
  52.          #local P = pavement_object_offset[V] + rand(_CT_rand2)*pavement_object_turb[V]; #while (P < PSize.x - pavement_object_offset[V])
  53.             object {pavement_object[V] rotate y*90 translate Corner1 + <P, pavement_height, 0>}
  54.             object {pavement_object[V] rotate y*270 translate Corner2 + <-P, pavement_height, 0>}
  55.          #if (pavement_object_spacing[V] <= 0) #local P = PSize.x; #else
  56.          #local P = P + pavement_object_spacing[V] + rand(_CT_rand2)*pavement_object_turb[V]; #end #end
  57.  
  58.          #local P = pavement_object_offset[V] + rand(_CT_rand2)*pavement_object_turb[V]; #while (P < PSize.z - pavement_object_offset[V])
  59.             object {pavement_object[V] translate <Corner2.x, pavement_height, Corner1.z + P>}
  60.             object {pavement_object[V] rotate y*180 translate <Corner1.x, pavement_height, Corner2.z - P>}
  61.          #if (pavement_object_spacing[V] <= 0) #local P = PSize.z; #else #local P = P + pavement_object_spacing[V]; #end #end
  62.       #local V = V + 1; #end #end
  63.    #end
  64.  
  65.    #macro city_traffic ()
  66.       #local V = dimension_size(city_vehicle, 1);
  67.       #if (Direction = 0) #local I = BlockSize.x; #else #local I = BlockSize.z; #end #local I = I + street_width;
  68.       #local L = -traffic_lanes; #while (L <= traffic_lanes)
  69.          #local VD = (L < 0 ? -1 : 1); #local VZ = From.z + traffic_width*VD*(abs(L)-.5);
  70.          #local VX = From.x + street_width + rand(_CT_rand1)*traffic_spacing; #while (VX < To.x - (city_tileable ? 0 : street_width))
  71.             #local VT = int(V*rand(_CT_rand1)); object {city_vehicle[VT] rotate y*90*VD translate <VX, 0, VZ> rotate -y*90*Direction}
  72.          #local VX = VX + city_vehicle_spacing[VT] + (1 + 2*rand(_CT_rand1))*traffic_spacing;
  73.          #if (mod(VX - From.x, I) < street_width) #local VX = VX + street_width; #end #end
  74.       #local L = L + (L = -1 ? 2 : 1); #end
  75.    #end
  76.  
  77.    #macro city_street (From, To, Direction)
  78.       #if (Direction != 0) #local From = vrotate(From, y*90*Direction); #local To = vrotate(To, y*90*Direction); #end
  79.  
  80.       #ifdef (street_overlay) box {From - <0, 0, street_width*.5>, To + <0, (Direction+1)*.001, street_width*.5>
  81.          texture {street_overlay scale traffic_width translate From}
  82.          rotate -y*90*Direction} #end
  83.  
  84.       #if (traffic_spacing > 0 & defined(city_vehicle)) city_traffic () #end
  85.    #end
  86.  
  87.    #macro city_building (Corner1, Corner2, Direction)
  88.       #if (building_types > 0 & defined(building_size))
  89.          #local BCentre = (Corner1 + Corner2)/2;
  90.          #local BHeight = pow(1.2 - (vlength(BCentre) / _CT_extents), building_height_falloff);
  91.          #local BHeight = BHeight + (rand(_CT_rand3) - .5)*building_height_turb;
  92.          #local BHeight = min_building_height + BHeight*(max_building_height - min_building_height);
  93.          #if (BHeight > 0) city_assemble_building (int(building_types*rand(_CT_rand3)), (Corner2-Corner1) + y*BHeight, -y*90*Direction, BCentre + y*pavement_height) #end
  94.       #end
  95.    #end
  96.  
  97.    #macro city_option (Option) (mod(building_options[Type], Option*2) >= Option ? true : false) #end
  98.    #macro city_assemble_building (Type, Size, Rotate, Translate)
  99.       #local Levels = ceil((Size.y / Size.x) / (building_size[Type].y / building_size[Type].x));
  100.       #local LHeight = y*building_size[Type];
  101.       #local Scale = Size/building_size[Type]; #local Scale = <Scale.x, (Scale.x+Scale.z)/2, Scale.z>;
  102.       #local CLevel = 0;
  103.  
  104.       union {
  105.          #if (city_option(build_profile)) object {building_profile[Type] scale <1, Levels, 1>} #end
  106.          #if (city_option(build_base)) object {building_base[Type]} #local CLevel = 1; #end
  107.          #if (city_option(build_details)) #while (CLevel < Levels)
  108.             object {building_details[Type] translate LHeight*CLevel}
  109.             #local CLevel = CLevel + 1; #end #end
  110.  
  111.          #if (city_option(build_window_profile)) object {building_windows[Type] scale <1, Levels, 1> texture {building_window_texture[Type]
  112.             translate <int(rand(_CT_rand4)*100)-50, int(rand(_CT_rand4)*100), int(rand(_CT_rand4)*100)-50>*building_window_size[Type]}} #end
  113.          #if (city_option(build_window_levels)) #local CLevel = 0; #while (CLevel < Levels)
  114.             object {building_windows[Type] texture {building_window_texture[Type]
  115.             translate <int(rand(_CT_rand4)*100)-50, int(rand(_CT_rand4)*100), int(rand(_CT_rand4)*100)-50>*building_window_size[Type]}
  116.             translate LHeight*CLevel}
  117.             #local CLevel = CLevel + 1; #end #end
  118.  
  119.          #if (city_option(build_roof)) object {building_roof[Type] translate LHeight*Levels}
  120.             #else sphere {0, 0 pigment {rgb 0}} #end
  121.  
  122.          #if (city_option(build_fit_texture)) texture {building_texture[Type]} #end
  123.          rotate Rotate  scale Scale  translate Translate
  124.          #if (city_option(build_texture)) texture {building_texture[Type] scale Scale} #end
  125.          }
  126.    #end
  127.