camera.h
#ifndef PCL_OUTOFCORE_CAMERA_H_
#define PCL_OUTOFCORE_CAMERA_H_
// C++
#include <iostream>
#include <string>
// PCL
#include <pcl/outofcore/visualization/object.h>
#include <pcl/common/eigen.h>
// VTK
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkCameraActor.h>
#include <vtkPolyData.h>
#include <vtkSmartPointer.h>
class Camera : public Object
{
public:
// Operators
// -----------------------------------------------------------------------------
Camera (std::string name);
Camera (std::string name, vtkSmartPointer<vtkCamera> camera);
private:
// friend std::ostream & operator<<(std::ostream &os, const Camera& camera);
public:
// Accessors
// -----------------------------------------------------------------------------
inline vtkSmartPointer<vtkCamera>
getCamera () const
{
return camera_;
}
inline vtkSmartPointer<vtkCameraActor>
getCameraActor () const
{
return camera_actor_;
}
inline vtkSmartPointer<vtkActor>
getHullActor () const
{
return hull_actor_;
}
inline bool
getDisplay () const
{
return display_;
}
void
setDisplay (bool display)
{
this->display_ = display;
}
void
getFrustum (double frustum[])
{
for (int i = 0; i < 24; i++)
frustum[i] = frustum_[i];
}
void
setProjectionMatrix (const Eigen::Matrix4d &projection_matrix)
{
projection_matrix_ = projection_matrix;
}
Eigen::Matrix4d
getProjectionMatrix ()
{
return projection_matrix_;
}
void
setModelViewMatrix (const Eigen::Matrix4d &model_view_matrix)
{
model_view_matrix_ = model_view_matrix;
}
Eigen::Matrix4d
getModelViewMatrix ()
{
return model_view_matrix_;
}
Eigen::Matrix4d
getViewProjectionMatrix ()
{
return Eigen::Matrix4d (projection_matrix_ * model_view_matrix_);
}
Eigen::Vector3d
getPosition ()
{
//Compute eye or position from model view matrix
Eigen::Matrix4d inverse_model_view_matrix = model_view_matrix_.inverse ();
Eigen::Vector3d position;
for (int i = 0; i < 3; i++)
{
position (i) = inverse_model_view_matrix (i, 3);
}
return position;
}
inline void
setClippingRange (float near_value = 0.0001f, float far_value = 100000.f)
{
camera_->SetClippingRange (near_value, far_value);
}
virtual void
render (vtkRenderer* renderer);
// Methods
// -----------------------------------------------------------------------------
//void computeFrustum(double aspect);
void
computeFrustum ();
//computeFrustum(double aspect);
void
printFrustum ();
private:
// Members
// -----------------------------------------------------------------------------
vtkSmartPointer<vtkCamera> camera_;
vtkSmartPointer<vtkCameraActor> camera_actor_;
vtkSmartPointer<vtkActor> hull_actor_;
bool display_;
double frustum_[24];
Eigen::Matrix4d projection_matrix_;
Eigen::Matrix4d model_view_matrix_;
double prevUp_[3];
double prevFocal_[3];
double prevPos_[3];
};
#endif
Camera::setProjectionMatrix
void setProjectionMatrix(const Eigen::Matrix4d &projection_matrix)
Definition: camera.h:73
vtkSmartPointer< vtkCamera >
Camera::setModelViewMatrix
void setModelViewMatrix(const Eigen::Matrix4d &model_view_matrix)
Definition: camera.h:85
Camera::getProjectionMatrix
Eigen::Matrix4d getProjectionMatrix()
Definition: camera.h:79
Camera::printFrustum
void printFrustum()
Camera::getPosition
Eigen::Vector3d getPosition()
Definition: camera.h:103
Camera::setDisplay
void setDisplay(bool display)
Definition: camera.h:60
Camera
Definition: camera.h:19
Camera::getHullActor
vtkSmartPointer< vtkActor > getHullActor() const
Definition: camera.h:48
Camera::computeFrustum
void computeFrustum()
Camera::getCameraActor
vtkSmartPointer< vtkCameraActor > getCameraActor() const
Definition: camera.h:42
Camera::getViewProjectionMatrix
Eigen::Matrix4d getViewProjectionMatrix()
Definition: camera.h:97
Camera::getCamera
vtkSmartPointer< vtkCamera > getCamera() const
Definition: camera.h:36
Camera::render
virtual void render(vtkRenderer *renderer)
Camera::getFrustum
void getFrustum(double frustum[])
Definition: camera.h:66
Object
Definition: object.h:23
Camera::getDisplay
bool getDisplay() const
Definition: camera.h:54
Camera::setClippingRange
void setClippingRange(float near_value=0.0001f, float far_value=100000.f)
Definition: camera.h:117
Camera::getModelViewMatrix
Eigen::Matrix4d getModelViewMatrix()
Definition: camera.h:91
Camera::Camera
Camera(std::string name)