Package org.mt4j.util.math

Examples of org.mt4j.util.math.Vector3D


  //Global input processor listener implementation (IMTInputEventListener)
  public boolean processInputEvent(MTInputEvent inEvt) {
    if (inEvt instanceof MTFiducialInputEvt) {
      MTFiducialInputEvt fEvt = (MTFiducialInputEvt)inEvt;
      int fID = fEvt.getFiducialId();
      Vector3D position = fEvt.getPosition();

      AbstractShape comp;
      switch (fEvt.getId()) {
      case MTFiducialInputEvt.INPUT_DETECTED:
        //Create a new component for the fiducial
View Full Code Here


    return false;
  }


  private AbstractShape createComponent(int id, Vector3D pos){
    MTEllipse comp = new MTEllipse(app, new Vector3D(pos), 50,50, 50);
    comp.setNoFill(false);
    float r = ToolsMath.getRandom(20, 255);
    float g = ToolsMath.getRandom(20, 255);
    float b = ToolsMath.getRandom(20, 255);
    comp.setFillColor(new MTColor(r, g, b, 200));
View Full Code Here

   */
  private class MapDrag implements IGestureEventListener{
    public boolean processGestureEvent(MTGestureEvent g) {
      if (g instanceof DragEvent){
        DragEvent dragEvent = (DragEvent)g;
        Vector3D tVect = dragEvent.getTranslationVect();
        map.move(tVect.x, tVect.y);
        /*
        transVect.setXYZ(tVect.x, tVect.y, 0);
        fotoTagContainer.translate(transVect);
        */
 
View Full Code Here

        50, new MTColor(255, 255, 255, 255), new MTColor(255, 255, 255, 255)));
    textField.setNoFill(true);
    textField.setNoStroke(true);
    textField.setText("Scene 3");
    this.getCanvas().addChild(textField);
    textField.setPositionGlobal(new Vector3D(mtApplication.width/2f, mtApplication.height/2f));
   
    //Button to return to the previous scene
    PImage arrow = mtApplication.loadImage(imagePath + "arrowRight.png");
    MTImageButton previousSceneButton = new MTImageButton(arrow, mtApplication);
    previousSceneButton.setNoStroke(true);
    if (MT4jSettings.getInstance().isOpenGlMode())
      previousSceneButton.setUseDirectGL(true);
    previousSceneButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
        switch (ae.getID()) {
        case TapEvent.BUTTON_CLICKED:
          mtApp.popScene();
          break;
        default:
          break;
        }
      }
    });
    getCanvas().addChild(previousSceneButton);
    previousSceneButton.scale(-1, 1, 1, previousSceneButton.getCenterPointLocal(), TransformSpace.LOCAL);
    previousSceneButton.setPositionGlobal(new Vector3D(previousSceneButton.getWidthXY(TransformSpace.GLOBAL) + 5, mtApp.height - previousSceneButton.getHeightXY(TransformSpace.GLOBAL) - 5, 0));
   
    //Set a scene transition - Flip transition only available using opengl supporting the FBO extenstion
    if (MT4jSettings.getInstance().isOpenGlMode() && GLFBO.isSupported(mtApp))
      this.setTransition(new FlipTransition(mtApp, 700));
    else{
View Full Code Here

            public void run() {
              MTRectangle r = new MTRectangle(0,0,ToolsMath.getRandom(50, 250),ToolsMath.getRandom(50, 250), instance);
              r.setFillColor(new MTColor(ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255)));
              r.addGestureListener(DragProcessor.class, new InertiaDragAction());
              instance.getCurrentScene().getCanvas().addChild(r);
              r.setPositionGlobal(new Vector3D(ToolsMath.getRandom(0, instance.width), ToolsMath.getRandom(0, instance.height)));
            }
          });
         
        }
      }
    });
        menu.add(addRectItem);
       
        JMenuItem addRoundRectItem = new JMenuItem("MTRoundRectangle", KeyEvent.VK_E);
        addRoundRectItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0) {
        if (instance.getCurrentScene() != null){
          //If we want to modify the MT4j applet from the swing thread
          //we should wrap the actions into an invokeLater runnable which
          //will be executed the next time the mt4j thread runs.
          instance.invokeLater(new Runnable() {
            public void run() {
              float arc = ToolsMath.getRandom(8, 25);
              MTRoundRectangle r = new MTRoundRectangle(0,0,0, ToolsMath.getRandom(50, 250),ToolsMath.getRandom(50, 250), arc, arc, instance);
              r.setFillColor(new MTColor(ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255)));
              r.addGestureListener(DragProcessor.class, new InertiaDragAction());
              instance.getCurrentScene().getCanvas().addChild(r);
              r.setPositionGlobal(new Vector3D(ToolsMath.getRandom(0, instance.width), ToolsMath.getRandom(0, instance.height)));
            }
          });
         
        }
      }
    });
        menu.add(addRoundRectItem);
       
        JMenuItem addEllItem = new JMenuItem("MTEllipse", KeyEvent.VK_E);
        addEllItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0) {
        if (instance.getCurrentScene() != null){
          //If we want to modify the MT4j applet from the swing thread
          //we should wrap the actions into an invokeLater runnable which
          //will be executed the next time the mt4j thread runs.
          instance.invokeLater(new Runnable() {
            public void run() {
              MTEllipse e = new MTEllipse(instance, new Vector3D(0,0), ToolsMath.getRandom(50, 150),ToolsMath.getRandom(50, 150));
              e.setFillColor(new MTColor(ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255)));
              e.addGestureListener(DragProcessor.class, new InertiaDragAction());
              instance.getCurrentScene().getCanvas().addChild(e);
              e.setPositionGlobal(new Vector3D(ToolsMath.getRandom(0, instance.width), ToolsMath.getRandom(0, instance.height)));
            }
          });
         
        }
      }
