|
@@ -106,6 +106,7 @@ class Terrain extends Object3D {
|
|
|
|
|
|
public function saveHeightTextures( ctx : Context ) {
|
|
public function saveHeightTextures( ctx : Context ) {
|
|
for( tile in terrain.tiles ) {
|
|
for( tile in terrain.tiles ) {
|
|
|
|
+ if( tile.tileX == null || tile.tileY == null ) continue;
|
|
var pixels = tile.heightMap.capturePixels();
|
|
var pixels = tile.heightMap.capturePixels();
|
|
var fileName = tile.tileX + "_" + tile.tileY + "_" + "h";
|
|
var fileName = tile.tileX + "_" + tile.tileY + "_" + "h";
|
|
ctx.shared.savePrefabDat(fileName, "heightMap", name, pixels.bytes);
|
|
ctx.shared.savePrefabDat(fileName, "heightMap", name, pixels.bytes);
|
|
@@ -115,6 +116,7 @@ class Terrain extends Object3D {
|
|
public function saveWeightTextures( ctx : Context ) {
|
|
public function saveWeightTextures( ctx : Context ) {
|
|
var packedWeightsTex = new h3d.mat.Texture(terrain.weightMapResolution, terrain.weightMapResolution, [Target], RGBA);
|
|
var packedWeightsTex = new h3d.mat.Texture(terrain.weightMapResolution, terrain.weightMapResolution, [Target], RGBA);
|
|
for( tile in terrain.tiles ) {
|
|
for( tile in terrain.tiles ) {
|
|
|
|
+ if( tile.tileX == null || tile.tileY == null ) continue;
|
|
h3d.Engine.getCurrent().pushTarget(packedWeightsTex);
|
|
h3d.Engine.getCurrent().pushTarget(packedWeightsTex);
|
|
packWeight.shader.indexMap = tile.surfaceIndexMap;
|
|
packWeight.shader.indexMap = tile.surfaceIndexMap;
|
|
packWeight.shader.weightTextures = tile.surfaceWeightArray;
|
|
packWeight.shader.weightTextures = tile.surfaceWeightArray;
|
|
@@ -137,12 +139,17 @@ class Terrain extends Object3D {
|
|
var resDir = ctx.shared.loadDir(name);
|
|
var resDir = ctx.shared.loadDir(name);
|
|
if( resDir == null ) return;
|
|
if( resDir == null ) return;
|
|
for( res in resDir ) {
|
|
for( res in resDir ) {
|
|
- var file = res.name.split(".")[0];
|
|
|
|
|
|
+ var fileInfos = res.name.split(".");
|
|
|
|
+ var ext = fileInfos[1];
|
|
|
|
+ var file = fileInfos[0];
|
|
|
|
+ if( ext == "bin" ) return;
|
|
var coords = file.split("_");
|
|
var coords = file.split("_");
|
|
var x = Std.parseInt(coords[0]);
|
|
var x = Std.parseInt(coords[0]);
|
|
var y = Std.parseInt(coords[1]);
|
|
var y = Std.parseInt(coords[1]);
|
|
|
|
+ if( x == null || y == null ) continue;
|
|
var type = coords[2];
|
|
var type = coords[2];
|
|
var tile = terrain.createTile(x, y);
|
|
var tile = terrain.createTile(x, y);
|
|
|
|
+
|
|
switch( type ) {
|
|
switch( type ) {
|
|
case "h":
|
|
case "h":
|
|
if( height ) {
|
|
if( height ) {
|