diff options
-rw-r--r-- | src/Camera.h | 65 | ||||
-rw-r--r-- | src/GLView.cc | 4 | ||||
-rw-r--r-- | src/GLView.h | 12 |
3 files changed, 70 insertions, 11 deletions
diff --git a/src/Camera.h b/src/Camera.h new file mode 100644 index 0000000..2d2b18f --- /dev/null +++ b/src/Camera.h @@ -0,0 +1,65 @@ +#ifndef OPENSCAD_CAMERA_H_ +#define OPENSCAD_CAMERA_H_ + +// Cameras +// Variant design is similar to value.h/value.cc +// see GLView.cc / export_png.cc / openscad.cc for usage + +#include <vector> +#include <Eigen/Geometry> +#include <boost/variant.hpp> + +class NullCamera +{ +public: + NullCamera(){} +}; + +class GimbalCamera +{ +public: + GimbalCamera() + { + object_trans << 0,0,0; + object_rot << 35,0,25; + viewer_distance = 500; + } + void setup( std::vector<double> d ) + { + assert( d.size() == 7 ); + object_trans << d[0], d[1], d[2]; + object_rot << d[3], d[4], d[5]; + viewer_distance = d[6]; + } + Eigen::Vector3d object_trans; + Eigen::Vector3d object_rot; + double viewer_distance; +}; + +class VectorCamera +{ +public: + VectorCamera() + { + center << 0,0,0; + Eigen::Vector3d cameradir(1, 1, -0.5); + eye = center - 500 * cameradir; + // "up" not currently used + } + Eigen::Vector3d eye; + Eigen::Vector3d center; // (aka 'target') + Eigen::Vector3d up; +}; + +class Camera +{ +public: + enum CameraType { NONE, GIMBAL, VECTOR }; + typedef boost::variant<NullCamera, GimbalCamera, VectorCamera> CamVariant; + CamVariant value; + Camera() {} + CameraType type() { return static_cast<CameraType>(value.which()); } +}; + + +#endif diff --git a/src/GLView.cc b/src/GLView.cc index 130df29..0c02922 100644 --- a/src/GLView.cc +++ b/src/GLView.cc @@ -1,9 +1,6 @@ #include "GLView.h" -#include "printutils.h" #include "stdio.h" - -#include "linalg.h" #include "rendersettings.h" #ifdef _WIN32 @@ -349,6 +346,7 @@ void GLView::gimbalCamPaintGL() glLoadIdentity(); Color4f bgcol = RenderSettings::inst()->color(RenderSettings::BACKGROUND_COLOR); + fprintf(stderr, "%f %f %f", bgcol[0], bgcol[1], bgcol[2] ); glClearColor(bgcol[0], bgcol[1], bgcol[2], 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); diff --git a/src/GLView.h b/src/GLView.h index 6dadbf8..5d52e05 100644 --- a/src/GLView.h +++ b/src/GLView.h @@ -8,14 +8,14 @@ This class is inherited by *QGLview (for Qt GUI) *OffscreenView (used in tests and for offscreen command-line rendering). -There are two different types of cameras (in linalg.h) +There are two different types of cameras *Gimbal camera - uses Euler Angles, object translation, and viewer distance *Vector camera - uses 'eye', 'center', and 'up' vectors -Currently, the two cameras are not kept in sync and there is no way -to switch between them at runtime. QGLView uses GimbalCamera and -OffscreenView uses VectorCamera. +Currently, the two cameras are not kept in sync and they are not easily +interchangable in code QGLView uses GimbalCamera while OffscreenView can +use both (but defaults to Vector) */ @@ -28,7 +28,6 @@ OffscreenView uses VectorCamera. #include "system-gl.h" #include <iostream> #include "renderer.h" -#include "linalg.h" #include "Camera.h" #define FAR_FAR_AWAY 100000.0 @@ -54,9 +53,6 @@ public: void setupVectorCamOrtho(bool offset=false); void vectorCamPaintGL(); - void setCamera( NullCamera &nc ); - void setCamera( GimbalCamera &gc ); - void setCamera( VectorCamera &vc ); void setCamera( Camera &cam ); void showCrosshairs(); |