more methods for projection/culling projection matrices & frustum
This commit is contained in:
@@ -101,8 +101,10 @@ namespace polyvox
|
||||
const math::mat4 getCameraModelMatrix();
|
||||
const math::mat4 getCameraViewMatrix();
|
||||
const math::mat4 getCameraProjectionMatrix();
|
||||
const math::mat4 getCameraCullingProjectionMatrix();
|
||||
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 setCameraFocusDistance(float focusDistance);
|
||||
void setCameraManipulatorOptions(filament::camutils::Mode mode, double orbitSpeedX, double orbitSpeedY, double zoomSpeed);
|
||||
|
||||
@@ -152,6 +152,8 @@ FLUTTER_PLUGIN_EXPORT void set_camera_model_matrix(const void* const viewer, con
|
||||
FLUTTER_PLUGIN_EXPORT const double* const get_camera_model_matrix(const void* const viewer);
|
||||
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 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);
|
||||
FLUTTER_PLUGIN_EXPORT void set_camera_focus_distance(const void* const viewer, float focusDistance);
|
||||
|
||||
@@ -112,14 +112,17 @@ EntityId AssetManager::loadGltf(const char *uri,
|
||||
}
|
||||
|
||||
// load resources synchronously
|
||||
if (!_gltfResourceLoader->loadResources(asset)) {
|
||||
Log("Unknown error loading glTF asset");
|
||||
if (!_gltfResourceLoader->asyncBeginLoad(asset)) {
|
||||
Log("Possible error loading glTF asset");
|
||||
_resourceLoaderWrapper->free(rbuf);
|
||||
for(auto& rb : resourceBuffers) {
|
||||
_resourceLoaderWrapper->free(rb);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
while(_gltfResourceLoader->asyncGetLoadProgress() < 1.0) {
|
||||
// noop
|
||||
}
|
||||
const utils::Entity *entities = asset->getEntities();
|
||||
|
||||
_scene->addEntities(asset->getEntities(), asset->getEntityCount());
|
||||
|
||||
@@ -1109,6 +1109,30 @@ namespace polyvox
|
||||
cam.setModelMatrix(modelMatrix);
|
||||
}
|
||||
|
||||
void FilamentViewer::setCameraProjectionMatrix(const double *const matrix, double near, double far)
|
||||
{
|
||||
Camera &cam = _view->getCamera();
|
||||
|
||||
mat4 projectionMatrix(
|
||||
matrix[0],
|
||||
matrix[1],
|
||||
matrix[2],
|
||||
matrix[3],
|
||||
matrix[4],
|
||||
matrix[5],
|
||||
matrix[6],
|
||||
matrix[7],
|
||||
matrix[8],
|
||||
matrix[9],
|
||||
matrix[10],
|
||||
matrix[11],
|
||||
matrix[12],
|
||||
matrix[13],
|
||||
matrix[14],
|
||||
matrix[15]);
|
||||
cam.setCustomProjection(projectionMatrix, near, far);
|
||||
}
|
||||
|
||||
const math::mat4 FilamentViewer::getCameraModelMatrix()
|
||||
{
|
||||
const auto &cam = _view->getCamera();
|
||||
@@ -1127,6 +1151,12 @@ namespace polyvox
|
||||
return cam.getProjectionMatrix();
|
||||
}
|
||||
|
||||
const math::mat4 FilamentViewer::getCameraCullingProjectionMatrix()
|
||||
{
|
||||
const auto &cam = _view->getCamera();
|
||||
return cam.getCullingProjectionMatrix();
|
||||
}
|
||||
|
||||
const filament::Frustum FilamentViewer::getCameraFrustum()
|
||||
{
|
||||
const auto &cam = _view->getCamera();
|
||||
|
||||
@@ -139,6 +139,19 @@ extern "C"
|
||||
memcpy(array, matrix.asArray(), 16 * sizeof(double));
|
||||
return array;
|
||||
}
|
||||
|
||||
const double *const get_camera_culling_projection_matrix(const void *const viewer)
|
||||
{
|
||||
const auto &matrix = ((FilamentViewer *)viewer)->getCameraCullingProjectionMatrix();
|
||||
double *array = (double *)calloc(16, sizeof(double));
|
||||
memcpy(array, matrix.asArray(), 16 * sizeof(double));
|
||||
return array;
|
||||
}
|
||||
|
||||
void set_camera_projection_matrix(const void *const viewer, const double* const matrix, double near, double far)
|
||||
{
|
||||
((FilamentViewer *)viewer)->setCameraProjectionMatrix(matrix, near, far);
|
||||
}
|
||||
|
||||
const double *const get_camera_frustum(const void *const viewer)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user