Search in sources :

Example 96 with Vector3

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

the class Window method setWindowWidth.

public void setWindowWidth(final double width) {
    final Vector3 a = toRelativeVector(getAbsPoint(2).subtract(getAbsPoint(0), null).normalizeLocal().multiplyLocal(0.5 * (width - getWindowWidth()) / Scene.getInstance().getAnnotationScale()));
    points.get(0).subtractLocal(a);
    points.get(1).subtractLocal(a);
    points.get(2).addLocal(a);
    points.get(3).addLocal(a);
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3)

Example 97 with Vector3

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

the class Window method drawShutter.

private void drawShutter(final Mesh shutter, final Mesh shutterOutline) {
    if (!(container instanceof Wall)) {
        return;
    }
    shutter.setDefaultColor(shutterColor);
    final FloatBuffer shutterVertexBuffer = shutter.getMeshData().getVertexBuffer();
    final FloatBuffer shutterNormalBuffer = shutter.getMeshData().getNormalBuffer();
    final FloatBuffer outlineBuffer = shutterOutline.getMeshData().getVertexBuffer();
    shutterVertexBuffer.rewind();
    shutterNormalBuffer.rewind();
    outlineBuffer.rewind();
    shutterVertexBuffer.limit(shutterVertexBuffer.capacity());
    shutterNormalBuffer.limit(shutterNormalBuffer.capacity());
    outlineBuffer.limit(outlineBuffer.capacity());
    final Vector3 out = new Vector3(normal).multiplyLocal(0.01);
    final boolean isLeft = shutter == leftShutter;
    final Vector3 v0 = (isLeft ? getAbsPoint(0) : getAbsPoint(2)).addLocal(out);
    final Vector3 v1 = (isLeft ? getAbsPoint(1) : getAbsPoint(3)).addLocal(out);
    final Vector3 u = isLeft ? getAbsPoint(0).subtractLocal(getAbsPoint(2)) : getAbsPoint(3).subtractLocal(getAbsPoint(1));
    final double gap = 0.1;
    final Vector3 p1 = new Vector3();
    u.multiply(gap, p1).addLocal(v1);
    final Vector3 p2 = new Vector3();
    u.multiply(gap, p2).addLocal(v0);
    final Vector3 p3 = new Vector3();
    u.multiply(shutterLength, p3).addLocal(p2);
    final Vector3 p4 = new Vector3();
    u.multiply(shutterLength, p4).addLocal(p1);
    shutterVertexBuffer.put(p1.getXf()).put(p1.getYf()).put(p1.getZf());
    shutterVertexBuffer.put(p2.getXf()).put(p2.getYf()).put(p2.getZf());
    shutterVertexBuffer.put(p3.getXf()).put(p3.getYf()).put(p3.getZf());
    shutterVertexBuffer.put(p4.getXf()).put(p4.getYf()).put(p4.getZf());
    for (int i = 0; i < 4; i++) {
        shutterNormalBuffer.put(normal.getXf()).put(normal.getYf()).put(normal.getZf());
    }
    shutterVertexBuffer.limit(shutterVertexBuffer.position());
    shutterNormalBuffer.limit(shutterNormalBuffer.position());
    shutter.getMeshData().updateVertexCount();
    shutter.updateModelBound();
    outlineBuffer.put(p1.getXf()).put(p1.getYf()).put(p1.getZf());
    outlineBuffer.put(p2.getXf()).put(p2.getYf()).put(p2.getZf());
    outlineBuffer.put(p2.getXf()).put(p2.getYf()).put(p2.getZf());
    outlineBuffer.put(p3.getXf()).put(p3.getYf()).put(p3.getZf());
    outlineBuffer.put(p3.getXf()).put(p3.getYf()).put(p3.getZf());
    outlineBuffer.put(p4.getXf()).put(p4.getYf()).put(p4.getZf());
    outlineBuffer.put(p4.getXf()).put(p4.getYf()).put(p4.getZf());
    outlineBuffer.put(p1.getXf()).put(p1.getYf()).put(p1.getZf());
    shutterOutline.getMeshData().updateVertexCount();
    shutterOutline.updateModelBound();
}
Also used : FloatBuffer(java.nio.FloatBuffer) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 98 with Vector3

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

the class Window method move.

public void move(final Vector3 d, final ArrayList<Vector3> houseMoveStartPoints) {
    final Foundation foundation = getTopContainer();
    if (foundation != null && foundation.getLockEdit()) {
        return;
    }
    final Vector3 p0 = getAbsPoint(0);
    final Vector3 p = toAbsolute(houseMoveStartPoints.get(0)).addLocal(d);
    snapToGrid(p, p0, getGridSize(), false);
    final Vector3 p_rel = toRelative(p);
    final Vector3 d_snap_rel = p_rel.subtract(houseMoveStartPoints.get(0), null);
    points.get(0).set(p_rel);
    for (int i = 1; i < 4; i++) {
        points.get(i).set(houseMoveStartPoints.get(i).add(d_snap_rel, null));
    }
    draw();
    container.draw();
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 99 with Vector3

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

the class Window method swap.

private void swap(final Vector3 v1, final Vector3 v2) {
    final Vector3 tmp = Vector3.fetchTempInstance();
    tmp.set(v1);
    v1.set(v2);
    v2.set(tmp);
    Vector3.releaseTempInstance(tmp);
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3)

Example 100 with Vector3

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

the class Window method computeArea.

@Override
protected void computeArea() {
    if (isDrawCompleted()) {
        final Vector3 p0 = getAbsPoint(0);
        final Vector3 p1 = getAbsPoint(1);
        final Vector3 p2 = getAbsPoint(2);
        final double C = 100.0;
        final double annotationScale = Scene.getInstance().getAnnotationScale();
        area = Math.round(Math.round(p2.subtract(p0, null).length() * annotationScale * C) / C * Math.round(p1.subtract(p0, null).length() * annotationScale * C) / C * C) / C;
    } else {
        area = 0.0;
    }
}
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