Placing an object 30 meters above a person
Asked Answered
M

1

4

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?

Miter answered 26/2, 2019 at 21:7 Comment(0)
O
3

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.

enter image description 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.

Ohmage answered 27/2, 2019 at 8:30 Comment(3)
Huge thanks, ARGeo! The answer is really useful. Could you advice, please, if I can set the projection matrix using Sceneform sdk. Sceneform's camera (arFragment.arSceneView.scene.camera) lets set projectionMatrix only for tests. Your answer would be really helpful, because I'm trying to solve exactly the same issue right now.Exploratory
Hi Olga. Please, publish it as a question. And supply it with your code. I'll try to answer.Ohmage
Done - #54927144. Thank you!Exploratory

© 2022 - 2024 — McMap. All rights reserved.