• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Animation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.jme3.animation.Animation的典型用法代码示例。如果您正苦于以下问题:Java Animation类的具体用法?Java Animation怎么用?Java Animation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Animation类属于com.jme3.animation包,在下文中一共展示了Animation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: ExtractSubAnimationDialog

import com.jme3.animation.Animation; //导入依赖的package包/类
public ExtractSubAnimationDialog(@NotNull final NodeTree<?> nodeTree, @NotNull final AnimationTreeNode node) {
    this.nodeTree = nodeTree;
    this.node = node;

    final Animation animation = node.getElement();
    final AnimControl control = notNull(node.getControl());
    final int frameCount = AnimationUtils.getFrameCount(animation);

    final TextField nameField = getNameField();
    nameField.setText(AnimationUtils.findFreeName(control, Messages.MANUAL_EXTRACT_ANIMATION_DIALOG_NAME_EXAMPLE));

    final IntegerTextField startFrameField = getStartFrameField();
    startFrameField.setMinMax(0, frameCount - 2);
    startFrameField.setValue(0);

    final IntegerTextField endFrameField = getEndFrameField();
    endFrameField.setMinMax(1, frameCount - 1);
    endFrameField.setValue(frameCount - 1);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:20,代码来源:ExtractSubAnimationDialog.java


示例2: process

import com.jme3.animation.Animation; //导入依赖的package包/类
@Override
@FXThread
protected void process() {
    super.process();

    final TreeNode<?> node = getNode();
    final Object element = node.getElement();

    if (!(element instanceof Animation)) return;
    final Animation animation = (Animation) element;

    final NodeTree<ModelChangeConsumer> nodeTree = getNodeTree();
    final TreeNode<?> parentNode = nodeTree.findParent(node);

    if (parentNode == null) {
        LOGGER.warning("not found parent node for " + node);
        return;
    }

    final AnimControl parent = (AnimControl) parentNode.getElement();

    final ModelChangeConsumer changeConsumer = notNull(nodeTree.getChangeConsumer());
    changeConsumer.execute(new RemoveAnimationNodeOperation(animation, parent));
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:25,代码来源:RemoveAnimationAction.java


示例3: extractAnimation

import com.jme3.animation.Animation; //导入依赖的package包/类
/**
 * Extract an animation from a source animation.
 *
 * @param source     the source animation.
 * @param newName    the new name of a sub animation.
 * @param startFrame the start frame.
 * @param endFrame   the end frame.
 * @return the new sub animation.
 */
@NotNull
@FromAnyThread
public static Animation extractAnimation(@NotNull final Animation source, @NotNull final String newName,
                                         final int startFrame, final int endFrame) {

    final Track[] sourceTracks = source.getTracks();
    final BoneTrack firstSourceTrack = (BoneTrack) sourceTracks[0];
    final float[] sourceTimes = firstSourceTrack.getTimes();

    final float newLength = (source.getLength() / (float) sourceTimes.length) * (float) (endFrame - startFrame);
    final Animation result = new Animation(newName, newLength);
    final Array<Track> newTracks = ArrayFactory.newArray(Track.class);

    for (final Track sourceTrack : sourceTracks) {
        if (sourceTrack instanceof BoneTrack) {
            newTracks.add(extractBoneTrack((BoneTrack) sourceTrack, startFrame, endFrame));
        }
    }

    result.setTracks(newTracks.toArray(Track.class));

    return result;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:33,代码来源:AnimationUtils.java


示例4: changeName

import com.jme3.animation.Animation; //导入依赖的package包/类
/**
 * Chane a name of an animation.
 *
 * @param control   the animation control.
 * @param animation the animation.
 * @param oldName   the old name.
 * @param newName   the new name.
 */
@FromAnyThread
public static void changeName(@NotNull final AnimControl control, @NotNull final Animation animation,
                              @NotNull final String oldName, @NotNull final String newName) {
    try {

        final Map<String, Animation> animationMap = unsafeCast(ANIMATIONS_MAP_FIELD.get(control));

        if (!animationMap.containsKey(oldName)) {
            throw new IllegalArgumentException("Given animation does not exist " + "in this AnimControl");
        }

        if (animationMap.containsKey(newName)) {
            throw new IllegalArgumentException("The same animation exist " + "in this AnimControl");
        }

        ANIMATION_NAME_FIELD.set(animation, newName);

        animationMap.remove(oldName);
        animationMap.put(newName, animation);

    } catch (final IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:33,代码来源:AnimationUtils.java


示例5: createNodes

import com.jme3.animation.Animation; //导入依赖的package包/类
@Override
    protected Node[] createNodes(Object key) {
//        for (SceneExplorerNode di : Lookup.getDefault().lookupAll(SceneExplorerNode.class)) {
//            if (di.getExplorerObjectClass().getName().equals(key.getClass().getName())) {
//                Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Found {0}", di.getExplorerNodeClass());
//                Node[] ret = di.createNodes(key, dataObject, readOnly);
//                if (ret != null) {
//                    return ret;
//                }
//            }
//        }

        if (key instanceof Animation) {
            JmeTrackChildren children = new JmeTrackChildren();
            children.setReadOnly(readOnly);            
            return new Node[]{new JmeAnimation(jmeAnimControl, (Animation) key, children, dataObject).setReadOnly(readOnly)};
        }
        return new Node[]{Node.EMPTY};
    }
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:20,代码来源:JmeAnimChildren.java


示例6: EffectTrackVisualPanel1

import com.jme3.animation.Animation; //导入依赖的package包/类
/**
 * Creates new form EffectTrackVisualPanel1
 */
public EffectTrackVisualPanel1(Spatial rootNode, JmeAnimation animation) {
    this.rootNode = rootNode;
    this.animation = animation;
    initComponents();
    lengthLabel.setText(animation.getLookup().lookup(Animation.class).getLength() + "");
    DefaultComboBoxModel model = new DefaultComboBoxModel();

    populateModel(rootNode, model);
    jComboBox1.setModel(model);
    jComboBox1.setRenderer(new ListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            if (value instanceof Spatial) {
                return new JLabel(((Spatial) value).getName());
            } else{
                return new JLabel("?");
            }
        }
    });
    jSlider1.setMaximum((int) (animation.getLookup().lookup(Animation.class).getLength() * 100));
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:24,代码来源:EffectTrackVisualPanel1.java


示例7: actionPerformed

import com.jme3.animation.Animation; //导入依赖的package包/类
public @Override
void actionPerformed(ActionEvent e) {
    WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels());
    // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
    wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
    wizardDescriptor.setTitle("Create a new AudioTrack");
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
    dialog.setVisible(true);
    dialog.toFront();
    boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
    if (!cancelled) {
        AudioNode audio = (AudioNode) wizardDescriptor.getProperty("Audio");
        float startOffset = (Float) wizardDescriptor.getProperty("startOffset");
        Animation anim = animation.getLookup().lookup(Animation.class);
        anim.addTrack(new AudioTrack(audio, anim.getLength(), startOffset));

        animation.refresh(false);
        animation.setChanged();
    }
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:21,代码来源:AudioTrackWizardAction.java


示例8: actionPerformed

import com.jme3.animation.Animation; //导入依赖的package包/类
public @Override
void actionPerformed(ActionEvent e) {
    WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels());
    // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
    wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
    wizardDescriptor.setTitle("Create a new EffectTrack");
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
    dialog.setVisible(true);
    dialog.toFront();
    boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
    if (!cancelled) {
        ParticleEmitter emitter = (ParticleEmitter) wizardDescriptor.getProperty("Emitter");
        float startOffset = (Float) wizardDescriptor.getProperty("startOffset");
        Animation anim = animation.getLookup().lookup(Animation.class);
        anim.addTrack(new EffectTrack(emitter, anim.getLength(), startOffset));                        
                
        animation.refresh(false);
        animation.setChanged();
    }
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:21,代码来源:EffectTrackWizardAction.java


示例9: AudioTrackVisualPanel1

import com.jme3.animation.Animation; //导入依赖的package包/类
/** Creates new form AudioTrackVisualPanel1 */
public AudioTrackVisualPanel1(Spatial rootNode, JmeAnimation animation) {
    this.rootNode = rootNode;
    this.animation = animation;
    initComponents();
    lengthLabel.setText(animation.getLookup().lookup(Animation.class).getLength() + "");
    DefaultComboBoxModel model = new DefaultComboBoxModel();

    populateModel(rootNode, model);
    
    jComboBox1.setModel(model);
    jComboBox1.setRenderer(new ListCellRenderer() {

        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            if (value instanceof Spatial) {
                return new JLabel(((Spatial) value).getName());
            } else{
                return new JLabel("?");
            }
        }
    }); 
    jSlider1.setMaximum((int) (animation.getLookup().lookup(Animation.class).getLength() * 100));
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:24,代码来源:AudioTrackVisualPanel1.java


示例10: JmeAnimation

import com.jme3.animation.Animation; //导入依赖的package包/类
public JmeAnimation(JmeAnimControl control, Animation animation, JmeTrackChildren children, DataObject dataObject) {
    super(children);
    this.dataObject = dataObject;
    children.setDataObject(dataObject);
    this.animation = animation;
    this.jmeControl = control;
    lookupContents.add(this);
    lookupContents.add(animation);
    setName(animation.getName());
    children.setAnimation(this);
    children.setAnimControl(jmeControl);
    icon = IconList.animation.getImage();

    addNodeListener(new NodeAdapter(){
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if(evt.getPropertyName().equalsIgnoreCase("name")){
                doRenameAnimation((String) evt.getOldValue(),(String)evt.getNewValue());
            }
        }        
    });
     
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:24,代码来源:JmeAnimation.java


示例11: createSheet

import com.jme3.animation.Animation; //导入依赖的package包/类
@Override
protected Sheet createSheet() {
    //TODO: multithreading..
    Sheet sheet = Sheet.createDefault();
    Sheet.Set set = Sheet.createPropertiesSet();
    set.setDisplayName("Animation");
    set.setName(Animation.class.getName());
    if (animation == null) {
        return sheet;
    }

    set.put(new AnimationProperty(jmeControl.getLookup().lookup(AnimControl.class)));

    sheet.put(set);
    return sheet;
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:17,代码来源:JmeAnimation.java


示例12: addSkeletonAnim

import com.jme3.animation.Animation; //导入依赖的package包/类
/**
     * 将from中的所有动画添加到to身上,如果已经存在同名动画则替换之.注意:该方
     * 法只是简单将Animation从from添加到to上,而to仍然保留了所有Animation的
     * 引用,这时改变to的Animation可能会影响from身上添加的Animation
     * @param from 
     * @param to 
     */
    public static void addSkeletonAnim(Spatial from, Spatial to) {
        AnimControl acFrom = from.getControl(AnimControl.class);
        AnimControl acTo = to.getControl(AnimControl.class);
        if (acFrom == null || acTo == null) {
            LOG.log(Level.WARNING, "from and to add need a AnimControl. from={0}, to={1}", new Object[] {from, to});
            return;
        }
        Collection<String> namesFrom = acFrom.getAnimationNames();
        if (namesFrom == null || namesFrom.isEmpty())
            return;
//        logger.log(Level.INFO, "Before add Animations:{0}", Arrays.toString(acTo.getAnimationNames().toArray()));
        for (String name : namesFrom) {
            Animation anim = acFrom.getAnim(name);
            acTo.addAnim(anim);
        }
//        logger.log(Level.INFO, "After add Animations:{0}", Arrays.toString(acTo.getAnimationNames().toArray()));
    }
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:25,代码来源:GeometryUtils.java


示例13: registerAction_PlayAnimation

import com.jme3.animation.Animation; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void registerAction_PlayAnimation(AnimationExplorer exp, SimpleApplication app) {
	exp.treeItemActions.add(new Action("play", (evt) -> {
		TreeItem<Object> treeItem = ((TreeItem<Object>)evt.getSource());
		Object target = treeItem.getValue();
		if (target instanceof Animation) {
			AnimControl ac = ((Spatial)treeItem.getParent().getValue()).getControl(AnimControl.class);
			ac.clearChannels();

			Animation ani = ((Animation)target);
			AnimChannel channel = ac.createChannel();
			channel.setAnim(ani.getName());
			channel.setLoopMode(LoopMode.DontLoop);
			channel.setSpeed(1f);
		}
	}));
}
 
开发者ID:davidB,项目名称:jme3_ext_spatial_explorer,代码行数:18,代码来源:Actions4Animation.java


示例14: exploreSpatial

import com.jme3.animation.Animation; //导入依赖的package包/类
void exploreSpatial(Spatial s) {
	AnimControl ac = s.getControl(AnimControl.class);
	if (ac != null) {
		TreeItem<Object> itemL1 = new TreeItem<>();
		itemL1.setValue(s);
		rootItem.getChildren().add(itemL1);
		for(String aname : ac.getAnimationNames()) {
			TreeItem<Object> animItem = new TreeItem<>();
			Animation anim = ac.getAnim(aname);
			animItem.setValue(anim);
			itemL1.getChildren().add(animItem);
			for(Track t : anim.getTracks()) {
				TreeItem<Object> trackItem = new TreeItem<>();
				trackItem.setValue(t);
				animItem.getChildren().add(trackItem);
			}
		}
	}
	rootItem.setExpanded(true);
}
 
开发者ID:davidB,项目名称:jme3_ext_spatial_explorer,代码行数:21,代码来源:AnimationExplorer.java


示例15: sampleCube

import com.jme3.animation.Animation; //导入依赖的package包/类
public static Spatial sampleCube(SimpleApplication app) {
	Geometry cube = Helper.makeShape("cube", new Box(0.5f, 0.5f, 0.5f), ColorRGBA.Brown, app.getAssetManager(), false);
	cube.setUserData("sample String", "string");
	cube.setUserData("sample int", 42);
	cube.setUserData("sample float", 42.0f);
	cube.setUserData("sample vector3f", new Vector3f(-2.0f, 3.0f, 4.0f));
	AnimControl ac = new AnimControl();
	Animation aniY = new Animation("Y basic translation", 10);
	aniY.addTrack(new SpatialTrack(new float[]{0, 5 , 10}, new Vector3f[]{new Vector3f(0, -5, 0), new Vector3f(0, 5, 0), new Vector3f(0, -5, 0)}, null, null));
	ac.addAnim(aniY);
	Animation aniX = new Animation("X basic translation", 10);
	aniX.addTrack(new SpatialTrack(new float[]{0, 5 , 10}, new Vector3f[]{new Vector3f(-5, 0, 0), new Vector3f(5, 0, 0), new Vector3f(-5, 0, 0)}, null, null));
	ac.addAnim(aniX);
	Animation aniZ = new Animation("Z basic translation", 10);
	aniZ.addTrack(new SpatialTrack(new float[]{0, 5 , 10}, new Vector3f[]{new Vector3f(0, 0, -5), new Vector3f(0, 0, 5), new Vector3f(0, 0, -5)}, null, null));
	ac.addAnim(aniZ);
	cube.addControl(ac);
	return cube;
}
 
开发者ID:davidB,项目名称:jme3_ext_spatial_explorer,代码行数:20,代码来源:Demo.java


示例16: computeAnimationTimeBoundaries

import com.jme3.animation.Animation; //导入依赖的package包/类
/**
 * Computes the maximum frame and time for the animation. Different tracks
 * can have different lengths so here the maximum one is being found.
 * 
 * @param animation
 *            the animation
 * @return maximum frame and time of the animation
 */
private float[] computeAnimationTimeBoundaries(Animation animation) {
    int maxFrame = Integer.MIN_VALUE;
    float maxTime = Float.MIN_VALUE;
    for (Track track : animation.getTracks()) {
        if (track instanceof BoneTrack) {
            maxFrame = Math.max(maxFrame, ((BoneTrack) track).getTranslations().length);
            maxTime = Math.max(maxTime, ((BoneTrack) track).getTimes()[((BoneTrack) track).getTimes().length - 1]);
        } else if (track instanceof SpatialTrack) {
            maxFrame = Math.max(maxFrame, ((SpatialTrack) track).getTranslations().length);
            maxTime = Math.max(maxTime, ((SpatialTrack) track).getTimes()[((SpatialTrack) track).getTimes().length - 1]);
        } else {
            throw new IllegalStateException("Unsupported track type for simuation: " + track);
        }
    }
    return new float[] { maxFrame, maxTime };
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:25,代码来源:SimulationNode.java


示例17: buildForImpl

import com.jme3.animation.Animation; //导入依赖的package包/类
@Override
@FXThread
protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent,
                            @NotNull final VBox container, @NotNull final ModelChangeConsumer changeConsumer) {

    if (object instanceof AbstractCinematicEvent) {
        build((AbstractCinematicEvent) object, container, changeConsumer);
    }  else if (object instanceof VehicleWheel) {
        build((VehicleWheel) object, container, changeConsumer);
    } else if (object instanceof Animation) {
        build((Animation) object, container, changeConsumer);
    }

    if (!(object instanceof Control)) return;

    if (object instanceof AbstractControl) {
        build((AbstractControl) object, container, changeConsumer);
    }

    super.buildForImpl(object, parent, container, changeConsumer);

    if (object instanceof SkeletonControl) {
        build((SkeletonControl) object, container, changeConsumer);
    } else if (object instanceof CharacterControl) {
        build((CharacterControl) object, container, changeConsumer);
    } else if (object instanceof RigidBodyControl) {
        build((RigidBodyControl) object, container, changeConsumer);
    } else if (object instanceof VehicleControl) {
        build((VehicleControl) object, container, changeConsumer);
    } else if (object instanceof MotionEvent) {
        build((MotionEvent) object, container, changeConsumer);
    }

    if (object instanceof PhysicsRigidBody) {
        build((PhysicsRigidBody) object, container, changeConsumer);
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:38,代码来源:DefaultControlPropertyBuilder.java


示例18: build

import com.jme3.animation.Animation; //导入依赖的package包/类
@FXThread
private void build(@NotNull final Animation animation, @NotNull final VBox container,
                   @NotNull final ModelChangeConsumer changeConsumer) {

    final float length = animation.getLength();

    final DefaultSinglePropertyControl<ModelChangeConsumer, Animation, Float> lengthControl =
            new DefaultSinglePropertyControl<>(length, Messages.MODEL_PROPERTY_LENGTH, changeConsumer);

    lengthControl.setSyncHandler(Animation::getLength);
    lengthControl.setToStringFunction(value -> Float.toString(value));
    lengthControl.setEditObject(animation);

    FXUtils.addToPane(lengthControl, container);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:16,代码来源:DefaultControlPropertyBuilder.java


示例19: processExtract

import com.jme3.animation.Animation; //导入依赖的package包/类
/**
 * Process of extraction a sub animation.
 */
@BackgroundThread
private void processExtract() {

    final AnimationTreeNode node = getNode();
    final AnimControl control = notNull(node.getControl());
    final Animation animation = node.getElement();

    final TextField nameField = getNameField();
    final IntegerTextField startFrameField = getStartFrameField();
    final IntegerTextField endFrameField = getEndFrameField();

    int startFrame = startFrameField.getValue();
    int endFrame = endFrameField.getValue();

    if (startFrame >= endFrame) {
        startFrame = endFrame - 1;
    }

    final Animation subAnimation = extractAnimation(animation, nameField.getText(), startFrame, endFrame);

    final NodeTree<?> nodeTree = getNodeTree();
    final ChangeConsumer changeConsumer = notNull(nodeTree.getChangeConsumer());
    changeConsumer.execute(new AddAnimationNodeOperation(subAnimation, control));

    EXECUTOR_MANAGER.addFXTask(EditorUtil::decrementLoading);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:30,代码来源:ExtractSubAnimationDialog.java


示例20: redoImpl

import com.jme3.animation.Animation; //导入依赖的package包/类
@Override
protected void redoImpl(@NotNull final ModelChangeConsumer editor) {
    EXECUTOR_MANAGER.addJMETask(() -> {
        final Animation anim = control.getAnim(oldName);
        AnimationUtils.changeName(control, anim, oldName, newName);
        EXECUTOR_MANAGER.addFXTask(() -> editor.notifyFXChangeProperty(control, anim, "name"));
    });
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:9,代码来源:RenameAnimationNodeOperation.java



注:本文中的com.jme3.animation.Animation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ReferenceType类代码示例发布时间:2022-05-23
下一篇:
Java Credential类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap