use focal length from GLTF
This commit is contained in:
@@ -360,13 +360,9 @@ namespace polyvox
|
|||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Sets the active camera to the GLTF camera specified by [name].
|
/// Sets the active camera to the GLTF camera node specified by [name].
|
||||||
/// Blender export arranges cameras as follows
|
/// N.B. Blender will generally export a three-node hierarchy - Camera1->Camera_Orientation->Camera2.
|
||||||
/// - parent node with global (?) matrix
|
/// The correct name will be the grandchild (i.e. Camera2 in this scenario).
|
||||||
/// --- child node with "camera" property set to camera node name
|
|
||||||
/// - camera node
|
|
||||||
/// We therefore find the first node where the "camera" property is equal to the requested name,
|
|
||||||
/// then use the parent transform matrix.
|
|
||||||
///
|
///
|
||||||
bool FilamentViewer::setCamera(const char *cameraName)
|
bool FilamentViewer::setCamera(const char *cameraName)
|
||||||
{
|
{
|
||||||
@@ -378,7 +374,7 @@ namespace polyvox
|
|||||||
}
|
}
|
||||||
|
|
||||||
const utils::Entity* cameras = _asset->getCameraEntities();
|
const utils::Entity* cameras = _asset->getCameraEntities();
|
||||||
Log("%zu cameras found in current asset", cameraName, count);
|
Log("%zu cameras found in current asset", count);
|
||||||
for(int i=0; i < count; i++) {
|
for(int i=0; i < count; i++) {
|
||||||
|
|
||||||
auto inst = _ncm->getInstance(cameras[i]);
|
auto inst = _ncm->getInstance(cameras[i]);
|
||||||
@@ -386,15 +382,14 @@ namespace polyvox
|
|||||||
Log("Camera %d : %s", i, name);
|
Log("Camera %d : %s", i, name);
|
||||||
if (strcmp(name, cameraName) == 0) {
|
if (strcmp(name, cameraName) == 0) {
|
||||||
|
|
||||||
Camera* camera = _engine->createCamera(cameras[i]);
|
Camera* camera = _engine->getCameraComponent(cameras[i]);
|
||||||
const Viewport &vp = _view->getViewport();
|
_view->setCamera(camera);
|
||||||
|
|
||||||
|
const Viewport &vp = _view->getViewport();
|
||||||
const double aspect = (double)vp.width / vp.height;
|
const double aspect = (double)vp.width / vp.height;
|
||||||
|
|
||||||
// todo - pull focal length from gltf node
|
Log("Camera focal length : %f aspect %f", camera->getFocalLength(), aspect);
|
||||||
|
camera->setScaling({1.0 / aspect, 1.0});
|
||||||
camera->setLensProjection(_cameraFocalLength, aspect, kNearPlane, kFarPlane);
|
|
||||||
_view->setCamera(camera);
|
|
||||||
Log("Successfully set camera.");
|
Log("Successfully set camera.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user