From 359e9d2d64b274877ca01a56ad00bc77ab7c5d83 Mon Sep 17 00:00:00 2001 From: Normen Hansen Date: Wed, 11 Jun 2014 21:56:22 +0200 Subject: [PATCH] SDK: - clean up NewGeometry actions --- .../actions/impl/NewGeometryBoxAction.java | 19 +++++------------ .../actions/impl/NewGeometryLineAction.java | 20 +++++------------- .../actions/impl/NewGeometryQuadAction.java | 21 ++++++------------- .../actions/impl/NewGeometrySphereAction.java | 20 +++++------------- 4 files changed, 21 insertions(+), 59 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryBoxAction.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryBoxAction.java index 960a03da1..ce2c97983 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryBoxAction.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryBoxAction.java @@ -54,24 +54,15 @@ public class NewGeometryBoxAction extends AbstractNewSpatialAction implements Ne @Override protected Spatial doCreateSpatial(Node parent) { - Geometry geom = box(pm); - parent.attachChild(geom); - return geom; - } - - static Material material(AssetManager assetManaget, NewGeometrySettings cfg) { - Material mat = new Material(assetManaget, "Common/MatDefs/Misc/Unshaded.j3md"); - ColorRGBA c = cfg.getMatRandom() ?ColorRGBA.randomColor() : cfg.getMatColor(); - mat.setColor("Color", c); - return mat; - } - - static Geometry box(AssetManager assetManager) { NewGeometrySettings cfg = new NewGeometrySettings(); Box b = new Box(cfg.getBoxX(), cfg.getBoxY(), cfg.getBoxZ()); b.setMode(cfg.getBoxMode()); Geometry geom = new Geometry(cfg.getBoxName(), b); - geom.setMaterial(material(assetManager, cfg)); + Material mat = new Material(pm, "Common/MatDefs/Misc/Unshaded.j3md"); + ColorRGBA c = cfg.getMatRandom() ?ColorRGBA.randomColor() : cfg.getMatColor(); + mat.setColor("Color", c); + geom.setMaterial(mat); + parent.attachChild(geom); return geom; } } diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryLineAction.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryLineAction.java index 124968444..13bfd9e0a 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryLineAction.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryLineAction.java @@ -54,25 +54,15 @@ public class NewGeometryLineAction extends AbstractNewSpatialAction implements N @Override protected Spatial doCreateSpatial(Node parent) { - Geometry geom = line(pm); - parent.attachChild(geom); - return geom; - } - - static Material material(AssetManager assetManaget, NewGeometrySettings cfg) { - Material mat = new Material(assetManaget, "Common/MatDefs/Misc/Unshaded.j3md"); - ColorRGBA c = cfg.getMatRandom() ?ColorRGBA.randomColor() : cfg.getMatColor(); - mat.setColor("Color", c); - return mat; - } - - static Geometry line(AssetManager assetManager) { NewGeometrySettings cfg = new NewGeometrySettings(); Line b = new Line(cfg.getLineStart(), cfg.getLineEnd()); b.setMode(cfg.getLineMode()); Geometry geom = new Geometry(cfg.getLineName(), b); - geom.setMaterial(material(assetManager, cfg)); + Material mat = new Material(pm, "Common/MatDefs/Misc/Unshaded.j3md"); + ColorRGBA c = cfg.getMatRandom() ?ColorRGBA.randomColor() : cfg.getMatColor(); + mat.setColor("Color", c); + geom.setMaterial(mat); + parent.attachChild(geom); return geom; } - } diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryQuadAction.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryQuadAction.java index 00634edac..a49228c25 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryQuadAction.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryQuadAction.java @@ -55,19 +55,6 @@ public class NewGeometryQuadAction extends AbstractNewSpatialAction implements N @Override protected Spatial doCreateSpatial(Node parent) { - Geometry geom = quad(pm); - parent.attachChild(geom); - return geom; - } - - static Material material(AssetManager assetManaget, NewGeometrySettings cfg) { - Material mat = new Material(assetManaget, "Common/MatDefs/Misc/Unshaded.j3md"); - ColorRGBA c = cfg.getMatRandom() ?ColorRGBA.randomColor() : cfg.getMatColor(); - mat.setColor("Color", c); - return mat; - } - - static Geometry quad(AssetManager assetManager) { NewGeometrySettings cfg = new NewGeometrySettings(); Quad b = new Quad(cfg.getQuadWidth(), cfg.getQuadHeight(), cfg.getQuadFlipCoords()); b.setMode(cfg.getQuadMode()); @@ -86,7 +73,11 @@ public class NewGeometryQuadAction extends AbstractNewSpatialAction implements N break; } } - geom.setMaterial(material(assetManager, cfg)); + Material mat = new Material(pm, "Common/MatDefs/Misc/Unshaded.j3md"); + ColorRGBA c = cfg.getMatRandom() ?ColorRGBA.randomColor() : cfg.getMatColor(); + mat.setColor("Color", c); + geom.setMaterial(mat); + parent.attachChild(geom); return geom; - } + } } diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySphereAction.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySphereAction.java index 842442ffd..d79d099e1 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySphereAction.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySphereAction.java @@ -54,19 +54,6 @@ public class NewGeometrySphereAction extends AbstractNewSpatialAction implements @Override protected Spatial doCreateSpatial(Node parent) { - Geometry geom = sphere(pm); - parent.attachChild(geom); - return geom; - } - - static Material material(AssetManager assetManaget, NewGeometrySettings cfg) { - Material mat = new Material(assetManaget, "Common/MatDefs/Misc/Unshaded.j3md"); - ColorRGBA c = cfg.getMatRandom() ?ColorRGBA.randomColor() : cfg.getMatColor(); - mat.setColor("Color", c); - return mat; - } - - static Geometry sphere(AssetManager assetManager) { NewGeometrySettings cfg = new NewGeometrySettings(); Sphere b = new Sphere( cfg.getSphereZSamples() @@ -77,8 +64,11 @@ public class NewGeometrySphereAction extends AbstractNewSpatialAction implements ); b.setMode(cfg.getSphereMode()); Geometry geom = new Geometry(cfg.getSphereName(), b); - geom.setMaterial(material(assetManager, cfg)); + Material mat = new Material(pm, "Common/MatDefs/Misc/Unshaded.j3md"); + ColorRGBA c = cfg.getMatRandom() ?ColorRGBA.randomColor() : cfg.getMatColor(); + mat.setColor("Color", c); + geom.setMaterial(mat); + parent.attachChild(geom); return geom; } - }