Examples of MTComponent


Examples of org.mt4j.components.MTComponent

            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));
View Full Code Here

Examples of org.mt4j.components.MTComponent

    material.setEmission(new float[]{ .0f, .0f, .0f, 1f });
    material.setSpecular(new float[]{ 0.9f, 0.9f, 0.9f, 1f })// almost white: very reflective
    material.setShininess(110);// 0=no shine,  127=max shine
   
    //Group used to move to the screen center and to put the mesh group in
    MTComponent group1 = new MTComponent(mtApplication);
   
    //Create a group and set the light for the whole mesh group ->better for performance than setting light to more comps
    final MTComponent meshGroup = new MTComponent(mtApplication, "Mesh group");
    meshGroup.setLight(light);
   
    //Desired position for the meshes to appear at
    Vector3D destinationPosition = new Vector3D(mtApplication.width/2, mtApplication.height/2, 50);
    //Desired scale for the meshes
    float destinationScale = mtApplication.width*0.85f;

    //Load the meshes with the ModelImporterFactory (A file can contain more than 1 mesh)
    //Loads 3ds model
    MTTriangleMesh[] meshes = ModelImporterFactory.loadModel(mtApplication, modelsPath + "jazz_Obj" + MTApplication.separator + "honda_jazz.obj", 180, true, false );
   
    //Get the biggest mesh in the group to use as a reference for setting the position/scale
    final MTTriangleMesh biggestMesh = this.getBiggestMesh(meshes);
   
    Vector3D translationToScreenCenter = new Vector3D(destinationPosition);
    translationToScreenCenter.subtractLocal(biggestMesh.getCenterPointGlobal());
   
    Vector3D scalingPoint = new Vector3D(biggestMesh.getCenterPointGlobal());
    float biggestWidth = biggestMesh.getWidthXY(TransformSpace.GLOBAL)
    float scale = destinationScale/biggestWidth;
   
    //Move the group the the desired position
    group1.scaleGlobal(scale, scale, scale, scalingPoint);
    group1.translateGlobal(translationToScreenCenter);
    this.getCanvas().addChild(group1);
    group1.addChild(meshGroup);
   
    //Inverts the normals, if they are calculated pointing inside of the mesh instead of outside
    boolean invertNormals = true;
   
    for (int i = 0; i < meshes.length; i++) {
      MTTriangleMesh mesh = meshes[i];
      meshGroup.addChild(mesh);
      mesh.unregisterAllInputProcessors(); //Clear previously registered input processors
      mesh.setPickable(true);

      if (invertNormals){
        Vector3D[] normals = mesh.getGeometryInfo().getNormals();
        for (int j = 0; j < normals.length; j++) {
          Vector3D vector3d = normals[j];
          vector3d.scaleLocal(-1);
        }
        mesh.getGeometryInfo().setNormals(mesh.getGeometryInfo().getNormals(), mesh.isUseDirectGL(), mesh.isUseVBOs());
      }

      //If the mesh has more than 20 vertices, use a display list for faster rendering
      if (mesh.getVertexCount() > 20)
        mesh.generateAndUseDisplayLists();
      //Set the material to the mesh  (determines the reaction to the lightning)
      if (mesh.getMaterial() == null)
        mesh.setMaterial(material);
      mesh.setDrawNormals(false);
    }
   
    //Register arcball gesture manipulation to the whole mesh-group
    meshGroup.setComposite(true); //-> Group gets picked instead of its children
    meshGroup.registerInputProcessor(new ArcballProcessor(mtApplication, biggestMesh));
    meshGroup.addGestureListener(ArcballProcessor.class, new IGestureEventListener(){
      //@Override
      public boolean processGestureEvent(MTGestureEvent ge) {
        ArcBallGestureEvent aEvt =  (ArcBallGestureEvent)ge;
        meshGroup.transform(aEvt.getTransformationMatrix());
        return false;
      }
    });
   
    meshGroup.registerInputProcessor(new ScaleProcessor(mtApplication));
    meshGroup.addGestureListener(ScaleProcessor.class, new IGestureEventListener(){
      //@Override
      public boolean processGestureEvent(MTGestureEvent ge) {
        ScaleEvent se = (ScaleEvent)ge;
        meshGroup.scaleGlobal(se.getScaleFactorX(), se.getScaleFactorY(), se.getScaleFactorX(), biggestMesh.getCenterPointGlobal());
        return false;
      }
    });
   
    meshGroup.registerInputProcessor(new RotateProcessor(mtApplication));
    meshGroup.addGestureListener(RotateProcessor.class, new DefaultRotateAction());
  }
View Full Code Here

