Package org.mt4j.util.math

Examples of org.mt4j.util.math.Vertex


          //set the old last point to the next index
          System.arraycopy(polyVertices, 0, newArr, 0, this.getPolygon().getVertexCount());
          newArr[newArr.length-1] = polyVertices[0]; //close poly correctly

          //Create the new vertex
          Vertex newVert = new Vertex(newPosition.getX(), newPosition.getY(), newPosition.getZ(), 100,150,250,255);
          newVert.setA(120);
          newArr[newArr.length-2] = newVert; //set the new value to be the length-2 one

          polygon.setVertices(newArr);
        }
      }
View Full Code Here


    VectorFontCharacter[] newArray = new VectorFontCharacter[chars.length+3];
    System.arraycopy(chars, 0, newArray, 0, chars.length);
   
    //Manually add a NEWLINE character to the font
    Vertex[] nlVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(200,0,0),new Vertex(200,100,0),/*new Vertex(0,100,0)*/};
    ArrayList<Vertex[]> nlContours = new ArrayList<Vertex[]>();
    nlContours.add(nlVerts);
    VectorFontCharacter newLine = new VectorFontCharacter(nlContours, pa);
    newLine.setPickable(false);                   
    newLine.setVisible(false);
    newLine.setNoFill(true);
    newLine.setNoStroke(true);
    newLine.setHorizontalDist(0);
    newLine.setUnicode("\n");
    newLine.setName("newline");
    newArray[newArray.length-3] = newLine;
   
    //Manually add a SPACE character to the font
//    int charIndex       = this.getCmapFormat(f).mapCharCode(32);
    int charIndex       = this.getCmapFormat(f).mapCharCode('i');
//    int charIndex       = this.getCmapFormat(f).mapCharCode('-');
    int default_advance_x   = f.getHmtxTable().getAdvanceWidth(charIndex);
    Glyph glyph        = f.getGlyph(charIndex);
    int xadvance = 0;
    if (glyph != null){
//      xadvance = Math.round((default_advance_x * (float)(1.0/(float)this.unitsPerEm)) * fontSize);
      xadvance = Math.round(default_advance_x * this.scaleFactor);
    }else{
//      xadvance = Math.round((fontDefaultXAdvancing * (float)(1.0/(float)this.unitsPerEm)) * fontSize);
      xadvance = Math.round(fontDefaultXAdvancing * this.scaleFactor);
    }
   
    Vertex[] spaceVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(xadvance,0,0),new Vertex(xadvance,100,0), /*new Vertex(0,100,0)*/};
    ArrayList<Vertex[]> spaceContours = new ArrayList<Vertex[]>();
    spaceContours.add(spaceVerts);
    VectorFontCharacter space = new VectorFontCharacter(spaceContours, pa);
    space.setPickable(false);                   
    space.setVisible(false);
    space.setNoFill(true);
    space.setNoStroke(true);
    space.setHorizontalDist(xadvance);
    space.setUnicode(" ");
    space.setName("space");
    newArray[newArray.length-2] = space;

    //Manually add a TAB character to the font
    int defaultTabWidth = fontDefaultXAdvancing*4;
    Vertex[] tabVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(200,0,0),new Vertex(200,100,0),/*new Vertex(0,100,0)*/};
    ArrayList<Vertex[]> tabContours = new ArrayList<Vertex[]>();
    tabContours.add(tabVerts);
    VectorFontCharacter tab = new VectorFontCharacter(tabContours, pa);
    tab.setPickable(false);
    try {
      int tabWidth = 4 * space.getHorizontalDist();
      tab.setHorizontalDist(tabWidth);
      tab.setVertices(new Vertex[]{new Vertex(0,0,0), new Vertex(tabWidth,0,0),new Vertex(tabWidth,100,0),/*new Vertex(0,100,0)*/} );
    } catch (Exception e) {
      tab.setHorizontalDist(defaultTabWidth);
    }
    tab.setUnicode("\t");
    tab.setName("tab");
View Full Code Here

   */
  public Vector3D[] getConvexHullXYGlobal(){
    ArrayList<Vector3D> vers = new ArrayList<Vector3D>();
    Vertex[] transVerts = this.getVerticesGlobal();
    for (int i = 0; i < transVerts.length; i++) {
      Vertex vertex = transVerts[i];
      vers.add(vertex);
    }
    ArrayList<Vector3D> edgeList = ConvexQuickHull2D.getConvexHull2D(vers);
    return (edgeList.toArray(new Vertex[edgeList.size()]));
  }
View Full Code Here

 
 
 
  private void unNormalizeFromPOTtoRectMode(PImage newTexture, Vertex[] verts){
    for (int i = 0; i < verts.length; i++) {
        Vertex vertex = verts[i];
        vertex.setTexCoordU(vertex.getTexCoordU() (float)newTexture.width);
        vertex.setTexCoordV(vertex.getTexCoordV() (float)newTexture.height);
//        System.out.println("TexU:" + vertex.getTexCoordU() + " TexV:" + vertex.getTexCoordV()); //FIXME REMOVE
      }
    this.getGeometryInfo().updateTextureBuffer(this.isUseVBOs());
  }
