Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARCore – Rendering objects 200m far from camera

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.

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.

Here is my code:

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 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?

Thank you in advance.

like image 500
Olga Konoreva Avatar asked Oct 28 '22 18:10

Olga Konoreva


1 Answers

Using Sceneform, you can set the far clip plane like this: arFragment.getArSceneView().getScene().getCamera().setFarClipPlane(…);

like image 154
Guerwan Avatar answered Nov 09 '22 08:11

Guerwan