Package org.mt4j.util.math

Examples of org.mt4j.util.math.Vector3D


    fotoButton = new MTImageButton(fotoButtonImg, p);
    fotoButton.setName("fotoButton");
    fotoButton.setNoStroke(true);
    fotoButton.setDepthBufferDisabled(true); //Draw on top of everything
//    fotoButton.translate(new Vector3D(MT4jSettings.getInstance().getScreenWidth() - fotoButton.getWidthXY(TransformSpace.RELATIVE_TO_PARENT) -5, MT4jSettings.getInstance().getScreenHeight()- fotoButton.getHeightXY(TransformSpace.RELATIVE_TO_PARENT) -5, 0));
    fotoButton.translate(new Vector3D(0, MT4jSettings.getInstance().getWindowHeight()- fotoButton.getHeightXY(TransformSpace.RELATIVE_TO_PARENT) , 0));
    fotoButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent ae) {
        switch (ae.getID()) {
        case TapEvent.BUTTON_CLICKED:
          Point[] p = getScreenPoints();
          for (int i = 0; i < p.length; i++) {
            Point point = p[i];
            Location loc = map.pointLocation(point.x ,point.y);
            getPictures(loc, getAccuracyForZoom(map), true);
          }
          getPictures(map.getCenter(), getAccuracyForZoom(map), false);
        }
      }
    });
    fotoButton.setTextureEnabled(true);
    fotoButton.setUseDirectGL(true);
    this.buttonContainer.addChild(fotoButton);
   
    tagToPhoto = new HashMap<MTEllipse, Photo>();
   
    /// Create map provider menu \\\
    IFont font = FontManager.getInstance().createFont(p, "SansSerif.Bold", 15, MTColor.WHITE, MTColor.WHITE);
    MTRoundRectangle mapMenu = new MTRoundRectangle(0,0,0, 220,335, 20,20, p);
//    mapMenu.setFillColor(new MTColor(110,110,110,180));
//    mapMenu.setStrokeColor(new MTColor(110,110,110,180));
    mapMenu.setFillColor(new MTColor(35,35,35,180));
    mapMenu.setStrokeColor(new MTColor(35,35,35,180));
    mapMenu.setPositionGlobal(new Vector3D(p.width/2f, p.height/2f));
    mapMenu.translateGlobal(new Vector3D(-p.width/2f - 80,0));
    getCanvas().addChild(mapMenu);
   
    float cellWidth = 155;
    float cellHeight = 40;
    MTColor cellFillColor = new MTColor(new MTColor(0,0,0,210));
    MTColor cellPressedFillColor = new MTColor(new MTColor(20,20,20,220));
   
    MTList list = new MTList(0,0, 152, 7* cellHeight + 7*3, p);
    list.setChildClip(null); //FIXME TEST -> do no clipping for performance
    list.setNoFill(true);
    list.setNoStroke(true);
    list.unregisterAllInputProcessors();
    list.setAnchor(PositionAnchor.CENTER);
    list.setPositionRelativeToParent(mapMenu.getCenterPointLocal());
    mapMenu.addChild(list);
   
    list.addListElement(this.createListCell("Microsoft Aerial", font, new Microsoft.AerialProvider(), cellWidth, cellHeight, cellFillColor, cellPressedFillColor));
    list.addListElement(this.createListCell("Microsoft Road", font, new Microsoft.RoadProvider(), cellWidth, cellHeight, cellFillColor, cellPressedFillColor));
    list.addListElement(this.createListCell("Microsoft Hybrid", font, new Microsoft.HybridProvider(), cellWidth, cellHeight, cellFillColor, cellPressedFillColor));
    list.addListElement(this.createListCell("Open Street Maps", font, new OpenStreetMaps(), cellWidth, cellHeight, cellFillColor, cellPressedFillColor));
    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;
View Full Code Here


                  System.out.println("\"" + fotoName + "\"" + " Has GeoData! -> Lat:" + lat + " Lon:" + lon + " PlaceID: " + foto.getPlaceId());

                  Point2f pointOnScreen   = map.locationPoint(new Location(lat, lon));
//                  System.out.println(" -> Point on Screen: " + pointOnScreen);

                  Vector3D vecOnScreen   = new Vector3D(0,0,0f);
