Search in sources :

Example 1 with SizeAnnotation

use of org.concord.energy3d.shapes.SizeAnnotation in project energy3d by concord-consortium.

the class Floor method drawAnnotations.

@Override
public void drawAnnotations() {
    if (container == null) {
        return;
    }
    int annotCounter = 0;
    for (int i = 0; i < wallUpperPoints.size(); i++) {
        PolygonPoint p = wallUpperPoints.get(i);
        final Vector3 a = new Vector3(p.getX(), p.getY(), p.getZ());
        p = wallUpperPoints.get((i + 1) % wallUpperPoints.size());
        final Vector3 b = new Vector3(p.getX(), p.getY(), p.getZ());
        final SizeAnnotation sizeAnnot = fetchSizeAnnot(annotCounter++);
        sizeAnnot.setRange(a, b, getCenter(), getNormal(), original == null, Align.Center, true, false, Scene.isDrawAnnotationsInside());
        sizeAnnot.setLineWidth(original == null ? 1f : 2f);
    }
}
Also used : PolygonPoint(org.poly2tri.geometry.polygon.PolygonPoint) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) SizeAnnotation(org.concord.energy3d.shapes.SizeAnnotation) CullHint(com.ardor3d.scenegraph.hint.CullHint) PolygonPoint(org.poly2tri.geometry.polygon.PolygonPoint) TPoint(org.poly2tri.triangulation.point.TPoint)

Example 2 with SizeAnnotation

use of org.concord.energy3d.shapes.SizeAnnotation in project energy3d by concord-consortium.

the class Foundation method drawAnnotations.

@Override
public void drawAnnotations() {
    final int[] order = { 0, 1, 3, 2, 0 };
    int annotCounter = 0;
    for (int i = 0; i < order.length - 1; i++, annotCounter++) {
        final SizeAnnotation annot = fetchSizeAnnot(annotCounter++);
        annot.setRange(getAbsPoint(order[i]), getAbsPoint(order[i + 1]), getCenter(), getNormal(), false, Align.Center, true, true, false);
        annot.setLineWidth(original == null ? 1f : 2f);
    }
}
Also used : SizeAnnotation(org.concord.energy3d.shapes.SizeAnnotation) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 3 with SizeAnnotation

use of org.concord.energy3d.shapes.SizeAnnotation in project energy3d by concord-consortium.

the class Window method drawAnnotations.

@Override
public void drawAnnotations() {
    if (points.size() < 4) {
        return;
    }
    int annotCounter = 0;
    Vector3 p0 = getAbsPoint(0);
    Vector3 p1 = getAbsPoint(1);
    Vector3 p2 = getAbsPoint(2);
    Vector3 p3 = getAbsPoint(3);
    final int vIndex = getNormal().equals(Vector3.UNIT_Z) ? 1 : 2;
    if (!Util.isEqual(p0.getValue(vIndex), p2.getValue(vIndex))) {
        final Vector3 tmp = p0;
        p0 = p2;
        p2 = p3;
        p3 = p1;
        p1 = tmp;
    }
    if (p0.getValue(vIndex) > p1.getValue(vIndex)) {
        swap(p0, p1);
        swap(p2, p3);
    }
    final Vector3 p01 = p1.subtract(p0, null).normalizeLocal();
    if (p2.subtract(p0, null).normalizeLocal().dot(p01.cross(getNormal(), null)) < 0) {
        swap(p0, p2);
        swap(p1, p3);
    }
    final Vector3 cornerXY = p0.subtract(container.getAbsPoint(0), null);
    cornerXY.setZ(0);
    final ReadOnlyVector3 faceDirection = getNormal();
    if (container instanceof Wall) {
        final ReadOnlyVector3 v02 = container.getAbsPoint(2).subtract(container.getAbsPoint(0), null);
        final boolean reversedFace = v02.normalize(null).crossLocal(container.getNormal()).dot(Vector3.NEG_UNIT_Z) < 0.0;
        double xy = cornerXY.length();
        if (reversedFace) {
            xy = v02.length() - xy;
        }
        label1.setText("(" + Math.round(Scene.getInstance().getAnnotationScale() * 10 * xy) / 10.0 + ", " + Math.round(Scene.getInstance().getAnnotationScale() * 10.0 * (p0.getZ() - container.getAbsPoint(0).getZ())) / 10.0 + ")");
        label1.setTranslation(p0);
        label1.setRotation(new Matrix3().fromAngles(0, 0, -Util.angleBetween(v02.normalize(null).multiplyLocal(reversedFace ? -1 : 1), Vector3.UNIT_X, Vector3.UNIT_Z)));
    }
    final ReadOnlyVector3 center = getCenter();
    final float lineWidth = original == null ? 1f : 2f;
    SizeAnnotation annot = fetchSizeAnnot(annotCounter++);
    annot.setRange(p0, p1, center, faceDirection, false, Align.Center, true, true, false);
    annot.setLineWidth(lineWidth);
    annot = fetchSizeAnnot(annotCounter++);
    annot.setRange(p0, p2, center, faceDirection, false, Align.Center, true, false, false);
    annot.setLineWidth(lineWidth);
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) SizeAnnotation(org.concord.energy3d.shapes.SizeAnnotation) CullHint(com.ardor3d.scenegraph.hint.CullHint) Matrix3(com.ardor3d.math.Matrix3)

