I’m looping through each spatial in my scene and checking if they have animation controls. Currently this is the working code I have for the test.
for (Spatial x : sceneNode.descendantMatches(Spatial.class, null)) {
int i = x.getNumControls();
for (int n = 0;n<i;n++){
if (x.getControl(n).getClass().equals(AnimControl.class)){
System.out.println("animation control");
}
}
}
I’m curious if there is a more efficient way or an equivalent to descendantMatches for animation controls.
@pspeed My spatials have multiple controls and some may not have any controls. If I call getControl and the spatial doesn’t contain one it crashes the app. Hence why I have that test.
I have models that have separate animation controls for each limb. I didn’t rig them they came this way. I’m looping through the spatial for each subset and getting the control.
To explain what I’m doing is I’m creating a master control for the spatial. That when you run the animation for one limb it runs it for all limbs. For example when the “walk” animation is called then all limbs on the model play the walk animation. In order to do this I’m creating a List of controls for the model.
It’s not just the bob model I’m looping through. I’m going through every node in my scene. Most of which do not have animation controls. If I call getControl(AnimControl.class) on a node without an animation control it just crashes with a null exception.
getControl(AnimControl.class) returns null if no animation control is present on the spatial. Then, you just have to test if the returned value is null.
This may crash if the return of getControl is null, obviously :
@methusalah Thank you very much , that was exactly what I was looking for. I don’t have duplicate controls for a mesh. Each mesh is divided into parts for example legs , arms , body etc. have their own geometries and each of those geometries has it’s own control. I succeeded in making my master control , finally
So no one else is confused by this thread here is a screen shot of bob.
Judgement day and the rise of the machines is coming.
Sorry , for all of those who I frustrated but I know I’m not crazy lol
I must say forum wise you guys are still the best most responsive team on the internet. Heck , you even put up with me which proves you are numero uno !