arcore 显示图像垂直于平面
arcore the displaying image is perpendicular to the plane
这就是我想要的 ->
这里有一些重要的代码部分,我想在书的顶部显示书的作者,但是正如您所看到的那样,显示的图像与书垂直。帮帮我,这是我得到的 ->
private void OnUpdateFrame(FrameTime frameTime){
Frame frame=arFragment.getArSceneView().getArFrame();
Collection<AugmentedImage> augmentedImages=frame.getUpdatedTrackables(AugmentedImage.class);
for(AugmentedImage augmentedImage: augmentedImages){
if(augmentedImage.getTrackingState()== TrackingState.TRACKING ){
if(augmentedImage.getName().equals("arimage") && shouldAddModel){
placeObject(arFragment,
augmentedImage.createAnchor(augmentedImage.getCenterPose()),
Uri.parse("author.jpg"));
shouldAddModel=false;
}
}}
}
private void placeObject(ArFragment fragment, Anchor anchor, Uri model){
ViewRenderable.builder().
setView(this,R.layout.lol)
.setVerticalAlignment(ViewRenderable.VerticalAlignment.BOTTOM)
.build()
.thenAccept(viewRenderable -> addNodeToScene(fragment,anchor,viewRenderable))
.exceptionally(throwable -> {
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setMessage(throwable.getMessage())
.setTitle("Error!");
AlertDialog dialog=builder.create();
dialog.show();
return null;
});
}
private void addNodeToScene(ArFragment fragment, Anchor anchor, ViewRenderable viewRenderable) {
AnchorNode anchorNode=new AnchorNode(anchor);
anchorNode.setLocalScale(new Vector3(0.5f, 0.5f, 0.5f));
TransformableNode node=new TransformableNode(fragment.getTransformationSystem());
node.setRenderable(viewRenderable);
node.setParent(anchorNode);
fragment.getArSceneView().getScene().addChild(anchorNode);
node.select();
}
节点的简单局部旋转应该可以完成 trick.Once 您已将节点的父节点设置为这个。
node.setParent(anchorNode);
node.setLocalRotation(Quaternion.axisAngle(new Vector3(0, 0, 1f), 180));
fragment.getArSceneView().getScene().addChild(anchorNode);
玩转四元数的值。你应该得到它。
这就是我想要的 ->
这里有一些重要的代码部分,我想在书的顶部显示书的作者,但是正如您所看到的那样,显示的图像与书垂直。帮帮我,这是我得到的 ->
private void OnUpdateFrame(FrameTime frameTime){
Frame frame=arFragment.getArSceneView().getArFrame();
Collection<AugmentedImage> augmentedImages=frame.getUpdatedTrackables(AugmentedImage.class);
for(AugmentedImage augmentedImage: augmentedImages){
if(augmentedImage.getTrackingState()== TrackingState.TRACKING ){
if(augmentedImage.getName().equals("arimage") && shouldAddModel){
placeObject(arFragment,
augmentedImage.createAnchor(augmentedImage.getCenterPose()),
Uri.parse("author.jpg"));
shouldAddModel=false;
}
}}
}
private void placeObject(ArFragment fragment, Anchor anchor, Uri model){
ViewRenderable.builder().
setView(this,R.layout.lol)
.setVerticalAlignment(ViewRenderable.VerticalAlignment.BOTTOM)
.build()
.thenAccept(viewRenderable -> addNodeToScene(fragment,anchor,viewRenderable))
.exceptionally(throwable -> {
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setMessage(throwable.getMessage())
.setTitle("Error!");
AlertDialog dialog=builder.create();
dialog.show();
return null;
});
}
private void addNodeToScene(ArFragment fragment, Anchor anchor, ViewRenderable viewRenderable) {
AnchorNode anchorNode=new AnchorNode(anchor);
anchorNode.setLocalScale(new Vector3(0.5f, 0.5f, 0.5f));
TransformableNode node=new TransformableNode(fragment.getTransformationSystem());
node.setRenderable(viewRenderable);
node.setParent(anchorNode);
fragment.getArSceneView().getScene().addChild(anchorNode);
node.select();
}
节点的简单局部旋转应该可以完成 trick.Once 您已将节点的父节点设置为这个。
node.setParent(anchorNode);
node.setLocalRotation(Quaternion.axisAngle(new Vector3(0, 0, 1f), 180));
fragment.getArSceneView().getScene().addChild(anchorNode);
玩转四元数的值。你应该得到它。