-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglwidget.hpp
126 lines (110 loc) · 4.21 KB
/
glwidget.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef GLWIDGET_HPP
#define GLWIDGET_HPP
#include "vec.hpp"
#include "particlesystem.hpp"
#include <assimp/Importer.hpp>
#include <QGLWidget>
#include <QTimer>
#include <vector>
class GLWidget : public QGLWidget {
Q_OBJECT
public:
explicit GLWidget(QWidget *parent = 0);
void resizeGL(int w, int h);
void loadModel(const QString &qFName);
void openTetFile(const QString &fileName);
void saveToFile(const QString &fileName);
void saveAllToFile(const QString &fileName);
void openAllFromFile(const QString &fileName);
void importTetgenFiles(const QString &fileNameNode,
const QString &fileNameEle);
std::vector<Vec3f> mVertices;
std::vector<Vec3f> mVerticesInitPos;
std::vector<std::vector<int>> mTets;
std::vector<std::vector<int>> mBones;
float mHorMove;
float mVertMove;
float mDepthMove;
std::vector<GLfloat> mObjVertices;
Vec3f mPreviewVertPos;
ParticleSystem mParticleSystem;
typedef struct
{
Vec4f m[3];
} float3x4;
Vec3f mul(const float3x4 &M, const Vec3f &v)
{
Vec3f r;
r[0] = (v * Vec3f(M.m[0][0], M.m[0][1], M.m[0][2]));
r[1] = (v * Vec3f(M.m[1][0], M.m[1][1], M.m[1][2]));
r[2] = (v * Vec3f(M.m[2][0], M.m[2][1], M.m[2][2]));
return r;
}
private:
void initializeGL();
void paintGL();
void drawRectFace(const Vec3f&, const Vec3f&, const Vec3f&, const Vec3f&);
void drawTriFace(const Vec3f&, const Vec3f&, const Vec3f&);
void drawTet(const Vec3f&, const Vec3f&, const Vec3f&, const Vec3f&);
void setXRotation(int angle);
void setYRotation(int angle);
void setZRotation(int angle);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent* event);
void ybox(float h);
void drawLabel(const char* format , ...);
void mouseReleaseEvent(QMouseEvent *event) ;
int selection(int x, int y);
std::vector<GLfloat> mObjVerticesInitPos;
std::vector<GLfloat> mObjNormals;
std::vector<GLuint> mObjIndices;
bool showVerts;
bool showTets;
bool showAxes;
bool showObject;
bool showSkeleton;
bool showGround;
int xRot;
int yRot;
int zRot;
QPoint lastPos;
float zoomFactor;
bool previewVertState;
bool mStickTetState;
bool mBoneStickTetState;
Assimp::Importer importer;
bool simulate;
QTimer mTimerSim;
QTimer mTimerVis;
std::vector<Vec3f> mVerticesBackup;
std::vector<std::vector<int>> mTetsBackup;
std::vector<std::vector<int>> mBonesBackup;
std::vector<GLfloat> mObjVerticesBackup;
std::vector<GLfloat> mObjNormalsBackup;
std::vector<GLuint> mObjIndicesBackup;
bool mMidbutton;
GLint viewport[4];
GLdouble modelview[16];
GLdouble projection[16];
int whichtetvertice;
public slots:
void showVertsStateChanged(int state);
void showTetsStateChanged(int state);
void showAxesStateChanged(int state);
void showObjectStateChanged(int state);
void showSkeletonStateChanged(int state);
void showGroundStateChanged(int state);
void tetsEdited();
void objectEdited();
void bonesEdited();
void previewVertStateChanged(int state);
void simulationStateChanged(int state);
void resetSim();
void stickObjectToTetsStateChanged(int state);
void boneStickTetStateChanged(int state);
private slots:
void updateSimulation();
void updateSimulationGL();
};
#endif // GLWIDGET_HPP