View Full Code Here

        50, new MTColor(255, 255, 255, 255), new MTColor(255, 255, 255, 255)));
    textField.setNoFill(true);
    textField.setNoStroke(true);
    textField.setText("Scene 2");
    this.getCanvas().addChild(textField);
    textField.setPositionGlobal(new Vector3D(mtApplication.width/2f, mtApplication.height/2f));
   
    //Button to change to the previous scene on the scene stack
    PImage arrow = mtApplication.loadImage(imagePath + "arrowRight.png");
    MTImageButton previousSceneButton = new MTImageButton(arrow, mtApplication);
    previousSceneButton.setNoStroke(true);
    if (MT4jSettings.getInstance().isOpenGlMode())
      previousSceneButton.setUseDirectGL(true);
    previousSceneButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
        switch (ae.getID()) {
        case TapEvent.BUTTON_CLICKED:
          mtApp.popScene();
          break;
        default:
          break;
        }
      }
    });
    getCanvas().addChild(previousSceneButton);
    previousSceneButton.scale(-1, 1, 1, previousSceneButton.getCenterPointLocal(), TransformSpace.LOCAL);
    previousSceneButton.setPositionGlobal(new Vector3D(previousSceneButton.getWidthXY(TransformSpace.GLOBAL) + 5, mtApp.height - previousSceneButton.getHeightXY(TransformSpace.GLOBAL) - 5, 0));
   
    //Button to get to the next scene
    MTImageButton nextSceneButton = new MTImageButton(arrow, mtApplication);
    nextSceneButton.setNoStroke(true);
    if (MT4jSettings.getInstance().isOpenGlMode())
      nextSceneButton.setUseDirectGL(true);
    nextSceneButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
        switch (ae.getID()) {
        case TapEvent.BUTTON_CLICKED:
          //Save the current scene on the scene stack before changing
          mtApp.pushScene();
          if (scene3 == null){
            scene3 = new Scene3(mtApp, "Scene 3");
            mtApp.addScene(scene3);
          }
          //Do the scene change
          mtApp.changeScene(scene3);
          break;
        default:
          break;
        }
      }
    });
    getCanvas().addChild(nextSceneButton);
    nextSceneButton.setPositionGlobal(new Vector3D(mtApp.width - nextSceneButton.getWidthXY(TransformSpace.GLOBAL) - 5, mtApp.height - nextSceneButton.getHeightXY(TransformSpace.GLOBAL) - 5, 0));

    //Set a scene transition - Flip transition only available using opengl supporting the FBO extenstion
    if (MT4jSettings.getInstance().isOpenGlMode() && GLFBO.isSupported(mtApp))
      this.setTransition(new SlideTransition(mtApp, 700));
    else{
View Full Code Here

    for (int i = 0; i < count; i++) {
      MTRectangle r = new MTRectangle(0,0,ToolsMath.getRandom(50, 250),ToolsMath.getRandom(50, 250),mtApplication);
      r.setFillColor(new MTColor(ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255)));
      r.addGestureListener(DragProcessor.class, new InertiaDragAction());
      getCanvas().addChild(r);
      r.setPositionGlobal(new Vector3D(ToolsMath.getRandom(0, mtApplication.width), ToolsMath.getRandom(0, mtApplication.height)));
    }
  }
