Java Code Examples for com.jme3.animation.AnimControl#getNumChannels()

The following examples show how to use com.jme3.animation.AnimControl#getNumChannels() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StopAnimationAction.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
@Override
@FxThread
protected void process() {
    super.process();

    final AnimationTreeNode modelNode = (AnimationTreeNode) getNode();
    if (modelNode.getChannel() < 0) return;

    final AnimControl control = modelNode.getControl();
    if (control == null || control.getNumChannels() <= 0) return;

    final AnimChannel channel = control.getChannel(modelNode.getChannel());
    channel.setLoopMode(LoopMode.DontLoop);

    EXECUTOR_MANAGER.addJmeTask(control::clearChannels);

    final NodeTree<ModelChangeConsumer> nodeTree = getNodeTree();
    nodeTree.update(modelNode);
}
 
Example 2
Source File: PauseAnimationAction.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
@Override
@FxThread
protected void process() {
    super.process();

    final AnimationTreeNode modelNode = (AnimationTreeNode) getNode();
    if (modelNode.getChannel() < 0) return;

    final AnimControl control = modelNode.getControl();
    if (control == null || control.getNumChannels() <= 0) return;

    final AnimChannel channel = control.getChannel(modelNode.getChannel());
    channel.setSpeed(0);
    modelNode.setSpeed(0);

    final NodeTree<ModelChangeConsumer> nodeTree = getNodeTree();
    nodeTree.update(modelNode);
}
 
Example 3
Source File: AnimationTreeNode.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree,
                            @NotNull final ObservableList<MenuItem> items) {

    final Animation animation = getElement();
    final AnimationControlTreeNode controlModelNode = notNull(getControlModelNode());
    final AnimControl control = controlModelNode.getElement();

    final int frameCount = AnimationUtils.getFrameCount(animation);

    if (getChannel() < 0 && control.getNumChannels() < 1) {
        items.add(new PlayAnimationAction(nodeTree, this));
        items.add(new RemoveAnimationAction(nodeTree, this));
        items.add(new RenameNodeAction(nodeTree, this));
    } else if (getChannel() >= 0 && control.getChannel(getChannel()).getSpeed() < 0.0001F) {
        items.add(new PlayAnimationAction(nodeTree, this));
        items.add(new StopAnimationAction(nodeTree, this));
    } else if (getChannel() >= 0) {
        items.add(new PauseAnimationAction(nodeTree, this));
        items.add(new StopAnimationAction(nodeTree, this));
    }

    if (getChannel() < 0 && frameCount > 0) {
        items.add(new ManualExtractSubAnimationAction(nodeTree, this));
    }

    super.fillContextMenu(nodeTree, items);
}