Package org.mt4j.components.visibleComponents

Examples of org.mt4j.components.visibleComponents.GeometryInfo


    for (int i = 0; i < indices.length; i++) {
      texIndices[i] = indices[i];
    }
   
    //Generate normals
    GeometryInfo geom = null;
    if (creaseAngle == 180){
      geom = this.generateSmoothNormals(pa, vertices, indices, texCoords, texIndices, creaseAngle, false, false);
    }else{
      geom = this.generateCreaseAngleNormals(pa, vertices, indices, texCoords, texIndices, creaseAngle, false, false);
    }
   
    //Reset indices if they werent set before,too
    //Reconstruct the passed in geometryinfo
    if (!geometryInfo.isIndexed()){
      geometryInfo.reconstruct(geom.getVertices(), geom.getNormals(), null, true, false, null);
    }else{
      geometryInfo.reconstruct(geom.getVertices(), geom.getNormals(), geom.getIndices(), true, false, null);
    }
    geom = null;
    return geometryInfo;
  }
View Full Code Here


      logger.debug("Final number of normals: " + normals.length);
      logger.debug("----------------------------------------------------------------------------------");
     
      if (newVertices.length > 2 && faces.size() > 0){
        // Create a geometryInfo with all vertices of the mesh
        GeometryInfo geometryInfo = new GeometryInfo(pa, newVertices, newIndices);
 
        //Set the normals for the geometry
        geometryInfo.setNormals(normals, true, false);
 
        //Clean up a bit
        vertexDatas = null;
        faces    = null;
       
View Full Code Here

      logger.debug("Final number of normals: " + normals.length);
      logger.debug("----------------------------------------------------------------------------------");
     
      if (newVertices.length > 2 && faces.size() > 0){
        // Create a geometryInfo with all vertices of the mesh
        GeometryInfo geometryInfo = new GeometryInfo(pa, newVertices, newIndices);
 
        //Set the normals for the geometry
        geometryInfo.setNormals(normals, true, false);
 
        //Clean up a bit
        vertexDatas = null;
        faces    = null;
       
View Full Code Here

   */
  public VectorFontCharacter(/*Vertex[] innerVertices,*/ List<Vertex[]> contours, PApplet pApplet) {
//    super(innerVertices, outlines, pApplet);
//    /*
     //Create dummy vertices, will be replaced later in the constructor
    super(pApplet, new GeometryInfo(pApplet, new Vertex[]{}), false);
   
    //Caluculate vertices from bezierinformation
    int segments = 10;
    List<Vertex[]> bezierContours = ToolsGeometry.createVertexArrFromBezierVertexArrays(contours, segments);
   
    //Triangulate bezier contours
    GluTrianglulator triangulator = new GluTrianglulator(pApplet);
    List<Vertex> tris = triangulator.tesselate(bezierContours);
    //Set new geometry info with triangulated vertices
    super.setGeometryInfo(new GeometryInfo(pApplet, tris.toArray(new Vertex[tris.size()])));
    //Set Mesh outlines
    this.setOutlineContours(bezierContours);
    //Delete triangulator (C++ object)
    triangulator.deleteTess();
//    */
 
View Full Code Here

  //-> else we do expensive checks against each triangle
  //TODO note that its expensive to re/set vertices often
  //TODO note that using setGeometryInfo directly is discouraged here
 
  public MTComplexPolygon(PApplet app, Vertex[] vertices) {
    super(app, new GeometryInfo(app, new Vertex[]{}), false);
    this.setVertices(vertices);
    this.setNoStroke(false);
  }
View Full Code Here

  public MTComplexPolygon(PApplet app, List<Vertex[]> contours) {
    this(app, contours, GluTrianglulator.WINDING_RULE_ODD);
  }
 
  public MTComplexPolygon(PApplet app, List<Vertex[]> contours, int windingRule) {
    super(app, new GeometryInfo(app, new Vertex[]{}), false);
    this.setVertices(contours, windingRule);
    this.setNoStroke(false);
  }
View Full Code Here

       public MTTriangleMesh toTriangleMesh(List<Vertex[]> contours, int windingRule){
         this.triList.clear();
         this.tesselate(contours, windingRule);
         List<Vertex> tris = this.getTriList();
         Vertex[] verts = tris.toArray(new Vertex[tris.size()]);
         GeometryInfo geom = new GeometryInfo(p, verts);
         MTTriangleMesh mesh = new MTTriangleMesh(p, geom, false);
         return mesh;
       }
View Full Code Here

    this.setGestureAllowance(RotateProcessor.class, false);
   
    //Scale shape vertices
//    this.setGeometryInfo(new GeometryInfo(applet, Vertex.scaleVectorArray(this.getGeometryInfo().getVertices(), Vector3D.ZERO_VECTOR, 1f/scale, 1f/scale, 1)));
//    this.setGeometryInfo(new GeometryInfo(applet, PhysicsHelper.scaleDown(this.getGeometryInfo().getVertices(), scale)));
    this.setGeometryInfo(new GeometryInfo(applet, PhysicsHelper.scaleDown(Vertex.getDeepVertexArrayCopy(this.getGeometryInfo().getVertices()), scale)));
   
    //Scale physics vertics
//    Vertex.scaleVectorArray(bodyVerts, Vector3D.ZERO_VECTOR, 1f/scale, 1f/scale, 1);
    PhysicsHelper.scaleDown(physicsVertices, scale);
   
View Full Code Here

            logger.debug("\nGroup: \"" + currentGroup.name + "\" ->Vertices: " + currentGroup.verticesForGroup.size()+ " ->TextureCoords: " + currentGroup.texCoordsForGroup.size() + " ->Indices: " + currentGroup.indexArray.length + " ->Texcoord Indices: " + currentGroup.texCoordIndexArray.length );
            logger.debug("");

            if (vertices.length > 2){
              GeometryInfo geometry  = null;
              //Load as all vertex normals smoothed if creaseAngle == 180;
              if (creaseAngle == 180){
                geometry = normalGenerator.generateSmoothNormals(pa, newVertices , newIndices, newTextureCoords, newTexIndices, creaseAngle, flipTextureY, flipTextureX);
              }else{
                geometry = normalGenerator.generateCreaseAngleNormals(pa, newVertices, newIndices, newTextureCoords, newTexIndices, creaseAngle, flipTextureY, flipTextureX);
              }

              MTTriangleMesh mesh = new MTTriangleMesh(pa, geometry);

              if (mesh != null){
                mesh.setName(m.name() + " material: " + new Integer(currentGroupName).toString());
                //Assign texture
                this.assignMaterial(pathToModel, file, scene, m, currentGroupName, mesh);

                if (mesh.getTexture() != null){
                  mesh.setTextureEnabled(true);
                }else{
                  logger.debug("No texture could be assigned to mesh.");
                }
                returnMeshList.add(mesh);
              }
            }
          }
        }else{
          //If there are no materials for this mesh dont split mesh into
          //groups by material
          //Fill indices array and texcoords array (Here: vertex index = texcoord index)
          for( int faceIndex = 0; faceIndex < m.faces(); faceIndex++ ){
            Face3ds f = m.face( faceIndex );

            indices[faceIndex*3]   = f.P0;
            indices[faceIndex*3+1]   = f.P1;
            indices[faceIndex*3+2]   = f.P2;

            texCoordIndices[faceIndex*3]   = f.P0;
            texCoordIndices[faceIndex*3+1]   = f.P1;
            texCoordIndices[faceIndex*3+2]   = f.P2;
          }//for faces

          //Create the Mesh and set a texture
          if (vertices.length > 2){
            //Create normals for the mesh and duplicate vertices for faces that share the same
            //Vertex, but with different texture coordinates or different normals
            GeometryInfo geometry = null;
            //Generate normals and denormalize vertices with more than 1 texture coordinate
            if (creaseAngle == 180){
              geometry = normalGenerator.generateSmoothNormals(pa, vertices, indices, textureCoords, texCoordIndices, creaseAngle, flipTextureY, flipTextureX);
            }else{
              geometry = normalGenerator.generateCreaseAngleNormals(pa, vertices, indices, textureCoords, texCoordIndices, creaseAngle, flipTextureY, flipTextureX);
View Full Code Here

   * @see org.mt4j.components.visibleComponents.shapes.AbstractShape#setVertices(org.mt4j.util.math.Vertex[])
   */
  @Override
  public void setVertices(Vertex[] vertices) {
    //create tris before setVertices, because in setVerts, defaultBounds are calced (depend on triangles)
    this.createTriangles(new GeometryInfo(this.getRenderer(), vertices, this.getGeometryInfo().getNormals(), //TODO why not reconstruct() when geometryinfo already there?
        this.getGeometryInfo().getIndices()));
    super.setVertices(vertices);
    this.createDefaultNormals(this.getGeometryInfo());
  }
View Full Code Here

TOP

Related Classes of org.mt4j.components.visibleComponents.GeometryInfo

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.