2014-02-10 13:41:05 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef _VIEWERWIDGET_HPP_
|
|
|
|
#define _VIEWERWIDGET_HPP_
|
2016-09-09 22:13:21 +02:00
|
|
|
#include <QTimer>
|
2017-01-03 15:18:06 +01:00
|
|
|
#include <data/Clump.hpp>
|
2014-02-11 06:46:29 +01:00
|
|
|
#include <engine/GameData.hpp>
|
|
|
|
#include <engine/GameWorld.hpp>
|
2016-04-16 15:06:02 +02:00
|
|
|
#include <gl/DrawBuffer.hpp>
|
|
|
|
#include <gl/GeometryBuffer.hpp>
|
2014-06-10 21:26:04 +02:00
|
|
|
#include <glm/glm.hpp>
|
2016-09-09 22:13:21 +02:00
|
|
|
#include <loaders/LoaderIFP.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;
|
2017-01-03 15:18:06 +01:00
|
|
|
class Clump;
|
2016-09-09 22:13:21 +02:00
|
|
|
class ViewerWidget : public QGLWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
GameRenderer* renderer;
|
|
|
|
|
|
|
|
QString currentFile;
|
|
|
|
|
|
|
|
QTimer timer;
|
|
|
|
GameWorld* gworld;
|
|
|
|
|
rwlib: Use ClumpPtr instead of Clump*
Should fix these memory leaks:
==22737== 14,598,040 (131,472 direct, 14,466,568 indirect) bytes in 2,739 blocks are definitely lost in loss record 3,124 of 3,126
==22737== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==22737== by 0x90FE4B: LoaderDFF::loadFromMemory(std::shared_ptr<FileContentsInfo>) (LoaderDFF.cpp:443)
==22737== by 0x7BCC86: GameData::loadModel(unsigned short) (GameData.cpp:474)
==22737== by 0x7DF7BC: GameWorld::createInstance(unsigned short, glm::tvec3<float, (glm::precision)0> const&, glm::tquat<float, (glm::precision)0> const&) (GameWorld.cpp:144)
==22737== by 0x7DF44C: GameWorld::placeItems(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameWorld.cpp:120)
==22737== by 0x758D38: RWGame::newGame() (RWGame.cpp:116)
==22737== by 0x786389: LoadingState::enter() (LoadingState.cpp:9)
==22737== by 0x75DC59: void StateManager::enter<LoadingState, RWGame*, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}>(RWGame*&&, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}&&) (StateManager.hpp:40)
==22737== by 0x758484: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:81)
==22737== by 0x747815: main (main.cpp:13)
2017-09-13 00:47:22 +02:00
|
|
|
ClumpPtr activeModel;
|
2016-09-09 22:13:21 +02:00
|
|
|
ModelFrame* selectedFrame;
|
|
|
|
GameObject* dummyObject;
|
|
|
|
quint16 currentObjectID;
|
|
|
|
|
rwlib: Use ClumpPtr instead of Clump*
Should fix these memory leaks:
==22737== 14,598,040 (131,472 direct, 14,466,568 indirect) bytes in 2,739 blocks are definitely lost in loss record 3,124 of 3,126
==22737== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==22737== by 0x90FE4B: LoaderDFF::loadFromMemory(std::shared_ptr<FileContentsInfo>) (LoaderDFF.cpp:443)
==22737== by 0x7BCC86: GameData::loadModel(unsigned short) (GameData.cpp:474)
==22737== by 0x7DF7BC: GameWorld::createInstance(unsigned short, glm::tvec3<float, (glm::precision)0> const&, glm::tquat<float, (glm::precision)0> const&) (GameWorld.cpp:144)
==22737== by 0x7DF44C: GameWorld::placeItems(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameWorld.cpp:120)
==22737== by 0x758D38: RWGame::newGame() (RWGame.cpp:116)
==22737== by 0x786389: LoadingState::enter() (LoadingState.cpp:9)
==22737== by 0x75DC59: void StateManager::enter<LoadingState, RWGame*, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}>(RWGame*&&, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}&&) (StateManager.hpp:40)
==22737== by 0x758484: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:81)
==22737== by 0x747815: main (main.cpp:13)
2017-09-13 00:47:22 +02:00
|
|
|
ClumpPtr _lastModel;
|
2016-09-09 22:13:21 +02:00
|
|
|
Animation* canimation;
|
|
|
|
|
|
|
|
float viewDistance;
|
|
|
|
glm::vec2 viewAngles;
|
|
|
|
glm::vec3 viewPosition;
|
|
|
|
|
|
|
|
bool dragging;
|
|
|
|
QPointF dstart;
|
|
|
|
glm::vec2 dastart;
|
|
|
|
bool moveFast;
|
|
|
|
|
|
|
|
DrawBuffer* _frameWidgetDraw;
|
|
|
|
GeometryBuffer* _frameWidgetGeom;
|
|
|
|
GLuint whiteTex;
|
|
|
|
|
|
|
|
void drawFrameWidget(ModelFrame* f, const glm::mat4& = glm::mat4(1.f));
|
|
|
|
|
2014-02-10 13:41:05 +01:00
|
|
|
public:
|
2016-09-09 22:13:21 +02:00
|
|
|
ViewerWidget(QGLFormat g, QWidget* parent = 0,
|
|
|
|
const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
|
|
|
|
|
|
|
|
virtual void initializeGL();
|
2014-06-08 02:58:49 +02:00
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
virtual void resizeGL(int w, int h);
|
2014-02-11 06:46:29 +01:00
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
virtual void paintGL();
|
2014-06-08 02:58:49 +02:00
|
|
|
|
rwlib: Use ClumpPtr instead of Clump*
Should fix these memory leaks:
==22737== 14,598,040 (131,472 direct, 14,466,568 indirect) bytes in 2,739 blocks are definitely lost in loss record 3,124 of 3,126
==22737== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==22737== by 0x90FE4B: LoaderDFF::loadFromMemory(std::shared_ptr<FileContentsInfo>) (LoaderDFF.cpp:443)
==22737== by 0x7BCC86: GameData::loadModel(unsigned short) (GameData.cpp:474)
==22737== by 0x7DF7BC: GameWorld::createInstance(unsigned short, glm::tvec3<float, (glm::precision)0> const&, glm::tquat<float, (glm::precision)0> const&) (GameWorld.cpp:144)
==22737== by 0x7DF44C: GameWorld::placeItems(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameWorld.cpp:120)
==22737== by 0x758D38: RWGame::newGame() (RWGame.cpp:116)
==22737== by 0x786389: LoadingState::enter() (LoadingState.cpp:9)
==22737== by 0x75DC59: void StateManager::enter<LoadingState, RWGame*, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}>(RWGame*&&, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}&&) (StateManager.hpp:40)
==22737== by 0x758484: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:81)
==22737== by 0x747815: main (main.cpp:13)
2017-09-13 00:47:22 +02:00
|
|
|
ClumpPtr currentModel() const;
|
2016-09-09 22:13:21 +02:00
|
|
|
GameObject* currentObject() const;
|
2014-09-19 01:10:05 +02:00
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
GameWorld* world();
|
2014-02-10 18:22:07 +01:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
void showObject(qint16 item);
|
rwlib: Use ClumpPtr instead of Clump*
Should fix these memory leaks:
==22737== 14,598,040 (131,472 direct, 14,466,568 indirect) bytes in 2,739 blocks are definitely lost in loss record 3,124 of 3,126
==22737== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==22737== by 0x90FE4B: LoaderDFF::loadFromMemory(std::shared_ptr<FileContentsInfo>) (LoaderDFF.cpp:443)
==22737== by 0x7BCC86: GameData::loadModel(unsigned short) (GameData.cpp:474)
==22737== by 0x7DF7BC: GameWorld::createInstance(unsigned short, glm::tvec3<float, (glm::precision)0> const&, glm::tquat<float, (glm::precision)0> const&) (GameWorld.cpp:144)
==22737== by 0x7DF44C: GameWorld::placeItems(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameWorld.cpp:120)
==22737== by 0x758D38: RWGame::newGame() (RWGame.cpp:116)
==22737== by 0x786389: LoadingState::enter() (LoadingState.cpp:9)
==22737== by 0x75DC59: void StateManager::enter<LoadingState, RWGame*, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}>(RWGame*&&, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}&&) (StateManager.hpp:40)
==22737== by 0x758484: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:81)
==22737== by 0x747815: main (main.cpp:13)
2017-09-13 00:47:22 +02:00
|
|
|
void showModel(ClumpPtr model);
|
2016-09-09 22:13:21 +02:00
|
|
|
void selectFrame(ModelFrame* frame);
|
2014-02-11 06:46:29 +01:00
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
void exportModel();
|
2014-06-10 01:46:48 +02:00
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
void dataLoaded(GameWorld* world);
|
2014-06-08 02:58:49 +02:00
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
void setRenderer(GameRenderer* renderer);
|
2015-04-13 02:48:29 +02:00
|
|
|
|
2014-09-19 01:10:05 +02:00
|
|
|
signals:
|
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
void fileOpened(const QString& file);
|
2014-02-11 06:46:29 +01:00
|
|
|
|
rwlib: Use ClumpPtr instead of Clump*
Should fix these memory leaks:
==22737== 14,598,040 (131,472 direct, 14,466,568 indirect) bytes in 2,739 blocks are definitely lost in loss record 3,124 of 3,126
==22737== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==22737== by 0x90FE4B: LoaderDFF::loadFromMemory(std::shared_ptr<FileContentsInfo>) (LoaderDFF.cpp:443)
==22737== by 0x7BCC86: GameData::loadModel(unsigned short) (GameData.cpp:474)
==22737== by 0x7DF7BC: GameWorld::createInstance(unsigned short, glm::tvec3<float, (glm::precision)0> const&, glm::tquat<float, (glm::precision)0> const&) (GameWorld.cpp:144)
==22737== by 0x7DF44C: GameWorld::placeItems(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameWorld.cpp:120)
==22737== by 0x758D38: RWGame::newGame() (RWGame.cpp:116)
==22737== by 0x786389: LoadingState::enter() (LoadingState.cpp:9)
==22737== by 0x75DC59: void StateManager::enter<LoadingState, RWGame*, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}>(RWGame*&&, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}&&) (StateManager.hpp:40)
==22737== by 0x758484: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:81)
==22737== by 0x747815: main (main.cpp:13)
2017-09-13 00:47:22 +02:00
|
|
|
void modelChanged(ClumpPtr model);
|
2014-06-10 17:47:44 +02:00
|
|
|
|
2014-02-11 16:45:45 +01:00
|
|
|
protected:
|
2016-09-09 22:13:21 +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
|