From f5f133e99320dccf2bb5c946f156a8a490e438d4 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Wed, 12 Sep 2018 13:27:36 -0700 Subject: [PATCH] LandscapeControl: use MyAsset to create shaded materials --- .../jme3utilities/debug/LandscapeControl.java | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/debug/src/main/java/jme3utilities/debug/LandscapeControl.java b/debug/src/main/java/jme3utilities/debug/LandscapeControl.java index 5ab66ff3f..68a39f87d 100644 --- a/debug/src/main/java/jme3utilities/debug/LandscapeControl.java +++ b/debug/src/main/java/jme3utilities/debug/LandscapeControl.java @@ -184,12 +184,14 @@ public LandscapeControl(AssetManager assetManager) { /** * Access the material applied to the terrain. * - * @return the material + * @return the material (not null) */ final public Material getGrass() { if (terrainMaterial == null) { - terrainMaterial = createShadedMaterial(defaultGrassColor); + terrainMaterial = MyAsset.createShadedMaterial(assetManager, + defaultGrassColor); } + return terrainMaterial; } @@ -311,7 +313,8 @@ public void write(JmeExporter exporter) throws IOException { * Create a circular monument that vaguely resembles Stonehenge. */ private Node createMonument() { - Material stoneMaterial = createShadedMaterial(defaultStoneColor); + Material stoneMaterial + = MyAsset.createShadedMaterial(assetManager, defaultStoneColor); Node node = new Node("monument"); float ringRadius = ringDiameter / 2f; Box uprightMesh @@ -356,24 +359,6 @@ private Node createMonument() { return node; } - /** - * Create a shaded material for the specified color. TODO move to MyAsset - * - * @param color ambient/diffuse color (not null, unaffected) - * @return new material - */ - private Material createShadedMaterial(ColorRGBA color) { - assert color != null; - - Material material - = new Material(assetManager, MyAsset.shadedMaterialAssetPath); - material.setBoolean("UseMaterialColors", true); - material.setColor("Ambient", color.clone()); - material.setColor("Diffuse", color.clone()); - - return material; - } - /** * Load terrain from assets. */