5

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.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Olga Konoreva
  • 1,338
  • 13
  • 20
  • Not really supported according to this: https://github.com/google-ar/sceneform-android-sdk/issues/498 – pezcode Mar 02 '19 at 03:32

2 Answers2

2

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

Guerwan
  • 766
  • 6
  • 4
0

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.

Let's wait for a while when Google allows it for ARCore developers.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220