diff --git a/app/src/main/java/com/google/ar/core/examples/java/helloar/HelloArActivity.java b/app/src/main/java/com/google/ar/core/examples/java/helloar/HelloArActivity.java index e159fe7..42ab509 100644 --- a/app/src/main/java/com/google/ar/core/examples/java/helloar/HelloArActivity.java +++ b/app/src/main/java/com/google/ar/core/examples/java/helloar/HelloArActivity.java @@ -99,6 +99,7 @@ private Universe universe; private PhysicalSystem physicalSystem; private Ground ground = null; + private Object3D rectObj; private boolean installRequested; @@ -385,28 +386,27 @@ } // Visualize planes. - Collection updatedPlanes = frame.getUpdatedTrackables(Plane.class); + Collection updatedPlanes = frame.getUpdatedTrackables(Plane.class); for (Plane plane : updatedPlanes) { if (placedPlane == null) { placedPlane = plane; Appearance ap = new Appearance(); ap.setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.BLENDED, 0.5f)); - Box rect = new Box(plane.getExtentX() / 2, 0.005f, plane.getExtentZ() / 2, ap); - Object3D rectObj = new Object3D("plane", rect); + Box rect = new Box(1.0f, 1.0f, 1.0f, ap); + rectObj = new Object3D("plane", rect); Pose p = plane.getCenterPose(); + rectObj.scale(plane.getExtentX() / 2.0, 0.05, plane.getExtentZ() / 2.0); rectObj.apply(new Position3D(p.tx(), p.ty(), p.tz()), false); rectObj.apply(new Quaternion3D((double) p.qx(), (double) p.qy(), (double) p.qz(), (double) p.qw()), false); + System.out.println(plane + " x:" + plane.getExtentX() + ", y:" + plane.getExtentZ()); ground = new Ground(rectObj); universe.place(ground); - } - if (plane == placedPlane) { - Appearance ap = new Appearance(); - ap.setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.BLENDED, 0.5f)); - Box rect = new Box(plane.getExtentX() / 2, 0.005f, plane.getExtentZ() / 2, ap); - Object3D rectObj = new Object3D("plane", rect); + } else if (plane.equals(placedPlane)) { Pose p = plane.getCenterPose(); + rectObj.scale(plane.getExtentX() / 2.0, 0.05, plane.getExtentZ() / 2.0); rectObj.apply(new Position3D(p.tx(), p.ty(), p.tz()), false); rectObj.apply(new Quaternion3D((double) p.qx(), (double) p.qy(), (double) p.qz(), (double) p.qw()), false); + System.out.println(plane + " x:" + plane.getExtentX() + ", y:" + plane.getExtentZ()); ground.updateBody(rectObj); } }