将物体放置在人上方 30 米处 [英] Placing an object 30 meters above a person

查看:20
本文介绍了将物体放置在人上方 30 米处的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将物体放在 30 或 50 米高的人的正上方?

当我尝试放置链接到锚点的对象时,它在 20 米内可见而在 40 米内不可见?

为什么会发生这种情况,我该如何配置?

解决方案

这是 ARCore 中的视锥剔除问题——不在相机视锥可视区域内的对象将不会被渲染.通常,Android 设备中的 FoV(视野)在水平方向约为 60 度(垂直光圈取决于纵横比).视锥体剔除是从渲染过程中移除完全位于视锥体之外的对象的过程,从而显着降低 CPU 和 GPU 的计算负担.并且不要忘记近剪裁平面和远剪裁平面也是截锥体的一部分.

<块引用>

要正确设置对象的可见性,只需使用以下建议,您可以找到

<块引用>

要了解有关 frustum culling 的更多信息,请阅读 这篇有用的文章.

要返回用于渲染内容的投影矩阵,请使用以下 java 方法:

public void getProjectionMatrix (float[] dest,整数偏移,飘近,飘远);

我可以在MainActivity.java文件中这样使用它:

//获取投影矩阵浮动[]投影Mtx =新浮动[16];arSession.getProjectionMatrix(projectionMtx, 0, 0.5f, 201.0f);//设置投影矩阵arRenderer.setProjectionMatrix(projectionMtx);

...或者在 MainActivity.kt 文件中这样:

//获取投影矩阵私人乐趣 computeProjectionMatrix(): FloatArray {val 投影Mtx = FloatArray(16)session.getProjectionMatrix(projectionMtx, 0, 0.5f, 201.0f)返回投影Mtx}//设置投影矩阵renderer.setProjectionMatrix(computeProjectionMatrix())

希望这会有所帮助.

Is it possible to place an object right above a person that is 30 or 50 meters higher?

When I try to place an object linked to anchor it is visible in 20 meters and not visible in 40 meters?

Why this happens and how can I configure this?

解决方案

It is frustum culling issue in ARCore – objects that aren't within the viewable area of camera frustum won't be rendered. Typically FoV (field of view) in Android devices is around 60 degrees horizontally (vertical aperture depends on aspect ratio). Viewing frustum culling is the process of removing objects that lie completely outside the viewing frustum from the rendering process, thus significantly decreasing CPU's and GPU's computational burden. And don't forget that near and far clipping planes are also parts of frustum.

To setup your objects' visibility properly just use the following recommendation that you can find HERE and HERE.

To know more about frustum culling read this useful article.

For returning a projection matrix for rendering content use the following java method:

public void getProjectionMatrix (float[] dest, 
                                 int offset, 
                                 float near, 
                                 float far);

I can use it this way in MainActivity.java file:

// Getting Projection Matrix
float[] projectionMtx = new float[16];
arSession.getProjectionMatrix(projectionMtx, 0, 0.5f, 201.0f);

// Setting Projection Matrix
arRenderer.setProjectionMatrix(projectionMtx);

...or this way in MainActivity.kt file:

// Getting Projection Matrix
private fun computeProjectionMatrix(): FloatArray {
    val projectionMtx = FloatArray(16)
    session.getProjectionMatrix(projectionMtx, 0, 0.5f, 201.0f)
    return projectionMtx
}

// Setting Projection Matrix
renderer.setProjectionMatrix(computeProjectionMatrix())

Hope this helps.

这篇关于将物体放置在人上方 30 米处的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