Example 4 with SizeAnnotation

use of org.concord.energy3d.shapes.SizeAnnotation in project energy3d by concord-consortium.

the class Wall method drawAnnotations.

@Override
public void drawAnnotations() {
    if (points.size() < 4) {
        return;
    }
    final ReadOnlyVector3 faceDirection = getNormal();
    int annotCounter = 0;
    int angleAnnotCounter = 0;
    if (wallAndWindowsPoints != null) {
        final List<Vector3> wallPolygonPoints = wallAndWindowsPoints.get(0);
        final Vector3 actualNormal = wallPolygonPoints.get(0).subtract(wallPolygonPoints.get(1), null).normalizeLocal().crossLocal(wallPolygonPoints.get(2).subtract(wallPolygonPoints.get(1), null).normalizeLocal()).negateLocal();
        final boolean reverse = actualNormal.dot(getNormal()) < 0;
        final double lowestWallZ = Math.min(wallPolygonPoints.get(0).getZ(), wallPolygonPoints.get(3).getZ());
        double low = lowestWallZ;
        double hi = Math.max(wallPolygonPoints.get(0).getZ(), wallPolygonPoints.get(3).getZ());
        for (int i = 4; i < wallPolygonPoints.size(); i++) {
            if (wallPolygonPoints.get(i).getZ() < low) {
                low = wallPolygonPoints.get(i).getZ();
            }
            if (wallPolygonPoints.get(i).getZ() > hi) {
                hi = wallPolygonPoints.get(i).getZ();
            }
        }
        final float lineWidth = original == null ? 1f : 2f;
        final boolean isRectangular = hi - low < 0.1;
        ;
        if (isRectangular) {
            final ReadOnlyVector3 p1 = wallPolygonPoints.get(0).multiply(new Vector3(1, 1, 0), null).addLocal(0, 0, lowestWallZ);
            final ReadOnlyVector3 p2 = wallPolygonPoints.get(1);
            final ReadOnlyVector3 p3 = wallPolygonPoints.get(2);
            final ReadOnlyVector3 p4 = wallPolygonPoints.get(3).multiply(new Vector3(1, 1, 0), null).addLocal(0, 0, lowestWallZ);
            final boolean front = false;
            fetchSizeAnnot(annotCounter++).setRange(p1, p2, getCenter(), faceDirection, front, front ? Align.South : Align.Center, true, reverse, Scene.isDrawAnnotationsInside());
            fetchSizeAnnot(annotCounter++).setRange(p2, p3, getCenter(), faceDirection, original == null, original == null ? Align.South : Align.Center, true, reverse, Scene.isDrawAnnotationsInside());
            fetchSizeAnnot(annotCounter++).setRange(p3, p4, getCenter(), faceDirection, front, front ? Align.South : Align.Center, true, reverse, Scene.isDrawAnnotationsInside());
            fetchSizeAnnot(annotCounter++).setRange(p4, p1, getCenter(), faceDirection, front, front ? Align.South : Align.Center, true, reverse, Scene.isDrawAnnotationsInside());
            for (int i = 0; i < annotCounter; i++) {
                fetchSizeAnnot(i).setLineWidth(lineWidth);
            }
            fetchAngleAnnot(angleAnnotCounter++).setRange(p2, p1, p3, getNormal());
            fetchAngleAnnot(angleAnnotCounter++).setRange(p3, p2, p4, getNormal());
            fetchAngleAnnot(angleAnnotCounter++).setRange(p4, p3, p1, getNormal());
            fetchAngleAnnot(angleAnnotCounter++).setRange(p1, p4, p2, getNormal());
            for (int i = 0; i < annotCounter; i++) {
                fetchAngleAnnot(i).setLineWidth(lineWidth);
            }
        } else {
            for (int i = 0; i < wallPolygonPoints.size(); i++) {
                final boolean front = i == 1 && original == null;
                final ReadOnlyVector3 p1 = wallPolygonPoints.get(i);
                final ReadOnlyVector3 p2 = wallPolygonPoints.get((i + 1) % wallPolygonPoints.size());
                final ReadOnlyVector3 p3 = wallPolygonPoints.get((i + 2) % wallPolygonPoints.size());
                final double minLength = 4.0;
                if (p1.distance(p2) > minLength) {
                    final ReadOnlyVector3 min = new Vector3(Math.min(p1.getX(), Math.min(p2.getX(), p3.getX())), Math.min(p1.getY(), Math.min(p2.getY(), p3.getY())), 0);
                    final ReadOnlyVector3 max = new Vector3(Math.max(p1.getX(), Math.max(p2.getX(), p3.getX())), Math.max(p1.getY(), Math.max(p2.getY(), p3.getY())), 0);
                    final ReadOnlyVector3 center = min.add(max, null).divideLocal(2.0).addLocal(0, 0, getCenter().getZ());
                    final SizeAnnotation sizeAnnot = fetchSizeAnnot(annotCounter++);
                    sizeAnnot.setRange(p1, p2, center, faceDirection, front, front ? Align.South : Align.Center, true, reverse, Scene.isDrawAnnotationsInside());
                    sizeAnnot.setLineWidth(lineWidth);
                }
                if (p1.distance(p2) > minLength && p2.distance(p3) > minLength) {
                    final AngleAnnotation angleAnnot = fetchAngleAnnot(angleAnnotCounter++);
                    angleAnnot.setRange(p2, p1, p3, getNormal());
                    angleAnnot.setLineWidth(lineWidth);
                }
            }
        }
    }
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) AngleAnnotation(org.concord.energy3d.shapes.AngleAnnotation) SizeAnnotation(org.concord.energy3d.shapes.SizeAnnotation) 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)

