@Override
 public void setPreviewPoint(final int x, final int y) {
   final EditState editState = new EditState();
   if (editPointIndex == -1) {
     pickContainer(x, y, Wall.class);
     recalculateEditPoints = true;
   } else if (editPointIndex == 0) {
     final ReadOnlyVector3 base = getCenter();
     final Vector3 p = Util.closestPoint(base, Vector3.UNIT_Z, x, y);
     if (p != null) {
       snapToGrid(p, getAbsPoint(editPointIndex), getGridSize());
       height = Math.max(0, p.getZ() - base.getZ());
     }
   } else if (editPointIndex == 1 || editPointIndex == 2) {
     final Vector3 hipDirection =
         container.getAbsPoint(2).subtractLocal(container.getAbsPoint(0)).normalizeLocal();
     final Vector3 p = Util.closestPoint(getAbsPoint(0), hipDirection, x, y);
     if (p != null) {
       // snapToGrid(p, getAbsPoint(editPointIndex), getGridSize(), false);
       if (insideWallsPolygon(p)) points.get(editPointIndex).set(toRelative(p));
     }
   }
   postEdit(editState);
 }
 private Vector3 findFarthestIntersection(
     final List<? extends ReadOnlyVector3> wallUpperPoints,
     final ReadOnlyVector3 center,
     final Vector3 p) {
   double farthestDistance = 0;
   Vector3 farthestIntersection = null;
   final int n = wallUpperPoints.size();
   for (int i = 0; i < n; i++) {
     final Vector3 intersect =
         Util.intersectLineSegments(
             center, p, wallUpperPoints.get(i), wallUpperPoints.get((i + 1) % n));
     if (intersect != null) {
       final double d = intersect.distanceSquared(center);
       if (d > farthestDistance) {
         farthestDistance = d;
         farthestIntersection = intersect;
       }
     }
   }
   return farthestIntersection;
 }
Exemple #3
0
 public Arc(final String name, final int vertices) {
   super(name);
   getMeshData().setIndexMode(IndexMode.LineStrip);
   getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(vertices));
   Util.disablePickShadowLight(this);
 }