use of org.pepsoft.worldpainter.heightMaps.TransformingHeightMap in project WorldPainter by Captain-Chaos.
the class ImportHeightMapOp method go.
@Override
public World2 go() throws ScriptException {
goCalled();
if (heightMap == null) {
throw new ScriptException("heightMap not set");
}
HeightMap adjustedHeightMap = heightMap;
if ((scale != 100) || (offsetX != 0) || (offsetY != 0)) {
heightMap.setSmoothScaling(true);
adjustedHeightMap = new TransformingHeightMap(heightMap.getName() + " transformed", heightMap, scale, scale, offsetX, offsetY, 0);
}
importer.setHeightMap(adjustedHeightMap);
importer.setImageFile(heightMap.getImageFile());
HeightMapTileFactory tileFactory = TileFactoryFactory.createNoiseTileFactory(new Random().nextLong(), Terrain.GRASS, DEFAULT_MAX_HEIGHT_2, 58, 62, false, true, 20, 1.0);
Theme defaults = Configuration.getInstance().getHeightMapDefaultTheme();
if (defaults != null) {
tileFactory.setTheme(defaults);
}
importer.setTileFactory(tileFactory);
String name = heightMap.getName();
int p = name.lastIndexOf('.');
if (p != -1) {
name = name.substring(0, p);
}
importer.setName(name);
try {
return importer.importToNewWorld(null);
} catch (ProgressReceiver.OperationCancelled e) {
// Can never happen since we don't pass a progress receiver in
throw new InternalError();
}
}
Aggregations