mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 03:12:36 +01:00
Restore rwviewer to functional state
This commit is contained in:
parent
97afc19cfb
commit
1827b9cca3
@ -183,6 +183,9 @@ public:
|
|||||||
/** Increases cinematic value */
|
/** Increases cinematic value */
|
||||||
void renderLetterbox();
|
void renderLetterbox();
|
||||||
|
|
||||||
|
void setupRender();
|
||||||
|
void renderPostProcess();
|
||||||
|
|
||||||
Renderer* getRenderer()
|
Renderer* getRenderer()
|
||||||
{
|
{
|
||||||
return renderer;
|
return renderer;
|
||||||
|
@ -226,6 +226,15 @@ float mix(uint8_t a, uint8_t b, float num)
|
|||||||
return a+(b-a)*num;
|
return a+(b-a)*num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameRenderer::setupRender()
|
||||||
|
{
|
||||||
|
// Set the viewport
|
||||||
|
const glm::ivec2& vp = getRenderer()->getViewport();
|
||||||
|
glViewport(0, 0, vp.x, vp.y);
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, framebufferName);
|
||||||
|
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
void GameRenderer::renderWorld(const ViewCamera &camera, float alpha)
|
void GameRenderer::renderWorld(const ViewCamera &camera, float alpha)
|
||||||
{
|
{
|
||||||
_renderAlpha = alpha;
|
_renderAlpha = alpha;
|
||||||
@ -233,11 +242,7 @@ void GameRenderer::renderWorld(const ViewCamera &camera, float alpha)
|
|||||||
// Store the input camera,
|
// Store the input camera,
|
||||||
_camera = camera;
|
_camera = camera;
|
||||||
|
|
||||||
// Set the viewport
|
setupRender();
|
||||||
const glm::ivec2& vp = getRenderer()->getViewport();
|
|
||||||
glViewport(0, 0, vp.x, vp.y);
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, framebufferName);
|
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
glBindVertexArray( vao );
|
glBindVertexArray( vao );
|
||||||
|
|
||||||
@ -497,6 +502,16 @@ void GameRenderer::renderWorld(const ViewCamera &camera, float alpha)
|
|||||||
renderLetterbox();
|
renderLetterbox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderPostProcess();
|
||||||
|
|
||||||
|
glUseProgram(0);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
glBindVertexArray( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameRenderer::renderPostProcess()
|
||||||
|
{
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
@ -508,11 +523,6 @@ void GameRenderer::renderWorld(const ViewCamera &camera, float alpha)
|
|||||||
wdp.textures = {fbTextures[0]};
|
wdp.textures = {fbTextures[0]};
|
||||||
|
|
||||||
renderer->drawArrays(glm::mat4(), &ssRectDraw, wdp);
|
renderer->drawArrays(glm::mat4(), &ssRectDraw, wdp);
|
||||||
|
|
||||||
glUseProgram(0);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
|
||||||
glBindVertexArray( 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameRenderer::renderPedestrian(CharacterObject *pedestrian)
|
void GameRenderer::renderPedestrian(CharacterObject *pedestrian)
|
||||||
|
@ -6,16 +6,19 @@ find_package(Qt5Core REQUIRED)
|
|||||||
add_executable(rwviewer
|
add_executable(rwviewer
|
||||||
main.cpp
|
main.cpp
|
||||||
ViewerWindow.cpp
|
ViewerWindow.cpp
|
||||||
ObjectViewer.cpp
|
|
||||||
|
|
||||||
models/ObjectListModel.cpp
|
models/ObjectListModel.cpp
|
||||||
|
models/DFFFramesTreeModel.cpp
|
||||||
|
|
||||||
|
|
||||||
|
views/ObjectViewer.cpp
|
||||||
|
views/ModelViewer.cpp
|
||||||
|
|
||||||
ViewerWidget.cpp
|
ViewerWidget.cpp
|
||||||
ItemListModel.cpp
|
ItemListModel.cpp
|
||||||
ItemListWidget.cpp
|
ItemListWidget.cpp
|
||||||
IMGArchiveModel.cpp
|
IMGArchiveModel.cpp
|
||||||
DFFFramesTreeModel.cpp
|
widgets/ModelFramesWidget.cpp
|
||||||
ModelFramesWidget.cpp
|
|
||||||
AnimationListModel.cpp
|
AnimationListModel.cpp
|
||||||
AnimationListWidget.cpp)
|
AnimationListWidget.cpp)
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "ViewerWidget.hpp"
|
#include "ViewerWidget.hpp"
|
||||||
#include <render/Model.hpp>
|
#include <render/Model.hpp>
|
||||||
|
#include <render/GameRenderer.hpp>
|
||||||
|
#include <render/OpenGLRenderer.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <engine/GameObject.hpp>
|
#include <engine/GameObject.hpp>
|
||||||
@ -13,7 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
ViewerWidget::ViewerWidget(QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f)
|
ViewerWidget::ViewerWidget(QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f)
|
||||||
: QGLWidget(parent, shareWidget, f), gworld(nullptr), dummyObject(nullptr), currentObjectID(0),
|
: QGLWidget(parent, shareWidget, f), gworld(nullptr), activeModel(nullptr), dummyObject(nullptr), currentObjectID(0),
|
||||||
_lastModel(nullptr), canimation(nullptr), viewDistance(1.f), dragging(false),
|
_lastModel(nullptr), canimation(nullptr), viewDistance(1.f), dragging(false),
|
||||||
_frameWidgetDraw(nullptr), _frameWidgetGeom(nullptr)
|
_frameWidgetDraw(nullptr), _frameWidgetGeom(nullptr)
|
||||||
{
|
{
|
||||||
@ -66,25 +68,29 @@ void ViewerWidget::paintGL()
|
|||||||
|
|
||||||
if( gworld == nullptr ) return;
|
if( gworld == nullptr ) return;
|
||||||
|
|
||||||
auto& r = gworld->renderer;
|
auto& r = *renderer;
|
||||||
|
|
||||||
|
r.setViewport(width(), height());
|
||||||
|
|
||||||
if(dummyObject && dummyObject->animator) {
|
if(dummyObject && dummyObject->animator) {
|
||||||
dummyObject->animator->tick(1.f/60.f);
|
dummyObject->animator->tick(1.f/60.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dummyObject) {
|
if(activeModel) {
|
||||||
gworld->_work->update();
|
gworld->_work->update();
|
||||||
|
|
||||||
r.getRenderer()->invalidate();
|
r.getRenderer()->invalidate();
|
||||||
|
|
||||||
if( dummyObject->model->model != _lastModel ) {
|
Model* model = activeModel;
|
||||||
_lastModel = dummyObject->model->model;
|
|
||||||
|
if( model != _lastModel ) {
|
||||||
|
_lastModel = model;
|
||||||
emit modelChanged(_lastModel);
|
emit modelChanged(_lastModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
glm::mat4 m;
|
glm::mat4 m(1.f);
|
||||||
|
|
||||||
r.getRenderer()->useProgram(r.worldProg);
|
r.getRenderer()->useProgram(r.worldProg);
|
||||||
|
|
||||||
@ -105,24 +111,31 @@ void ViewerWidget::paintGL()
|
|||||||
|
|
||||||
r.getRenderer()->invalidate();
|
r.getRenderer()->invalidate();
|
||||||
|
|
||||||
if( dummyObject->model->model ) {
|
r.setupRender();
|
||||||
gworld->renderer.renderModel(dummyObject->model->model, m, dummyObject);
|
if( model ) {
|
||||||
|
r.renderModel(model, m, dummyObject);
|
||||||
|
|
||||||
drawFrameWidget(dummyObject->model->model->frames[dummyObject->model->model->rootFrameIdx]);
|
drawFrameWidget(model->frames[model->rootFrameIdx]);
|
||||||
}
|
}
|
||||||
|
r.renderPostProcess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerWidget::drawFrameWidget(ModelFrame* f, const glm::mat4& m)
|
void ViewerWidget::drawFrameWidget(ModelFrame* f, const glm::mat4& m)
|
||||||
{
|
{
|
||||||
auto thisM = m * f->getTransform();
|
auto thisM = m * f->getTransform();
|
||||||
if(f->getGeometries().size() == 0) {
|
if(f->getGeometries().size() == 0)
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
{
|
||||||
/*glUniform4f(gworld->renderer.uniCol, 1.f, 1.f, 1.f, 1.f);
|
Renderer::DrawParameters dp;
|
||||||
glUniformMatrix4fv(gworld->renderer.uniModel, 1, GL_FALSE, glm::value_ptr(thisM));*/
|
dp.count = _frameWidgetGeom->getCount();
|
||||||
glBindVertexArray(_frameWidgetDraw->getVAOName());
|
dp.start = 0;
|
||||||
glDrawArrays(_frameWidgetDraw->getFaceType(), 0, 6);
|
dp.ambient = 1.f;
|
||||||
|
dp.diffuse = 1.f;
|
||||||
|
dp.colour = {255, 255, 255, 255};
|
||||||
|
dp.textures = { 0 };
|
||||||
|
renderer->getRenderer()->drawArrays(thisM, _frameWidgetDraw, dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto c : f->getChildren()) {
|
for(auto c : f->getChildren()) {
|
||||||
drawFrameWidget(c, thisM);
|
drawFrameWidget(c, thisM);
|
||||||
}
|
}
|
||||||
@ -155,9 +168,18 @@ void ViewerWidget::showItem(qint16 item)
|
|||||||
{
|
{
|
||||||
dummyObject = gworld->createVehicle(item, {});
|
dummyObject = gworld->createVehicle(item, {});
|
||||||
}
|
}
|
||||||
|
activeModel = dummyObject->model->resource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewerWidget::showModel(Model* model)
|
||||||
|
{
|
||||||
|
if( dummyObject ) gworld->destroyObject( dummyObject );
|
||||||
|
dummyObject = nullptr;
|
||||||
|
activeModel = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ViewerWidget::exportModel()
|
void ViewerWidget::exportModel()
|
||||||
{
|
{
|
||||||
QString toSv = QFileDialog::getSaveFileName(this,
|
QString toSv = QFileDialog::getSaveFileName(this,
|
||||||
@ -189,9 +211,14 @@ void ViewerWidget::dataLoaded(GameWorld *world)
|
|||||||
gworld = world;
|
gworld = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewerWidget::setRenderer(GameRenderer *render)
|
||||||
|
{
|
||||||
|
renderer = render;
|
||||||
|
}
|
||||||
|
|
||||||
Model* ViewerWidget::currentModel() const
|
Model* ViewerWidget::currentModel() const
|
||||||
{
|
{
|
||||||
return _lastModel;
|
return activeModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerWidget::mousePressEvent(QMouseEvent* e)
|
void ViewerWidget::mousePressEvent(QMouseEvent* e)
|
||||||
|
@ -8,18 +8,23 @@
|
|||||||
#include <loaders/LoaderIFP.hpp>
|
#include <loaders/LoaderIFP.hpp>
|
||||||
#include <render/DrawBuffer.hpp>
|
#include <render/DrawBuffer.hpp>
|
||||||
#include <render/GeometryBuffer.hpp>
|
#include <render/GeometryBuffer.hpp>
|
||||||
|
#include <render/Model.hpp>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
|
class GameRenderer;
|
||||||
class Model;
|
class Model;
|
||||||
class ViewerWidget : public QGLWidget
|
class ViewerWidget : public QGLWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
GameRenderer* renderer;
|
||||||
|
|
||||||
QString currentFile;
|
QString currentFile;
|
||||||
|
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
GameWorld* gworld;
|
GameWorld* gworld;
|
||||||
|
|
||||||
|
Model* activeModel;
|
||||||
GameObject* dummyObject;
|
GameObject* dummyObject;
|
||||||
quint16 currentObjectID;
|
quint16 currentObjectID;
|
||||||
|
|
||||||
@ -35,7 +40,7 @@ class ViewerWidget : public QGLWidget
|
|||||||
|
|
||||||
DrawBuffer* _frameWidgetDraw;
|
DrawBuffer* _frameWidgetDraw;
|
||||||
GeometryBuffer* _frameWidgetGeom;
|
GeometryBuffer* _frameWidgetGeom;
|
||||||
void drawFrameWidget(ModelFrame* f, const glm::mat4& = {});
|
void drawFrameWidget(ModelFrame* f, const glm::mat4& = glm::mat4(1.f));
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ViewerWidget(QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
|
ViewerWidget(QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
|
||||||
@ -53,11 +58,14 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void showItem(qint16 item);
|
void showItem(qint16 item);
|
||||||
|
void showModel(Model* model);
|
||||||
|
|
||||||
void exportModel();
|
void exportModel();
|
||||||
|
|
||||||
void dataLoaded(GameWorld* world);
|
void dataLoaded(GameWorld* world);
|
||||||
|
|
||||||
|
void setRenderer(GameRenderer* renderer);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void fileOpened(const QString& file);
|
void fileOpened(const QString& file);
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#include "ViewerWindow.hpp"
|
#include "ViewerWindow.hpp"
|
||||||
#include "ObjectViewer.hpp"
|
#include "views/ObjectViewer.hpp"
|
||||||
|
#include "views/ModelViewer.hpp"
|
||||||
|
|
||||||
#include <engine/GameWorld.hpp>
|
#include <engine/GameWorld.hpp>
|
||||||
|
#include <render/GameRenderer.hpp>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -14,7 +16,7 @@
|
|||||||
static int MaxRecentGames = 5;
|
static int MaxRecentGames = 5;
|
||||||
|
|
||||||
ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags)
|
ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags)
|
||||||
: QMainWindow(parent, flags), gameWorld(nullptr)
|
: QMainWindow(parent, flags), gameWorld(nullptr), renderer(nullptr)
|
||||||
{
|
{
|
||||||
setMinimumSize(640, 480);
|
setMinimumSize(640, 480);
|
||||||
|
|
||||||
@ -47,8 +49,17 @@ ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags)
|
|||||||
connect(this, SIGNAL(loadedData(GameWorld*)), objectViewer, SLOT(showData(GameWorld*)));
|
connect(this, SIGNAL(loadedData(GameWorld*)), objectViewer, SLOT(showData(GameWorld*)));
|
||||||
connect(this, SIGNAL(loadedData(GameWorld*)), viewerWidget, SLOT(dataLoaded(GameWorld*)));
|
connect(this, SIGNAL(loadedData(GameWorld*)), viewerWidget, SLOT(dataLoaded(GameWorld*)));
|
||||||
|
|
||||||
|
modelViewer = new ModelViewer(viewerWidget);
|
||||||
|
|
||||||
|
connect(this, SIGNAL(loadedData(GameWorld*)), modelViewer, SLOT(showData(GameWorld*)));
|
||||||
|
|
||||||
viewSwitcher = new QStackedWidget;
|
viewSwitcher = new QStackedWidget;
|
||||||
viewSwitcher->addWidget(objectViewer);
|
viewSwitcher->addWidget(objectViewer);
|
||||||
|
viewSwitcher->addWidget(modelViewer);
|
||||||
|
|
||||||
|
connect(objectViewer, SIGNAL(modelChanged(Model*)), modelViewer, SLOT(showModel(Model*)));
|
||||||
|
|
||||||
|
objectViewer->setViewerWidget( viewerWidget );
|
||||||
|
|
||||||
QMenu* view = mb->addMenu("&View");
|
QMenu* view = mb->addMenu("&View");
|
||||||
QAction* objectAction = view->addAction("&Object");
|
QAction* objectAction = view->addAction("&Object");
|
||||||
@ -66,13 +77,6 @@ ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags)
|
|||||||
QMenu* anim = mb->addMenu("&Animation");
|
QMenu* anim = mb->addMenu("&Animation");
|
||||||
anim->addAction("Load &Animations", this, SLOT(openAnimations()));
|
anim->addAction("Load &Animations", this, SLOT(openAnimations()));
|
||||||
|
|
||||||
modelLayout = new QVBoxLayout;
|
|
||||||
|
|
||||||
QWidget* span = new QWidget;
|
|
||||||
span->setLayout(modelLayout);
|
|
||||||
|
|
||||||
viewSwitcher->addWidget(span);
|
|
||||||
|
|
||||||
this->setCentralWidget(viewSwitcher);
|
this->setCentralWidget(viewSwitcher);
|
||||||
|
|
||||||
updateRecentGames();
|
updateRecentGames();
|
||||||
@ -144,8 +148,11 @@ void ViewerWindow::loadGame(const QString &path)
|
|||||||
QDir gameDir( path );
|
QDir gameDir( path );
|
||||||
|
|
||||||
if( gameDir.exists() && path.size() > 0 ) {
|
if( gameDir.exists() && path.size() > 0 ) {
|
||||||
gameWorld = new GameWorld( gameDir.absolutePath().toStdString() );
|
gameWorld = new GameWorld( &engineLog, gameDir.absolutePath().toStdString() );
|
||||||
gameWorld->load();
|
renderer = new GameRenderer(&engineLog, gameWorld);
|
||||||
|
viewerWidget->setRenderer(renderer);
|
||||||
|
|
||||||
|
gameWorld->gameData.load();
|
||||||
|
|
||||||
// Initalize all the archives.
|
// Initalize all the archives.
|
||||||
gameWorld->gameData.loadIMG("/models/gta3");
|
gameWorld->gameData.loadIMG("/models/gta3");
|
||||||
@ -181,12 +188,11 @@ void ViewerWindow::switchWidget()
|
|||||||
|
|
||||||
if( index == 0 )
|
if( index == 0 )
|
||||||
{
|
{
|
||||||
modelLayout->removeWidget( viewerWidget );
|
|
||||||
objectViewer->setViewerWidget( viewerWidget );
|
objectViewer->setViewerWidget( viewerWidget );
|
||||||
}
|
}
|
||||||
else if( index == 1 )
|
else if( index == 1 )
|
||||||
{
|
{
|
||||||
modelLayout->addWidget( viewerWidget );
|
modelViewer->setViewerWidget( viewerWidget );
|
||||||
}
|
}
|
||||||
|
|
||||||
viewSwitcher->setCurrentIndex( index );
|
viewSwitcher->setCurrentIndex( index );
|
||||||
|
@ -3,25 +3,30 @@
|
|||||||
#define _VIEWERWINDOW_HPP_
|
#define _VIEWERWINDOW_HPP_
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <engine/GameWorld.hpp>
|
#include <engine/GameWorld.hpp>
|
||||||
|
#include <core/Logger.hpp>
|
||||||
#include <QGLContext>
|
#include <QGLContext>
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
class ObjectViewer;
|
class ObjectViewer;
|
||||||
|
class ModelViewer;
|
||||||
class ViewerWidget;
|
class ViewerWidget;
|
||||||
|
class GameRenderer;
|
||||||
|
|
||||||
class ViewerWindow : public QMainWindow
|
class ViewerWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Logger engineLog;
|
||||||
|
|
||||||
GameWorld* gameWorld;
|
GameWorld* gameWorld;
|
||||||
|
GameRenderer* renderer;
|
||||||
|
|
||||||
/** Contains the OGL context */
|
/** Contains the OGL context */
|
||||||
ViewerWidget* viewerWidget;
|
ViewerWidget* viewerWidget;
|
||||||
|
|
||||||
ObjectViewer* objectViewer;
|
ObjectViewer* objectViewer;
|
||||||
|
ModelViewer* modelViewer;
|
||||||
QVBoxLayout* modelLayout;
|
|
||||||
|
|
||||||
QStackedWidget* viewSwitcher;
|
QStackedWidget* viewSwitcher;
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <engine/RWTypes.hpp>
|
#include <engine/RWTypes.hpp>
|
||||||
|
|
||||||
|
class Model;
|
||||||
|
|
||||||
class DFFFramesTreeModel : public QAbstractItemModel
|
class DFFFramesTreeModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Model* model;
|
Model* model;
|
43
rwviewer/views/ModelViewer.cpp
Normal file
43
rwviewer/views/ModelViewer.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#include "ModelViewer.hpp"
|
||||||
|
#include <widgets/ModelFramesWidget.hpp>
|
||||||
|
#include "ViewerWidget.hpp"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
ModelViewer::ModelViewer(ViewerWidget* viewer, QWidget* parent, Qt::WindowFlags f)
|
||||||
|
: QWidget(parent, f), _world(nullptr), viewing(nullptr)
|
||||||
|
{
|
||||||
|
mainSplit = new QSplitter;
|
||||||
|
mainLayout = new QVBoxLayout;
|
||||||
|
|
||||||
|
viewerWidget = viewer;
|
||||||
|
viewerWidget->setMinimumSize(250,250);
|
||||||
|
|
||||||
|
frames = new ModelFramesWidget;
|
||||||
|
frames->setMaximumWidth(300);
|
||||||
|
|
||||||
|
mainSplit->addWidget(frames);
|
||||||
|
mainLayout->addWidget(mainSplit);
|
||||||
|
|
||||||
|
this->setLayout(mainLayout);
|
||||||
|
|
||||||
|
setViewerWidget(viewerWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelViewer::setViewerWidget(ViewerWidget* widget)
|
||||||
|
{
|
||||||
|
viewerWidget = widget;
|
||||||
|
mainSplit->addWidget(viewerWidget);
|
||||||
|
showModel(viewing);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelViewer::showData(GameWorld* world)
|
||||||
|
{
|
||||||
|
_world = world;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelViewer::showModel(Model* model)
|
||||||
|
{
|
||||||
|
viewing = model;
|
||||||
|
viewerWidget->showModel(model);
|
||||||
|
frames->setModel(model);
|
||||||
|
}
|
47
rwviewer/views/ModelViewer.hpp
Normal file
47
rwviewer/views/ModelViewer.hpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _MODELVIEWER_HPP_
|
||||||
|
#define _MODELVIEWER_HPP_
|
||||||
|
#include <engine/GameData.hpp>
|
||||||
|
#include <engine/GameWorld.hpp>
|
||||||
|
#include <QGLWidget>
|
||||||
|
#include <QTreeView>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QLayout>
|
||||||
|
|
||||||
|
class ViewerWidget;
|
||||||
|
class Model;
|
||||||
|
class ModelFramesWidget;
|
||||||
|
|
||||||
|
class ModelViewer : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
GameWorld* _world;
|
||||||
|
Model* viewing;
|
||||||
|
|
||||||
|
QSplitter* mainSplit;
|
||||||
|
QVBoxLayout* mainLayout;
|
||||||
|
ViewerWidget* viewerWidget;
|
||||||
|
|
||||||
|
ModelFramesWidget* frames;
|
||||||
|
public:
|
||||||
|
|
||||||
|
ModelViewer(ViewerWidget *viewer = 0, QWidget* parent = 0, Qt::WindowFlags f = 0);
|
||||||
|
|
||||||
|
GameWorld* world()
|
||||||
|
{
|
||||||
|
return _world;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setViewerWidget( ViewerWidget* widget );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
void showModel(Model* model);
|
||||||
|
|
||||||
|
void showData(GameWorld* world);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -78,6 +78,7 @@ void ObjectViewer::showItem(qint16 item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
previewWidget->showItem(item);
|
previewWidget->showItem(item);
|
||||||
|
modelChanged( previewWidget->currentModel() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -10,6 +10,7 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
class ViewerWidget;
|
class ViewerWidget;
|
||||||
|
class Model;
|
||||||
|
|
||||||
class ObjectViewer : public QWidget
|
class ObjectViewer : public QWidget
|
||||||
{
|
{
|
||||||
@ -35,6 +36,10 @@ public:
|
|||||||
|
|
||||||
void setViewerWidget( ViewerWidget* widget );
|
void setViewerWidget( ViewerWidget* widget );
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void modelChanged(Model* model);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void showItem(qint16 item);
|
void showItem(qint16 item);
|
@ -34,19 +34,17 @@ void ModelFramesWidget::selectedModelChanged(const QModelIndex & n, const QModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags)
|
ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags)
|
||||||
: QDockWidget(parent, flags), gmodel(nullptr), framemodel(nullptr)
|
: QWidget(parent, flags), gmodel(nullptr), framemodel(nullptr)
|
||||||
{
|
{
|
||||||
setWindowTitle("Frames");
|
setWindowTitle("Frames");
|
||||||
|
|
||||||
QWidget* w = new QWidget(this);
|
_layout = new QVBoxLayout;
|
||||||
|
|
||||||
_layout = new QVBoxLayout(w);
|
|
||||||
tree = new QTreeView(this);
|
tree = new QTreeView(this);
|
||||||
_layout->addWidget(tree);
|
_layout->addWidget(tree);
|
||||||
_frameLabel = new QLabel(this);
|
_frameLabel = new QLabel(this);
|
||||||
_layout->addWidget(_frameLabel);
|
_layout->addWidget(_frameLabel);
|
||||||
|
|
||||||
setWidget(w);
|
setLayout(_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelFramesWidget::setModel(Model *model)
|
void ModelFramesWidget::setModel(Model *model)
|
@ -3,14 +3,14 @@
|
|||||||
#define _MODELFRAMESWIDGET_HPP_
|
#define _MODELFRAMESWIDGET_HPP_
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include "DFFFramesTreeModel.hpp"
|
#include "models/DFFFramesTreeModel.hpp"
|
||||||
#include <engine/RWTypes.hpp>
|
#include <engine/RWTypes.hpp>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
class ModelFrame;
|
class ModelFrame;
|
||||||
|
|
||||||
class ModelFramesWidget : public QDockWidget
|
class ModelFramesWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
Loading…
Reference in New Issue
Block a user