- add progress indicators for navmesh and terrain entropy generation

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9084 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent 68901f6bc4
commit 445cbdc09c
  1. 42
      sdk/jme3-navmesh-gen/src/com/jme3/gde/nmgen/wizard/NewNavMeshWizardAction.java
  2. 16
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/GenerateTerrainEntropiesAction.java

@ -25,6 +25,8 @@ import java.util.List;
import javax.swing.JComponent;
import jme3tools.optimize.GeometryBatchFactory;
import org.critterai.nmgen.IntermediateData;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.DialogDisplayer;
import org.openide.WizardDescriptor;
@ -61,28 +63,34 @@ public final class NewNavMeshWizardAction extends AbstractNewSpatialWizardAction
if (configuration == null) {
return null;
}
//TODO: maybe offload to other thread..
WizardDescriptor wizardDescriptor = (WizardDescriptor) configuration;
ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Generating NavMesh");
progressHandle.start();
final Geometry navMesh = new Geometry("NavMesh");
try {
//TODO: maybe offload to other thread..
WizardDescriptor wizardDescriptor = (WizardDescriptor) configuration;
NavMeshGenerator generator = (NavMeshGenerator) wizardDescriptor.getProperty("generator");
IntermediateData id = new IntermediateData();
NavMeshGenerator generator = (NavMeshGenerator) wizardDescriptor.getProperty("generator");
IntermediateData id = new IntermediateData();
generator.setIntermediateData(null);
generator.setIntermediateData(null);
Mesh mesh = new Mesh();
Mesh mesh = new Mesh();
GeometryBatchFactory.mergeGeometries(findGeometries(rootNode, new LinkedList<Geometry>(), generator), mesh);
Mesh optiMesh = generator.optimize(mesh);
if(optiMesh == null) return null;
GeometryBatchFactory.mergeGeometries(findGeometries(rootNode, new LinkedList<Geometry>(), generator), mesh);
Mesh optiMesh = generator.optimize(mesh);
if(optiMesh == null) return null;
final Geometry navMesh = new Geometry("NavMesh");
Material material = new Material(pm, "Common/MatDefs/Misc/Unshaded.j3md");
material.getAdditionalRenderState().setWireframe(true);
material.setColor("Color", ColorRGBA.Green);
navMesh.setMaterial(material);
navMesh.setMesh(optiMesh);
navMesh.setCullHint(CullHint.Always);
navMesh.setModelBound(new BoundingBox());
Material material = new Material(pm, "Common/MatDefs/Misc/Unshaded.j3md");
material.getAdditionalRenderState().setWireframe(true);
material.setColor("Color", ColorRGBA.Green);
navMesh.setMaterial(material);
navMesh.setMesh(optiMesh);
navMesh.setCullHint(CullHint.Always);
navMesh.setModelBound(new BoundingBox());
} finally {
progressHandle.finish();
}
return navMesh;
}

@ -8,9 +8,10 @@ import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode;
import com.jme3.gde.core.sceneexplorer.nodes.JmeTerrainQuad;
import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractToolAction;
import com.jme3.gde.core.sceneexplorer.nodes.actions.ToolAction;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.terrain.geomipmap.TerrainQuad;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
/**
*
@ -22,12 +23,18 @@ public class GenerateTerrainEntropiesAction extends AbstractToolAction {
public GenerateTerrainEntropiesAction() {
name = "Generate Entropies";
}
@Override
protected Object doApplyTool(AbstractSceneExplorerNode rootNode) {
Node terrain = rootNode.getLookup().lookup(Node.class);
if (terrain instanceof TerrainQuad) { // it should be terrain anyways
((TerrainQuad)terrain).generateEntropy(null); //TODO hook up to progress monitor
ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Generating Entropies");
progressHandle.start();
try {
if (terrain instanceof TerrainQuad) { // it should be terrain anyways
((TerrainQuad) terrain).generateEntropy(null); //TODO hook up to progress monitor
}
} finally {
progressHandle.finish();
}
return true;
}
@ -40,5 +47,4 @@ public class GenerateTerrainEntropiesAction extends AbstractToolAction {
public Class<?> getNodeClass() {
return JmeTerrainQuad.class;
}
}

Loading…
Cancel
Save