Merge remote-tracking branch 'origin/master' into gridfix
|
@ -3,13 +3,13 @@
|
|||
#include "printutils.h"
|
||||
|
||||
Camera::Camera(enum CameraType camtype) :
|
||||
type(camtype), projection(Camera::PERSPECTIVE), fov(45), viewall(false), zoom_value(60)
|
||||
type(camtype), projection(Camera::PERSPECTIVE), fov(45), viewall(false), height(60)
|
||||
{
|
||||
PRINTD("Camera()");
|
||||
if (this->type == Camera::GIMBAL) {
|
||||
object_trans << 0,0,0;
|
||||
object_rot << 35,0,25;
|
||||
zoom_value = 500;
|
||||
viewer_distance = 500;
|
||||
} else if (this->type == Camera::VECTOR) {
|
||||
center << 0,0,0;
|
||||
Eigen::Vector3d cameradir(1, 1, -0.5);
|
||||
|
@ -26,7 +26,8 @@ void Camera::setup(std::vector<double> params)
|
|||
type = Camera::GIMBAL;
|
||||
object_trans << params[0], params[1], params[2];
|
||||
object_rot << params[3], params[4], params[5];
|
||||
zoom_value = params[6];
|
||||
viewer_distance = params[6];
|
||||
height = params[6];
|
||||
} else if (params.size() == 6) {
|
||||
type = Camera::VECTOR;
|
||||
eye << params[0], params[1], params[2];
|
||||
|
@ -73,13 +74,13 @@ void Camera::viewAll(const BoundingBox &bbox, float scalefactor)
|
|||
|
||||
switch (this->projection) {
|
||||
case Camera::ORTHOGONAL:
|
||||
this->zoom_value = bbox.diagonal().norm();
|
||||
this->height = bbox.diagonal().norm();
|
||||
break;
|
||||
case Camera::PERSPECTIVE: {
|
||||
double radius = bbox.diagonal().norm()/2;
|
||||
switch (this->type) {
|
||||
case Camera::GIMBAL:
|
||||
this->zoom_value = radius / tan(this->fov*M_PI/360);
|
||||
this->viewer_distance = radius / tan(this->fov*M_PI/360);
|
||||
break;
|
||||
case Camera::VECTOR: {
|
||||
Vector3d cameradir = (this->center - this->eye).normalized();
|
||||
|
@ -100,7 +101,8 @@ void Camera::viewAll(const BoundingBox &bbox, float scalefactor)
|
|||
|
||||
void Camera::zoom(int delta)
|
||||
{
|
||||
this->zoom_value *= pow(0.9, delta / 120.0);
|
||||
this->viewer_distance *= pow(0.9, delta / 120.0);
|
||||
this->height = this->viewer_distance;
|
||||
}
|
||||
|
||||
void Camera::setProjection(ProjectionType type)
|
||||
|
@ -110,14 +112,16 @@ void Camera::setProjection(ProjectionType type)
|
|||
|
||||
void Camera::resetView()
|
||||
{
|
||||
type = Camera::GIMBAL;
|
||||
object_rot << 35, 0, -25;
|
||||
object_trans << 0, 0, 0;
|
||||
zoom_value = 140;
|
||||
height = 140;
|
||||
viewer_distance = 140;
|
||||
}
|
||||
|
||||
double Camera::zoomValue()
|
||||
{
|
||||
return zoom_value;
|
||||
return this->projection == PERSPECTIVE ? viewer_distance : height;
|
||||
}
|
||||
|
||||
std::string Camera::statusText()
|
||||
|
@ -125,6 +129,6 @@ std::string Camera::statusText()
|
|||
boost::format fmt(_("Viewport: translate = [ %.2f %.2f %.2f ], rotate = [ %.2f %.2f %.2f ], distance = %.2f"));
|
||||
fmt % object_trans.x() % object_trans.y() % object_trans.z()
|
||||
% object_rot.x() % object_rot.y() % object_rot.z()
|
||||
% zoom_value;
|
||||
% (this->projection == PERSPECTIVE ? viewer_distance : height);
|
||||
return fmt.str();
|
||||
}
|
||||
|
|
10
src/Camera.h
|
@ -30,9 +30,9 @@ public:
|
|||
void gimbalDefaultTranslate();
|
||||
void setProjection(ProjectionType type);
|
||||
void zoom(int delta);
|
||||
double zoomValue();
|
||||
void resetView();
|
||||
void viewAll(const BoundingBox &bbox, float scalefactor = 1.0f);
|
||||
double zoomValue();
|
||||
std::string statusText();
|
||||
|
||||
// Vectorcam
|
||||
|
@ -59,8 +59,8 @@ public:
|
|||
unsigned int pixel_height;
|
||||
|
||||
protected:
|
||||
// This is the viewer-distance in perspective mode and in
|
||||
// ortographic mode, this is defining the viewport height
|
||||
// (in world-space)
|
||||
double zoom_value;
|
||||
// Perspective settings
|
||||
double viewer_distance;
|
||||
// Orthographic settings
|
||||
double height; // world-space height of viewport
|
||||
};
|
||||
|
|
|
@ -92,21 +92,22 @@ void GLView::setupCamera()
|
|||
|
||||
switch (this->cam.type) {
|
||||
case Camera::GIMBAL: {
|
||||
double eyeY = 0.0;
|
||||
switch (this->cam.projection) {
|
||||
case Camera::PERSPECTIVE: {
|
||||
double dist = cam.zoomValue();
|
||||
gluPerspective(cam.fov, aspectratio, 0.1 * dist, 100 * dist);
|
||||
eyeY = cam.zoomValue();
|
||||
gluPerspective(cam.fov, aspectratio, 0.1 * eyeY, 100 * eyeY);
|
||||
break;
|
||||
}
|
||||
case Camera::ORTHOGONAL: {
|
||||
double height = cam.zoomValue();
|
||||
glOrtho(-height/2*aspectratio, height*aspectratio/2,
|
||||
-height/2, height/2,
|
||||
eyeY = cam.zoomValue();
|
||||
glOrtho(-eyeY/2*aspectratio, eyeY*aspectratio/2,
|
||||
-eyeY/2, eyeY/2,
|
||||
-far_far_away, +far_far_away);
|
||||
break;
|
||||
}
|
||||
}
|
||||
gluLookAt(0.0, -cam.zoomValue(), 0.0,
|
||||
gluLookAt(0.0, -eyeY, 0.0,
|
||||
0.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
|
|
@ -64,7 +64,6 @@ static bool running_under_wine = false;
|
|||
|
||||
void QGLView::init()
|
||||
{
|
||||
cam.type = Camera::GIMBAL;
|
||||
resetView();
|
||||
|
||||
this->mouse_drag_active = false;
|
||||
|
@ -245,6 +244,7 @@ void QGLView::mouseMoveEvent(QMouseEvent *event)
|
|||
if ((QApplication::keyboardModifiers() & Qt::ShiftModifier) != 0) {
|
||||
cam.zoom(-12.0 * dy);
|
||||
} else {
|
||||
|
||||
double mx = +(dx) * 3.0 * cam.zoomValue() / QWidget::width();
|
||||
double mz = -(dy) * 3.0 * cam.zoomValue() / QWidget::height();
|
||||
|
||||
|
|
|
@ -457,10 +457,7 @@ int cmdline(const char *deps_output_file, const std::string &filename, Camera &c
|
|||
// echo or OpenCSG png -> don't necessarily need geometry evaluation
|
||||
} else {
|
||||
root_geom = geomevaluator.evaluateGeometry(*tree.root(), true);
|
||||
if (!root_geom) {
|
||||
PRINT("No top-level object found.");
|
||||
return 1;
|
||||
}
|
||||
if (!root_geom) root_geom.reset(new CGAL_Nef_polyhedron());
|
||||
if (renderer == Render::CGAL && root_geom->getDimension() == 3) {
|
||||
const CGAL_Nef_polyhedron *N = dynamic_cast<const CGAL_Nef_polyhedron*>(root_geom.get());
|
||||
if (!N) {
|
||||
|
|
|
@ -934,6 +934,11 @@ function(add_cmdline_test TESTCMD_BASENAME)
|
|||
set_test_config(Default ${TEST_FULLNAME})
|
||||
endif()
|
||||
set_test_config(All ${TEST_FULLNAME})
|
||||
list(FIND FOUNDCONFIGS Bugs FOUND)
|
||||
if (FOUND EQUAL -1)
|
||||
set_test_config(Good ${TEST_FULLNAME})
|
||||
endif()
|
||||
|
||||
unset(FOUNDCONFIGS)
|
||||
get_test_config(${TEST_FULLNAME} FOUNDCONFIGS)
|
||||
set(CONFARG CONFIGURATIONS)
|
||||
|
@ -1206,30 +1211,16 @@ list(APPEND BUGS_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue584.scad
|
|||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue666.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue791.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue802.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue835.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue899.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue904.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue911.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue913.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue936.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue945.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue964.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue964b.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue990.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1004.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1005.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1061.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1069.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1089.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1105.scad)
|
||||
list(APPEND EXPORT3D_TEST_FILES ${BUGS_FILES})
|
||||
list(REMOVE_ITEM EXPORT3D_TEST_FILES
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue899.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue964.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue964b.scad)
|
||||
list(APPEND EXPORTCSG_TEST_FILES
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue964.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue964b.scad)
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue899.scad)
|
||||
#list(APPEND EXPORTCSG_TEST_FILES )
|
||||
list(APPEND ALL_2D_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue899.scad)
|
||||
|
||||
list(APPEND OPENCSGTEST_FILES ${BUGS_FILES})
|
||||
|
|
After Width: | Height: | Size: 9.1 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 9.9 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 5.8 KiB |