getControl(AnimControl.class) returns null on imported j3o Spatial

Hello.

In blender I created a box, used e to Extrude it. created 4 bones and set up that they will be a child of this parent with auto weight and i tested that it works by going to Pose mode and moving/rotating the bones.

I used JMonkeyEngine IDE to convert it to a j3o file, loaded the j3o file with the assetManager and displayed it on the screen propery.

I would like now to use the SkeletonDebugger in order to see the bones of the mesh.



i paste the code at : http://pastebin.com/hNUdFURm





the problem is that when I use the following code to get the AnimControl, it returns null.



final AnimControl control = hand.getControl(AnimControl.class);



any ideas ?



thank you!



kfir

Load the model in the SceneComposer and check the SceneExplorer, if there is no AnimControl then the animations were not exported/imported (mostly because they are set up wrong).

for now I didn’t create any animation.

I want to create the animation within JMonkeyEngine.

I saw in the example that by fetching the AnimControl the SkeletonDebugger can be used to show the bones structure of the object.

am i doing it wrong because there are no animations ?

you will need at least a base animation with the rest pose to get an AnimControl

AnimControl => animation control, means you can control animations. If there’s no animations, there’s nothing to control in the first place.

first of all thanks for your wonderful support.



I loaded blender, created some keyframes to test the animation, re-created the j30 file and noticed in the SceneExplorer

that my blend file contains:

  • Armature->Cube->AnimControl
  • PointLight



    so my guess is that:

    Spatial hand = assetManager.loadModel(“Models/Worm/worm.j3o”);

    final AnimControl control = hand.getControl(AnimControl.class);



    is not enough. i need to fetch the Cube object and to load the AnimControl of that specific Object.



    how do i do that ?!

ok it was way more simple then I thought.

I just attached the spatial to the root node and then fetched the required child based on the object name:



Spatial hand = assetManager.loadModel(“Models/Worm/worm.j3o”);





Spatial model = rootNode.getChild(“Cube”);

Material mat_default = new Material(

assetManager, “Common/MatDefs/Misc/ShowNormals.j3md”);

hand.setMaterial(mat_default);

rootNode.attachChild(hand);

Spatial model = rootNode.getChild(“cube01”);



final AnimControl control = model.getControl(AnimControl.class);


now finally control is not null!! :) yay!

why you assign that shownormals material :?

Edit: read your code again and look what every line does, try to understand it and write it clean. if you just copy-paste stuff until it works somehow you will have all kinds of mess happening.

In that same example i was using SkeletonDebugger to show bone structure of objects. that’s why i was using that material. .

Nah, still doesn’t make no sense.

1 Like

so any ideas where I can read some more about these materials types ? by reading the skeleton debugger example to view bones structure of objects it seemed very logical to useit.

Try the tutorials…:



https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_material

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:intermediate:how_to_use_materials

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:j3m_material_files

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:material_definitions

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:materials_overview