View Full Code Here

    textField.setNoStroke(true);
    textField.setNoFill(true);
   
    textField.setText("Hello World!");
    //Center the textfield on the screen
    textField.setPositionGlobal(new Vector3D(mtApplication.width/2f, mtApplication.height/2f));
    //Add the textfield to our canvas
    this.getCanvas().addChild(textField);
  }
View Full Code Here

    this.setClearColor(new MTColor(255, 255, 255, 255));
    //Show touches
    this.registerGlobalInputProcessor(new CursorTracer(mtApplication, this));
   
    MTSvg svg = new MTSvg(mtApplication, svgPath + "windmill.svg");
    svg.setPositionGlobal(new Vector3D(mtApplication.width/2, mtApplication.height/2,0));
    this.getCanvas().addChild(svg);
   
    MTSvg butterFly = new MTSvg(mtApplication, svgPath + "butterfly.svg");
    butterFly.setPositionGlobal(new Vector3D(300, 100,0));
    this.getCanvas().addChild(butterFly);
   
    this.getCanvas().addChild(new MTSvg(mtApplication, svgPath + "primitives.svg"));
  }
View Full Code Here

        50, new MTColor(255, 255, 255, 255), new MTColor(255, 255, 255, 255)));
    textField.setNoFill(true);
    textField.setNoStroke(true);
    textField.setText("Scene 1");
    this.getCanvas().addChild(textField);
    textField.setPositionGlobal(new Vector3D(mtApp.width/2f, mtApp.height/2f));
   
    //Button to get to the next scene
    PImage arrow = mtApplication.loadImage(imagePath +  "arrowRight.png");
    MTImageButton nextSceneButton = new MTImageButton(arrow, mtApplication);
    nextSceneButton.setNoStroke(true);
    if (MT4jSettings.getInstance().isOpenGlMode())
      nextSceneButton.setUseDirectGL(true);
    nextSceneButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
        switch (ae.getID()) {
        case TapEvent.BUTTON_CLICKED:
          //Save the current scene on the scene stack before changing
          mtApp.pushScene();
          if (scene2 == null){
            scene2 = new Scene2(mtApp, "Scene 2");
            //Add the scene to the mt application
            mtApp.addScene(scene2);
          }
          //Do the scene change
          mtApp.changeScene(scene2);
          break;
        default:
          break;
        }
      }
    });
    getCanvas().addChild(nextSceneButton);
    nextSceneButton.setPositionGlobal(new Vector3D(mtApp.width - nextSceneButton.getWidthXY(TransformSpace.GLOBAL) - 5, mtApp.height - nextSceneButton.getHeightXY(TransformSpace.GLOBAL) - 5, 0));
   
    //Set a scene transition - Flip transition only available using opengl supporting the FBO extenstion
    if (MT4jSettings.getInstance().isOpenGlMode() && GLFBO.isSupported(mtApp))
      this.setTransition(new BlendTransition(mtApp, 700));
    else{
View Full Code Here

TOP

Related Classes of org.mt4j.util.math.Vector3D

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.