2018-03-20 07:56:49 +00:00
|
|
|
#ifndef MODEL_WIDGET_H
|
|
|
|
#define MODEL_WIDGET_H
|
2018-03-10 06:57:14 +00:00
|
|
|
#include <QOpenGLWidget>
|
|
|
|
#include <QOpenGLFunctions>
|
|
|
|
#include <QOpenGLVertexArrayObject>
|
|
|
|
#include <QOpenGLBuffer>
|
|
|
|
#include <QMatrix4x4>
|
|
|
|
#include <QMutex>
|
2018-03-29 23:32:30 +00:00
|
|
|
#include <QRubberBand>
|
2018-03-10 06:57:14 +00:00
|
|
|
#include "mesh.h"
|
2018-04-02 06:05:06 +00:00
|
|
|
#include "modelshaderprogram.h"
|
|
|
|
#include "modelmeshbinder.h"
|
2018-03-10 06:57:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
class SkeletonGraphicsFunctions;
|
2018-03-30 07:41:29 +00:00
|
|
|
|
2018-03-20 07:56:49 +00:00
|
|
|
class ModelWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
2018-03-10 06:57:14 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-03-20 07:56:49 +00:00
|
|
|
ModelWidget(QWidget *parent = 0);
|
|
|
|
~ModelWidget();
|
2018-03-10 06:57:14 +00:00
|
|
|
|
|
|
|
static bool isTransparent() { return m_transparent; }
|
|
|
|
static void setTransparent(bool t) { m_transparent = t; }
|
|
|
|
|
|
|
|
void updateMesh(Mesh *mesh);
|
2018-03-20 07:56:49 +00:00
|
|
|
void exportMeshAsObj(const QString &filename);
|
2018-04-07 08:44:39 +00:00
|
|
|
void setGraphicsFunctions(SkeletonGraphicsFunctions *graphicsFunctions);
|
2018-04-15 12:48:54 +00:00
|
|
|
void toggleWireframe();
|
2018-03-10 06:57:14 +00:00
|
|
|
public slots:
|
|
|
|
void setXRotation(int angle);
|
|
|
|
void setYRotation(int angle);
|
|
|
|
void setZRotation(int angle);
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void xRotationChanged(int angle);
|
|
|
|
void yRotationChanged(int angle);
|
|
|
|
void zRotationChanged(int angle);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void initializeGL() override;
|
|
|
|
void paintGL() override;
|
|
|
|
void resizeGL(int width, int height) override;
|
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
2018-03-29 23:32:30 +00:00
|
|
|
void wheelEvent(QWheelEvent *event) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
2018-04-12 12:27:21 +00:00
|
|
|
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
|
|
|
void keyPressEvent(QKeyEvent *event) override;
|
2018-04-10 07:59:20 +00:00
|
|
|
public:
|
|
|
|
int xRot();
|
|
|
|
int yRot();
|
|
|
|
int zRot();
|
2018-03-10 06:57:14 +00:00
|
|
|
private:
|
|
|
|
int m_xRot;
|
|
|
|
int m_yRot;
|
|
|
|
int m_zRot;
|
2018-04-15 12:48:54 +00:00
|
|
|
ModelShaderProgram *m_program;
|
|
|
|
bool m_moveStarted;
|
|
|
|
SkeletonGraphicsFunctions *m_graphicsFunctions;
|
|
|
|
private:
|
2018-03-10 06:57:14 +00:00
|
|
|
QPoint m_lastPos;
|
2018-04-02 06:05:06 +00:00
|
|
|
ModelMeshBinder m_meshBinder;
|
2018-03-10 06:57:14 +00:00
|
|
|
QMatrix4x4 m_proj;
|
|
|
|
QMatrix4x4 m_camera;
|
|
|
|
QMatrix4x4 m_world;
|
|
|
|
static bool m_transparent;
|
2018-03-29 23:32:30 +00:00
|
|
|
QPoint m_moveStartPos;
|
|
|
|
QRect m_moveStartGeometry;
|
2018-03-10 06:57:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|