@SuppressWarnings("unchecked")
  public void read(JMEImporter e) throws IOException {
    super.read(e);
    InputCapsule capsule = e.getCapsule(this);

    numObjects = capsule.readInt("numObjects", 0);

    Savable[] savs = capsule.readSavableArray("toChange", new Spatial[0]);
    if (savs == null) {
      toChange = null;
    } else {
      toChange = new Spatial[savs.length];
      for (int x = 0; x < savs.length; x++) {
        toChange[x] = (Spatial) savs[x];
      }
    }

    savs = capsule.readSavableArray("pivots", new TransformQuaternion[0]);
    if (savs == null) {
      pivots = null;
    } else {
      pivots = new TransformQuaternion[savs.length];
      for (int x = 0; x < savs.length; x++) {
        pivots[x] = (TransformQuaternion) savs[x];
      }
    }

    parentIndexes = capsule.readIntArray("parentIndexes", new int[0]);
    keyframes = capsule.readSavableArrayList("keyframes", new ArrayList());
    haveChanged = capsule.readBooleanArray("haveChanged", new boolean[0]);

    beginPointTime = (PointInTime) capsule.readSavable("beginPointTime", null);
    endPointTime = (PointInTime) capsule.readSavable("endPointTime", null);
  }
Exemplo n.º 2
0
  /** <b>This method foces interpolation mode, regardless of input</b> */
  @SuppressWarnings("unchecked")
  public void read(JMEImporter e) throws IOException {
    InputCapsule cap = e.getCapsule(this);
    name = cap.readString("name", null);
    keyframeTime = cap.readFloatArray("keyframeTime", null);
    interpolationType = cap.readIntArray("interpolationType", null);
    boneTransforms = cap.readSavableArrayList("boneTransforms", null);
    currentTime = cap.readFloat("currentTime", 0);
    currentFrame = cap.readInt("currentFrame", 1);
    prevFrame = cap.readInt("prevFrame", 0);
    endFrame = cap.readInt("endFrame", 0);
    startFrame = cap.readInt("startFrame", 0);
    interpolationRate = cap.readFloat("interpolationRate", DEFAULT_RATE);
    lastTime = cap.readFloat("lastTime", 0);
    cycleMode = cap.readInt("cycleMode", 1);
    interpolate = cap.readBoolean("interpolate", true);
    children = cap.readSavableArrayList("children", null);

    int[] frames = cap.readIntArray("eventFrames", null);

    if (frames != null) {
      for (int i = 0; i < frames.length; i++) {
        ArrayList<Savable> events = cap.readSavableArrayList("event" + frames[i], null);
        for (int j = 0; j < events.size(); j++) {
          AnimationEventManager.getInstance()
              .addAnimationEvent(this, frames[i], (AnimationEvent) events.get(i));
        }
      }
    }

    // Update the method Javadoc when non-interpolation is supported again.
    interpolationType = new int[keyframeTime.length];
    for (int i = 0; i < keyframeTime.length; i++) {
      interpolationType[i] = BoneAnimation.LINEAR;
    }
  }