Package org.mt4j.util.animation

Examples of org.mt4j.util.animation.Animation


    earth.rotateX(earth.getCenterPointRelativeToParent(), -90);
    earth.setTexture(new GLTexture(pa,imagesPath + "worldMap.jpg", new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.CLAMP_TO_EDGE, WRAP_MODE.CLAMP_TO_EDGE)));
        earth.generateAndUseDisplayLists();
        earth.setPositionGlobal(new Vector3D(pa.width/2f, pa.height/2f, 250)); //earth.setPositionGlobal(new Vector3D(200, 200, 250));
        //Animate earth rotation
        new Animation("rotation animation", new MultiPurposeInterpolator(0,360, 17000, 0, 1, -1) , earth).addAnimationListener(new IAnimationListener(){
          public void processAnimationEvent(AnimationEvent ae) {
            earth.rotateY(earth.getCenterPointLocal(), ae.getCurrentStepDelta(), TransformSpace.LOCAL);
          }}).start();
       
        //Put planets in a group that can be manipulated by gestures
        //so the rotation of the planets doesent get changed by the gestures
    MTComponent group = new MTComponent(mtApplication);
    group.setComposite(true); //This makes the group "consume" all picking and gestures of the children
    group.registerInputProcessor(new DragProcessor(mtApplication));
    group.addGestureListener(DragProcessor.class, new DefaultDragAction());
    group.addGestureListener(DragProcessor.class, new InertiaDragAction(80, 0.8f, 10));
    group.registerInputProcessor(new RotateProcessor(mtApplication));
    group.addGestureListener(RotateProcessor.class, new DefaultRotateAction());
    //Scale the earth from the center. Else it might get distorted
    group.registerInputProcessor(new ScaleProcessor(mtApplication));
    group.addGestureListener(ScaleProcessor.class, new IGestureEventListener() {
      public boolean processGestureEvent(MTGestureEvent ge) {
        ScaleEvent se = (ScaleEvent)ge;
        earth.scaleGlobal(se.getScaleFactorX(), se.getScaleFactorY(), se.getScaleFactorX(), earth.getCenterPointGlobal());
        return false;
      }
    });
    this.getCanvas().addChild(group);
        group.addChild(earth);
       
        //Create the moon
        final MTSphere moonSphere = new MTSphere(pa, "moon", 35, 35, 25, TextureMode.Polar);
         moonSphere.setMaterial(material);
        moonSphere.translate(new Vector3D(earth.getRadius() + moonSphere.getRadius() + 50, 0,0));
        moonSphere.setTexture(new GLTexture(pa, imagesPath + "moonmap1k.jpg", new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.CLAMP_TO_EDGE, WRAP_MODE.CLAMP_TO_EDGE)));
        moonSphere.generateAndUseDisplayLists();
        moonSphere.unregisterAllInputProcessors();
        //Rotate the moon around the earth
        new Animation("moon animation", new MultiPurposeInterpolator(0,360, 12000, 0, 1, -1) , moonSphere).addAnimationListener(new IAnimationListener(){
          public void processAnimationEvent(AnimationEvent ae) {
            moonSphere.rotateZ(earth.getCenterPointLocal(), ae.getCurrentStepDelta(), TransformSpace.RELATIVE_TO_PARENT);
          }}).start();
        //Rotate the moon around ints own center
        new Animation("moon animation around own axis", new MultiPurposeInterpolator(0,360, 9000, 0, 1, -1) , moonSphere).addAnimationListener(new IAnimationListener(){
          public void processAnimationEvent(AnimationEvent ae) {
            moonSphere.rotateZ(moonSphere.getCenterPointLocal(), -3*ae.getCurrentStepDelta(), TransformSpace.LOCAL);
            moonSphere.rotateY(moonSphere.getCenterPointLocal(), 0.5f*ae.getCurrentStepDelta(), TransformSpace.LOCAL);
          }}).start();
        earth.addChild(moonSphere);
