Package mri.v3ds

Examples of mri.v3ds.Face3ds


            //Go through all pointers to the faces for this material
            //and get the corresponding face
            for (int j = 0; j < faceIndicesForMaterial.length; j++) {
              int k = faceIndicesForMaterial[j];
              Face3ds face = m.face(k);

              AFace aFace = new AFace();
              aFace.p0 = face.P0;
              aFace.p1 = face.P1;
              aFace.p2 = face.P2;

              aFace.t0 = face.P0;
              aFace.t1 = face.P1;
              aFace.t2 = face.P2;

              group.addFace(aFace);
            }
          }

          Iterator<Integer> it = materialIdToGroup.keySet().iterator();
          logger.debug("Mesh: " + m.name() + " Anzahl Groups:" + materialIdToGroup.keySet().size());
          while (it.hasNext()) {
            int currentGroupName =  it.next();
            Group currentGroup = materialIdToGroup.get(currentGroupName);
            logger.debug("Current group: " + currentGroupName);

            currentGroup.compileItsOwnLists(vertices, textureCoords);

            //Get the new arrays
            Vertex[] newVertices     = currentGroup.getGroupVertices();
            int[] newIndices       = currentGroup.getIndexArray();
            float[][] newTextureCoords  = currentGroup.getGroupTexCoords();
            int[] newTexIndices     = currentGroup.getTexCoordIndices();

            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;

View Full Code Here

TOP

Related Classes of mri.v3ds.Face3ds

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.