[英]place bitmaps from gallery on walls using sceneform
hi i want to create some thing like this picture that嗨,我想创造一些像这张照片这样的东西
but i do not know how to place anchors on a wall and place images on the wall using those anchors但我不知道如何在墙上放置锚点并使用这些锚点将图像放在墙上
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);
}
);
this is the code that i got from a question on stackoverflow this is the one i want my user to be able to add images from gallery to the wall这是我从 stackoverflow 上的一个问题中得到的代码 这是我希望我的用户能够将图像从画廊添加到墙上的代码
you can detect the walls by creating a custom arfragment and making it detect planes vertically then you can place anchors on the wall.您可以通过创建自定义 arfragment 并使其垂直检测平面来检测墙壁,然后您可以在墙上放置锚点。 Another option will be using markers on the wall另一种选择是在墙上使用标记
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.