//                  Vector3D vecOnScreen   = new Vector3D(pointOnScreen.x , pointOnScreen.y , 0.01f);
//                  Vector3D vecOnScreen   = new Vector3D(pointOnScreen.x -p.width/2 +128, pointOnScreen.y -p.height/2 +128, 0.01f);

                  //System.out.println("-> Creating tag at: " + vecOnScreen);
                  if pointOnScreen.x >= 0 && pointOnScreen.x <= p.width
                    &&  pointOnScreen.y >= 0 && pointOnScreen.y <= p.height
                  ){
                    final MTEllipse tagCircle = new MTEllipse(p, vecOnScreen, 15, 15, 30);
                    tagCircle.setPickable(true);
                    tagCircle.setFillColor(new MTColor(90, 205, 230, 200));
                    tagCircle.setDrawSmooth(true);
                    tagCircle.setStrokeWeight(2);
                    tagCircle.setStrokeColor(new MTColor(40, 130, 220, 255));
                    tagCircle.translate(new Vector3D(pointOnScreen.x, pointOnScreen.y , 0.0f));
                    tagCircle.transform(tagContainer.getGlobalInverseMatrix());
                    tagCircle.setName(id);
                   
                    tagToPhoto.put(tagCircle, foto);
                   
View Full Code Here

    if (evtID != KeyEvent.KEY_PRESSED)
      return;

    switch (e.getKeyCode()){
    case KeyEvent.VK_G:
      tagContainer.scale(0.75f,0.75f,1, new Vector3D(0,0,0));
      tagContainer.scale(1f/0.75f,1f/0.75f,1, new Vector3D(0,0,0));
      break;
    case KeyEvent.VK_PLUS:
      map.zoomIn();
      this.updateTagContainerScale();
      break;
View Full Code Here

                InputCursor m = posEvt.getCursor();
                AbstractCursorInputEvt prev = m.getPreviousEventOf(posEvt);
                if (prev == null)
                  prev = posEvt;

                Vector3D pos = new Vector3D(posEvt.getPosX(), posEvt.getPosY(), 0);
                Vector3D prevPos = new Vector3D(prev.getPosX(), prev.getPosY(), 0);

                //System.out.println("Pos: " + pos);
                float mouseNormX = pos.x * invWidth;
                float mouseNormY = pos.y * invHeight;
                //System.out.println("MouseNormPosX: " + mouseNormX + "," + mouseNormY);
View Full Code Here

    polygons = new Polygon[capacity];
    crosses  = new int[capacity];
    for (int i=0;i<capacity;i++) {
      polygons[i] = new Polygon();
      polygons[i].npoints = 4;
      path[i] = new Vector3D();
      crosses[i] = 0;
    }
    nPoints = 0;
    nPolys = 0;
View Full Code Here

  }

  private void setPressures() {
    // pressures vary from 0...1
    float pressure;
    Vector3D tmp;
    float t = 0;
    float u = 1.0f / (nPoints - 1)*PApplet.TWO_PI;
    for (int i = 0; i < nPoints; i++) {
      pressure = PApplet.sqrt((1.0f - PApplet.cos(t)) * 0.5f);
      path[i].z = pressure;
View Full Code Here

    }
  }

  public float distToLast(float ix, float iy) {
    if (nPoints > 0) {
      Vector3D v = path[nPoints-1];
      float dx = v.x - ix;
      float dy = v.y - iy;
      return PApplet.mag(dx, dy);
    }
    else {
View Full Code Here

  public  void compile() {
    // compute the polygons from the path of Vector3D's
    if (exists) {
      clearPolys();

      Vector3D p0, p1, p2;
      float radius0, radius1;
      float ax, bx, cx, dx;
      float ay, by, cy, dy;
      int   axi, bxi, cxi, dxi, axip, axid;
      int   ayi, byi, cyi, dyi, ayip, ayid;
View Full Code Here

  public void smooth() {
    // average neighboring points
    final float weight = 18;
    final float scale  = 1.0f / (weight + 2);
    int nPointsMinusTwo = nPoints - 2;
    Vector3D lower, upper, center;

    for (int i = 1; i < nPointsMinusTwo; i++) {
      lower = path[i-1];
      center = path[i];
      upper = path[i+1];
View Full Code Here

          //Use normalized normals for all calculations
          //Also checks if normals are attempted to be added that are equal to this faces normal
          //or normals that have already been added -> those are not added
         
//          /*
          Vector3D normalizedFaceNormal = this.normal.getCopy();
          normalizedFaceNormal.normalizeLocal();

          logger.debug("");
          logger.debug("Face " + index + " normal: " + this.normal + " Normalized: " + normalizedFaceNormal);
          logger.debug("P0:");

          //For each face point, calc vertex normal by adding up all
          //smooth connected neighbors + this faces' normal and normalize in the end
          ArrayList<Vector3D> alreadyAddedInP0 = new ArrayList<Vector3D>();
//          vertexNormalP0 = this.normal.getCopy(); //Init with own faces face normal
          vertexNormalP0 = normalizedFaceNormal.getCopy();
          for (int i = 0; i < smoothNeighborsP0.size(); i++) {
            MyFace neighborFaceP0 = smoothNeighborsP0.get(i);

            Vector3D nextSmoothNeighborNormal       = neighborFaceP0.normal;
            Vector3D nextSmoothNeighborNormalNormalized = nextSmoothNeighborNormal.getCopy();
            //TODO doch nochmal probieren mit vorher ausgerechneter normal? sonst performance loss!
            nextSmoothNeighborNormalNormalized.normalizeLocal();//neighborFaceP0.normalNormalized;
            boolean alreadyAddedSameNormalIn = false;
           
           
            //Dont add faces normals that are equal to this faces normals
            if (!useNormalsEqualToFace && nextSmoothNeighborNormalNormalized.equalsVectorWithTolerance(normalizedFaceNormal, ToolsMath.ZERO_TOLERANCE)){
              alreadyAddedSameNormalIn = true;
              logger.debug("Not using normal: " + nextSmoothNeighborNormalNormalized + " of face " + neighborFaceP0.index + " in vertex norm calc because its equal to this faces normal.");
            }
//            else //Dont add face normals that are equal to one already added
//            {
            if (!useEqualNeighborNormalsAgain){
              for(Vector3D neighBorNorm : alreadyAddedInP0){
                if(neighBorNorm.equalsVectorWithTolerance(nextSmoothNeighborNormalNormalized, ToolsMath.ZERO_TOLERANCE)){
                  alreadyAddedSameNormalIn = true;
                  logger.debug("Already added same normal -> dont add again N: " + neighBorNorm);
                }
              }
            }
//            }

            if (!alreadyAddedSameNormalIn){
              vertexNormalP0.addLocal(nextSmoothNeighborNormalNormalized);
              alreadyAddedInP0.add(nextSmoothNeighborNormalNormalized);
              logger.debug("Added normal: " + nextSmoothNeighborNormalNormalized + " of face: " + neighborFaceP0.index);
            }
          }
          vertexNormalP0.normalizeLocal();

          logger.debug("P1");
          //For each face point, calc vertex normalby adding up all
          //smooth connected neighbors + this faces' normal and normalize in the end
          ArrayList<Vector3D> alreadyAddedInP1 = new ArrayList<Vector3D>();
//          vertexNormalP1 = this.normal.getCopy(); //Init with own faces face normal
          vertexNormalP1 = normalizedFaceNormal.getCopy();
          for (int i = 0; i < smoothNeighborsP1.size(); i++) {
            MyFace neighborFaceP1 = smoothNeighborsP1.get(i);

            Vector3D nextSmoothNeighborNormal       = neighborFaceP1.normal;
            Vector3D nextSmoothNeighborNormalNormalized = nextSmoothNeighborNormal.getCopy();
            //TODO doch nochmal probieren mit vorher ausgerechneter normal? sonst performance loss!
            nextSmoothNeighborNormalNormalized.normalizeLocal();//neighborFaceP1.normalNormalized;
            boolean alreadyAddedSameNormalIn = false;
           
            //Dont add faces normals that are equal to this faces normals
            if (!useNormalsEqualToFace && nextSmoothNeighborNormalNormalized.equalsVectorWithTolerance(normalizedFaceNormal, ToolsMath.ZERO_TOLERANCE)){
              alreadyAddedSameNormalIn = true;
              logger.debug("Not using normal: " + nextSmoothNeighborNormalNormalized + " of face " + neighborFaceP1.index + " in vertex norm calc because its equal to this faces normal.");
            }
//            else //Dont add face normals that are equal to one already added
//            {
            if (!useEqualNeighborNormalsAgain){
              for(Vector3D neighBorNorm : alreadyAddedInP1){
                if(neighBorNorm.equalsVectorWithTolerance(nextSmoothNeighborNormalNormalized, ToolsMath.ZERO_TOLERANCE)){
                  alreadyAddedSameNormalIn = true;
                  logger.debug("Already added same normal -> dont add again N: " + neighBorNorm);
                }
              }
            }
//            }

            if (!alreadyAddedSameNormalIn){
              vertexNormalP1.addLocal(nextSmoothNeighborNormalNormalized);

              alreadyAddedInP1.add(nextSmoothNeighborNormalNormalized);
              logger.debug("Added normal: " + nextSmoothNeighborNormalNormalized + " of face: " + neighborFaceP1.index);
            }
          }
          vertexNormalP1.normalizeLocal();

         
          logger.debug("P2");
          //For each face point, calc vertex normalby adding up all
          //smooth connected neighbors + this faces' normal and normalize in the end
          ArrayList<Vector3D> alreadyAddedInP2 = new ArrayList<Vector3D>();
//          vertexNormalP2 = this.normal.getCopy(); //Init with own faces face normal
          vertexNormalP2 = normalizedFaceNormal.getCopy();
          for (int i = 0; i < smoothNeighborsP2.size(); i++) {
            MyFace neighborFaceP2 = smoothNeighborsP2.get(i);

            Vector3D nextSmoothNeighborNormal       = neighborFaceP2.normal;
            Vector3D nextSmoothNeighborNormalNormalized = nextSmoothNeighborNormal.getCopy();
            //TODO doch nochmal probieren mit vorher ausgerechneter normal? sonst performance loss!
            nextSmoothNeighborNormalNormalized.normalizeLocal();//neighborFaceP2.normalNormalized;
            boolean alreadyAddedSameNormalIn = false;
           
           
            //Dont add faces normals that are equal to this faces normals
            if (!useNormalsEqualToFace && nextSmoothNeighborNormalNormalized.equalsVectorWithTolerance(normalizedFaceNormal, ToolsMath.ZERO_TOLERANCE)){
              alreadyAddedSameNormalIn = true;
              logger.debug("Not using normal: " + nextSmoothNeighborNormalNormalized + " of face " + neighborFaceP2.index + " in vertex norm calc because its equal to this faces normal.");
            }
//            else //Dont add face normals that are equal to one already added
//            {
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.