From 1625841c47f8ec3afcf5944c1cdcd7237115d00b Mon Sep 17 00:00:00 2001 From: "bre..ns" Date: Tue, 17 Jan 2012 19:51:16 +0000 Subject: [PATCH] fixed terrain scaling in navmesh generator git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9091 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../com/jme3/gde/nmgen/NavMeshGenerator.java | 4 +-- .../nmgen/wizard/NewNavMeshWizardAction.java | 25 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) 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;