com.jme3.animation.Animation类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中com.jme3.animation.Animation类的一些代码示例,展示了Animation类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Animation类的具体详情如下:
包路径:com.jme3.animation.Animation
类名称:Animation

Animation介绍

[英]The animation class updates the animation target with the tracks of a given type.
[中]动画类使用给定类型的轨迹更新动画目标。

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * Creates an Animation based on the keyFrames previously added to the helper.
 * @return the generated animation 
 */
public Animation buildAnimation() {
  interpolateTime();
  interpolate(keyFramesTranslation, Type.Translation);
  interpolate(keyFramesRotation, Type.Rotation);
  interpolate(keyFramesScale, Type.Scale);
  SpatialTrack spatialTrack = new SpatialTrack(times, translations, rotations, scales);
  //creating the animation
  Animation spatialAnimation = new Animation(name, duration);
  spatialAnimation.setTracks(new SpatialTrack[]{spatialTrack});
  return spatialAnimation;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

SpatialTrack[] tracks = action.toTracks(node, blenderContext);
if (tracks != null && tracks.length > 0) {
  Animation spatialAnimation = new Animation(action.getName(), action.getAnimationTime());
  spatialAnimation.setTracks(tracks);
  animations.add(spatialAnimation);
  blenderContext.addAnimation((Long) node.getUserData(ObjectHelper.OMA_MARKER), spatialAnimation);
for (int i = 0; i < animations.size(); ++i) {
  Animation animation = animations.get(i);
  anims.put(animation.getName(), animation);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

float animStart = animInfo.firstFrame / this.animFrameRate;
float animStop = animInfo.lastFrame / this.animFrameRate;
Animation anim = new Animation(animInfo.name, length);
  else
    track = new BoneTrack(limb.boneIndex, times, translations, rotations);
  anim.addTrack(track);
  Track[] tracks = anim.getTracks();
  if(tracks == null || tracks.length == 0)
    continue;
  anim = new Animation(animInfo.name, realLength);
  for(Track track : tracks)
    anim.addTrack(track);
anims.put(anim.getName(), anim);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

blendFrom.setTime(timeBlendFrom, 1f - blendAmount, control, this, vars);
                 blendFrom.getLength(),
                 loopModeBlendFrom);
  if (timeBlendFrom < 0){
animation.setTime(time, blendAmount, control, this, vars);
time += tpf * speed;      
if (animation.getLength() > 0){
  if (!notified && (time >= animation.getLength() || time < 0)) {
    if (loopMode == LoopMode.DontLoop) {
    control.notifyAnimCycleDone(this, animation.getName());
time = AnimationUtils.clampWrapTime(time, animation.getLength(), loopMode);
if (time < 0){

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

anim = new Animation(animName, duration);
    animControl.addAnim(anim);
  anim.addTrack(bt);
} else {
  Animation anim = new Animation(animName, duration);
  anim.setTracks(new Track[]{ pair.toJmeSpatialTrack() });

代码示例来源:origin: us.ihmc.thirdparty.jme/jme3-plugins

float animStart = animInfo.firstFrame / this.animFrameRate;
float animStop = animInfo.lastFrame / this.animFrameRate;
Animation anim = new Animation(animInfo.name, length);
  else
    track = new BoneTrack(limb.boneIndex, times, translations, rotations);
  anim.addTrack(track);
anims.put(anim.getName(), anim);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * @return The name of the currently playing animation, or null if
 * none is assigned.
 *
 * @see AnimChannel#setAnim(java.lang.String) 
 */
public String getAnimationName() {
  return animation != null ? animation.getName() : null;
}

代码示例来源:origin: org.jmonkeyengine/jme3-plugins

Animation anim = new Animation();
anim.setName(name);
int skinIndex = -1;
  if (trackData.length > anim.getLength()) {
    anim.setLength(trackData.length);
    SpatialTrack track = new SpatialTrack(trackData.times, trackData.translations, trackData.rotations, trackData.scales);
    track.setTrackSpatial(s);
    anim.addTrack(track);
  } else if (node instanceof BoneWrapper) {
    BoneWrapper b = (BoneWrapper) node;
    anim.addTrack(track);
    if (!usedBones.contains(bone) && !equalBindAndLocalTransforms(bone)) {
      float[] times = new float[]{0, anim.getLength()};
      anim.addTrack(track);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
   * No ClassCastException when clear() a Cinematic with AnimationEvent
   */
  @Test
  public void clearAnimationEvent() {
    Cinematic sut = new Cinematic();
    Node model = new Node("model");
    AnimControl ac = new AnimControl();
    ac.addAnim(new Animation("animName", 1.0f));
    model.addControl(ac);
    sut.enqueueCinematicEvent(new AnimationEvent(model, "animName"));
    sut.initialize(null, null);
    sut.clear();
  }
}

代码示例来源:origin: us.ihmc.thirdparty.jme/jme3-plugins

animation.setTracks(trackList);
  tracks.clear();
} else if (qName.equals("keyframe")) {

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

for (Track track : animation.getTracks()) {
  float time = ((BoneTrack) track).getTimes()[frame];
  track.setTime(time, 1, animControl, animChannel, vars);
if (newTrack != null) {
  boolean trackReplaced = false;
  for (Track track : animation.getTracks()) {
    if (((BoneTrack) track).getTargetBoneIndex() == trackEntry.getKey().intValue()) {
      animation.removeTrack(track);
      animation.addTrack(newTrack);
      trackReplaced = true;
      break;
    animation.addTrack(newTrack);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * @return The length of the currently playing animation, or zero
 * if no animation is playing.
 *
 * @see AnimChannel#getTime()
 */
public float getAnimMaxTime(){
  return animation != null ? animation.getLength() : 0f;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * 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.MAX_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 };
}

代码示例来源:origin: org.jmonkeyengine/jme3-plugins

anim = new Animation(animName, duration);
    animControl.addAnim(anim);
  anim.addTrack(bt);
} else {
  Animation anim = new Animation(animName, duration);
  anim.setTracks(new Track[]{ pair.toJmeSpatialTrack() });

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * Adds an animation to be available for playing to this
 * <code>AnimControl</code>.
 * @param anim The animation to add.
 */
public void addAnim(Animation anim) {
  animationMap.put(anim.getName(), anim);
}

代码示例来源:origin: info.projectkyoto/mms-engine

blendFrom.setTime(timeBlendFrom, 1f - blendAmount, control, this, vars);
                 blendFrom.getLength(),
                 loopModeBlendFrom);
  if (timeBlendFrom < 0){
animation.setTime(time, blendAmount, control, this, vars);
time += tpf * speed;
if (animation.getLength() > 0){
  if (!notified && (time >= animation.getLength() || time < 0)) {
    if (loopMode == LoopMode.DontLoop) {
    control.notifyAnimCycleDone(this, animation.getName());
time = clampWrapTime(time, animation.getLength(), loopMode);
if (time < 0){

代码示例来源:origin: org.jmonkeyengine/jme3-plugins

String name = SAXUtil.parseString(attribs.getValue("name"));
  float length = SAXUtil.parseFloat(attribs.getValue("length"));
  animation = new Animation(name, length);
} else if (qName.equals("bonehierarchy")) {
  assert elementStack.peek().equals("skeleton");

代码示例来源:origin: org.jmonkeyengine/jme3-plugins

animation.setTracks(trackList);
  tracks.clear();
} else if (qName.equals("keyframe")) {

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

for (Track track : animation.getTracks()) {
  for (int frame = 0; frame < maxFrame; ++frame) {
    spatial.setLocalTranslation(((SpatialTrack) track).getTranslations()[frame]);
    animation.removeTrack(track);
    animation.addTrack(newTrack);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * @param speed Set the speed of the animation channel. The speed
 * is a scale value starting from 0.0, at 1.0 the animation will play
 * at its default speed.
 */
public void setSpeed(float speed) {
  this.speed = speed;
  if(blendTime>0){
    this.speedBlendFrom = speed;
    blendTime = Math.min(blendTime, animation.getLength() / speed);  
    blendRate = 1/ blendTime;
  }
}

相关文章