23 #ifndef __QTFLYCAMERAWIDGET__ 24 #define __QTFLYCAMERAWIDGET__ 36 #include <QMouseEvent> 37 #include <QFileDialog> 106 QGLFormat glCurrentFormat = this->format();
107 cout <<
"QT GL version : " << glCurrentFormat.majorVersion() <<
" , " << glCurrentFormat.minorVersion() << endl;
116 camera->
setViewport(Eigen::Vector2f ((
float)this->width(), (
float)this->height()));
118 light_trackball.
setViewport(Eigen::Vector2f ((
float)this->width(), (
float)this->height()));
127 Eigen::Vector2i size;
128 size << this->width(), this->height();
131 camera->
setViewport(Eigen::Vector2f ((
float)this->width(), (
float)this->height()));
134 light_trackball.
setViewport(Eigen::Vector2f ((
float)this->width(), (
float)this->height()));
146 QString str (filename.c_str());
147 QStringList strlist = str.split(
".");
148 QString extension = strlist[strlist.size()-1];
150 if (extension.compare(
"ply") != 0 && extension.compare(
"obj") != 0)
152 cerr <<
"file format [" << extension.toStdString() <<
"] not supported" << endl;
158 if (extension.compare(
"ply") == 0)
162 if (extension.compare(
"obj") == 0)
178 if (event->key() == Qt::Key_O)
180 QString filename = QFileDialog::getOpenFileName(
this, tr(
"Open File"),
"", tr(
"Mesh Files (*.obj *.ply)"));
181 if (!filename.isEmpty())
183 openMesh (filename.toStdString());
186 if (event->key() == Qt::Key_R)
188 if (event->key() == Qt::Key_A)
190 if (event->key() == Qt::Key_D)
192 if (event->key() == Qt::Key_S)
194 if (event->key() == Qt::Key_W)
196 if (event->key() == Qt::Key_C)
198 if (event->key() == Qt::Key_E)
216 Eigen::Vector2f screen_pos (event->x(),
event->y());
217 if (event->button() == Qt::LeftButton)
222 if (event->button() == Qt::RightButton)
237 Eigen::Vector2f screen_pos (event->x(),
event->y());
238 if (event->buttons() & Qt::LeftButton)
240 camera->
rotate(screen_pos);
243 if (event->buttons() & Qt::RightButton)
260 if (event->button() == Qt::RightButton)
virtual Eigen::Quaternion< float > rotateCamera(const Eigen::Vector2f &pos)
Computes and applies the rotation transformations to the trackball given new position.
Definition: trackball.hpp:455
Definition: bufferobject.hpp:34
Trackball class for manipulating a camera.
Definition: trackball.hpp:79
void setViewport(const Eigen::Vector4f &vp)
Sets the viewport coordinates.
Definition: camera.hpp:274
This class is just to make sure that GLEW is initialized before anything else, so the constructor of ...
Definition: qtflycamerawidget.hpp:50
static void loadObjFile(Mesh *mesh, string filename) __attribute__((unused))
Loads a mesh from an OBJ file.
Definition: objimporter.hpp:50
virtual void rotate(Eigen::Vector2f new_mouse_pos)
Rotates the camera view direction.
Definition: flycamera.hpp:269
Flythrough camera class for manipulating a camera.
Definition: flycamera.hpp:41
virtual void moveBack(void)
Translates the view matrix back.
Definition: flycamera.hpp:214
Eigen::Matrix4f setPerspectiveMatrix(float fy, float in_aspect_ratio, float in_near_plane, float in_far_plane)
Sets the projection matrix as a perspective matrix.
Definition: camera.hpp:405
virtual void moveDown(void)
Translates the view matrix down.
Definition: flycamera.hpp:232
void setRenderFlag(bool flag)
Returns wether the trackball representation should be drawn or not.
Definition: trackball.hpp:299
QtGlewFlycameraInitializer(QWidget *parent)
Definition: qtflycamerawidget.hpp:53
virtual void endRotation(void)
Indicates that a rotation has ended. Disables the rotating flag, indicating that the mouse callback f...
Definition: trackball.hpp:279
virtual void moveForward(void)
Translates the view matrix forward.
Definition: flycamera.hpp:223
static bool loadPlyFile(Mesh *mesh, string filename) __attribute__((unused))
Loads a mesh from an PLY file.
Definition: plyimporter.hpp:150
float getFovy(void) const
Returns current field of view angle in y axis.
Definition: camera.hpp:344
virtual void moveUp(void)
Translates the view matrix up.
Definition: flycamera.hpp:240
virtual void strideLeft(void)
Translates the view matrix to the left.
Definition: flycamera.hpp:196
void normalizeModelMatrix(void)
Normalize model matrix to center and scale model. The model matrix will include a translation to plac...
Definition: model.hpp:141
void startRotation(Eigen::Vector2f pos)
Begin view direction rotation.
Definition: flycamera.hpp:260
virtual void strideRight(void)
Translates the view matrix to the right.
Definition: flycamera.hpp:205
A common Mesh, usually containing triagles or points.
Definition: mesh.hpp:194
virtual void updateViewMatrix()
Compose rotation and translation.
Definition: flycamera.hpp:166
virtual void reset(void)
Resets camera to initial position and orientation.
Definition: flycamera.hpp:76
void initGlew(void)
Initialize Glew.
Definition: misc.hpp:68