Package org.mt4j.util.math

Examples of org.mt4j.util.math.Vector3D


  }
 
  private Vector3D getContainerLowerLeftRelParent(){
    PositionAnchor saved = listCellContainer.getAnchor();
    listCellContainer.setAnchor(PositionAnchor.LOWER_LEFT);
    Vector3D returnPos = listCellContainer.getPosition(TransformSpace.RELATIVE_TO_PARENT);
    listCellContainer.setAnchor(saved);
    return returnPos;
  }
View Full Code Here


   
  }
 
 
  public void scrollY(float amount){
    listCellContainer.translate(new Vector3D(0, amount), TransformSpace.LOCAL)
    Vector3D listUpperLeftLocal = getListUpperLeftLocal();
    if (getContainerUpperLeftRelParent().y > listUpperLeftLocal.y){
      listCellContainer.setAnchor(PositionAnchor.UPPER_LEFT);
      listCellContainer.setPositionRelativeToParent(listUpperLeftLocal);
    }
    Vector3D listLowLeftLocal = getListLowerLeftLocal();
    if (this.getContainerLowerLeftRelParent().y < listLowLeftLocal.y){
      listCellContainer.setAnchor(PositionAnchor.LOWER_LEFT);
      listCellContainer.setPositionRelativeToParent(listLowLeftLocal);
    }
  }
View Full Code Here

      this.setWidthLocal(this.calcAllCellsWidth());
      this.setHeightLocal(this.calcAllCellsHeight());

      //Re-position list-container to upper left of MTList
      this.setAnchor(PositionAnchor.UPPER_LEFT);
      Vector3D listContainerUpperLeftLocal = getListUpperLeftLocal();
      this.setPositionRelativeToParent(listContainerUpperLeftLocal);
     
      //Set the Position of the list cells in listCellContainer (cells are aligned to the left side of the container)
      float offset = 0;
      if (this.cells.size() > 0 && !this.cells.get(0).isNoStroke()){//FIXME TEST so that stroke isnt cut off TOP because of clipping
        offset = this.cells.get(0).getStrokeWeight();
      }
      for (int i = 0; i < this.cells.size(); i++) {
        MTListCell cell = this.cells.get(i);
        cell.setAnchor(PositionAnchor.UPPER_LEFT);
//        Vector3D pos = new Vector3D(0, offset, 0);
        //FIXME TEST so that stroke isnt cut off left because of clipping
        Vector3D pos = new Vector3D(listContainerUpperLeftLocal.x + cell.getStrokeWeight(), listContainerUpperLeftLocal.y + offset, 0);
        cell.setPositionRelativeToParent(pos);
        offset += cellYPadding + cell.getHeightXY(TransformSpace.RELATIVE_TO_PARENT); //TODO take strokeweight into account here,too
      }
    }
View Full Code Here

//        System.out.println("Dragging list with cursor: " + de.getDragCursor().getId());
        theListCellContainer.setDragging(true);
        canDrag = true;
      }
     
      Vector3D dir = de.getTranslationVect();
      //Transform the global direction vector into listCellContainer local coordiante space
      dir.transformDirectionVector(theListCellContainer.getGlobalInverseMatrix());
     
      switch (de.getId()) {
      case MTGestureEvent.GESTURE_DETECTED:
      case MTGestureEvent.GESTURE_UPDATED:
        //Constrain the movement of the listcellcontainer to the boundaries of the List
        if (canDrag){
//          if (dir.y > 0){
            theListCellContainer.translate(new Vector3D(0, dir.y), TransformSpace.LOCAL)
           
            Vector3D listUpperLeftLocal = getListUpperLeftLocal();
            if (getContainerUpperLeftRelParent().y > listUpperLeftLocal.y){
              theListCellContainer.setAnchor(PositionAnchor.UPPER_LEFT);
              theListCellContainer.setPositionRelativeToParent(listUpperLeftLocal);
            }
//          }else if(dir.y < 0){
//            theListCellContainer.translate(new Vector3D(0, dir.y), TransformSpace.LOCAL);
           
            Vector3D listLowLeftLocal = getListLowerLeftLocal();
            if (getContainerLowerLeftRelParent().y < listLowLeftLocal.y){
              theListCellContainer.setAnchor(PositionAnchor.LOWER_LEFT);
              theListCellContainer.setPositionRelativeToParent(listLowLeftLocal);
            }
//          }
        }
        break;
      case MTGestureEvent.GESTURE_ENDED:
        if (canDrag){
          theListCellContainer.setDragging(false);
         
          Vector3D vel = de.getDragCursor().getVelocityVector(140);
          vel.scaleLocal(0.8f);
          vel = vel.getLimited(15);
          IMTController oldController = theListCellContainer.getController();
          theListCellContainer.setController(new InertiaListController(theListCellContainer, vel, oldController));
        }
        canDrag = false;
        break;
View Full Code Here

    //Put the partial path list of this path into hashmap
//    vertexArrToOutlinesList.put(allPathVertices, contours); //FIXME TEST
   
    //  CREATE THE Character \\
    //Rotate because font characters 0,0 is at bottom left
    Vertex.xRotateVectorArray(allPathVertices, new Vector3D((float)(currenthorizontalAdvX/2.0),0,0), 180);
    //Scale character to desired fontsize
//    Vertex.scaleVectorArray(allPathVertices, new Vector3D(0,0,0), (float)(1.0/(float)font_units_per_em));
//    Vertex.scaleVectorArray(allPathVertices, new Vector3D(0,0,0), fontSize);
    Vertex.scaleVectorArray(allPathVertices, new Vector3D(0,0,0), this.scaleFactor);
   
    //TODO nur contours als parameter is intuitiver
    VectorFontCharacter character = new VectorFontCharacter(contours,  pa);
   
    if (MT4jSettings.getInstance().isOpenGlMode())
View Full Code Here

          target.setController(oldController);
          return;
        }
        startVelocityVec.scaleLocal(dampingValue);
       
        Vector3D transVect = new Vector3D(startVelocityVec);
        transVect.transformDirectionVector(listCellContainer.getGlobalInverseMatrix());
       
        theListCellContainer.translate(new Vector3D(0, transVect.y), TransformSpace.LOCAL)
       