View Full Code Here


    list.addListElement(this.createListCell("Cloudmade Tourist", font, new CloudMade.Tourist(), cellWidth, cellHeight, cellFillColor, cellPressedFillColor));
    list.addListElement(this.createListCell("Blue Marble", font, new BlueMarble(), cellWidth, cellHeight, cellFillColor, cellPressedFillColor));
    list.addListElement(this.createListCell("Daily Planet", font, new DailyPlanet(), cellWidth, cellHeight, cellFillColor, cellPressedFillColor));
   
    MultiPurposeInterpolator in = new MultiPurposeInterpolator(0,170, 700, 0.1f, 0.7f, 1);
    final Animation slideOut = new Animation("slide out animation", in, mapMenu);
    slideOut.addAnimationListener(new IAnimationListener() {
      public void processAnimationEvent(AnimationEvent ae) {
        float delta = ae.getCurrentStepDelta();
        ((IMTComponent3D)ae.getTargetObject()).translateGlobal(new Vector3D(delta,0,0));
        switch (ae.getId()) {
        case AnimationEvent.ANIMATION_ENDED:
          doSlideIn = true;
          animationRunning = false;
          break;
        }
      }
    });
   
    final Animation slideIn = new Animation("slide out animation", in, mapMenu);
    slideIn.addAnimationListener(new IAnimationListener() {
      public void processAnimationEvent(AnimationEvent ae) {
        float delta = -ae.getCurrentStepDelta();
        ((IMTComponent3D)ae.getTargetObject()).translateGlobal(new Vector3D(delta,0,0));
        switch (ae.getId()) {
        case AnimationEvent.ANIMATION_ENDED:
          doSlideIn = false;
          animationRunning = false;
          break;
        }
      }
    });
   
    mapMenu.unregisterAllInputProcessors();
    mapMenu.registerInputProcessor(new TapProcessor(mtApplication, 50));
    mapMenu.addGestureListener(TapProcessor.class, new IGestureEventListener() {
      public boolean processGestureEvent(MTGestureEvent ge) {
        if (((TapEvent)ge).getTapID() == TapEvent.BUTTON_CLICKED){
          if (!animationRunning){
            animationRunning = true;
            if (doSlideIn){
              slideIn.start();
            }else{
              slideOut.start();
            }
          }
        }
View Full Code Here

              }
            }
          }
          float width = referencePoly.getWidthXY(TransformSpace.RELATIVE_TO_PARENT);

          Animation closeAnim = new Animation("comp Fade", new MultiPurposeInterpolator(width, 1, 300, 0.5f, 0.8f, 1), referencePoly);
          closeAnim.addAnimationListener(new IAnimationListener(){
            public void processAnimationEvent(AnimationEvent ae) {
              switch (ae.getId()) {
              case AnimationEvent.ANIMATION_STARTED:
              case AnimationEvent.ANIMATION_UPDATED:
                float currentVal = ae.getAnimation().getInterpolator().getCurrentValue();
                resize(referencePoly, comps[0], currentVal, currentVal);
                break;
              case AnimationEvent.ANIMATION_ENDED:
                comps[0].setVisible(false);
                for (int i = comps.length-1; i >0 ; i--) {
                  MTComponent currentComp =  comps[i];
                  //Call destroy which fires a destroy state change event
                  currentComp.destroy();
                  //System.out.println("destroyed: " + currentComp.getName());
                }
                destroy();
                //System.out.println("destroyed: " + getName());
                break
              default:
                destroy();
                break;
              }//switch
            }//processanimation
          });//new IAnimationListener
          closeAnim.start();
          break;
        default:
          break;
        }//switch aeID
      }
