Fixes mat param override reading null integenr params as 0

v3.2
Nehon 7 years ago
parent f85624a20a
commit 631794f7d6
  1. 7
      jme3-core/src/main/java/com/jme3/material/MatParamOverride.java
  2. 32
      jme3-examples/src/main/java/jme3test/model/anim/TestModelExportingCloning.java

@ -140,6 +140,9 @@ public final class MatParamOverride extends MatParam {
super.write(ex); super.write(ex);
OutputCapsule oc = ex.getCapsule(this); OutputCapsule oc = ex.getCapsule(this);
oc.write(enabled, "enabled", true); oc.write(enabled, "enabled", true);
if (value == null) {
oc.write(true, "isNull", false);
}
} }
@Override @Override
@ -147,5 +150,9 @@ public final class MatParamOverride extends MatParam {
super.read(im); super.read(im);
InputCapsule ic = im.getCapsule(this); InputCapsule ic = im.getCapsule(this);
enabled = ic.readBoolean("enabled", true); enabled = ic.readBoolean("enabled", true);
boolean isNull = ic.readBoolean("isNull", false);
if (isNull) {
setValue(null);
}
} }
} }

@ -49,35 +49,9 @@ public class TestModelExportingCloning extends SimpleApplication {
@Override @Override
public void simpleInitApp() { public void simpleInitApp() {
cam.setLocation(new Vector3f(10f, 3f, 40f)); Spatial s = assetManager.loadModel("Models/gltf/human/human.j3o");
cam.lookAtDirection(Vector3f.UNIT_Z.negate(), Vector3f.UNIT_Y); rootNode.attachChild(s);
DirectionalLight dl = new DirectionalLight(); rootNode.addLight(new DirectionalLight(new Vector3f(-1,-1,-1)));
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);
} }
} }

Loading…
Cancel
Save