google-ar / sceneform-android-sdk

Sceneform SDK for Android
https://developers.google.com/sceneform/develop/
Apache License 2.0
1.23k stars 604 forks source link

Control over camera aperture angle when not using ARCore #227

Open JessHolle opened 6 years ago

JessHolle commented 6 years ago

Looking at the SceneForm Camera code it would appear that the aperture angle (aka fovy in http://www.mathematik.uni-marburg.de/~thormae/lectures/graphics1/graphics_6_1_eng_web.html#19) is hardwired to 90 degrees when ARCore is not used.

That does not allow one to match the actual camera intrinsics to do AR on non-ARCore devices -- and in general would seem to provide insufficient control over the camera.

JessHolle commented 6 years ago

If setPerspective(float, float, float, float) was not private, we could just subclass Camera an ignore and override the first argument as a quick hack of a fix.

Of course, the real fix is to provide a camera angle setter (a getter is not really necessary), call refreshProjectionMatrix() if isArCamera is false, and use the angle in question in refreshProjectionMatrix() rather than 90.

I'm not sure if there's any clean way to thwack/patch this class until a fix is provided, unfortunately. Ideas?

mojikashani commented 5 years ago

I need the feature badly as well... really appreciate adding an view angle setter

Dosssik commented 4 years ago

There is a public API in last (1.13.0) release - https://developers.google.com/ar/reference/java/sceneform/reference/com/google/ar/sceneform/Camera#setVerticalFovDegrees(float)

But take care, using this API dramatically decrease performance on some devices :( I'll attach an issue link a bit later