How can auto stop the AnimControl if the model not in camera area

many model need play stand anim or idle anim! so how can auto stop the AnimControl if the model not in camera area?

To test whether the model is ā€œin cameraā€, you might use the Spatial.checkCulling() method.

To disable the control, you might use AnimControl.setEnabled(false);

To perform the test on every update, you might create an AppState or add it to SimpleApplication.simpleUpdate().

2 Likes

One question is why you want to do this.

The mesh itself is only updated when the object is on screen (controlRender()) even if the ā€˜animationā€™ and bones, etc. are updated when the character is off-screen. And sometimes itā€™s important for those bones to be updated even when they arenā€™t in view.

Do you have like several thousand animated characters or something? If so, I donā€™t think animating the bones is going to be your bottleneck.

2 Likes

yes i have 5 thousand anim ! so i need auto stop the anim while the model not in camera area

The work that animations are doing when not in view is not very much.

You can implement what you want as already described but it is unlikely to help much. Thatā€™s probably just too many animated characters at once. Off the shelf systems are unlikely to work well in that case.

ā€¦which is why you donā€™t see many video games with 5000 animated characters at once.

yes, even M&B Bannerlord that is known for big battles using detailed models have limits. i belive it was 1000.

well, you can do own control and check if is in view and disable anim control, but im also not sure if this will help.