Beispiel #1
0
  /**
   * Adds a SMRotationInterpolator Behavior to the SMGroup
   *
   * @param duration
   * @param start
   * @param rotXAxis Angle about x in which the axis of rotation is going to be rotated
   * @param rotYAxis Angle about y in which the axis of rotation is going to be rotated
   * @param rotZAxis Angle about z in which the axis of rotation is going to be rotated
   * @param startAngle
   * @param finsishAngle
   */
  public void addRotationAnim(
      long duration,
      long start,
      double rotXAxis,
      double rotYAxis,
      double rotZAxis,
      float startAngle,
      float finishAngle) {
    // Creates a necessary TransformGroup for the SMRotationInterpolator
    TransformGroup tg = new TransformGroup();

    // Adds the animation between the child and it Parent
    Group parent = (Group) _child.getParent();
    parent.removeChild(_child);
    tg.addChild(_child);
    parent.addChild(tg);

    // Allows writing on TransfomGroup
    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    // Creates an Alpha function
    Alpha rotationAlpha = new Alpha(1, duration);
    rotationAlpha.setStartTime(System.currentTimeMillis() + start);

    // Calculates the axis of rotation
    Transform3D rX = new Transform3D();
    Transform3D rY = new Transform3D();
    Transform3D rZ = new Transform3D();
    rX.rotX(rotXAxis);
    rY.rotY(rotYAxis);
    rZ.rotZ(rotZAxis);
    rY.mul(rZ);
    rX.mul(rY);

    // Creates the SMRotationInterpolator
    SMRotationInterpolator rotator =
        new SMRotationInterpolator(rotationAlpha, tg, rX, startAngle, finishAngle, start);

    // Sets the area to render
    rotator.setSchedulingBounds(_bounds);

    // Adds the rotation animation to the TransformGroup
    tg.addChild(rotator);
  }