View Full Code Here

   
    this.setClear(true);
     
    finished = false;
   
    anim2 = new Animation("Fade animation 2", new MultiPurposeInterpolator(255,0, this.duration/2f, 0, 0.8f, 1) , this).addAnimationListener(new IAnimationListener(){
      //@Override
      public void processAnimationEvent(AnimationEvent ae) {
        switch (ae.getId()) {
        case AnimationEvent.ANIMATION_STARTED:
        case AnimationEvent.ANIMATION_UPDATED:
          fullScreenQuad.setFillColor(new MTColor(0,0,0, ae.getAnimation().getInterpolator().getCurrentValue()));
          break;
        case AnimationEvent.ANIMATION_ENDED:
          fullScreenQuad.setFillColor(new MTColor(0,0,0, ae.getAnimation().getInterpolator().getCurrentValue()));
          finished = true;
          break;
        default:
          break;
        }
      }});
    anim2.setResetOnFinish(true);
   
        anim = new Animation("Fade animation 1", new MultiPurposeInterpolator(0,255, this.duration/2f, 0, 1, 1) , this).addAnimationListener(new IAnimationListener(){
          //@Override
          public void processAnimationEvent(AnimationEvent ae) {
            switch (ae.getId()) {
        case AnimationEvent.ANIMATION_STARTED:
        case AnimationEvent.ANIMATION_UPDATED:
View Full Code Here

    super(mtApplication, "Blend Transition");
    this.app = mtApplication;
    this.duration = duration;
    this.finished = true;
   
    anim = new Animation("Blend animation ", new MultiPurposeInterpolator(255,0, this.duration, 0, 0.7f, 1) , this).addAnimationListener(new IAnimationListener(){
      public void processAnimationEvent(AnimationEvent ae) {
        float val = ae.getAnimation().getInterpolator().getCurrentValue();
        switch (ae.getId()) {
        case AnimationEvent.ANIMATION_STARTED:
          lastSceneRectangle.setVisible(true);
View Full Code Here

    super(mtApplication, "Slide Transition");
    this.app = mtApplication;
    this.duration = duration;
    this.finished = true;
   
    anim = new Animation("Flip animation 2", new MultiPurposeInterpolator(app.width, 0, this.duration, 0.0f, 0.7f, 1) , this).addAnimationListener(new IAnimationListener(){
      //@Override
      public void processAnimationEvent(AnimationEvent ae) {
        switch (ae.getId()) {
        case AnimationEvent.ANIMATION_STARTED:
        case AnimationEvent.ANIMATION_UPDATED:
View Full Code Here

    super(mtApplication, "Flip Transition");
    this.app = mtApplication;
    this.duration = duration;
    this.finished = true;
   
    anim2 = new Animation("Flip animation 2", new MultiPurposeInterpolator(0,90, this.duration/2f, 0, 0.5f, 1) , this).addAnimationListener(new IAnimationListener(){
      //@Override
      public void processAnimationEvent(AnimationEvent ae) {
        switch (ae.getId()) {
        case AnimationEvent.ANIMATION_STARTED:
        case AnimationEvent.ANIMATION_UPDATED:
//          nextSceneWindow.rotateYGlobal(lastSceneWindow.getCenterPointGlobal(), ae.getAnimation().getInterpolator().getCurrentStepDelta());
          nextSceneRectangle.rotateYGlobal(lastSceneWindow.getCenterPointGlobal(), ae.getAnimation().getInterpolator().getCurrentStepDelta());
          break;
        case AnimationEvent.ANIMATION_ENDED:
          nextSceneRectangle.rotateYGlobal(lastSceneWindow.getCenterPointGlobal(), ae.getAnimation().getInterpolator().getCurrentStepDelta());
          finished = true;
          break;
        default:
          break;
        }
      }});
    anim2.setResetOnFinish(true);
   
        anim = new Animation("Flip animation 1", new MultiPurposeInterpolator(0,90, this.duration/2f, 0.5f, 1, 1) , this).addAnimationListener(new IAnimationListener(){
          //@Override
          public void processAnimationEvent(AnimationEvent ae) {
            switch (ae.getId()) {
        case AnimationEvent.ANIMATION_STARTED:
        case AnimationEvent.ANIMATION_UPDATED:
View Full Code Here

   
  }
 
  public void close(){
    float width = this.getWidthXY(TransformSpace.RELATIVE_TO_PARENT);
    Animation closeAnim = new Animation("Window Fade", new MultiPurposeInterpolator(width, 1, 350, 0.2f, 0.5f, 1), this);
    closeAnim.addAnimationListener(new IAnimationListener(){
      public void processAnimationEvent(AnimationEvent ae) {
//        float delta = ae.getAnimation().getInterpolator().getCurrentStepDelta();
        switch (ae.getId()) {
        case AnimationEvent.ANIMATION_STARTED:
        case AnimationEvent.ANIMATION_UPDATED:
          float currentVal = ae.getAnimation().getInterpolator().getCurrentValue();
          setWidthXYRelativeToParent(currentVal);
          break;
        case AnimationEvent.ANIMATION_ENDED:
          setVisible(false);
          destroy();
          break
        default:
          break;
        }//switch
      }//processanimation
    });
    closeAnim.start();
  }
View Full Code Here

    Vector3D directionVect   = targetPoint.getSubtracted(from);
   
    //GO through all animations for this shape
    Animation[] animations = AnimationManager.getInstance().getAnimationsForTarget(this);
    for (int i = 0; i < animations.length; i++) {
      Animation animation = animations[i];
     
      //Go through all listeners of these animations
      IAnimationListener[] animationListeners = animation.getAnimationListeners();
      for (int j = 0; j < animationListeners.length; j++) {
        IAnimationListener listener = animationListeners[j];
        //IF a listener is a TranslationAnimationListener the animations is a translationTween
        //and should be stopped before doing this new animation
        if (listener instanceof TranslationAnimationListener)
          animation.stop();
      }
    }
    return this.tweenTranslate(directionVect, interpolationDuration, accelerationEndTime, decelerationStartTime);
  }
View Full Code Here

   * @return the animation
   */
  public Animation tweenTranslate(Vector3D directionVect, float interpolationDuration, float accelerationEndTime, float decelerationStartTime, int triggerDelay){
    float distance = directionVect.length();
    MultiPurposeInterpolator interpolator = new MultiPurposeInterpolator(0, distance, interpolationDuration , accelerationEndTime, decelerationStartTime , 1);
    Animation animation = new Animation("Tween translate of " + this.getName(), interpolator, this, triggerDelay);
    animation.addAnimationListener(new TranslationAnimationListener(this, directionVect));
    animation.setResetOnFinish(false);
    animation.start();
    return animation;
  }
View Full Code Here

TOP

Related Classes of org.mt4j.util.animation.Animation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.