Package org.mt4j.util.math

Examples of org.mt4j.util.math.Vertex


   * @param leftOffset the left offset
   * @param topOffset the top offset
   * @param horizontalAdvance the horizontal advance
   */
  public BitmapFontCharacter(PImage texture, PApplet applet, String unicode, int leftOffset, int topOffset, int horizontalAdvance) {
    super(new Vertex(leftOffset, topOffset,0), texture.width, texture.height, applet);
    //hm..this is for the card loading, because
    //when we init gl texture in other thread it breaks..
//    this.setUseDirectGL(false);
//    this.setUseDirectGL(true);
   
View Full Code Here


            currentGlyphName = "missing-glyph";
          }
        }else if (currentAttributeName.equalsIgnoreCase("unicode")){
          currentUnicode = currentAttribueValue;
          if (currentUnicode.equalsIgnoreCase(" ")){
            Vertex[] spaceVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(fontDefaultXAdvancing,0,0),new Vertex(fontDefaultXAdvancing,100,0), /*new Vertex(0,100,0)*/};
            ArrayList<Vertex[]> spaceContours = new ArrayList<Vertex[]>();
            spaceContours.add(spaceVerts);
            VectorFontCharacter spaceCharacter = new VectorFontCharacter(spaceContours, pa);
//            VectorFontCharacter spaceCharacter = new VectorFontCharacter(new Vertex[]{new Vertex(0,0,0), new Vertex(100,0,0),new Vertex(100,100,0),new Vertex(0,100,0)}, new ArrayList<Vertex[]>(), pa);
            spaceCharacter.setPickable(false);
            if (MT4jSettings.getInstance().isOpenGlMode()){
              spaceCharacter.setUseDirectGL(true);
//              spaceCharacter.generateAndUseDisplayLists();
            }
            spaceCharacter.setVisible(false);
            spaceCharacter.setNoFill(true);
            spaceCharacter.setNoStroke(true);
            currentCharacter = spaceCharacter;
          }
        }else if (currentAttributeName.equalsIgnoreCase("glyph-name")){
          currentGlyphName = currentAttribueValue;
          if (currentUnicode.equalsIgnoreCase("space")){
            Vertex[] spaceVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(fontDefaultXAdvancing,0,0),new Vertex(fontDefaultXAdvancing,100,0), /*new Vertex(0,100,0)*/};
            ArrayList<Vertex[]> spaceContours = new ArrayList<Vertex[]>();
            spaceContours.add(spaceVerts);
            VectorFontCharacter spaceCharacter = new VectorFontCharacter(spaceContours, pa);
//            VectorFontCharacter spaceCharacter = new VectorFontCharacter(new Vertex[]{new Vertex(0,0,0), new Vertex(100,0,0),new Vertex(100,100,0),new Vertex(0,100,0)}, new ArrayList<Vertex[]>(), pa);
            spaceCharacter.setPickable(false);
            if (MT4jSettings.getInstance().isOpenGlMode()){
              spaceCharacter.setUseDirectGL(true);
//              spaceCharacter.generateAndUseDisplayLists();
            }
            spaceCharacter.setVisible(false);
            spaceCharacter.setNoFill(true);
            spaceCharacter.setNoStroke(true);
            currentCharacter = spaceCharacter;
          }
        }else if (currentAttributeName.equalsIgnoreCase("horiz-adv-x")){
          currenthorizontalAdvX = Integer.parseInt(currentAttribueValue);
        }
      }
     
      if (currentCharacter != null){
        currentCharacter.setName(currentGlyphName);
        currentGlyphName = "";
       
        currentCharacter.setUnicode(currentUnicode);
        currentUnicode = "";
       
        if (currenthorizontalAdvX != 0){
          currentCharacter.setHorizontalDist(currenthorizontalAdvX);
        }else{
          currentCharacter.setHorizontalDist(fontDefaultXAdvancing); //Default if character, nor the font specified this
        }
       
       
        //TODO this caused performance problems in the past - reason UNKOWN! DISABLE IF PERFORMANCE DROPS SIGNIFICANTLY!
        //Scale character advance distances according to fontsize
//        float tmp = currentCharacter.getHorizontalDist() * (float)(1.0/(float)font_units_per_em);
//        currentCharacter.setHorizontalDist(Math.round(tmp * fontSize));
        currentCharacter.setHorizontalDist(Math.round(currentCharacter.getHorizontalDist() * this.scaleFactor));
       
        //Set space's vertices to its horizontal advancement value
        //the vertices are important for showing the textbox caret
        //at the right position
        if (currentCharacter.getUnicode().equals(" ") || currentUnicode.equalsIgnoreCase("space")){
          int xadvance = currentCharacter.getHorizontalDist();
          currentCharacter.setVertices(new Vertex[]{new Vertex(0,0,0), new Vertex(xadvance,0,0),new Vertex(xadvance,100,0) /*,new Vertex(0,100,0)*/});
        }
       
        characters.add(currentCharacter);
       
        currenthorizontalAdvX = 0; //Reset
View Full Code Here

 
  @Override
  public void endDocument() throws SAXException {
   
    //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);
//    VectorFontCharacter newLine = new VectorFontCharacter(new Vertex[]{new Vertex(0,0,0), new Vertex(200,0,0),new Vertex(200,100,0),new Vertex(0,100,0)}, new ArrayList<Vertex[]>(), pa);
    newLine.setPickable(false);                   
    newLine.setVisible(false);
    newLine.setNoFill(true);
    newLine.setNoStroke(true);
    newLine.setHorizontalDist(0);
    newLine.setUnicode("\n");
    newLine.setName("newline");
    characters.add(newLine);
   
    //Manually add a TAB character to the font
    int defaultTabWidth = 200;
    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);
//    VectorFontCharacter tab = new VectorFontCharacter(new Vertex[]{new Vertex(0,0,0), new Vertex(defaultTabWidth,0,0),new Vertex(defaultTabWidth,100,0),new Vertex(0,100,0)}, new ArrayList<Vertex[]>(), pa);
    tab.setPickable(false);
    try {
      IFontCharacter space = svgFont.getFontCharacterByUnicode(" ");
      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

   * @param x2 the x2
   * @param y2 the y2
   * @param z2 the z2
   */
  public MTLine(PApplet pApplet, float x1, float y1, float z1, float x2, float y2, float z2) {
    this(pApplet, new Vertex(x1,y1,z1), new Vertex(x2,y2,z2));
  }
View Full Code Here

 
 
  //TODO  this works only on z=0..better create a boundingbox? -> but that wont fit very tightly..
  @Override
  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

  }

  @Override
  public Vector3D getCenterPointLocal() {
    Vertex[] v = this.getVerticesLocal();
    Vertex lengthVect = (Vertex)v[1].getSubtracted(v[0]);
    lengthVect.scaleLocal(0.5f);
    return v[0].getAdded(lengthVect);
  }
View Full Code Here

   *
   * @return the length
   */
  public float getLength() {
    Vertex[] v = this.getVerticesGlobal();
    Vertex lengthVect = (Vertex)v[1].getSubtracted(v[0]);
    return lengthVect.length();
  }
View Full Code Here

    return this.getLength();
  }
 
  public float getLengthRelativeToParent() {
    Vertex[] v = this.getVerticesLocal();
    Vertex lengthVect = (Vertex)v[1].getSubtracted(v[0]);
    lengthVect.transformDirectionVector(this.getLocalMatrix());
    return lengthVect.length();
  }
View Full Code Here

    return lengthVect.length();
  }
 
  public float getLengthLocal(){
    Vertex[] v = this.getVerticesLocal();
    Vertex lengthVect = (Vertex)v[1].getSubtracted(v[0]);
    return lengthVect.length();
  }
View Full Code Here

          return this.triList;
        }
       
        glu.gluTessBeginContour(tesselator);
        for(int i = 0; i < contour.length; i++) {
          Vertex v = contour[i];
          double[] pv = {v.x,v.y,v.z, v.getR()/255.0,v.getG()/255.0,v.getB()/255.0,v.getA()/255.0}; //{v.x,v.y,v.z};
          glu.gluTessVertex(tesselator, pv, 0, pv);
        }
        glu.gluTessEndContour(tesselator);
       
        return this.getTriList();
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.