Examples of GeometryInfo


Examples of org.mt4j.components.visibleComponents.GeometryInfo

  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

Examples of org.mt4j.components.visibleComponents.GeometryInfo

       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

Examples of org.mt4j.components.visibleComponents.GeometryInfo

    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

Examples of org.mt4j.components.visibleComponents.GeometryInfo

            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

Examples of org.mt4j.components.visibleComponents.GeometryInfo

   * @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

Examples of org.mt4j.components.visibleComponents.GeometryInfo

   * the normals
   */
  private Vector3D[] getFaceOrVertexNormals(){
    Vector3D[] normals = new Vector3D[this.triangles.length*3];
   
    GeometryInfo geom = this.getGeometryInfo();
    if (geom.isIndexed()){
      //Create smooth vertex normals, smoothed across all neighbors
      int[] indices = geom.getIndices();
      normals = new Vector3D[geom.getVertices().length];
      for (int i = 0; i < indices.length/3; i++) {
        if (normals[indices[i*3]] == null){
          normals[indices[i*3]] = triangles[i].getNormalLocal().getCopy();
        }else{
          normals[indices[i*3]].addLocal(triangles[i].getNormalLocal());
 
View Full Code Here

Examples of org.mt4j.components.visibleComponents.GeometryInfo

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

      if (vertices.length > 2){
        GeometryInfo geometry  = null;

        //Load as all vertex normals smoothed if creaseAngle == 180;
        if (creaseAngle == 180){
          geometry = normalGenerator.generateSmoothNormals(pa, vertices , indices, textureCoords, texIndices, creaseAngle, flipTextureY, flipTextureX);
        }else{
View Full Code Here

Examples of org.mt4j.components.visibleComponents.GeometryInfo

  private float restituion;
 
  public PhysicsPolygon(Vertex[] vertices, Vector3D position, PApplet applet,
      World world, float density, float friction, float restitution, float worldScale
  ) {
    super(applet, new GeometryInfo(applet, new Vertex[]{}), false);
    this.angle = 0;
    this.world = world;
    this.density = density;
    this.friction = friction;
    this.restituion = restitution;
   
    this.setGestureAllowance(ScaleProcessor.class, false);
    this.setGestureAllowance(RotateProcessor.class, false);
   
    Vertex.scaleVectorArray(vertices, Vector3D.ZERO_VECTOR, 1f/worldScale, 1f/worldScale, 1);
   
    position.scaleLocal(1f/worldScale); //FIXME REALLY?
   
      GluTrianglulator triangulator = new GluTrianglulator(applet);
    List<Vertex> physicsTris = triangulator.tesselate(vertices, GLU.GLU_TESS_WINDING_NONZERO);
    Vertex[] triangulatedBodyVerts = physicsTris.toArray(new Vertex[physicsTris.size()]);
    triangulator.deleteTess();
    //Set the triangulated vertices as the polygons (mesh's) vertices
    this.setGeometryInfo(new GeometryInfo(applet, triangulatedBodyVerts));
   
    this.translate(position);
    Vector3D realBodyCenter = this.getCenterPointGlobal(); //FIXME geht nur if detached from world //rename futurebodycenter?
    //Reset position
    this.translate(position.getScaled(-1));
   
    //Now get the position where the global center will be after setting the shape at the desired position
    this.setPositionGlobal(position);
    Vector3D meshCenterAtPosition = this.getCenterPointGlobal();
   
    //Compute the distance we would have to move the vertices for the body creation
    //so that the body.position(center) is at the same position as our mesh center
    Vector3D realBodyCenterToMeshCenter = meshCenterAtPosition.getSubtracted(realBodyCenter);
    //System.out.println("Diff:" +  realBodyCenterToMeshCenter);
   
    //Move the vertices so the body position is at the center of the shape
    Vertex.translateVectorArray(triangulatedBodyVerts, realBodyCenterToMeshCenter);
   
    this.setGeometryInfo(new GeometryInfo(applet, triangulatedBodyVerts));
   
//    MTPolygon p = new MTPolygon(vertices, applet);
//    p.translate(position);
////    p.setPositionGlobal(position);
//    Vector3D realBodyCenter = p.getCenterPointGlobal(); //FIXME geht nur if detached from world //rename futurebodycenter?
View Full Code Here

Examples of org.mt4j.components.visibleComponents.GeometryInfo

   *
   * @param vertices the vertices
   * @param pApplet the applet
   */
  public AbstractShape(Vertex[] vertices, PApplet pApplet) {
    this(new GeometryInfo(pApplet, vertices), pApplet);
  }
View Full Code Here

Examples of org.mt4j.components.visibleComponents.GeometryInfo

//    MTTriangleMesh mesh = triangulator.toTriangleMesh(bezierContours, windingRule);
   
    triangulator.tesselate(bezierContours, windingRule);
    List<Vertex> tris = triangulator.getTriList();
    Vertex[] verts = tris.toArray(new Vertex[tris.size()]);
    GeometryInfo geom = new GeometryInfo(pa, verts);
   
//    MTTriangleMesh mesh = new MTTriangleMesh(pa, geom);
    MTTriangleMesh mesh = new SVGMesh(pa, geom);
   
    //TODO put outline contourse in own class SVGMesh!
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.