ARCore – 渲染距离相机 200 米的物体
ARCore – Rendering objects 200m far from camera
我正在使用 ARCore 和 Sceneform 进行 Android AR 项目。我需要将物体 放置在距离用户相机 30 米到 200 米远的地方,并且在 ArCore 中面临 截锥体剔除 问题,描述 HERE.
我正在尝试设置 投影矩阵 以使用此方法增加 far
参数
public void getProjectionMatrix (float[] dest,
int offset,
float near,
float far);
但是我找不到设置渲染投影矩阵的可能性。
这是我的代码:
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
。所以,我不确定我是否应该使用它并且保证它会起作用。
如果我可以用其他方式做到这一点,请指教?
如果不是,让用户看到远处放置的对象的最佳方法是什么?
提前致谢。
After thorough investigation I discovered that at the moment (March 2019) there's no way to setup ARCamera's far clipping plane
and near clipping plane
.
等 Google 允许 ARCore 开发者使用.
使用Sceneform,您可以像这样设置远裁剪平面:arFragment.getArSceneView().getScene().getCamera().setFarClipPlane(…);
我正在使用 ARCore 和 Sceneform 进行 Android AR 项目。我需要将物体 放置在距离用户相机 30 米到 200 米远的地方,并且在 ArCore 中面临 截锥体剔除 问题,描述 HERE.
我正在尝试设置 投影矩阵 以使用此方法增加 far
参数
public void getProjectionMatrix (float[] dest,
int offset,
float near,
float far);
但是我找不到设置渲染投影矩阵的可能性。
这是我的代码:
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
。所以,我不确定我是否应该使用它并且保证它会起作用。
如果我可以用其他方式做到这一点,请指教? 如果不是,让用户看到远处放置的对象的最佳方法是什么?
提前致谢。
After thorough investigation I discovered that at the moment (March 2019) there's no way to setup ARCamera's
far clipping plane
andnear clipping plane
.
等 Google 允许 ARCore 开发者使用.
使用Sceneform,您可以像这样设置远裁剪平面:arFragment.getArSceneView().getScene().getCamera().setFarClipPlane(…);