ARCore – 渲染距离相机 200m 的物体 [英] ARCore – Rendering objects 200m far from camera
问题描述
我正在使用 ARCore 和 Sceneform 开发 Android AR 项目.我需要将对象放置在距离用户相机 30 米到 200 米远的位置,并面临 ArCore 中的视锥剔除问题,如这里.
I'm working on Android AR project using ARCore and Sceneform. I need to place the objects from 30 meters to 200 meters far from user's camera and faced with the frustum culling issue in ArCore, described HERE.
我正在尝试设置投影矩阵以使用此方法增加far
参数
I'm trying to set projection matrix to increase the far
parameter using this method
public void getProjectionMatrix (float[] dest,
int offset,
float near,
float far);
但是我找不到设置渲染投影矩阵的可能性.
But I can't find possibility to set the rendering projection matrix.
这是我的代码:
arFragment.arSceneView.apply {
scene.addOnUpdateListener {
// Some code to return from this callback if arFrame is not initialised yet
if (!objectsAdded) {
placeObject(Pose.makeTranslation(0f, 100f, 100f), this)
objectsAdded = true
scene.camera.projectionMatrix = Matrix(computeProjectionMatrix(frame.camera))
// P.S. frame.camera is ArCore's camera, scene.camera is Sceneform's one.
// So, I'm not sure that using them in such way is consistent
}
}
}
setProjectionMatrix
方法包含注释 VisibleForTesting
.所以,我不确定我是否应该使用它,并且可以保证它会起作用.
setProjectionMatrix
method contains annotation VisibleForTesting
. So, I'm not sure if I should use it and there is a guarantee that it will work.
请问我是否可以通过其他方式做到这一点?如果不是,那么让用户看到远处放置的对象的最佳方法是什么?
Please, advice if I can do it in some other way? If no, what the best way to do far placed objects visible for user?
提前致谢.
推荐答案
经过深入调查,我发现目前(2019 年 3 月)无法设置 ARCamera 的
远裁剪面
和近裁剪面
.
等 Google 允许 ARCore 开发者使用它.
这篇关于ARCore – 渲染距离相机 200m 的物体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!