2014-02-10 13:41:05 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef _VIEWERWIDGET_HPP_
|
|
|
|
#define _VIEWERWIDGET_HPP_
|
2014-02-11 06:46:29 +01:00
|
|
|
#include <engine/GameData.hpp>
|
|
|
|
#include <engine/GameWorld.hpp>
|
2014-02-10 18:22:07 +01:00
|
|
|
#include <QTimer>
|
2014-03-01 12:19:33 +01:00
|
|
|
#include <loaders/LoaderIFP.hpp>
|
2016-04-16 15:06:02 +02:00
|
|
|
#include <gl/DrawBuffer.hpp>
|
|
|
|
#include <gl/GeometryBuffer.hpp>
|
|
|
|
#include <data/Model.hpp>
|
2014-06-10 21:26:04 +02:00
|
|
|
#include <glm/glm.hpp>
|
2014-02-10 13:41:05 +01:00
|
|
|
|
2016-04-16 15:06:02 +02:00
|
|
|
// Prevent Qt from conflicting with glLoadGen
|
|
|
|
#define GL_ARB_debug_output
|
|
|
|
#define GL_KHR_debug
|
|
|
|
#include <QGLWidget>
|
|
|
|
|
2015-04-13 02:48:29 +02:00
|
|
|
class GameRenderer;
|
2014-02-11 14:40:56 +01:00
|
|
|
class Model;
|
2014-02-10 13:41:05 +01:00
|
|
|
class ViewerWidget : public QGLWidget
|
|
|
|
{
|
2014-02-10 18:22:07 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2015-04-13 02:48:29 +02:00
|
|
|
GameRenderer* renderer;
|
|
|
|
|
2014-02-11 06:46:29 +01:00
|
|
|
QString currentFile;
|
2014-02-10 18:22:07 +01:00
|
|
|
|
|
|
|
QTimer timer;
|
2014-02-11 06:46:29 +01:00
|
|
|
GameWorld* gworld;
|
2014-03-01 12:19:33 +01:00
|
|
|
|
2015-04-13 02:48:29 +02:00
|
|
|
Model* activeModel;
|
2015-04-13 03:09:14 +02:00
|
|
|
ModelFrame* selectedFrame;
|
2014-03-01 12:19:33 +01:00
|
|
|
GameObject* dummyObject;
|
2014-06-10 01:46:48 +02:00
|
|
|
quint16 currentObjectID;
|
2014-02-11 14:40:56 +01:00
|
|
|
|
2014-06-10 17:47:44 +02:00
|
|
|
Model* _lastModel;
|
2014-03-01 12:19:33 +01:00
|
|
|
Animation* canimation;
|
2014-02-11 14:40:56 +01:00
|
|
|
|
|
|
|
float viewDistance;
|
2014-02-11 16:45:45 +01:00
|
|
|
glm::vec2 viewAngles;
|
2016-05-16 01:06:51 +02:00
|
|
|
glm::vec3 viewPosition;
|
2014-02-11 16:45:45 +01:00
|
|
|
|
|
|
|
bool dragging;
|
|
|
|
QPointF dstart;
|
|
|
|
glm::vec2 dastart;
|
2016-05-16 01:06:51 +02:00
|
|
|
bool moveFast;
|
2014-06-10 21:26:04 +02:00
|
|
|
|
|
|
|
DrawBuffer* _frameWidgetDraw;
|
|
|
|
GeometryBuffer* _frameWidgetGeom;
|
2015-04-13 03:09:14 +02:00
|
|
|
GLuint whiteTex;
|
|
|
|
|
2015-04-13 02:48:29 +02:00
|
|
|
void drawFrameWidget(ModelFrame* f, const glm::mat4& = glm::mat4(1.f));
|
2014-02-10 13:41:05 +01:00
|
|
|
public:
|
2014-06-08 02:58:49 +02:00
|
|
|
|
2016-08-08 06:30:11 +02:00
|
|
|
ViewerWidget(QGLFormat g, QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
|
2014-02-11 06:46:29 +01:00
|
|
|
|
2014-09-19 01:10:05 +02:00
|
|
|
virtual void initializeGL();
|
2014-02-10 13:41:05 +01:00
|
|
|
|
2014-09-19 01:10:05 +02:00
|
|
|
virtual void resizeGL(int w, int h);
|
2014-02-10 13:41:05 +01:00
|
|
|
|
2014-09-19 01:10:05 +02:00
|
|
|
virtual void paintGL();
|
2014-06-08 02:58:49 +02:00
|
|
|
|
2014-06-10 17:47:44 +02:00
|
|
|
Model *currentModel() const;
|
2015-04-14 02:06:50 +02:00
|
|
|
GameObject* currentObject() const;
|
2014-09-19 01:10:05 +02:00
|
|
|
|
2014-02-11 06:46:29 +01:00
|
|
|
GameWorld* world();
|
2014-02-10 18:22:07 +01:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
2015-04-14 02:06:50 +02:00
|
|
|
void showObject(qint16 item);
|
2015-04-13 02:48:29 +02:00
|
|
|
void showModel(Model* model);
|
2015-04-13 03:09:14 +02:00
|
|
|
void selectFrame(ModelFrame* frame);
|
2014-02-11 06:46:29 +01:00
|
|
|
|
2014-06-10 01:46:48 +02:00
|
|
|
void exportModel();
|
|
|
|
|
2014-06-08 02:58:49 +02:00
|
|
|
void dataLoaded(GameWorld* world);
|
|
|
|
|
2015-04-13 02:48:29 +02:00
|
|
|
void setRenderer(GameRenderer* renderer);
|
|
|
|
|
2014-09-19 01:10:05 +02:00
|
|
|
signals:
|
|
|
|
|
2014-02-11 06:46:29 +01:00
|
|
|
void fileOpened(const QString& file);
|
|
|
|
|
2014-06-10 17:47:44 +02:00
|
|
|
void modelChanged(Model* model);
|
|
|
|
|
2014-02-11 16:45:45 +01:00
|
|
|
protected:
|
|
|
|
|
2016-05-16 01:06:51 +02:00
|
|
|
void keyPressEvent(QKeyEvent*) override;
|
|
|
|
void keyReleaseEvent(QKeyEvent*) override;
|
|
|
|
void mousePressEvent(QMouseEvent*) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent*) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent*) override;
|
|
|
|
void wheelEvent(QWheelEvent*) override;
|
2014-02-10 13:41:05 +01:00
|
|
|
};
|
|
|
|
|
2014-03-01 12:19:33 +01:00
|
|
|
#endif
|