Search in sources :

Example 21 with Vector3

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

the class Foundation method setHeight.

@Override
public void setHeight(final double height) {
    final double delta = height - this.height;
    if (!Util.isZero(delta)) {
        this.height = height;
        for (final HousePart c : children) {
            final int n = c.points.size();
            for (int i = 0; i < n; i++) {
                final Vector3 v = c.points.get(i);
                v.setZ(v.getZ() + delta);
            }
        }
    }
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 22 with Vector3

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

the class Foundation method getSolarReceiverCenter.

public Vector3 getSolarReceiverCenter() {
    double rx = 0;
    double ry = 0;
    int count = 0;
    for (final HousePart p : children) {
        if (p instanceof Wall) {
            final Vector3 c = p.getAbsCenter();
            rx += c.getX();
            ry += c.getY();
            count++;
        }
    }
    Vector3 o;
    if (count == 0) {
        o = getAbsCenter();
        o.setZ(getSolarReceiverHeight(0.1));
    } else {
        o = new Vector3(rx / count, ry / count, getSolarReceiverHeight(0.1));
    }
    return o;
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 23 with Vector3

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

the class Foundation method updateHandle.

private void updateHandle(final Vector3 p, final ReadOnlyVector3 dir) {
    final ReadOnlyVector3 step = dir.normalize(null).multiplyLocal(3);
    if (step.length() == 0) {
        return;
    }
    final ReadOnlyVector3 center = getCenter();
    p.set(center).addLocal(dir).addLocal(step);
    final Point2D p2D = new Point2D.Double();
    for (final HousePart part : Scene.getInstance().getParts()) {
        if (part != this && part instanceof Foundation) {
            final ArrayList<Vector3> points = part.getPoints();
            final Path2D foundationPoly = new Path2D.Double();
            foundationPoly.moveTo(points.get(0).getX(), points.get(0).getY());
            foundationPoly.lineTo(points.get(2).getX(), points.get(2).getY());
            foundationPoly.lineTo(points.get(3).getX(), points.get(3).getY());
            foundationPoly.lineTo(points.get(1).getX(), points.get(1).getY());
            foundationPoly.closePath();
            p2D.setLocation(p.getX(), p.getY());
            if (foundationPoly.contains(p2D)) {
                while (foundationPoly.contains(p2D)) {
                    p.addLocal(step);
                    p2D.setLocation(p.getX(), p.getY());
                }
                p.addLocal(step);
            }
        }
    }
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Point2D(java.awt.geom.Point2D) Path2D(java.awt.geom.Path2D) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3)

Example 24 with Vector3

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

the class Foundation method drawAzimuthArrow.

public void drawAzimuthArrow() {
    final double cos30 = Math.cos(Math.toRadians(30));
    final double sin30 = Math.sin(Math.toRadians(30));
    final FloatBuffer arrowVertices = azimuthArrow.getMeshData().getVertexBuffer();
    arrowVertices.clear();
    final Vector3 v = getAbsPoint(0).subtractLocal(getAbsPoint(1)).normalizeLocal().multiplyLocal(20).negateLocal();
    final Vector3 p = getAbsPoint(1).addLocal(getAbsPoint(3)).multiplyLocal(0.5);
    arrowVertices.put(p.getXf()).put(p.getYf()).put(p.getZf());
    p.addLocal(v);
    arrowVertices.put(p.getXf()).put(p.getYf()).put(p.getZf());
    final double arrowX = v.getX() / v.length();
    final double arrowY = v.getY() / v.length();
    final float r = 3;
    float wingx = (float) (r * (arrowX * cos30 + arrowY * sin30));
    float wingy = (float) (r * (arrowY * cos30 - arrowX * sin30));
    arrowVertices.put(p.getXf()).put(p.getYf()).put(p.getZf());
    arrowVertices.put(p.getXf() - wingx).put(p.getYf() - wingy).put(p.getZf());
    wingx = (float) (r * (arrowX * cos30 - arrowY * sin30));
    wingy = (float) (r * (arrowY * cos30 + arrowX * sin30));
    arrowVertices.put(p.getXf()).put(p.getYf()).put(p.getZf());
    arrowVertices.put(p.getXf() - wingx).put(p.getYf() - wingy).put(p.getZf());
    azimuthArrow.getMeshData().updateVertexCount();
    azimuthArrow.updateModelBound();
    updateAzimuthArrowVisibility(SceneManager.getInstance().getSelectedPart() == this);
}
Also used : FloatBuffer(java.nio.FloatBuffer) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3)

Example 25 with Vector3

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

the class Foundation method getAzimuth.

/**
 * @return the azimuth of the reference vector of this foundation in degrees
 */
public double getAzimuth() {
    final Vector3 v = getAbsPoint(0);
    final Vector3 v1 = getAbsPoint(1);
    final double ly = v.distance(v1);
    double a = 90 + Math.toDegrees(Math.asin((v.getY() - v1.getY()) / ly));
    if (v.getX() > v1.getX()) {
        a = 360 - a;
    }
    if (Util.isZero(a - 360)) {
        a = 0;
    }
    return a;
}
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