本文整理汇总了Java中com.jme3.animation.Animation类的典型用法代码示例。如果您正苦于以下问题:Java Animation类的具体用法?Java Animation怎么用?Java Animation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Animation类属于com.jme3.animation包,在下文中一共展示了Animation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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));
}
示例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;
}
示例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);
}
}
示例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};
}
示例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));
}
示例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();
}
}
示例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();
}
}
示例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));
}
示例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());
}
}
});
}
示例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;
}
示例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()));
}
示例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);
}
}));
}
示例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);
}
示例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;
}