Examples of org.mt4j.components.MTComponent

    initTiles();
  }
 
  private void initTiles(){
    SVGLoader l = new SVGLoader(app);
    MTComponent knob = l.loadSvg(svgPath + svgname);
    MTPolygon knobRight = (MTPolygon) knob.getChildByIndex(0).getChildByIndex(0);
    knobRight.setNoFill(false);
    knobRight.setUseDisplayList(false);
    float origHeight = knobRight.getHeightXY(TransformSpace.LOCAL);
   
    //Snap to upper left 0,0
View Full Code Here

Examples of org.mt4j.components.MTComponent

    this.registerGlobalInputProcessor(new CursorTracer(mtApplication, this));
   
    defaultCenterCam = new MTCamera(p);
   
    //Container for the foto tags on the map
    tagContainer = new MTComponent(p);
   
    //Container for the Fotos
    fotoContainer = new MTComponent(p);
    fotoContainer.attachCamera(defaultCenterCam);
   
    //Container for the buttons
    buttonContainer = new MTComponent(p);
    buttonContainer.attachCamera(defaultCenterCam);
   
    //Create map
    AbstractMapProvider mapProvider = new Microsoft.HybridProvider();
    map = new TestInteractiveMap(mtApplication, mapProvider);
View Full Code Here

Examples of org.mt4j.components.MTComponent

   */
  private void updateTagShapeScale(float scale){
    MTComponent[] tags = tagContainer.getChildren();
    float scX = 1f/scale;
    for (int i = 0; i < tags.length; i++) {
      MTComponent baseComponent = tags[i];
      if (baseComponent instanceof AbstractShape) {
        AbstractShape shape = (AbstractShape) baseComponent;
//        System.out.println("Scaling: " + scX + " " + scY);
//        shape.scale(scX, scY, 1, shape.getCenterPointGlobal(), TransformSpace.GLOBAL);
        shape.scale(scX, scX, 1, shape.getCenterPointRelativeToParent(), TransformSpace.RELATIVE_TO_PARENT);
View Full Code Here

Examples of org.mt4j.components.MTComponent

    this.getCanvas().setDepthBufferDisabled(true); //to avoid display errors because everything is 2D
   
    MTBackgroundImage background = new MTBackgroundImage(mtApplication, mtApplication.loadImage(imagesPath + "webtreats_wood-pattern1-512d.jpg") , true);
    this.getCanvas().addChild(background);
   
    this.puzzleGroup = new MTComponent(mtApplication);
    this.getCanvas().addChild(puzzleGroup);
   
    //Puzzle tile factory
    this.pf = new PuzzleFactory(getMTApplication());
   
View Full Code Here

Examples of org.mt4j.components.MTComponent

    this.getCanvas().addGestureListener(PanProcessorTwoFingers.class, new DefaultPanAction());

    this.getCanvas().registerInputProcessor(new ZoomProcessor(app));
    this.getCanvas().addGestureListener(ZoomProcessor.class, new DefaultZoomAction());
   
    pictureLayer = new MTComponent(app);
   
    MTComponent topLayer = new MTComponent(app, "top layer group", new MTCamera(app));
   
    //Load from file system
//    PImage keyboardImg = app.loadImage(System.getProperty("user.dir")+File.separator + "examples"+  File.separator +"advanced"+ File.separator+ File.separator + "flickrMT"+ File.separator +  File.separator + "data"+ File.separator
////    + "keyb2.png");
//    + "keyb128.png");
    //Load from classpath
    PImage keyboardImg = app.loadImage("advanced" + MTApplication.separator + "flickrMT"+ MTApplication.separator + "data"+ MTApplication.separator
//        + "keyb2.png");
        + "keyb128.png");
   
    final MTImageButton keyboardButton = new MTImageButton(keyboardImg, app);
    keyboardButton.setFillColor(new MTColor(255,255,255,200));
    keyboardButton.setName("KeyboardButton");
    keyboardButton.setNoStroke(true);
//    keyboardButton.translateGlobal(new Vector3D(5,5,0));
    keyboardButton.translateGlobal(new Vector3D(-2,app.height-keyboardButton.getWidthXY(TransformSpace.GLOBAL)+2,0));
    topLayer.addChild(keyboardButton);

//    progressBar = new MTProgressBar(app, app.loadFont(MT4jSettings.getInstance().getDefaultFontPath()+ "Ziggurat.vlw"));
    progressBar = new MTProgressBar(app, app.createFont("arial", 18));
   
    progressBar.setDepthBufferDisabled(true);
    progressBar.setVisible(false);
    topLayer.addChild(progressBar);
   
    keyboardButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent ae) {
        switch (ae.getID()) {
        case TapEvent.BUTTON_CLICKED:
View Full Code Here

Examples of org.mt4j.components.MTComponent

        if (instance.getCurrentScene() != null){
          instance.invokeLater(new Runnable() {
            public void run() {
              MTComponent[] ch = instance.getCurrentScene().getCanvas().getChildren();
              for (int i = 0; i < ch.length; i++) {
                MTComponent mtComponent = ch[i];
                if (!(mtComponent instanceof MTOverlayContainer)){
                  mtComponent.destroy()
                }
              }
            }
          });
         
View Full Code Here

Examples of org.mt4j.components.MTComponent

      this.addChild(keybCloseSvg);
    }else{
      //Remove svg button and destroy child display lists
      MTComponent[] childs = this.getChildren();
      for (int i = 0; i < childs.length; i++) {
        MTComponent component = childs[i];
        if (component.getName().equals("closeButton")) {
          MTSvgButton svgButton = (MTSvgButton) component;
          svgButton.destroy();
        }
      }
    }
View Full Code Here

Examples of org.mt4j.components.MTComponent

      public void actionPerformed(ActionEvent arg0) {
        switch (arg0.getID()) {
        case TapEvent.BUTTON_CLICKED:
          //Get the first polygon type out of the array
          for (int i = 0; i < comps.length; i++) { //TODO this is stupid.. redo this whole thing
            MTComponent comp = comps[i];
            if (comp instanceof MTPolygon) {
              MTPolygon poly = (MTPolygon) comp;
              if (referencePoly == null){//nur 1. occur zuweisen
                referencePoly = poly;
              }
            }
          }
          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
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.