Просмотр исходного кода

SDK:
- clean up NewGeometry actions

Normen Hansen 11 лет назад
Родитель
Сommit
359e9d2d64

+ 5 - 14
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;
     }
 }

+ 5 - 15
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;
     }
-
 }

+ 6 - 15
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;
-    }    
+    }
 }

+ 5 - 15
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;
     }
-
 }