Search in sources :

Example 1 with PolygonWithHoles

use of org.concord.energy3d.util.PolygonWithHoles in project energy3d by concord-consortium.

the class Roof method drawRoof.

private void drawRoof() {
    applyOverhang(wallUpperPoints, wallNormals);
    processRoofEditPoints(wallUpperPoints);
    computeGableEditPoints();
    ensureEditPointsInside();
    final PolygonWithHoles polygon = makePolygon(wallUpperPoints);
    applySteinerPoint(polygon);
    MeshLib.fillMeshWithPolygon(mesh, polygon, null, true, null, null, null, false);
    MeshLib.groupByPlanar(mesh, roofPartsRoot);
    hideGableRoofParts();
    int roofPartIndex = 0;
    for (final Spatial child : roofPartsRoot.getChildren()) {
        ((Mesh) ((Node) child).getChild(0)).setUserData(new UserData(this, roofPartIndex, false));
        ((Mesh) ((Node) child).getChild(REAL_MESH_INDEX)).setUserData(new UserData(this, roofPartIndex, false));
        roofPartIndex++;
    }
    final List<Window> windows = new ArrayList<Window>();
    for (final HousePart part : children) {
        if (part instanceof Window && part.isDrawable()) {
            windows.add((Window) part);
        }
    }
    MeshLib.applyHoles(roofPartsRoot, windows);
    setAnnotationsVisible(Scene.getInstance().areAnnotationsVisible());
}
Also used : Spatial(com.ardor3d.scenegraph.Spatial) PolygonWithHoles(org.concord.energy3d.util.PolygonWithHoles) ArrayList(java.util.ArrayList) Mesh(com.ardor3d.scenegraph.Mesh) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) TriangulationPoint(org.poly2tri.triangulation.TriangulationPoint) PolygonPoint(org.poly2tri.geometry.polygon.PolygonPoint)

Example 2 with PolygonWithHoles

use of org.concord.energy3d.util.PolygonWithHoles in project energy3d by concord-consortium.

the class Wall method drawPolygon.

private void drawPolygon(final List<List<Vector3>> wallAndWindowsPoints, final Mesh mesh, final boolean drawHoles, final boolean normal, final boolean texture) {
    final List<PolygonPoint> polygonPoints = new ArrayList<PolygonPoint>(wallAndWindowsPoints.get(0).size());
    for (final Vector3 p : wallAndWindowsPoints.get(0)) {
        final PolygonPoint tp = new PolygonPoint(p.getX(), p.getY(), p.getZ());
        toXY.transform(tp);
        polygonPoints.add(tp);
    }
    final PolygonWithHoles polygon = new PolygonWithHoles(polygonPoints);
    if (drawHoles) {
        for (int i = 1; i < wallAndWindowsPoints.size(); i++) {
            final List<PolygonPoint> holePoints = new ArrayList<PolygonPoint>(wallAndWindowsPoints.get(i).size());
            for (final Vector3 p : wallAndWindowsPoints.get(i)) {
                final PolygonPoint tp = new PolygonPoint(p.getX(), p.getY(), p.getZ());
                toXY.transform(tp);
                holePoints.add(tp);
            }
            polygon.addHole(new Polygon(holePoints));
        }
    }
    if (texture) {
        final double scale = Scene.getInstance().getTextureMode() == TextureMode.Simple ? 1.0 : 8.0;
        final boolean fullTexture = Scene.getInstance().getTextureMode() == TextureMode.Full;
        final ReadOnlyVector3 p0 = getAbsPoint(0);
        final ReadOnlyVector3 p01 = getAbsPoint(1).subtractLocal(p0).normalizeLocal().multiplyLocal(scale * (fullTexture ? 1.5 : 1.0));
        final ReadOnlyVector3 p02 = getAbsPoint(2).subtractLocal(p0).normalizeLocal().multiplyLocal(scale * (fullTexture ? 2.0 : 1.0));
        final TPoint o = new TPoint(p0.getX(), p0.getY(), p0.getZ());
        final TPoint u = new TPoint(p01.getX(), p01.getY(), p01.getZ());
        final TPoint v = new TPoint(p02.getX(), p02.getY(), p02.getZ());
        toXY.transform(o);
        toXY.transform(u);
        MeshLib.fillMeshWithPolygon(mesh, polygon, fromXY, normal, o, u, v, true);
    } else {
        MeshLib.fillMeshWithPolygon(mesh, polygon, fromXY, normal, null, null, null, true);
    }
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) PolygonPoint(org.poly2tri.geometry.polygon.PolygonPoint) ArrayList(java.util.ArrayList) PolygonWithHoles(org.concord.energy3d.util.PolygonWithHoles) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) Polygon(org.poly2tri.geometry.polygon.Polygon) CullHint(com.ardor3d.scenegraph.hint.CullHint) PolygonPoint(org.poly2tri.geometry.polygon.PolygonPoint) ArdorVector3Point(org.poly2tri.triangulation.point.ardor3d.ArdorVector3Point) PickingHint(com.ardor3d.scenegraph.hint.PickingHint) TPoint(org.poly2tri.triangulation.point.TPoint) Point(org.poly2tri.geometry.primitives.Point) TPoint(org.poly2tri.triangulation.point.TPoint)

Aggregations

CullHint (com.ardor3d.scenegraph.hint.CullHint)2 ArrayList (java.util.ArrayList)2 PolygonWithHoles (org.concord.energy3d.util.PolygonWithHoles)2 PolygonPoint (org.poly2tri.geometry.polygon.PolygonPoint)2 TPoint (org.poly2tri.triangulation.point.TPoint)2 Vector3 (com.ardor3d.math.Vector3)1 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)1 Mesh (com.ardor3d.scenegraph.Mesh)1 Spatial (com.ardor3d.scenegraph.Spatial)1 PickingHint (com.ardor3d.scenegraph.hint.PickingHint)1 Polygon (org.poly2tri.geometry.polygon.Polygon)1 Point (org.poly2tri.geometry.primitives.Point)1 TriangulationPoint (org.poly2tri.triangulation.TriangulationPoint)1 ArdorVector3Point (org.poly2tri.triangulation.point.ardor3d.ArdorVector3Point)1