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

  1. /*************************************************************************
  2.         CITY GENERATOR INCLUDE FILE FOR PERSISTENCE OF VISION 3.x
  3. **************************************************************************
  4.  
  5. Created by Chris Colefax, 1 February 1999
  6.  
  7. See City.htm for more information.
  8.  
  9. *************************************************************************/
  10.  
  11. // CHECK VERSION
  12.    #if (version < 3.1) #warning "The City Generator Include File requires POV-Ray 3.1 or later!\n\n" #else
  13.    #local _CT_version = version; #version 3.1;
  14.  
  15. // INCLUDE CITY MACROS/OBJECTS
  16.    #ifndef (debug_progress) #local debug_progress = false; #end
  17.    #if (debug_progress) #debug "CITY GENERATOR INCLUDE FILE:\n" #end
  18.    #ifdef (city_macro_file) #include city_macro_file
  19.       #if (debug_progress) #debug concat ("  Including \"", city_macro_file, "\"...\n") #end
  20.    #else #ifndef (city_base) #include "CITY.MCR"
  21.       #if (debug_progress) #debug concat ("  Including \"City.mcr\"...\n") #end
  22.    #end #end
  23.  
  24. // CHECK OPTIONS AND ASSIGN DEFAULTS
  25.    #macro _CT_get_dimensions(V1, V2)
  26.       #local Vec = <1, 1, 1> * V1;
  27.       #declare V2 = <max(1, Vec.x), 0, max(max(1, Vec.y), Vec.z)>;
  28.    #end
  29.  
  30.    #local BlockCount = <2, 0, 2>;
  31.    #ifdef (city_block_count) _CT_get_dimensions (city_block_count, BlockCount) #end
  32.  
  33.    #local BPB = <3, 0, 2>;
  34.    #ifdef (buildings_per_block) _CT_get_dimensions (buildings_per_block, BPB) #end
  35.  
  36.    #ifndef (street_width) #local street_width = 10; #end
  37.    #ifndef (pavement_width) #local pavement_width = 4; #end
  38.    #ifndef (building_width) #local building_width = 25; #end
  39.    #ifndef (building_gap) #local building_gap = 2; #end
  40.    #ifndef (city_tileable) #local city_tileable = false; #end
  41.  
  42. // CREATE UNION OF CITY BLOCKS
  43.    #macro VStr(V, C1, C2)
  44.       concat("<", str(V.x, C1, C2), ",", str(V.y, C1, C2), ",", str(V.z, C1, C2), ">")
  45.    #end
  46.  
  47.    #local BlockSize = building_width * BPB + building_gap * (BPB - <1, 0, 1>) + pavement_width * <2, 0, 2>;
  48.    #declare city_corner1 = (BlockCount * BlockSize + (BlockCount + <1, 0, 1>) * street_width) * <-.5, 0, -.5>;
  49.    #declare city_corner2 = -city_corner1;                                                                
  50.    #if (city_tileable) #declare city_corner2 = city_corner2 - street_width * <1, 0, 1>; #end
  51.  
  52.    union {
  53.       #if (debug_progress) #debug concat ("  Creating city base from ", VStr(city_corner1, 0, 2), " to ", VStr(city_corner2, 0, 2), "...\n") #end
  54.       city_base (city_corner1, city_corner2)
  55.    
  56. // CREATE CITY STREETS
  57.    #ifdef (city_street)
  58.    #if (debug_progress) #debug concat ("  Creating city streets...\n") #end
  59.    #local BlockZ = 0; #while (BlockZ < BlockCount.z + (city_tileable ? 0 : 1))
  60.       #local StreetStart = city_corner1 + z*(BlockZ*(BlockSize+street_width) + street_width/2);
  61.       city_street (StreetStart, StreetStart + x*(city_corner2-city_corner1), 0)
  62.    #local BlockZ = BlockZ + 1; #end
  63.  
  64.    #local BlockX = 0; #while (BlockX < BlockCount.x + (city_tileable ? 0 : 1))
  65.       #local StreetStart = city_corner1 + x*(BlockX*(BlockSize+street_width) + street_width/2);
  66.       city_street (StreetStart, StreetStart + z*(city_corner2-city_corner1), 1)
  67.    #local BlockX = BlockX + 1; #end
  68.    #end
  69.  
  70. // CREATE CITY BLOCKS
  71.    #local BlockX = 0; #while (BlockX < BlockCount.x)
  72.       #local BlockZ = 0; #while (BlockZ < BlockCount.z)
  73.          #local BlockCorner1 = city_corner1 + <BlockX, 0, BlockZ> * (BlockSize + street_width);
  74.          #local BlockCorner2 = BlockCorner1 + BlockSize + street_width * <1, 0, 1>;
  75.  
  76. // CREATE PAVEMENT FOR CURRENT BLOCK
  77.    #if (debug_progress) #debug concat ("  Creating city block ", str(BlockX * BlockCount.z + BlockZ + 1, 0, 0), " of ", str(BlockCount.x * BlockCount.z, 0, 0), "...\n") #end
  78.    #ifdef (city_pavement)
  79.       #if (debug_progress) #debug "    Creating pavement..." #end
  80.       city_pavement (BlockCorner1 + street_width * <1, 0, 1>, BlockCorner2)
  81.    #end
  82.  
  83. // CREATE BUILDINGS FOR CURRENT BLOCK
  84.    #ifdef (city_building)
  85.    #if (debug_progress) #debug "\r    Creating buildings...            " #end
  86.    #local FirstBuildingPos = BlockCorner1 + (street_width + pavement_width) * <1, 0, 1>;
  87.    #local CurPos = FirstBuildingPos;
  88.    #local BuildingX = 0; #while (BuildingX < BPB.x)
  89.       #local CurPos = CurPos * <1, 1, 0> + FirstBuildingPos * z;
  90.       #local BuildingZ = 0; #while (BuildingZ < BPB.z)
  91.          #local BuildingDir = 1; #if (BuildingZ = BPB.z - 1) #local BuildingDir = 2; #end
  92.          #if (BuildingX = 0) #local BuildingDir = 3; #end #if (BuildingZ = 0 & BuildingX < BPB.x - 1) #local BuildingDir = 0; #end
  93.          city_building (CurPos, CurPos + building_width * <1, 0, 1>, BuildingDir)
  94.          #local CurPos = CurPos + z * (building_width + building_gap);
  95.       #local BuildingZ = BuildingZ + 1; #end
  96.       #local CurPos = CurPos + x * (building_width + building_gap);
  97.    #local BuildingX = BuildingX + 1; #end
  98.    #if (debug_progress) #debug "\r" #end
  99.    #end
  100.  
  101. // LOOP THROUGH NEXT BLOCK
  102.       #local BlockZ = BlockZ + 1; #end
  103.    #local BlockX = BlockX + 1; #end
  104.  
  105.    #ifdef (city_finish) city_finish () #end
  106.    #ifdef (city_transform) transform city_transform #end }
  107.    #if (debug_progress) #debug "  Finished creating city!\n\n" #end
  108.  
  109.    #version _CT_version; #end
  110.