|
|
|
@ -2,6 +2,7 @@ package com.jme3.scene.plugins.blender.modifiers; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.Collection; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.LinkedHashSet; |
|
|
|
@ -129,6 +130,8 @@ public class SubdivisionSurfaceModifier extends Modifier { |
|
|
|
|
for (int i = 0; i < temporalMesh.getVertexCount(); ++i) { |
|
|
|
|
// finding adjacent edges that were created by dividing original edges
|
|
|
|
|
List<Edge> adjacentOriginalEdges = new ArrayList<Edge>(); |
|
|
|
|
Collection<Edge> adjacentEdges = temporalMesh.getAdjacentEdges(i); |
|
|
|
|
if(adjacentEdges != null) {// this can be null if a vertex with index 'i' is not connected to any face nor edge
|
|
|
|
|
for (Edge edge : temporalMesh.getAdjacentEdges(i)) { |
|
|
|
|
if (verticesOnOriginalEdges.contains(edge.getFirstIndex()) || verticesOnOriginalEdges.contains(edge.getSecondIndex())) { |
|
|
|
|
adjacentOriginalEdges.add(edge); |
|
|
|
@ -136,6 +139,9 @@ public class SubdivisionSurfaceModifier extends Modifier { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
creasePoints.add(new CreasePoint(i, boundaryVertices.contains(i), adjacentOriginalEdges, temporalMesh)); |
|
|
|
|
} else { |
|
|
|
|
creasePoints.add(null);//the count of crease points must be equal to vertex count; otherwise we'll get IndexOutofBoundsException later
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Vector3f[] averageVert = new Vector3f[temporalMesh.getVertexCount()]; |
|
|
|
@ -174,6 +180,7 @@ public class SubdivisionSurfaceModifier extends Modifier { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < averageVert.length; ++i) { |
|
|
|
|
if(averageVert[i] != null && averageCount[i] > 0) { |
|
|
|
|
Vector3f v = temporalMesh.getVertices().get(i); |
|
|
|
|
averageVert[i].divideLocal(averageCount[i]); |
|
|
|
|
|
|
|
|
@ -194,6 +201,7 @@ public class SubdivisionSurfaceModifier extends Modifier { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* The method performs a simple subdivision of the mesh. |
|
|
|
|