diff --git a/src/Camera.cc b/src/Camera.cc index fcb96fd5..a774fda9 100644 --- a/src/Camera.cc +++ b/src/Camera.cc @@ -52,23 +52,21 @@ void Camera::viewAll(const BoundingBox &bbox, float scalefactor) { if (this->type == Camera::NONE) { this->type = Camera::VECTOR; - this->center = getBoundingCenter(bbox); + this->center = bbox.center(); this->eye = this->center - Vector3d(1,1,-0.5); } switch (this->projection) { case Camera::ORTHOGONAL: - this->height = getBoundingRadius(bbox)*2; + this->height = bbox.diagonal().norm(); break; case Camera::PERSPECTIVE: { - double radius = getBoundingRadius(bbox); + double radius = bbox.diagonal().norm()/2; switch (this->type) { case Camera::GIMBAL: - // FIXME: viewAll() of gimbal cameras doesn't work this->viewer_distance = radius / tan(this->fov*M_PI/360); break; case Camera::VECTOR: { - // FIXME: viewAll() of orthographic cameras doesn't work Vector3d cameradir = (this->center - this->eye).normalized(); this->eye = this->center - radius*scalefactor*cameradir; break; diff --git a/src/GLView.cc b/src/GLView.cc index 973a259e..f10a43f5 100644 --- a/src/GLView.cc +++ b/src/GLView.cc @@ -66,19 +66,18 @@ void GLView::setupCamera() case Camera::PERSPECTIVE: { double dist = cam.viewer_distance; gluPerspective(cam.fov, aspectratio, 0.1*dist, 100*dist); - gluLookAt(0.0, -cam.viewer_distance, 0.0, - 0.0, 0.0, 0.0, - 0.0, 0.0, 1.0); break; } case Camera::ORTHOGONAL: { glOrtho(-cam.height/2*aspectratio, cam.height*aspectratio/2, -cam.height/2, cam.height/2, -far_far_away, +far_far_away); - gluLookAt(0.0, -cam.viewer_distance, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); break; } } + gluLookAt(0.0, -cam.viewer_distance, 0.0, + 0.0, 0.0, 0.0, + 0.0, 0.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotated(cam.object_rot.x(), 1.0, 0.0, 0.0); @@ -105,7 +104,7 @@ void GLView::setupCamera() glLoadIdentity(); gluLookAt(cam.eye[0], cam.eye[1], cam.eye[2], cam.center[0], cam.center[1], cam.center[2], - 0.0, 0.0, 1.0); + 0.0, 0.1, 1.0); // Tilt it a bit to be able to look down the Z axis break; default: break; diff --git a/src/linalg.cc b/src/linalg.cc index 274a70a5..4d85a710 100644 --- a/src/linalg.cc +++ b/src/linalg.cc @@ -46,18 +46,3 @@ bool matrix_contains_nan( const Transform3d &m ) } return false; } - -double getBoundingRadius(BoundingBox bbox) -{ - // FIXME: For eigen3, we can use bbox.diagonal().norm()/2; - double radius = (bbox.max() - bbox.min()).norm() / 2; - return radius; // 0; -} - -Vector3d getBoundingCenter(BoundingBox bbox) -{ - // FIXME: For eigen3, we can use bbox.center(); - Vector3d center = (bbox.min() + bbox.max()) / 2; - return center; // Vector3d(0,0,0); -} - diff --git a/src/linalg.h b/src/linalg.h index 8cf19392..d43a28a5 100644 --- a/src/linalg.h +++ b/src/linalg.h @@ -21,9 +21,6 @@ bool matrix_contains_infinity( const Transform3d &m ); bool matrix_contains_nan( const Transform3d &m ); BoundingBox operator*(const Transform3d &m, const BoundingBox &box); -Vector3d getBoundingCenter(BoundingBox bbox); -double getBoundingRadius(BoundingBox bbox); - class Color4f : public Eigen::Vector4f {