add setCameraCulling method to set near/far culling plane and return vector_math:Frustum from planes returned by get_camera_frustum
This commit is contained in:
@@ -105,7 +105,8 @@ namespace polyvox
|
||||
const filament::Frustum getCameraFrustum();
|
||||
void setCameraModelMatrix(const float *const matrix);
|
||||
void setCameraProjectionMatrix(const double *const matrix, double near, double far);
|
||||
void setCameraFocalLength(float fl);
|
||||
void setCameraFocalLength(float focalLength);
|
||||
void setCameraCulling(double near, double far);
|
||||
void setCameraFocusDistance(float focusDistance);
|
||||
void setCameraManipulatorOptions(filament::camutils::Mode mode, double orbitSpeedX, double orbitSpeedY, double zoomSpeed);
|
||||
void grabBegin(float x, float y, bool pan);
|
||||
@@ -169,6 +170,8 @@ namespace polyvox
|
||||
math::mat4f _cameraPosition;
|
||||
math::mat4f _cameraRotation;
|
||||
void _createManipulator();
|
||||
double _near = 0.05;
|
||||
double _far = 1000.0;
|
||||
|
||||
ColorGrading *colorGrading = nullptr;
|
||||
|
||||
|
||||
@@ -153,6 +153,7 @@ FLUTTER_PLUGIN_EXPORT const double* const get_camera_model_matrix(const void* co
|
||||
FLUTTER_PLUGIN_EXPORT const double* const get_camera_view_matrix(const void* const viewer);
|
||||
FLUTTER_PLUGIN_EXPORT const double* const get_camera_projection_matrix(const void* const viewer);
|
||||
FLUTTER_PLUGIN_EXPORT void set_camera_projection_matrix(const void* const viewer, const double *const matrix, double near, double far);
|
||||
FLUTTER_PLUGIN_EXPORT void set_camera_culling(const void* const viewer, double near, double far);
|
||||
FLUTTER_PLUGIN_EXPORT const double* const get_camera_culling_projection_matrix(const void* const viewer);
|
||||
FLUTTER_PLUGIN_EXPORT const double* const get_camera_frustum(const void* const viewer);
|
||||
FLUTTER_PLUGIN_EXPORT void set_camera_focal_length(const void* const viewer, float focalLength);
|
||||
|
||||
@@ -96,9 +96,6 @@ namespace filament
|
||||
namespace polyvox
|
||||
{
|
||||
|
||||
const double kNearPlane = 0.05; // 5 cm
|
||||
const double kFarPlane = 1000.0; // 1 km
|
||||
|
||||
// const float kAperture = 1.0f;
|
||||
// const float kShutterSpeed = 1.0f;
|
||||
// const float kSensitivity = 50.0f;
|
||||
@@ -163,8 +160,8 @@ namespace polyvox
|
||||
_view->setCamera(_mainCamera);
|
||||
|
||||
_cameraFocalLength = 28.0f;
|
||||
_mainCamera->setLensProjection(_cameraFocalLength, 1.0f, kNearPlane,
|
||||
kFarPlane);
|
||||
_mainCamera->setLensProjection(_cameraFocalLength, 1.0f, _near,
|
||||
_far);
|
||||
// _mainCamera->setExposure(kAperture, kShutterSpeed, kSensitivity);
|
||||
Log("View created");
|
||||
const float aperture = _mainCamera->getAperture();
|
||||
@@ -743,8 +740,20 @@ namespace polyvox
|
||||
{
|
||||
Camera &cam = _view->getCamera();
|
||||
_cameraFocalLength = focalLength;
|
||||
cam.setLensProjection(_cameraFocalLength, 1.0f, kNearPlane,
|
||||
kFarPlane);
|
||||
cam.setLensProjection(_cameraFocalLength, 1.0f, _near,
|
||||
_far);
|
||||
}
|
||||
|
||||
///
|
||||
/// Set the focal length of the active camera.
|
||||
///
|
||||
void FilamentViewer::setCameraCulling(double near, double far)
|
||||
{
|
||||
Camera &cam = _view->getCamera();
|
||||
_near = near;
|
||||
_far = far;
|
||||
cam.setLensProjection(_cameraFocalLength, 1.0f, _near,
|
||||
_far);
|
||||
}
|
||||
|
||||
///
|
||||
@@ -1036,8 +1045,8 @@ namespace polyvox
|
||||
const double aspect = (double)width / height;
|
||||
|
||||
Camera &cam = _view->getCamera();
|
||||
cam.setLensProjection(_cameraFocalLength, 1.0f, kNearPlane,
|
||||
kFarPlane);
|
||||
cam.setLensProjection(_cameraFocalLength, 1.0f, _near,
|
||||
_far);
|
||||
|
||||
cam.setScaling({1.0 / aspect, 1.0});
|
||||
|
||||
@@ -1128,7 +1137,7 @@ namespace polyvox
|
||||
matrix[13],
|
||||
matrix[14],
|
||||
matrix[15]);
|
||||
cam.setCustomProjection(projectionMatrix, near, far);
|
||||
cam.setCustomProjection(projectionMatrix,projectionMatrix, near, far);
|
||||
}
|
||||
|
||||
const math::mat4 FilamentViewer::getCameraModelMatrix()
|
||||
|
||||
@@ -152,6 +152,11 @@ extern "C"
|
||||
{
|
||||
((FilamentViewer *)viewer)->setCameraProjectionMatrix(matrix, near, far);
|
||||
}
|
||||
|
||||
void set_camera_culling(const void *const viewer, double near, double far)
|
||||
{
|
||||
((FilamentViewer *)viewer)->setCameraCulling(near, far);
|
||||
}
|
||||
|
||||
const double *const get_camera_frustum(const void *const viewer)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user