| 
									
										
										
										
											2016-12-24 16:03:37 +01:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "geometryengine.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QOpenGLWidget>
 | 
					
						
							|  |  |  | #include <QOpenGLFunctions>
 | 
					
						
							|  |  |  | #include <QMatrix4x4>
 | 
					
						
							|  |  |  | #include <QQuaternion>
 | 
					
						
							|  |  |  | #include <QVector2D>
 | 
					
						
							|  |  |  | #include <QBasicTimer>
 | 
					
						
							|  |  |  | #include <QOpenGLShaderProgram>
 | 
					
						
							| 
									
										
										
										
											2016-12-29 13:37:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-24 16:03:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | class GeometryEngine; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class OglViewerWidget : public QOpenGLWidget, protected QOpenGLFunctions | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	explicit OglViewerWidget(QWidget *parent = 0); | 
					
						
							|  |  |  | 	~OglViewerWidget(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-03 11:47:27 +01:00
										 |  |  | signals: | 
					
						
							| 
									
										
										
										
											2017-01-07 15:59:16 +01:00
										 |  |  | 	void loadFile(QString); | 
					
						
							| 
									
										
										
										
											2017-01-03 11:47:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 14:06:25 +01:00
										 |  |  | private: | 
					
						
							|  |  |  | 	struct { | 
					
						
							|  |  |  | 		bool left = false; | 
					
						
							|  |  |  | 		bool right = false; | 
					
						
							|  |  |  | 		QVector2D position; | 
					
						
							|  |  |  | 	} m_mouse; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-07 12:46:06 +01:00
										 |  |  | 	struct { | 
					
						
							|  |  |  | 		bool x = true; | 
					
						
							|  |  |  | 		bool y = true; | 
					
						
							|  |  |  | 		bool z = true; | 
					
						
							|  |  |  | 	} m_rotDirections; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-17 17:48:54 +01:00
										 |  |  | 	struct { | 
					
						
							| 
									
										
										
										
											2017-01-21 15:22:43 +01:00
										 |  |  | 		QVector4D position = { 1,1,1,0 }; | 
					
						
							| 
									
										
										
										
											2017-01-20 16:54:27 +01:00
										 |  |  | 		QVector3D intensities = { 1.0,1.0,1.0 }; | 
					
						
							| 
									
										
										
										
											2017-01-19 17:57:50 +01:00
										 |  |  | 		float attenuationFactor = 0.2f; | 
					
						
							|  |  |  | 		float ambientCoefficient = 0.005f; | 
					
						
							| 
									
										
										
										
											2017-01-17 17:48:54 +01:00
										 |  |  | 	} m_light; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-20 16:39:17 +01:00
										 |  |  | 	QVector4D m_backgroundColor = {0.5f, 0.8f, 1.0f, 1.0f}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 14:06:25 +01:00
										 |  |  | 	QOpenGLShaderProgram m_program; | 
					
						
							|  |  |  | 	GeometryEngine *m_dataEngine; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	QMatrix4x4 m_projection; | 
					
						
							| 
									
										
										
										
											2016-12-30 13:28:07 +01:00
										 |  |  | 	QVector3D m_translation; | 
					
						
							| 
									
										
										
										
											2016-12-29 14:06:25 +01:00
										 |  |  | 	QQuaternion m_rotation; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-16 14:24:30 +01:00
										 |  |  | 	bool m_wireframe = false; | 
					
						
							| 
									
										
										
										
											2017-01-18 17:01:43 +01:00
										 |  |  | 	bool m_lightOn = false; | 
					
						
							| 
									
										
										
										
											2017-01-16 14:24:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-21 15:22:43 +01:00
										 |  |  | 	double m_zSpeed = 1.0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-24 16:03:37 +01:00
										 |  |  | protected: | 
					
						
							|  |  |  | 	void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; | 
					
						
							|  |  |  | 	void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE; | 
					
						
							| 
									
										
										
										
											2016-12-27 14:05:39 +01:00
										 |  |  | 	void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE; | 
					
						
							| 
									
										
										
										
											2016-12-30 13:28:07 +01:00
										 |  |  | 	void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE; | 
					
						
							| 
									
										
										
										
											2017-01-03 11:47:27 +01:00
										 |  |  | 	void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE; | 
					
						
							| 
									
										
										
										
											2016-12-31 16:18:35 +01:00
										 |  |  | 	void dropEvent(QDropEvent * event) Q_DECL_OVERRIDE; | 
					
						
							| 
									
										
										
										
											2016-12-27 14:05:39 +01:00
										 |  |  | 	void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; | 
					
						
							| 
									
										
										
										
											2016-12-24 16:03:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void initializeGL() Q_DECL_OVERRIDE; | 
					
						
							|  |  |  | 	void resizeGL(int w, int h) Q_DECL_OVERRIDE; | 
					
						
							|  |  |  | 	void paintGL() Q_DECL_OVERRIDE; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 13:37:15 +01:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2016-12-24 16:03:37 +01:00
										 |  |  | 	void initShaders(); | 
					
						
							| 
									
										
										
										
											2017-01-04 14:35:27 +01:00
										 |  |  | 	void setConnections(); | 
					
						
							| 
									
										
										
										
											2017-01-18 17:01:43 +01:00
										 |  |  | 	void updateLightPosition(); | 
					
						
							| 
									
										
										
										
											2016-12-24 16:03:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												add exe icon,
signal-slot for openFile,
resetView on openFile,
cleanup when open a new file,
triangulate quad poly now correctly, more not working, bug from previous version,
next:
fix 5,6,.. triangulation,
triClothMan, IC Helmet, still buggy,
											
										 
											2017-01-02 12:21:32 +01:00
										 |  |  | private slots: | 
					
						
							|  |  |  | 	void resetView(); | 
					
						
							| 
									
										
										
										
											2017-01-05 16:04:51 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | public slots: | 
					
						
							|  |  |  | 	void changeDirection(int direction); | 
					
						
							| 
									
										
										
										
											2017-01-16 14:24:30 +01:00
										 |  |  | 	void toggleWireframe(); | 
					
						
							| 
									
										
										
										
											2017-01-18 17:01:43 +01:00
										 |  |  | 	void toggleLight(); | 
					
						
							| 
									
										
										
										
											2017-01-21 15:22:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | signals: | 
					
						
							|  |  |  | 	void sendMessage(QString message, int severity); | 
					
						
							| 
									
										
										
										
											2016-12-24 16:03:37 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 |