[SOLVED] Please Help Me Understand Attaching Geometries to an Animated Node

So, in the initialization step I create a Node, attach it to the rootNode, add an AnimControl and SkeletonControl, then I attach some Geometries to the Node.

In the update loop, I then add some more Geometries to the Node and then start the animation.

But only the Geometries that were added during initialization animate. Can anyone help me understand what’s going on here?

EDIT: And if I wait to add the controls during the update loop, Geometries that are before or during that loop animate, but any Geometries that are attached after don’t animate. This is true even if I remove and then add the controls back when I add the later Geometries. The original Geometries continue to animate fine.

SOLUTION: After adding a new Geometry, it seems like the thing you have to do is generate a new SkeletonControl, as follows:

node.addControl(new SkeletonControl(node.getControl(AnimControl.class).getSkeleton());

Code would be nice, so we can see how you’re trying to do it.
Also, I don’t think changing the title helps. :stuck_out_tongue:

What I’m trying to do is add more Geometries to a Node that already has an Anim and Skeleton control and have the new Geometries also be animated.

I changed the title because I felt that the original title no longer helpfully captured what I am trying to figure out.

EDIT: I’m hoping someone will say something like, “You’re not supposed to add Geometries to Nodes that already had an AnimControl added to them. If you want to add another Geometry, the best/simplest thing to do is X.” Because, if what I describe should work, it means that I’m running into a really weird bug and I have no idea how my code could be causing the problem. And my code base is too large to make sharing it a convenient option for me or the people I’d share it with.

I still don’t really get what you want to achieve …
…Hey i want to travel with my car and i need a route…where do you want to go? i just want to travel with my car please give me a route…
…If you are talking about moving a weapon when a character move its hands, you should take a look to AttachmentsNode.


@haze, Let me explain it again. I’m not talking about attachment nodes or weapons. I’m talking about Node#attachChild(Spatial). I’m trying to attach a model to a Node that’s currently being controlled by an AnimControl and still have that model be animated by the AnimControl. Tell me what you don’t understand. More specifically, I’ve tried:

  1. In my AppState’s initialize() method: create a Node, give it a SkeletonControl and AnimControl, attachChild() some models to it.
  2. In my update() method, attach some more models to to the node, and start an animation on the AnimControl.
  3. Have both the models attached in the initialize() method and the update() method actually animate.

But instead only the ones attached in the initialize() method animate, regardless of which models I load when.

Is there any part of that you don’t understand? I’m not looking for advice on how to implement a feature, I’m looking for an explanation for why that doesn’t work or an explanation for how to attach a model to a Node that’s currently being controlled by an AnimControl and still have that model be animated by the AnimControl.

Remove the animation or skeleton control and readd it. They were not meant to be used in this way.

Edit: the part folks didn’t understand… and was still kind of buried half way into your latest post is that the newly added children are also animated. It’s still a strange use-case, I guess.

1 Like

Tell me what you don’t understand. => I’m trying to attach a model to a Node that’s currently being controlled by an AnimControl

I’m certainly stupid but SkeletonControl and AnimControl have no sense for a Node …
There is no magic there if you don’t have a rig, animationControl doesn’t do anything we are not in unity you can’t animate a gameObject with it !

What model are you trying to load and what do you want to attach to it ???

When the animation control is attached then it will search the subgraph of what it is attached to so that it can locate all of the animated children. If you add animated children after that then they won’t be controlled by it.

So, if you have a happy beaver model and you make him run then later add a squirrel to his back then the squirrel won’t be animated… just sit there in the default pose.

Now, “why” is left as an exercise for the OP but that’s what he’s talking about.

Edit: and may be the start of another series of “this didn’t work the way I expected” questions.

1 Like

@pspeed, thanks for understanding what I’m talking about.

I’ve already tried this like so:

AnimControl ac = node.getControl(AnimControl.class);
SkeletonControl sc = node.getControl(SkeletonControl.class);

But that makes no difference. The Geometries that were added when the controls were originally added still animate while those that get added later, but before or after the code above, don’t animate. What am I doing wrong?

UPDATE: The following seems to be working best, so far:

node.addControl(new SkeletonControl(node.getControl(AnimControl.class).getSkeleton());

Hmm, I guess the reason why it works is because the other model is using software skinning, and SkeletonControl isn’t smart enough to realize that new geometries that were added after initialization need to have prepareForAnim called on them.

I’ll have to investigate that.