2014-04-28 21:09:25 +04:00
|
|
|
#pragma once
|
2013-03-02 04:41:50 +04:00
|
|
|
|
2013-03-03 20:52:25 +04:00
|
|
|
/*
|
|
|
|
|
|
|
|
Camera
|
|
|
|
|
2013-03-04 04:10:12 +04:00
|
|
|
For usage, see QGLView.cc, GLView.cc, export_png.cc, openscad.cc
|
2013-03-03 20:52:25 +04:00
|
|
|
|
|
|
|
There are two different types of cameras represented in this class:
|
|
|
|
|
|
|
|
*Gimbal camera - uses Euler Angles, object translation, and viewer distance
|
|
|
|
*Vector camera - uses 'eye', 'center', and 'up' vectors ('lookat' style)
|
|
|
|
|
2013-03-04 05:47:07 +04:00
|
|
|
They are not necessarily kept in sync. There are two modes of
|
|
|
|
projection, Perspective and Orthogonal.
|
2013-03-03 23:48:23 +04:00
|
|
|
|
2013-03-03 20:52:25 +04:00
|
|
|
*/
|
2013-03-02 04:41:50 +04:00
|
|
|
|
2014-06-20 01:47:38 +04:00
|
|
|
#include "linalg.h"
|
2013-03-02 04:41:50 +04:00
|
|
|
#include <vector>
|
|
|
|
#include <Eigen/Geometry>
|
|
|
|
|
2013-03-03 20:52:25 +04:00
|
|
|
class Camera
|
2013-03-02 04:41:50 +04:00
|
|
|
{
|
|
|
|
public:
|
2013-03-03 20:52:25 +04:00
|
|
|
enum CameraType { NONE, GIMBAL, VECTOR } type;
|
2013-03-03 23:48:23 +04:00
|
|
|
enum ProjectionType { ORTHOGONAL, PERSPECTIVE } projection;
|
2014-06-20 01:47:38 +04:00
|
|
|
Camera(enum CameraType camtype = NONE);
|
|
|
|
void setup(std::vector<double> params);
|
|
|
|
void gimbalDefaultTranslate();
|
2014-06-26 23:34:15 +04:00
|
|
|
void setProjection(ProjectionType type);
|
|
|
|
void zoom(int delta);
|
2015-03-05 18:24:13 +03:00
|
|
|
double zoomValue();
|
|
|
|
void resetView();
|
|
|
|
void viewAll(const BoundingBox &bbox);
|
|
|
|
std::string statusText();
|
2013-09-12 04:52:31 +04:00
|
|
|
|
2013-03-03 20:52:25 +04:00
|
|
|
// Vectorcam
|
2013-03-02 04:41:50 +04:00
|
|
|
Eigen::Vector3d eye;
|
|
|
|
Eigen::Vector3d center; // (aka 'target')
|
2013-03-04 05:47:07 +04:00
|
|
|
Eigen::Vector3d up; // not used currently
|
2013-03-02 04:41:50 +04:00
|
|
|
|
2013-03-03 20:52:25 +04:00
|
|
|
// Gimbalcam
|
|
|
|
Eigen::Vector3d object_trans;
|
|
|
|
Eigen::Vector3d object_rot;
|
2013-03-03 22:20:18 +04:00
|
|
|
|
2014-06-28 03:52:08 +04:00
|
|
|
// Perspective settings
|
2014-06-20 01:47:38 +04:00
|
|
|
double fov; // Field of view
|
|
|
|
|
2014-07-01 06:53:06 +04:00
|
|
|
// true if camera should try to view everything in a given
|
|
|
|
// bounding box.
|
2014-06-20 01:47:38 +04:00
|
|
|
bool viewall;
|
|
|
|
|
2014-07-01 06:53:06 +04:00
|
|
|
// true if camera should point at center of bounding box
|
|
|
|
// (normally it points at 0,0,0 or at given coordinates)
|
|
|
|
bool autocenter;
|
|
|
|
|
2013-03-03 22:20:18 +04:00
|
|
|
unsigned int pixel_width;
|
|
|
|
unsigned int pixel_height;
|
2015-01-05 20:34:08 +03:00
|
|
|
|
|
|
|
protected:
|
2015-01-06 05:43:17 +03:00
|
|
|
// Perspective settings
|
|
|
|
double viewer_distance;
|
|
|
|
// Orthographic settings
|
|
|
|
double height; // world-space height of viewport
|
2013-03-02 04:41:50 +04:00
|
|
|
};
|