// first try to load the root, otherwise generate it
String filename0 = "0.mxml";
File file0 = new File(outputDir + File.separator + filename0);
// ensure that there is a root node
MapTile mt0 = null;
if (file0.exists()) {
mt0 = new MapTile(outputDir, filename0, BufferedImage.TYPE_USHORT_GRAY);
mt0.setCoordinates(new Rect2D(new Point2D(0,0), new Point2D(1,1)));
}
else {
mt0 = new MapTile(BufferedImage.TYPE_USHORT_GRAY);
mt0.setCoordinates(new Rect2D(new Point2D(0,0), new Point2D(1,1)));
mt0.setFilename(filename0);
mt0.setDirectory(outputDir);
mt0.setPos(0);
if (maps.size() == 0) {
// if the user did not specify a heightfield and there is not already one on the disk, an empty one is created
mt0.setImg(new BufferedImage(Global.SOURCEWIDTH, Global.SOURCEHEIGHT, BufferedImage.TYPE_USHORT_GRAY));
mt0.write(outputDir);
}
}
// start with it and modify and write it
insertIntoMapNodes(maps, mt0, outputDir, 0, 1, false);