Example 5 with SizeAnnotation

use of org.concord.energy3d.shapes.SizeAnnotation in project energy3d by concord-consortium.

the class Roof method drawAnnotations.

@Override
public void drawAnnotations() {
    if (container == null) {
        return;
    }
    for (final Spatial roofPart : roofPartsRoot.getChildren()) {
        if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
            int annotCounter = 0, angleAnnotCounter = 0;
            final Node roofPartNode = (Node) roofPart;
            final FloatBuffer buf = ((Mesh) roofPartNode.getChild(0)).getMeshData().getVertexBuffer();
            final ArrayList<ReadOnlyVector3> convexHull = MeshLib.computeOutline(buf);
            final ReadOnlyVector3 normal = (ReadOnlyVector3) roofPart.getUserData();
            final int n = convexHull.size();
            for (int i = 0; i < n; i++) {
                final ReadOnlyVector3 p1 = convexHull.get(i);
                final ReadOnlyVector3 p2 = convexHull.get((i + 1) % n);
                final ReadOnlyVector3 p3 = convexHull.get((i + 2) % n);
                // Size annotation
                final ReadOnlyVector3 center = p1.add(p2, null).addLocal(p3).multiplyLocal(1.0 / 3.0);
                final SizeAnnotation sizeAnnot = fetchSizeAnnot(annotCounter++, (Node) roofPartNode.getChild(1));
                final boolean drawAnnotationsInside = Scene.isDrawAnnotationsInside();
                sizeAnnot.setRange(p2, p3, center, normal, false, Align.Center, true, true, drawAnnotationsInside);
                sizeAnnot.setLineWidth(original == null ? 1f : 2f);
                if (drawAnnotationsInside) {
                    sizeAnnot.setColor(ColorRGBA.WHITE);
                } else {
                    sizeAnnot.setColor(ColorRGBA.BLACK);
                }
                // Angle annotations
                final AngleAnnotation angleAnnot = fetchAngleAnnot(angleAnnotCounter++, (Node) roofPartNode.getChild(2));
                angleAnnot.setLineWidth(original == null ? 1f : 2f);
                angleAnnot.setRange(p2, p1, p3, normal);
            }
        }
    }
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Spatial(com.ardor3d.scenegraph.Spatial) Node(com.ardor3d.scenegraph.Node) FloatBuffer(java.nio.FloatBuffer) AngleAnnotation(org.concord.energy3d.shapes.AngleAnnotation) SizeAnnotation(org.concord.energy3d.shapes.SizeAnnotation) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) TriangulationPoint(org.poly2tri.triangulation.TriangulationPoint) PolygonPoint(org.poly2tri.geometry.polygon.PolygonPoint)

Aggregations

SizeAnnotation (org.concord.energy3d.shapes.SizeAnnotation)6 CullHint (com.ardor3d.scenegraph.hint.CullHint)5 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)4 Vector3 (com.ardor3d.math.Vector3)3 PolygonPoint (org.poly2tri.geometry.polygon.PolygonPoint)3 TPoint (org.poly2tri.triangulation.point.TPoint)3 AngleAnnotation (org.concord.energy3d.shapes.AngleAnnotation)2 Matrix3 (com.ardor3d.math.Matrix3)1 Node (com.ardor3d.scenegraph.Node)1 Spatial (com.ardor3d.scenegraph.Spatial)1 PickingHint (com.ardor3d.scenegraph.hint.PickingHint)1 FloatBuffer (java.nio.FloatBuffer)1 Point (org.poly2tri.geometry.primitives.Point)1 TriangulationPoint (org.poly2tri.triangulation.TriangulationPoint)1 ArdorVector3Point (org.poly2tri.triangulation.point.ardor3d.ArdorVector3Point)1