Clean up the test case and add some more context. #1340

v3.3
rvandoosselaer 5 years ago committed by Stephen Gold
parent 227de6f22a
commit 9a84e72f03
  1. 41
      jme3-examples/src/main/java/jme3test/light/pbr/TestIssue1340.java

@ -1,5 +1,6 @@
package jme3test.light.pbr;
import com.jme3.anim.SkinningControl;
import com.jme3.app.SimpleApplication;
import com.jme3.asset.plugins.UrlLocator;
import com.jme3.environment.EnvironmentCamera;
@ -9,15 +10,20 @@ import com.jme3.light.DirectionalLight;
import com.jme3.light.LightProbe;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.system.AppSettings;
/**
* @author: rvandoosselaer
* This test case validates a shader compilation fix with a model using a PBR material in combination with a
* SkinningControl. When you run this application and you don't see a RenderException, the test is successful.
* For a detailed explanation consult the github issue: https://github.com/jMonkeyEngine/jmonkeyengine/issues/1340
* -rvandoosselaer
*/
public class TestIssue1340 extends SimpleApplication {
int frame;
private Spatial model;
private int frame;
public static void main(String[] args) {
TestIssue1340 testIssue1340 = new TestIssue1340();
@ -40,8 +46,11 @@ public class TestIssue1340 extends SimpleApplication {
assetManager.registerLocator("https://github.com/KhronosGroup/glTF-Sample-Models/raw/master/2.0/RiggedFigure/", UrlLocator.class);
Spatial model = assetManager.loadModel("/glTF-Embedded/RiggedFigure.gltf");
rootNode.attachChild(model);
model = assetManager.loadModel("/glTF-Embedded/RiggedFigure.gltf");
SkinningControl skinningControl = getSkinningControl(model);
if (skinningControl == null || !skinningControl.isHardwareSkinningPreferred()) {
throw new IllegalArgumentException("This test case requires a model with a SkinningControl and with Hardware skinning preferred!");
}
viewPort.setBackgroundColor(ColorRGBA.LightGray);
}
@ -53,9 +62,31 @@ public class TestIssue1340 extends SimpleApplication {
LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class), rootNode, new JobProgressAdapter<LightProbe>() {
@Override
public void done(LightProbe result) {
enqueue(() -> rootNode.addLight(result));
enqueue(() -> {
rootNode.attachChild(model);
rootNode.addLight(result);
});
}
});
}
}
private SkinningControl getSkinningControl(Spatial model) {
SkinningControl control = model.getControl(SkinningControl.class);
if (control != null) {
return control;
}
if (model instanceof Node) {
for (Spatial child : ((Node) model).getChildren()) {
SkinningControl skinningControl = getSkinningControl(child);
if (skinningControl != null) {
return skinningControl;
}
}
}
return null;
}
}

Loading…
Cancel
Save