Search in sources :

Example 11 with Vector3

use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.

the class Foundation method move.

public void move(final Vector3 d, final ArrayList<Vector3> movePoints) {
    if (lockEdit) {
        return;
    }
    if (selectedMesh != null) {
        // if a mesh is selected, move the parent node
        translateImportedNode(selectedMesh.getParent(), d.getX(), d.getY(), d.getZ());
        draw();
        drawMeshSelection(selectedMesh);
    } else {
        final List<Vector3> orgPoints = new ArrayList<Vector3>(movePoints.size());
        for (int i = 0; i < points.size(); i++) {
            orgPoints.add(points.get(i));
        }
        for (int i = 0; i < points.size(); i++) {
            final Vector3 newP = movePoints.get(i).add(d, null);
            points.set(i, newP);
            if (i == points.size() - 1 && ensureDistanceFromOtherFoundations(newP, i) != newP) {
                for (int j = 0; j < points.size(); j++) {
                    points.set(j, orgPoints.get(j));
                }
                return;
            }
        }
        if (SceneManager.getInstance().getSelectedPart() == this) {
            drawAzimuthArrow();
        }
        draw();
        drawChildren();
        updateHandlesOfAllFoudations();
    }
    updateImportedNodePositionsAfterMove();
}
Also used : ArrayList(java.util.ArrayList) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 12 with Vector3

use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.

the class Foundation method setEditPoint.

@Override
public void setEditPoint(int editPoint) {
    if (!resizeHouseMode && editPoint > 3 && editPoint < 8) {
        editPoint -= 4;
    }
    // super.setEditPoint(editPoint);
    editPointIndex = editPoint;
    if (editPoint < 8) {
        drawCompleted = false;
    }
    if (!resizeHouseMode) {
        saveOrgPoints();
        minX = Double.MAX_VALUE;
        minY = Double.MAX_VALUE;
        maxX = -Double.MAX_VALUE;
        maxY = -Double.MAX_VALUE;
        for (final HousePart part : children) {
            if (part.children.size() > 2 && part.getPoints().size() > 1) {
                final Vector3 p1 = part.getAbsPoint(0);
                final Vector3 p2 = part.getAbsPoint(2);
                minX = Math.min(p1.getX(), minX);
                minX = Math.min(p2.getX(), minX);
                minY = Math.min(p1.getY(), minY);
                minY = Math.min(p2.getY(), minY);
                maxX = Math.max(p1.getX(), maxX);
                maxX = Math.max(p2.getX(), maxX);
                maxY = Math.max(p1.getY(), maxY);
                maxY = Math.max(p2.getY(), maxY);
            } else {
                // if the child is a solar panel, a rack, or a mirror
                final Vector3 p1 = part.getAbsPoint(0);
                minX = Math.min(p1.getX(), minX);
                minY = Math.min(p1.getY(), minY);
                maxX = Math.max(p1.getX(), maxX);
                maxY = Math.max(p1.getY(), maxY);
            }
        }
    }
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3)

Example 13 with Vector3

use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.

the class Foundation method reverseFoundationResizeEffect.

private void reverseFoundationResizeEffect(final HousePart child, final double dx, final double dxOrg, final double ratioX, final double dy, final double dyOrg, final double ratioY) {
    for (final Vector3 childPoint : child.getPoints()) {
        double x = childPoint.getX() / ratioX;
        if (editPointIndex == 0 || editPointIndex == 1) {
            x += (dx - dxOrg) / dx;
        }
        childPoint.setX(x);
        double y = childPoint.getY() / ratioY;
        if (editPointIndex == 0 || editPointIndex == 2) {
            y += (dy - dyOrg) / dy;
        }
        childPoint.setY(y);
    }
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3)

Example 14 with Vector3

use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.

the class Foundation method getNearestParabolicTrough.

public ParabolicTrough getNearestParabolicTrough(final ParabolicTrough trough) {
    if (trough.getTopContainer() != this) {
        return null;
    }
    final List<ParabolicTrough> troughs = getParabolicTroughs();
    if (troughs.isEmpty() || (troughs.size() == 1 && troughs.get(0) == trough)) {
        return null;
    }
    ParabolicTrough nearest = null;
    double dmin = Double.MAX_VALUE;
    final Vector3 o = trough.getAbsCenter();
    double d;
    for (final ParabolicTrough t : troughs) {
        if (t != trough) {
            d = t.getAbsCenter().distanceSquared(o);
            if (d < dmin) {
                dmin = d;
                nearest = t;
            }
        }
    }
    troughs.clear();
    return nearest;
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3)

Example 15 with Vector3

use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.

the class Foundation method getNearestFresnelReflector.

public FresnelReflector getNearestFresnelReflector(final FresnelReflector reflector) {
    if (reflector.getTopContainer() != this) {
        return null;
    }
    final List<FresnelReflector> reflectors = getFresnelReflectors();
    if (reflectors.isEmpty() || (reflectors.size() == 1 && reflectors.get(0) == reflector)) {
        return null;
    }
    FresnelReflector nearest = null;
    double dmin = Double.MAX_VALUE;
    final Vector3 o = reflector.getAbsCenter();
    double d;
    for (final FresnelReflector r : reflectors) {
        if (r != reflector) {
            d = r.getAbsCenter().distanceSquared(o);
            if (d < dmin) {
                dmin = d;
                nearest = r;
            }
        }
    }
    reflectors.clear();
    return nearest;
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3)

Aggregations

Vector3 (com.ardor3d.math.Vector3)284 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)258 CullHint (com.ardor3d.scenegraph.hint.CullHint)106 FloatBuffer (java.nio.FloatBuffer)69 TPoint (org.poly2tri.triangulation.point.TPoint)41 Point (org.poly2tri.geometry.primitives.Point)35 ArrayList (java.util.ArrayList)34 PolygonPoint (org.poly2tri.geometry.polygon.PolygonPoint)32 Matrix3 (com.ardor3d.math.Matrix3)30 Mesh (com.ardor3d.scenegraph.Mesh)25 Spatial (com.ardor3d.scenegraph.Spatial)24 PickingHint (com.ardor3d.scenegraph.hint.PickingHint)22 Foundation (org.concord.energy3d.model.Foundation)22 Node (com.ardor3d.scenegraph.Node)20 HousePart (org.concord.energy3d.model.HousePart)20 ArdorVector3Point (org.poly2tri.triangulation.point.ardor3d.ArdorVector3Point)20 Ray3 (com.ardor3d.math.Ray3)15 PickResults (com.ardor3d.intersection.PickResults)13 PrimitivePickResults (com.ardor3d.intersection.PrimitivePickResults)13 Vector2 (com.ardor3d.math.Vector2)12