Placing an object 30 meters above a person

旧巷老猫 提交于 2019-12-07 07:05:28

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/54894108/placing-an-object-30-meters-above-a-person

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!