Search in sources :

Example 21 with HalfMesh2

use of org.twak.utils.geom.HalfMesh2 in project chordatlas by twak.

the class SkelFootprint method fracture.

private static void fracture(HalfMesh2 mesh, HalfEdge previous, Vector2d dir, double remainingHard, double remainingSoft, Line line, boolean setLine) {
    if (previous == null)
        // at edge of shape: done
        return;
    HalfEdge p2 = previous.face.fracture(previous.end, dir, previous, previous.next);
    if (p2 == null) {
        System.err.println("failed to find intersection from " + previous.end + " dir " + dir);
        return;
    }
    HalfEdge next = p2.next.over;
    HalfEdge dividing = previous.face.split(mesh, previous, p2);
    ((SuperEdge) dividing).profLine = setLine ? (SuperLine) line : null;
    double l = dividing.length();
    if (remainingHard != 0)
        if (remainingHard < l) {
            Point2d softStart = new Point2d(dir);
            softStart.scale(remainingHard / dir.length());
            softStart.add(previous.end);
            dividing.split(softStart);
            ((SuperEdge) dividing.next).profLine = null;
            ((SuperEdge) dividing.next.over).profLine = null;
            fracture(mesh, next, dir, 0, remainingSoft - l + remainingHard, null, setLine);
        } else
            fracture(mesh, next, dir, remainingHard - l, remainingSoft, line, setLine);
    else if (remainingSoft > l)
        fracture(mesh, next, dir, 0, remainingSoft - l, line, setLine);
}
Also used : Point2d(javax.vecmath.Point2d) SuperLine(org.twak.viewTrace.SuperLine) HalfEdge(org.twak.utils.geom.HalfMesh2.HalfEdge)

Aggregations

HalfEdge (org.twak.utils.geom.HalfMesh2.HalfEdge)18 HalfFace (org.twak.utils.geom.HalfMesh2.HalfFace)18 Point2d (javax.vecmath.Point2d)10 MFPoint (org.twak.tweed.gen.FeatureCache.MFPoint)10 Line (org.twak.utils.Line)10 HalfMesh2 (org.twak.utils.geom.HalfMesh2)9 ArrayList (java.util.ArrayList)7 MegaFeatures (org.twak.tweed.gen.FeatureCache.MegaFeatures)7 HashMap (java.util.HashMap)6 SuperLine (org.twak.viewTrace.SuperLine)6 Color (java.awt.Color)5 LinkedHashMap (java.util.LinkedHashMap)5 Material (com.jme3.material.Material)4 ColorRGBA (com.jme3.math.ColorRGBA)4 Geometry (com.jme3.scene.Geometry)4 Node (com.jme3.scene.Node)4 File (java.io.File)4 HashSet (java.util.HashSet)4 LinkedHashSet (java.util.LinkedHashSet)4 Map (java.util.Map)4