예제 #1
0
 /**
  * computes opposite halfEdge for the given half edge.
  *
  * @param halfEdge the halfEdge to compute the opposite for.
  * @return the opposite HalfEdge to the given one.
  */
 private HalfEdge computeOppositeHalfEdge(HalfEdge halfEdge) {
   Vertex destination = halfEdge.getNext().getStartVertex();
   for (HalfEdge opposite : halfEdges) {
     if (!halfEdge.equals(opposite) && opposite.getStartVertex().equals(destination)) {
       if (opposite.getNext().getStartVertex().equals(halfEdge.getStartVertex())) {
         return opposite;
       }
     }
   }
   return null;
 }
예제 #2
0
 public void computeVertexNormals() {
   for (HalfEdge first : halfEdges) {
     HalfEdge cur = first;
     Vector3 sum = cur.getFacet().getNormal();
     do {
       cur = cur.getOpposite().getNext();
       sum.add(cur.getFacet().getNormal());
     } while (cur != first);
     first.getStartVertex().setNormal(sum.getNormalized());
   }
 }