I want to place an image, on the wall with ARCore. The image is converted from a regular image view. I only detect vertical surfaces but when I place the image it is placed like this: I can not figure out how to transform in order to hang the image on the wall, just like in real life.
AR fragment
fragment = (ArFragment)
getSupportFragmentManager().findFragmentById(R.id.sceneform_fragment);
CompletableFuture<ViewRenderable> imgView = ViewRenderable.builder()
.setView(this, R.layout.textview)
.build();
CompletableFuture.allOf(imgView).handle((notUsed, throwable) -> {
// When you build a Renderable, Sceneform loads its resources in the background while
// returning a CompletableFuture. Call handle(), thenAccept(), or check isDone()
// before calling get().
if (throwable != null) {
Log.d("MainActivity", "onCreate: " + "Unable to load renderable");
return null;
}
try {
imageViewRenderable = imgView.get();
} catch (InterruptedException | ExecutionException ex) {
Log.d("MainActivity", "onCreate: Unable to load renderable");
}
return null;
});
try {
mArSession = new Session(this);
} catch (UnavailableArcoreNotInstalledException e) {
e.printStackTrace();
} catch (UnavailableApkTooOldException e) {
e.printStackTrace();
} catch (UnavailableSdkTooOldException e) {
e.printStackTrace();
} catch (UnavailableDeviceNotCompatibleException e) {
e.printStackTrace();
}
mArConfig = new Config(mArSession);
mArConfig.setUpdateMode(Config.UpdateMode.LATEST_CAMERA_IMAGE);
mArConfig.setPlaneFindingMode(Config.PlaneFindingMode.VERTICAL);
mArSession.configure(mArConfig);
fragment.getArSceneView().setupSession(mArSession);
fragment.setOnTapArPlaneListener((HitResult hitresult, Plane plane, MotionEvent motionevent) -> {
Anchor anchor = hitresult.createAnchor();
AnchorNode anchorNode = new AnchorNode(anchor);
anchorNode.setParent(fragment.getArSceneView().getScene());
TransformableNode art = new TransformableNode(fragment.getTransformationSystem());
art.setParent(anchorNode);
art.setRenderable(imageViewRenderable);
art.select();
ImageView imageView = (ImageView)imageViewRenderable.getView();
Picasso.get().load("http://www.cbk-enschede.nl/plaatjes/ens/jpg/GSA023.jpg").into(imageView);
}
);
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)