diff --git a/sdk/jme3-navmesh-gen/src/com/jme3/gde/nmgen/NavMeshGenerator.java b/sdk/jme3-navmesh-gen/src/com/jme3/gde/nmgen/NavMeshGenerator.java index d576c3f64..480d7777f 100644 --- a/sdk/jme3-navmesh-gen/src/com/jme3/gde/nmgen/NavMeshGenerator.java +++ b/sdk/jme3-navmesh-gen/src/com/jme3/gde/nmgen/NavMeshGenerator.java @@ -153,8 +153,8 @@ public class NavMeshGenerator implements Savable { Vector3f trans = ((Node) terr).getWorldTranslation().clone(); trans.x -= terr.getTerrainSize() / 2f; trans.z -= terr.getTerrainSize() / 2f; - float offsetX = trans.x * scale.x; - float offsetZ = trans.z * scale.z; + float offsetX = trans.x;// * scale.x; + float offsetZ = trans.z;// * scale.z; // do vertices int i = 0; diff --git a/sdk/jme3-navmesh-gen/src/com/jme3/gde/nmgen/wizard/NewNavMeshWizardAction.java b/sdk/jme3-navmesh-gen/src/com/jme3/gde/nmgen/wizard/NewNavMeshWizardAction.java index f11c4efa8..d48e04646 100644 --- a/sdk/jme3-navmesh-gen/src/com/jme3/gde/nmgen/wizard/NewNavMeshWizardAction.java +++ b/sdk/jme3-navmesh-gen/src/com/jme3/gde/nmgen/wizard/NewNavMeshWizardAction.java @@ -10,6 +10,7 @@ import com.jme3.gde.core.sceneexplorer.nodes.actions.NewSpatialAction; import com.jme3.gde.nmgen.NavMeshGenerator; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; +import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.Mesh; import com.jme3.scene.Node; @@ -77,7 +78,7 @@ public final class NewNavMeshWizardAction extends AbstractNewSpatialWizardAction Mesh mesh = new Mesh(); - GeometryBatchFactory.mergeGeometries(findGeometries(rootNode, new LinkedList(), generator), mesh); + GeometryBatchFactory.mergeGeometries(findGeometries(rootNode, new LinkedList(), generator, rootNode), mesh); Mesh optiMesh = generator.optimize(mesh); if(optiMesh == null) return null; @@ -95,20 +96,24 @@ public final class NewNavMeshWizardAction extends AbstractNewSpatialWizardAction return navMesh; } - private List findGeometries(Node node, List geoms, NavMeshGenerator generator) { + private List findGeometries(Node node, List geoms, NavMeshGenerator generator, Node originalRoot) { + if (node instanceof Terrain) { + Terrain terr = (Terrain)node; + Mesh merged = generator.terrain2mesh(terr); + Geometry g = new Geometry("mergedTerrain"); + g.setMesh(merged); + if (node != originalRoot) + g.setLocalScale(((Node)terr).getLocalScale()); + geoms.add(g); + return geoms; + } + for (Iterator it = node.getChildren().iterator(); it.hasNext();) { Spatial spatial = it.next(); if (spatial instanceof Geometry) { geoms.add((Geometry) spatial); } else if (spatial instanceof Node) { - if (spatial instanceof Terrain) { - Mesh merged = generator.terrain2mesh((Terrain) spatial); - Geometry g = new Geometry("mergedTerrain"); - g.setMesh(merged); - geoms.add(g); - } else { - findGeometries((Node) spatial, geoms, generator); - } + findGeometries((Node) spatial, geoms, generator, originalRoot); } } return geoms;