这就是我想要的-> enter image description here这里是代码的一些重要部分,我想在这本书的顶部显示该书的作者,但正如您看到的那样,显示与该书垂直的图像。帮帮我,这就是我得到的-> enter image description here
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();
}
答案 0 :(得分:0)
一个简单的节点本地旋转就可以解决问题。一旦将节点的父节点设置为此。
node.setParent(anchorNode);
node.setLocalRotation(Quaternion.axisAngle(new Vector3(0, 0, 1f), 180));
fragment.getArSceneView().getScene().addChild(anchorNode);
尝试使用四元数的值。你应该得到它。