From 631794f7d61d848e8b4136db78787e6182919258 Mon Sep 17 00:00:00 2001 From: Nehon Date: Sat, 19 May 2018 00:22:47 +0200 Subject: [PATCH] Fixes mat param override reading null integenr params as 0 --- .../com/jme3/material/MatParamOverride.java | 7 ++++ .../model/anim/TestModelExportingCloning.java | 32 ++----------------- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/material/MatParamOverride.java b/jme3-core/src/main/java/com/jme3/material/MatParamOverride.java index 8a7355b87..1b4aad480 100644 --- a/jme3-core/src/main/java/com/jme3/material/MatParamOverride.java +++ b/jme3-core/src/main/java/com/jme3/material/MatParamOverride.java @@ -140,6 +140,9 @@ public final class MatParamOverride extends MatParam { super.write(ex); OutputCapsule oc = ex.getCapsule(this); oc.write(enabled, "enabled", true); + if (value == null) { + oc.write(true, "isNull", false); + } } @Override @@ -147,5 +150,9 @@ public final class MatParamOverride extends MatParam { super.read(im); InputCapsule ic = im.getCapsule(this); enabled = ic.readBoolean("enabled", true); + boolean isNull = ic.readBoolean("isNull", false); + if (isNull) { + setValue(null); + } } } diff --git a/jme3-examples/src/main/java/jme3test/model/anim/TestModelExportingCloning.java b/jme3-examples/src/main/java/jme3test/model/anim/TestModelExportingCloning.java index de162907d..7552583c1 100644 --- a/jme3-examples/src/main/java/jme3test/model/anim/TestModelExportingCloning.java +++ b/jme3-examples/src/main/java/jme3test/model/anim/TestModelExportingCloning.java @@ -49,35 +49,9 @@ public class TestModelExportingCloning extends SimpleApplication { @Override public void simpleInitApp() { - cam.setLocation(new Vector3f(10f, 3f, 40f)); - cam.lookAtDirection(Vector3f.UNIT_Z.negate(), Vector3f.UNIT_Y); + Spatial s = assetManager.loadModel("Models/gltf/human/human.j3o"); + rootNode.attachChild(s); - DirectionalLight dl = new DirectionalLight(); - dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal()); - dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); - rootNode.addLight(dl); - - AnimControl control; - AnimChannel channel; - - Spatial originalModel = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); - control = originalModel.getControl(AnimControl.class); - channel = control.createChannel(); - channel.setAnim("Walk"); - rootNode.attachChild(originalModel); - - Spatial clonedModel = originalModel.clone(); - clonedModel.move(10, 0, 0); - control = clonedModel.getControl(AnimControl.class); - channel = control.createChannel(); - channel.setAnim("push"); - rootNode.attachChild(clonedModel); - - Spatial exportedModel = BinaryExporter.saveAndLoad(assetManager, originalModel); - exportedModel.move(20, 0, 0); - control = exportedModel.getControl(AnimControl.class); - channel = control.createChannel(); - channel.setAnim("pull"); - rootNode.attachChild(exportedModel); + rootNode.addLight(new DirectionalLight(new Vector3f(-1,-1,-1))); } }