Morphing...Please!

What

The error is:



java.lang.NullPointerException

at com.jme.animation.KeyframeController.update(Unknown Source)

at com.jme.scene.Spatial.updateWorldData(Unknown Source)

at com.jme.scene.Spatial.updateGeometricState(Unknown Source)

at com.jme.scene.Node.updateWorldData(Unknown Source)

at com.jme.scene.Spatial.updateGeometricState(Unknown Source)

at com.jme.app.SimpleGame.initGame(Unknown Source)

at com.jme.app.BaseGame.start(Unknown Source)

at Morphing.main(Morphing.java:38)

Do some debugging and figure it out…I would start by checking the value assigned to my TriMeshes as they are being assigned from a child of a Node of which child may or may not exist.



If all else fails do system outs through your code to find what it is that is null.



darkfrog

darkfrog said:

If all else fails do system outs through your code to find what it is that is null.

Whaaa! *shrug* Debugging by System.out.println, huh?! No, please don't!

In general: use a nice IDE (e.g. Eclipse) compile jME with debug info, set a breakpoint for NullPointerExceptions and have a look what is null, check why it is null (e.g. who calls what, why) and try to understand what's going on and has to be changed...

Some things about your code: it does not make sense to call setMorphingMesh several times. Could t or t2 be null? Try to check that. Have a look at TestKeyframeController for a usage example.

Note the "if all else fails"…I didn't know what IDE (or if he was using one) he was using and didn't want to get into a discussion of proper debugging with breakpoints. :slight_smile:



Just trying to defend my image as a coder. :wink:



darkfrog

I have debugged my code with Eclipse and I found no null objects. If delete one of these methods -  kc.setMorphingMesh(renderedObject) or renderedObject.addController(kc), will not occur any erros, but the object don

Hmm, yes you should not remove those method calls.

Consider to remove these:

kc.setMorphingMesh(t);

kc.setMorphingMesh(t2);

I

app.start() that calls the error (NullPointerException…)…Why?



aaaaaaaaahhhhhhhhhhhh!!!



Thx everybody for your atention

I believe that the error is:



t = (TriMesh)node.getChild(0);

t2 = (TriMesh)node.getChild(0);

t3 = (TriMesh)node.getChild(0);



(Cast)…but why?



when I do: TriMesh t = new Sphere("teste",1,1,1) will not occur any erros, but the object don

Finally I found the error…It was on these lines:



kc.setKeyframe(.5f, t);

kc.setKeyframe(.5f, t2);



…the first parameters of both methods were equals and they couldn