Apr 27, 2022 10:12:04 AM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.NullPointerException
at mygame.TestOgreAnim.simpleInitApp(TestOgreAnim.java:48)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:239)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
at java.base/java.lang.Thread.run(Thread.java:834)
didn’t work but I decided to slap a 1 in there and then it worked :oooo
My brother is doin the blender work so I don’t know what’s going on here yet exactly but pretty cool!
err so I am trying to be a detective but I don’t think I am doing it right- not sure where exactly to put this or if I need to modify anythin. Do I change the “T” value ??
public class Advice extends SimpleApplication {
private AnimComposer animComposer;
public static void main(String[] args) {
Advice app = new Advice();
app.start();
}
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(10f);
cam.setLocation(new Vector3f(6.4013605f, 7.488437f, 12.843031f));
cam.setRotation(new Quaternion(-0.060740203f, 0.93925786f, -0.2398315f, -0.2378785f));
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);
Spatial model = assetManager.loadModel("Models/WoodChop.j3o");
model.center();
animComposer = ((Node)model).getChild(1).getControl(AnimComposer.class);
animComposer.setCurrentAction("wc");
rootNode.attachChild(model);
}
public static <T extends Control> T findControl( Spatial s, Class<T> type ) {
T result = s.getControl(type);
if( result != null ) {
return result;
}
if( s instanceof Node ) {
for( Spatial child : ((Node)s).getChildren() ) {
result = findControl(child, type);
if( result != null ) {
return result;
}
}
}
return null;
}
}
It’s a method. You add it to the class like any other method.
In the above, you’ve pasted the body of the findControl() method inside your simpleInitApp() method. You can’t declare methods inside of methods.
You may want to wait to use the “findControl” way until you’ve learned more about Java. In the mean time, if you know the name of the node you can at least model.getChild(name) it.