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 ad4b63b..e159fe7 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 @@ -385,33 +385,30 @@ } // Visualize planes. - Collection allPlanes = session.getAllTrackables(Plane.class); - for (Plane plane : allPlanes) { - 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); - Pose p = plane.getCenterPose(); - 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); - ground = new Ground(rectObj); - universe.place(ground); - } - } - Collection updatedPlanes = frame.getUpdatedTrackables(Plane.class); - for(Plane plane : updatedPlanes) { - 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); - Pose p = plane.getCenterPose(); - 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); - ground.updateBody(rectObj); - } + 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); + Pose p = plane.getCenterPose(); + 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); + 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); + Pose p = plane.getCenterPose(); + 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); + ground.updateBody(rectObj); + } } // planeRenderer.drawPlanes(