//        System.out.println("Vel vect: " + transVect);
       
        //Constrain the movement of the listcellcontainer to the boundaries of the List
        Vector3D listUpperLeftLocal = getListUpperLeftLocal();
        if (getContainerUpperLeftRelParent().y > listUpperLeftLocal.y){
          theListCellContainer.setAnchor(PositionAnchor.UPPER_LEFT);
          theListCellContainer.setPositionRelativeToParent(listUpperLeftLocal);
          //Bounce off list end         
          startVelocityVec.scaleLocal(-0.25f);
        }
       
        Vector3D listLowLeftLocal = getListLowerLeftLocal();
        if (getContainerLowerLeftRelParent().y < listLowLeftLocal.y){
          theListCellContainer.setAnchor(PositionAnchor.LOWER_LEFT);
          theListCellContainer.setPositionRelativeToParent(listLowLeftLocal);
          //Bounce off list end
          startVelocityVec.scaleLocal(-0.25f);
View Full Code Here

  protected IBoundingShape computeDefaultBounds() {
    Vertex v0 = getVerticesLocal()[0];
    Vertex v1 = getVerticesLocal()[1];

    if (v0.z == 0 && v1.z == 0){ //Only create bounding poly if the line is in the z=0 plane
      Vector3D dir = v1.getSubtracted(v0);
      dir.normalizeLocal();
      dir.scaleLocal(10);
      dir.rotateZ(PApplet.radians(90));
      Vector3D bv0 = new Vector3D(v0.getAdded(dir));
      Vector3D bv1 = new Vector3D(v0.getAdded(dir.getScaled(-1)));
      Vector3D bv2 = new Vector3D(v1.getAdded(dir.getScaled(-1)));
      Vector3D bv3 = new Vector3D(v1.getAdded(dir));
      Vector3D[] v = new Vector3D[]{
          bv0,
          bv1,
          bv2,
          bv3,
View Full Code Here

    outerShape.addGestureListener(TapProcessor.class, new IGestureEventListener() {
      public boolean processGestureEvent(MTGestureEvent ge) {
        TapEvent te = (TapEvent)ge;
        switch (te.getTapID()) {
        case TapEvent.BUTTON_CLICKED:
          Vector3D screenPos = te.getLocationOnScreen();
          Vector3D intersection = outerShape.getIntersectionGlobal(Tools3D.getCameraPickRay(app, outerShape, screenPos.x, screenPos.y));
          if (intersection != null){
            //Get the intersection point into knob local relative space
            Vector3D localClickPos = knob.globalToLocal(intersection);
            Vector3D knobCenterLocal = knob.getCenterPointLocal();
            float range = getValueRange();
            float step = range/5f; //Arbitrary step value
            float oldValue = getValue();
            if (localClickPos.x < knobCenterLocal.x){
              setValue(oldValue - step); //Move knob Left
            }else if (localClickPos.x > knobCenterLocal.x){
              setValue(oldValue + step)//Move knob Right
            }
          }
          break;
        }
        return false;
      }
    });
   
//    knob = new MTRectangle(x+innerOffset, y+innerOffset,   knobWidth, knobHeight, applet);
    knob = new MTEllipse(applet,  new Vector3D(0,0,0), knobWidth*0.5f, knobHeight*0.5f);
    knob.setFillColor(new MTColor(140, 140, 140, 255));
    AbstractComponentProcessor[] inputPs = knob.getInputProcessors();
    for (int i = 0; i < inputPs.length; i++) {
      AbstractComponentProcessor p = inputPs[i];
      if (!(p instanceof DragProcessor)){
        knob.unregisterInputProcessor(p);
      }
    }
    knob.removeAllGestureEventListeners(DragProcessor.class);
   
    outerShape.addChild(knob);
    this.addChild(outerShape);
   
    //TODO these have to be updated if knob or outershape are changed
//    final float knobWidthRelParent = knob.getWidthXY(TransformSpace.RELATIVE_TO_PARENT);
//    final float knobHeightRelParent = knob.getHeightXY(TransformSpace.RELATIVE_TO_PARENT);
//    final float outerWidthLocal = outerShape.getWidthXY(TransformSpace.LOCAL);
   
    knob.addGestureListener(DragProcessor.class, new IGestureEventListener() {
      //@Override
      public boolean processGestureEvent(MTGestureEvent ge) {
        DragEvent de = (DragEvent)ge;
        Vector3D dir = new Vector3D(de.getTranslationVect());
        //Transform the global direction vector into knob local coordiante space
        dir.transformDirectionVector(knob.getGlobalInverseMatrix());
       
        float oldValue = getValue();
       
        if (horizontal){
          knob.translate(new Vector3D(dir.x,0,0), TransformSpace.LOCAL);
          float knobWidthRelParent = knob.getWidthXY(TransformSpace.RELATIVE_TO_PARENT);
          float knobHeightRelParent = knob.getHeightXY(TransformSpace.RELATIVE_TO_PARENT);
          float outerWidthLocal = outerShape.getWidthXY(TransformSpace.LOCAL);
          
          Vector3D knobCenterRelToParent = knob.getCenterPointRelativeToParent();
          //Cap the movement at both ends of the slider
          if( (knobCenterRelToParent.x + knobWidthRelParent*0.5f) > (x + outerWidthLocal - innerPadding) ){
            //FIXME we could insetead just set the new value with setValue()
//            System.out.println("OUT OF BOUNDS RIGHT ->");
            Vector3D pos = new Vector3D( x + outerWidthLocal - innerPadding -knobWidthRelParent*0.5f, y + knobHeightRelParent*0.5f + innerPadding, 0);
//            pos.transform(outerShape.getGlobalMatrix());
//            knob.setPositionGlobal(pos);
            pos.transform(outerShape.getLocalMatrix());
            knob.setPositionRelativeToParent(pos);
          }else if( (knobCenterRelToParent.x - knobWidthRelParent*0.5f ) < (x + innerPadding) ){
//            System.out.println("OUT OF BOUNDS LEFT <-");
            Vector3D pos = new Vector3D( x + knobWidthRelParent*0.5f  + innerPadding, y + knobHeightRelParent*0.5f + innerPadding, 0);
//            pos.transform(outerShape.getGlobalMatrix());
//            knob.setPositionGlobal(pos);
            pos.transform(outerShape.getLocalMatrix());
            knob.setPositionRelativeToParent(pos);
          }
         
//          System.out.println("Slider value: " + getValue());
         
          //Fire property change event
          if (propertyChangeSupport.hasListeners("value")){
            propertyChangeSupport.firePropertyChange("value", oldValue, getValue())
          }
        }else{
          knob.translate(new Vector3D(0,dir.y,0), TransformSpace.LOCAL);
        }
        return false;
      }
    });
   
View Full Code Here

   
    float valueOffsetFromMinValue = Math.abs(value - minValue);
//    float knobValue = minValue +  value*valueAreaToSliderValueArea;
    float knobAdvanceFromLeftValue =  valueOffsetFromMinValue * valueRangeToSliderValueRange;
   
    Vector3D pos = new Vector3D( x + innerPadding + knobWidthRelParent*0.5f + knobAdvanceFromLeftValue , y + knob.getHeightXY(TransformSpace.RELATIVE_TO_PARENT)*0.5f + innerPadding, 0);
//    pos.transform(outerShape.getGlobalMatrix());
//    knob.setPositionGlobal(pos);
    pos.transform(outerShape.getLocalMatrix());
    knob.setPositionRelativeToParent(pos);
   
//    System.out.println("slidervalue: " + sliderAdvanceFromLeftValue);
   
    //Fire property change event
View Full Code Here

            }

            public void processAction() {
              //User direct gl..
              image.setDisplayCloseButton(true);
              image.scale(0.5f, 0.5f, 1, new Vector3D(0,0,0), TransformSpace.LOCAL);
              image.translate(new Vector3D(MT4jSettings.getInstance().getWindowWidth(), 0, 0));
              image.tweenTranslate(new Vector3D(-MT4jSettings.getInstance().getWindowWidth(), 0, 0), 600, 0.1f, 0.6f);
              fotoContainer.addChild(image);
            }

          });
        }
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.