#1236 Revert camera FOV

master
Marius Kintel 2015-03-05 10:24:13 -05:00
parent e8ad157619
commit 039d0806e6
3 changed files with 16 additions and 16 deletions

View File

@ -3,7 +3,7 @@
#include "printutils.h"
Camera::Camera(enum CameraType camtype) :
type(camtype), projection(Camera::PERSPECTIVE), fov(45), viewall(false), height(60)
type(camtype), projection(Camera::PERSPECTIVE), fov(22.5), viewall(false), height(60)
{
PRINTD("Camera()");
if (this->type == Camera::GIMBAL) {
@ -48,10 +48,8 @@ void Camera::gimbalDefaultTranslate()
/*!
Moves camera so that the given bbox is fully visible.
FIXME: The scalefactor is a temporary hack to be compatible with
earlier ways of showing the whole scene.
*/
void Camera::viewAll(const BoundingBox &bbox, float scalefactor)
void Camera::viewAll(const BoundingBox &bbox)
{
if (this->type == Camera::NONE) {
this->type = Camera::VECTOR;
@ -75,15 +73,17 @@ void Camera::viewAll(const BoundingBox &bbox, float scalefactor)
case Camera::ORTHOGONAL:
this->height = this->viewer_distance = bbox.diagonal().norm();
break;
case Camera::PERSPECTIVE: {
double radius = bbox.diagonal().norm()/2;
case Camera::PERSPECTIVE: {
double bboxRadius = bbox.diagonal().norm()/2;
double radius = (bbox.center()-this->center).norm() + bboxRadius;
double distance = radius / sin(this->fov*M_PI/360);
switch (this->type) {
case Camera::GIMBAL:
this->height = this->viewer_distance = radius / tan(this->fov*M_PI/360);
this->height = this->viewer_distance = distance;
break;
case Camera::VECTOR: {
Vector3d cameradir = (this->center - this->eye).normalized();
this->eye = this->center - radius*scalefactor*cameradir;
this->eye = this->center - distance*cameradir;
break;
}
default:

View File

@ -30,10 +30,10 @@ public:
void gimbalDefaultTranslate();
void setProjection(ProjectionType type);
void zoom(int delta);
double zoomValue();
void resetView();
void viewAll(const BoundingBox &bbox, float scalefactor = 1.0f);
std::string statusText();
double zoomValue();
void resetView();
void viewAll(const BoundingBox &bbox);
std::string statusText();
// Vectorcam
Eigen::Vector3d eye;

View File

@ -12,11 +12,11 @@
#include "cgalutils.h"
#include "CGAL_Nef_polyhedron.h"
static void setupCamera(Camera &cam, const BoundingBox &bbox, float scalefactor)
static void setupCamera(Camera &cam, const BoundingBox &bbox)
{
PRINTDB("setupCamera() %i",cam.type);
if (cam.type == Camera::NONE) cam.viewall = true;
if (cam.viewall) cam.viewAll(bbox, scalefactor);
if (cam.viewall) cam.viewAll(bbox);
}
void export_png(shared_ptr<const Geometry> root_geom, Camera &cam, std::ostream &output)
@ -32,7 +32,7 @@ void export_png(shared_ptr<const Geometry> root_geom, Camera &cam, std::ostream
CGALRenderer cgalRenderer(root_geom);
BoundingBox bbox = cgalRenderer.getBoundingBox();
setupCamera(cam, bbox, 3);
setupCamera(cam, bbox);
glview->setCamera(cam);
glview->setRenderer(&cgalRenderer);
@ -75,7 +75,7 @@ void export_png_preview_common(Tree &tree, Camera &cam, std::ostream &output, Pr
csgInfo.glview->setRenderer(&thrownTogetherRenderer);
#ifdef ENABLE_OPENCSG
BoundingBox bbox = csgInfo.glview->getRenderer()->getBoundingBox();
setupCamera(cam, bbox, 2.7);
setupCamera(cam, bbox);
csgInfo.glview->setCamera(cam);
OpenCSG::setContext(0);