Improvements to Camera APIs (#3701)
* move the focus distance from DofOptions to Camera The DofOption parameter is now deprecated, but will still work if the focus distance is not set on Camera. * A few new helper APIs on Camera - getFocalLength() which returns the focal length used internally for DoF computations. - computeEffectiveFov() and computeEffectiveFocalLength() which can be used to better simulate a real camera's FOV changes with the focus distance. Modified gltf_viewer so it uses the effective fov/focallendth when DoF is active. * simplify setLensProjection We can call setProjection directly instead of converting to a fov first, which ends up performing atan(tan(x)). Also improve parameters names.
This commit is contained in:
@@ -216,3 +216,36 @@ Java_com_google_android_filament_Camera_nGetSensitivity(JNIEnv*, jclass,
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
return camera->getSensitivity();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Camera_nSetFocusDistance(JNIEnv*, jclass,
|
||||
jlong nativeCamera, jfloat focusDistance) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
camera->setFocusDistance(focusDistance);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_Camera_nGetFocusDistance(JNIEnv*, jclass,
|
||||
jlong nativeCamera) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
return camera->getFocusDistance();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jdouble JNICALL
|
||||
Java_com_google_android_filament_Camera_nGetFocalLength(JNIEnv*, jclass,
|
||||
jlong nativeCamera) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
return camera->getFocalLength();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jdouble JNICALL
|
||||
Java_com_google_android_filament_Camera_nComputeEffectiveFocalLength(JNIEnv*, jclass,
|
||||
jdouble focalLength, jdouble focusDistance) {
|
||||
return Camera::computeEffectiveFocalLength(focalLength, focusDistance);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jdouble JNICALL
|
||||
Java_com_google_android_filament_Camera_nComputeEffectiveFov(JNIEnv*, jclass,
|
||||
jdouble fovInDegrees, jdouble focusDistance) {
|
||||
return Camera::computeEffectiveFov(fovInDegrees, focusDistance);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user