openscad/src/Camera.h

67 lines
1.6 KiB
C
Raw Permalink Normal View History

#pragma once
/*
Camera
2013-03-04 04:10:12 +04:00
For usage, see QGLView.cc, GLView.cc, export_png.cc, openscad.cc
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.
*/
#include "linalg.h"
#include <vector>
#include <Eigen/Geometry>
class Camera
{
public:
enum CameraType { NONE, GIMBAL, VECTOR } type;
enum ProjectionType { ORTHOGONAL, PERSPECTIVE } projection;
Camera(enum CameraType camtype = NONE);
void setup(std::vector<double> params);
void gimbalDefaultTranslate();
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
// Vectorcam
Eigen::Vector3d eye;
Eigen::Vector3d center; // (aka 'target')
2013-03-04 05:47:07 +04:00
Eigen::Vector3d up; // not used currently
// Gimbalcam
Eigen::Vector3d object_trans;
Eigen::Vector3d object_rot;
// Perspective settings
double fov; // Field of view
// true if camera should try to view everything in a given
// bounding box.
bool viewall;
// true if camera should point at center of bounding box
// (normally it points at 0,0,0 or at given coordinates)
bool autocenter;
unsigned int pixel_width;
unsigned int pixel_height;
protected:
// Perspective settings
double viewer_distance;
// Orthographic settings
double height; // world-space height of viewport
};