Пример #1
0
def main():
    # read settings from cfg files to avoid having to modify vode.
    # set the directory to the path of the script to allow running it from any place
    abspath = os.path.abspath(__file__)
    dname = os.path.dirname(abspath)
    os.chdir(dname)

    def toInt(l):
        for x in l:
            try:
                yield int(x)
            except ValueError:
                yield x

    with open(sys.argv[1], 'r') as f:
        tmpList = f.read().split()
        config = list(
            toInt([tmpList[3 * i + 2] for i in range(len(tmpList) / 3)]))
        if config[0] == 'gridGenerator':
            print("Using Grid Generator")
            generator = gridGenerator(config[1], config[2], config[3],
                                      config[4], config[5], config[6],
                                      config[7])
            city = cityLayout(generator.getBuildingList(), config[5], True)
        elif config[0] == 'cityLoader':
            print("Loading data from " + config[1] + "...")
            cityLoader = cityIO()
            cityLoader.read(config[1])
            city = cityLayout(cityLoader.getBuildingList(), config[2])
        elif config[0] == 'randomPlacement':
            print("Using Random Generator")
            generator = randomPlacement(config[1], config[2], config[3],
                                        config[4], config[5], config[6],
                                        config[7])
            city = cityLayout(generator.getBuildingList(), config[5])
        elif config[0] == 'voronoi':
            print("Using Voronoi Generator")
            generator = voronoi(config[1], config[2], config[3], config[4],
                                config[5], config[6], config[7])
            city = cityLayout(generator.getBuildingList(), config[5])
        else:
            print("Error: generator type " + config[0] + " is not defined")
        f.close()

    print("Generating...")
    city.makeCity()
    print("Done")
def main():
    # read settings from cfg files to avoid having to modify vode.
    # set the directory to the path of the script to allow running it from any place
    abspath = os.path.abspath(__file__)
    dname = os.path.dirname(abspath)
    os.chdir(dname)

    def toInt(l):
        for x in l:
            try:
                yield int(x)
            except ValueError:
                yield x

    with open(sys.argv[1], 'r') as f:
        tmpList = f.read().split()
        config = list(toInt([tmpList[3*i+2] for i in range(len(tmpList)/3)]))
        if config[0] == 'gridGenerator':
            print("Using Grid Generator")
            generator = gridGenerator(config[1], config[2], config[3], config[4], config[5], config[6], config[7])
            city = cityLayout(generator.getBuildingList(), config[5], True)
        elif config[0] == 'cityLoader':
            print("Loading data from " + config[1] + "...")
            cityLoader = cityIO()
            cityLoader.read(config[1])
            city = cityLayout(cityLoader.getBuildingList(), config[2])
        elif config[0] == 'randomPlacement':
            print("Using Random Generator")
            generator = randomPlacement(config[1], config[2], config[3], config[4], config[5], config[6], config[7])
            city = cityLayout(generator.getBuildingList(), config[5])
        elif config[0] == 'voronoi':
            print("Using Voronoi Generator")
            generator = voronoi(config[1], config[2], config[3], config[4], config[5], config[6], config[7])
            city = cityLayout(generator.getBuildingList(), config[5])
        else:
            print("Error: generator type " + config[0] + " is not defined")
        f.close()

    print("Generating...")
    city.makeCity()
    print("Done")
Пример #3
0
def main():
    #set the directory to the path of the script to allow running it from any place
    abspath = os.path.abspath(__file__)
    dname = os.path.dirname(abspath)
    os.chdir(dname)

    #functions that convert int into ints and leaves other unchanged
    def toInt(l):
        for x in l:
            try:
                yield int(x)
            except ValueError:
                yield x

    print(sys.argv)
    with open(sys.argv[1], 'r') as f:
        tmpList = f.read().split()
        config = list(
            toInt([tmpList[3 * i + 2] for i in range(len(tmpList) / 3)]))
        if config[0] == 'gridGenerator':
            print("Using Grid Generator")
            generator = gridGenerator(config[1], config[2], config[3],
                                      config[4],
                                      config[5])  #(1, 1, "scene/testScene")
            city = cityIO()
            city.loadList(generator.getBuildingList())
            print("Writing to City File...")
            city.write(config[5] + '.cty')
            print("Done")
        elif config[0] == 'voronoi':
            print("Next Level Troll")
            generator = voronoi(config[1], config[2], config[3], config[4],
                                config[5], config[6], config[7])
            city = cityIO()
            city.loadList(generator.getBuildingList())
            print("Writing to City File...")
            city.write(config[5] + '.cty')
            print("Done")
        else:
            print("Error: generator type " + config[0] + " is not defined")
        f.close()
def main():
    #set the directory to the path of the script to allow running it from any place
    abspath = os.path.abspath(__file__)
    dname = os.path.dirname(abspath)
    os.chdir(dname)
    
    #functions that convert int into ints and leaves other unchanged
    def toInt(l):
        for x in l:
            try:
                yield int(x)
            except ValueError:
                yield x

    print(sys.argv)
    with open(sys.argv[1], 'r') as f:
        tmpList = f.read().split()
        config = list(toInt([tmpList[3*i+2] for i in range(len(tmpList)/3)]))
        if config[0] == 'gridGenerator':
            print("Using Grid Generator")
            generator = gridGenerator(config[1], config[2], config[3], config[4], config[5]) #(1, 1, "scene/testScene")
            city = cityIO()
            city.loadList(generator.getBuildingList())
            print("Writing to City File...")
            city.write(config[5]+'.cty')
            print("Done")
        elif config[0] == 'voronoi':
            print("Next Level Troll")
            generator = voronoi(config[1], config[2], config[3], config[4], config[5], config[6], config[7])
            city = cityIO()
            city.loadList(generator.getBuildingList())
            print("Writing to City File...")
            city.write(config[5]+'.cty')
            print("Done")
        else:
            print("Error: generator type " + config[0] + " is not defined")
        f.close()