Skip to content

Commit

Permalink
LandscapeControl: use MyAsset to create shaded materials
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Sep 12, 2018
1 parent 9e455d8 commit f5f133e
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions debug/src/main/java/jme3utilities/debug/LandscapeControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit f5f133e

Please sign in to comment.