nnpa
March 5, 2023, 7:05am
1
Hello i have model with animation
the screenshot shows that the model has anim composer
in object 1
my code:
Node player= (Node)assetManager.loadModel("Models/char.j3o");
Node object = (Node)player.getChild(0);
System.out.println(object);
AnimControl baseAnimControl = object.getControl(AnimControl.class);
System.out.println(baseAnimControl);
return
1 (Node)
null
how to get AnimControl form model?
1 Like
sgold
March 5, 2023, 7:13am
2
When this happens it’s usually because the control is attached to some spatial other than object
. Either analyze the model in advance or else search the scene-graph subtree at runtime.
1 Like
nnpa
March 5, 2023, 7:26am
3
try search objects
Node player= (Node)assetManager.loadModel("Models/char.j3o");
ArrayList<Spatial> nodes = new ArrayList(player.getChildren());
for(Spatial item:nodes){
Node rootScene= (Node) item;
ArrayList<Spatial> nodesChild = new ArrayList(rootScene.getChildren());
for(Spatial itemChild:nodesChild){
System.out.println(itemChild.getName());
}
}
returns
Cube.001
nnpa
March 5, 2023, 7:29am
4
Node player= (Node)assetManager.loadModel("Models/char.j3o");
Geometry node = (Geometry)player.getChild("Cube.001");
AnimControl baseAnimControl = node.getControl(AnimControl.class);
System.out.println(baseAnimControl);
null
pspeed
March 5, 2023, 7:32am
5
Why do you add so much extra unnecessary code?
Node player= (Node)assetManager.loadModel("Models/char.j3o");
for(Spatial item:player.getChildren()){
Node rootScene= (Node)item;
for(Spatial itemChild:rootScene.getChildren()){
System.out.println(itemChild.getName());
}
}
Yes, and it’s very clearly on the root object and not one of the children:
…completely unnecessary.
AnimComposer anim = player.getControl(AnimComposer.class);
…would work in your object.
Edit: and actually, that may be wrong based on the printlns but I’m not convinced that you have presented the output that goes with the posted code.
1 Like
nnpa
March 5, 2023, 7:40am
6
Node player= (Node)assetManager.loadModel("Models/char.j3o");
AnimControl baseAnimControl = player.getControl(AnimControl.class);
System.out.println(baseAnimControl);
null
Ali_RS
March 5, 2023, 7:41am
7
nnpa:
AnimControl
AnimComposer not AnimControl!
1 Like
nnpa
March 5, 2023, 7:41am
8
thank you already understood
pspeed
March 5, 2023, 7:41am
9
Yeah, I completely missed that.
1 Like
nnpa
March 5, 2023, 9:00am
11
anim composer i getting
now how to get skeleton?
SkeletonControl skeleton;
Node player= (Node)assetManager.loadModel("Models/test.glb");
Node armature = (Node)player.getChild("Armature");
Geometry cube = (Geometry)player.getChild("Cube");
for(Spatial item:player.getChildren()){
Node rootScene= (Node)item;
for(Spatial itemChild:rootScene.getChildren()){
System.out.println("childs:" + itemChild.getName());
}
}
AnimComposer anim = armature.getControl(AnimComposer.class);
System.out.println("anim composer " + anim);//true
skeleton = player.getControl(SkeletonControl.class);
System.out.println("skeleton of player " + skeleton);
skeleton = armature.getControl(SkeletonControl.class);
System.out.println("skeleton of armature " + skeleton);
skeleton = cube.getControl(SkeletonControl.class);
System.out.println("skeleton of cube " + skeleton);
childs:Cube
anim composer com.jme3.anim.AnimComposer@76bfd9f6
skeleton of player null
skeleton of armature null
skeleton of cube null
Ali_RS
March 5, 2023, 12:10pm
12
nnpa:
SkeletonControl
It should be SkinningControl
I guess.
AnimControl and SkeletonControl are from the old animation system.
I have done some tests myself and found that the FBXImported still make use of the AnimControl and not the AnimComposer.
I just want to confirm that this is correct?
1 Like
sgold
March 5, 2023, 8:07pm
14
confirm that this is correct?
Yes, that’s correct. Since it’s so easy to convert from old system to the new system, I don’t see this as a major issue.
opened 05:26PM - 27 Oct 20 UTC
enhancement
The FBX importer still imports animations with the old animation system. It need… s to be updated to support the new system.