use of com.ardor3d.math.Plane in project energy3d by concord-consortium.
the class CustomRoof method setPreviewPoint.
@Override
public void setPreviewPoint(final int x, final int y) {
final Foundation foundation = getTopContainer();
if (foundation != null && foundation.getLockEdit()) {
return;
}
final EditState editState = new EditState();
if (editPointIndex == -1) {
recalculateEditPoints = true;
pickContainer(x, y, Wall.class);
} else if (editPointIndex == 0) {
final ReadOnlyVector3 base = getCenter();
final Vector3 p = Util.closestPoint(base, Vector3.UNIT_Z, x, y);
if (p == null) {
return;
}
snapToGrid(p, getAbsPoint(editPointIndex), getGridSize());
height = Math.max(0, p.getZ() - container.getPoints().get(1).getZ());
final double z = container.getPoints().get(1).getZ() + height;
for (final Vector3 v : points) {
v.setZ(z);
}
} else {
final Ray3 pickRay = SceneManager.getInstance().getCamera().getPickRay(new Vector2(x, y), false, null);
final Vector3 p = new Vector3();
if (pickRay.intersectsPlane(new Plane(Vector3.UNIT_Z, points.get(0).getZ()), p)) {
snapToGrid(p, getAbsPoint(editPointIndex), getGridSize(), false);
snapToWallsPolygon(p);
points.get(editPointIndex).set(toRelative(p));
}
}
postEdit(editState);
}
Aggregations