View Full Code Here

    this.getGeometryInfo().updateTextureBuffer(this.isUseVBOs());
  }
 
  private void normalizeFromRectMode(PImage newTexture, Vertex[] verts, float oldTexWidth, float oldTexHeight){
    for (int i = 0; i < verts.length; i++) {
        Vertex vertex = verts[i];
//        vertex.setTexCoordU(ToolsMath.map(vertex.getTexCoordU(), 0, oldTexWidth, 0, 1));
//        vertex.setTexCoordV(ToolsMath.map(vertex.getTexCoordV(), 0, oldTexWidth, 0, 1));
       
        vertex.setTexCoordU(vertex.getTexCoordU() / oldTexWidth);
        vertex.setTexCoordV(vertex.getTexCoordV() / oldTexHeight);
      }
    this.getGeometryInfo().updateTextureBuffer(this.isUseVBOs());
  }
View Full Code Here

    this.getGeometryInfo().updateTextureBuffer(this.isUseVBOs());
  }
 
  private void fromRectModeToRectMode(PImage newTexture, Vertex[] verts, float oldTexWidth, float oldTexHeight){
    for (int i = 0; i < verts.length; i++) {
        Vertex vertex = verts[i];
        vertex.setTexCoordU( (vertex.getTexCoordU() / oldTexWidth(float)newTexture.width);
      vertex.setTexCoordV( (vertex.getTexCoordV() / oldTexHeight) (float)newTexture.height);
      }
    this.getGeometryInfo().updateTextureBuffer(this.isUseVBOs());
  }
View Full Code Here

      @Override
      public void runMTTestCode() {
       
            MTPolygon poly = new MTPolygon(
                new Vertex[]{
                    new Vertex(0,0,100),
                    new Vertex(0,0,0),
                    new Vertex(0,100,0),
                    new Vertex(0,100,100),
                    new Vertex(0,0,100)
                }
                ,getMTApplication());
            getCanvas().addChild(poly);
           
        MTLine line = new MTLine(getMTApplication(), new Vertex(30,30), new Vertex(150,110));
        getCanvas().addChild(line);
       
        MTRectangle r1 = new MTRectangle(10,10, 200,100, getMTApplication());
        getCanvas().addChild(r1);
        assertEquals(getCanvas().getChildren()[3], r1);
       
        MTRoundRectangle roundRect = new MTRoundRectangle(0,0,0, 160, 110, 30,30, getMTApplication());
            getCanvas().addChild(roundRect);
           
        MTEllipse ellipse = new MTEllipse(getMTApplication(), new Vector3D(100,100,0), 160, 80);
        getCanvas().addChild(ellipse);
       
        MTCube cube = new MTCube(getMTApplication(), 150);
        getCanvas().addChild(cube);
       
        MTSphere sphere = new MTSphere(getMTApplication(), "sphere", 30,30, 130);
        getCanvas().addChild(sphere);
       
        MTTriangleMesh mesh = new MTTriangleMesh(getMTApplication(), new GeometryInfo(getMTApplication(), new Vertex[]{
          new Vertex(0,0,0),
          new Vertex(100,0,0),
          new Vertex(50,50,0),
        }));
        getCanvas().addChild(mesh);
       
        assertTrue(getCanvas().getChildren().length == 9);
      }
View Full Code Here

      //this is a hack to fit the bounding shape of the "enter" key to its non-rectangular shape
      if (key.getCharacterToWrite().equals("\n")){
        Vector3D[] v = key.getBounds().getVectorsLocal();
        float indent = (v[1].getX()-v[0].getX())/2f;
        Vertex[] vNew = new Vertex[]{
             new Vertex(v[0].getX(),v[0].getY()+indent,0)
            ,new Vertex(v[0].getX()+indent  -indent/8f ,v[0].getY()+indent,0) //
            ,new Vertex(v[0].getX()+indent  -indent/8f,v[0].getY(),0) //
            ,new Vertex(v[1])
            ,new Vertex(v[2])
            ,new Vertex(v[3])
            ,new Vertex(v[0].getX(),v[0].getY()+indent,0)
        };
        BoundsArbitraryPlanarPolygon newBounds = new BoundsArbitraryPlanarPolygon(key, vNew); //Expensive..
        key.setBoundsBehaviour(AbstractShape.BOUNDS_ONLY_CHECK);
        key.setBounds(newBounds);
      }
View Full Code Here

    }
  } // End of readFile


  void readVertex(ObjectFileParser st) throws ParsingErrorException {
    Vertex p = new Vertex();

    st.getNumber();
    p.x = (float)st.nval;
    st.getNumber();
    p.y = (float)st.nval;
View Full Code Here

   * Returns an array of Vertex which form a bounding box around the
   * object.  Element 0 is the low value, element 1 is the high value.
   * See normalize() below for an example of how to use this method.
   */
  private Vertex[] getLimits() {
    Vertex cur_vtx = new Vertex();

    // Find the limits of the model
    Vertex[] limit = new Vertex[2];
    limit[0] = new Vertex(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);
    limit[1] = new Vertex(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
    for (int i = 0 ; i < coordList.size() ; i++) {

      cur_vtx = (Vertex)coordList.get(i);

      // Keep track of limits for normalization
View Full Code Here

TOP

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

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.