expose getters for near/far culling distance and clean up example project for more readability on frustum

This commit is contained in:
Nick Fisher
2023-12-17 15:17:17 +08:00
parent 8c3d113ab4
commit 3e368e1a31
9 changed files with 147 additions and 62 deletions

View File

@@ -757,8 +757,17 @@ namespace polyvox
Camera &cam = _view->getCamera();
_near = near;
_far = far;
cam.setLensProjection(_cameraFocalLength, 1.0f, _near,
_far);
cam.setLensProjection(_cameraFocalLength, 1.0f, _near, _far);
Log("Set lens projection to focal length %f, near %f and far %f", _cameraFocalLength, _near, _far);
}
double FilamentViewer::getCameraCullingNear() {
Camera &cam = _view->getCamera();
return cam.getNear();
}
double FilamentViewer::getCameraCullingFar() {
Camera &cam = _view->getCamera();
return cam.getCullingFar();
}
///

View File

@@ -158,6 +158,14 @@ extern "C"
((FilamentViewer *)viewer)->setCameraCulling(near, far);
}
double get_camera_culling_near(const void *const viewer) {
return ((FilamentViewer*)viewer)->getCameraCullingNear();
}
double get_camera_culling_far(const void *const viewer) {
return ((FilamentViewer*)viewer)->getCameraCullingFar();
}
const double *const get_camera_frustum(const void *const viewer)
{
const auto frustum = ((FilamentViewer *)viewer)->getCameraFrustum();
@@ -165,10 +173,11 @@ extern "C"
double *array = (double *)calloc(24, sizeof(double));
for (int i = 0; i < 6; i++)
{
array[i * 4] = planes[i].x;
array[i * 4 + 1] = planes[i].y;
array[i * 4 + 2] = planes[i].z;
array[i * 4 + 3] = planes[i].w;
auto plane = planes[i];
array[i * 4] = double(plane.x);
array[i * 4 + 1] = double(plane.y);
array[i * 4 + 2] = double(plane.z);
array[i * 4 + 3] = double(plane.w);
}
return array;