我在ARcore n android studio上遇到问题。我想禁用表面检测,以便在用户打开相机时显示对象。请帮我。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!checkIsSupportedDeviceOrFinish(this)) {
return;
}
setContentView(R.layout.activity_ux);
arFragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.ux_fragment);
arFragment.getPlaneDiscoveryController().hide();
arFragment.getPlaneDiscoveryController().setInstructionView(null);
AR();
} // onCreate
private void AR() {
ModelRenderable.builder()
.setSource(this, R.raw.andy)
.build()
.thenAccept(renderable -> andyRenderable = renderable)
.exceptionally(
throwable -> {
Toast toast =
Toast.makeText(this, "Unable to load andy renderable", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
return null;
});
AnchorNode anchorNode = new AnchorNode();
anchorNode.setParent(arFragment.getArSceneView().getScene());
Node node = new Node();
node.setRenderable(andyRenderable);
//The z-axis is negative and is displayed in front of the camera
node.setLocalPosition(new Vector3(getScreenCenter()));
node.setParent(anchorNode);
} // AR
private Vector3 getScreenCenter() {
View vw = findViewById(android.R.id.content);
return new Vector3(vw.getWidth() / 2f, vw.getHeight() / 2f, 0f);
}
那是我的代码-很简单,但是不起作用。