Ejemplo n.º 1
0
    def generate(self, seed, config, depth, region):
        R = Random(seed)

        length = R.generate(config.length)
        height = R.generate(config.height)
        num_roads = R.generate(config.num_roads)
        min_gap = config.min_gap_between_roads

        road_data, spaces = make_roads(length, height, config.road_width,
                                       num_roads, min_gap, R)

        road_models = []
        for origin, road_length, config.road_width, orientation in road_data:
            road = RoadModel(road_length, config.road_width, orientation)
            road_models.append((origin, road))
        #print 'sub-roads: ', len(road_models)

        layouts = []
        lgen = LayoutGenerator()

        for index, (origin, (llength, lheight)) in enumerate(spaces):
            lseed = make_seed(seed, index)
            lconfig = LayoutConfig()
            lconfig.length = llength
            lconfig.height = lheight
            layout = lgen.generate(lseed, lconfig, depth, region)
            x, y = origin
            origin = x, 0, -y
            layouts.append((origin, layout))

        sector = Model(length, height, road_models, layouts)
        return sector
Ejemplo n.º 2
0
    def generate(self, seed, config, depth, region):
        R = Random(seed)

        length = R.generate(config.length)
        height = R.generate(config.height)
        num_roads = R.generate(config.num_roads)
        min_gap = config.min_gap_between_roads

        road_data, spaces = make_roads(length, height, config.road_width,
                                       num_roads, min_gap, R)

        road_models = []
        for origin, road_length, road_width, orientation in road_data:
            road = RoadModel(road_length, road_width, orientation)
            road_models.append((origin, road))
        #print 'roads: ', len(road_models)

        sectors = []
        sgen = SectorGenerator()

        for index, (origin, (slength, sheight)) in enumerate(spaces):
            sseed = make_seed(seed, index)
            sconfig = SectorConfig()
            sconfig.length = slength
            sconfig.height = sheight
            sector = sgen.generate(sseed, sconfig, depth, region)
            x, y = origin
            origin = x, 0, -y
            sectors.append((origin, sector))

        city = Model(length, height, road_models, sectors)
        return city
Ejemplo n.º 3
0
    def generate(self, seed, config, depth, region):
        R = Random(seed)

        length = R.generate(config.length)
        height = R.generate(config.height)

        layout = Model(length, height)

        return layout
Ejemplo n.º 4
0
    def generate(self, seed, config, depth, region):
        R = Random(seed)
        radius = R.random(config.min_radius, config.max_radius)

        model = Model(radius)
        return model