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);
}
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();
}
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();
}
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);
}
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;
}
}
Aggregations