/** * Calculates smoothing groups for data formatted in TriangleMesh style * @param flatFaces An array of faces, where each triangle face is represented by 6 (vertex and uv) indices * @param flatFaceNormals An array of face normals, where each triangle face is represented by 3 normal indices * @param normals The array of normals * @return An array of smooth groups, where the length of the array is the number of faces */ public static int[] calcSmoothGroups(TriangleMesh mesh, int[] flatFaces, int[] flatFaceNormals, float[] normals) { int faceElementSize = mesh.getFaceElementSize(); int[][] faces = new int[flatFaces.length/faceElementSize][faceElementSize]; for (int f = 0; f < faces.length; f++) { for (int e = 0; e < faceElementSize; e++) { faces[f][e] = flatFaces[f * faceElementSize + e]; } } int pointElementSize = mesh.getPointElementSize(); int[][] faceNormals = new int[flatFaceNormals.length/pointElementSize][pointElementSize]; for (int f = 0; f < faceNormals.length; f++) { for (int e = 0; e < pointElementSize; e++) { faceNormals[f][e] = flatFaceNormals[f * pointElementSize + e]; } } SmoothingGroups smoothGroups = new SmoothingGroups(faces, faceNormals, normals); return smoothGroups.calcSmoothGroups(); } }
int numPoints = tMesh.getPoints().size() / tMesh.getPointElementSize(); int numTexCoords = tMesh.getTexCoords().size() / tMesh.getTexCoordElementSize(); int numFaces = tMesh.getFaces().size() / tMesh.getFaceElementSize(); if (numPoints == 0 || numPoints * tMesh.getPointElementSize() != tMesh.getPoints().size()) { throw new AssertionError("Points array size is not correct: " + tMesh.getPoints().size());
TriangleMesh mesh = (TriangleMesh) meshView.getMesh(); ObservableFloatArray points = mesh.getPoints(); int pointElementSize = mesh.getPointElementSize(); int os = points.size() / pointElementSize;
"Added mesh '" + key + "' of " + mesh.getPoints().size() / mesh.getPointElementSize() + " vertexes, " + mesh.getTexCoords().size() / mesh.getTexCoordElementSize() + " uvs, " + mesh.getFaces().size() / mesh.getFaceElementSize() + " faces, "
newFaceSmoothingGroups.clear(); newFaceSmoothingGroups.ensureCapacity(faceSmoothingGroups.size()); int pointElementSize = mesh.getPointElementSize(); int faceElementSize = mesh.getFaceElementSize(); for (int i = 0; i < faces.size(); i += faceElementSize) {
final int pointElementSize = triangleMesh.getPointElementSize(); final int faceElementSize = triangleMesh.getFaceElementSize(); final boolean isWireframe = getDrawMode() == DrawMode.LINE;