1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 02:12:45 +01:00

Fix compilation and runtime issues with reviewer from recent changes

This commit is contained in:
Daniel Evans 2016-04-16 14:06:02 +01:00
parent f3b81c5690
commit 76eb43c023
11 changed files with 70 additions and 43 deletions

View File

@ -1,5 +1,5 @@
#include "ViewerWidget.hpp"
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <render/GameRenderer.hpp>
#include <render/OpenGLRenderer.hpp>
#include <glm/gtc/type_ptr.hpp>
@ -187,7 +187,10 @@ void ViewerWidget::showObject(qint16 item)
{
dummyObject = gworld->createVehicle(item, {});
}
activeModel = dummyObject->model->resource;
RW_CHECK(dummyObject != nullptr, "Dummy Object is null");
if (dummyObject != nullptr) {
activeModel = dummyObject->model->resource;
}
}
}

View File

@ -3,14 +3,18 @@
#define _VIEWERWIDGET_HPP_
#include <engine/GameData.hpp>
#include <engine/GameWorld.hpp>
#include <QGLWidget>
#include <QTimer>
#include <loaders/LoaderIFP.hpp>
#include <render/DrawBuffer.hpp>
#include <render/GeometryBuffer.hpp>
#include <render/Model.hpp>
#include <gl/DrawBuffer.hpp>
#include <gl/GeometryBuffer.hpp>
#include <data/Model.hpp>
#include <glm/glm.hpp>
// Prevent Qt from conflicting with glLoadGen
#define GL_ARB_debug_output
#define GL_KHR_debug
#include <QGLWidget>
class GameRenderer;
class Model;
class ViewerWidget : public QGLWidget

View File

@ -101,33 +101,10 @@ void ViewerWindow::closeEvent(QCloseEvent* event)
void ViewerWindow::openAnimations()
{
#if 0
QFileDialog dialog(this, "Open Animations", QDir::homePath(), "IFP Animations (*.ifp)");
if(dialog.exec()) {
std::ifstream dfile(dialog.selectedFiles().at(0).toStdString().c_str());
AnimationList anims;
if(dfile.is_open())
{
dfile.seekg(0, std::ios_base::end);
size_t length = dfile.tellg();
dfile.seekg(0);
char *file = new char[length];
dfile.read(file, length);
LoaderIFP loader;
if( loader.loadFromMemory(file) ) {
for(auto& f : loader.animations) {
anims.push_back(f);
}
}
delete[] file;
}
animationswidget->setAnimations(anims);
modelViewer->loadAnimations(dialog.selectedFiles()[0]);
}
#endif
}
void ViewerWindow::loadGame()

View File

@ -5,7 +5,6 @@
#include <engine/GameData.hpp>
#include <engine/GameWorld.hpp>
#include <core/Logger.hpp>
#include <QGLContext>
#include <QStackedWidget>
#include <QVBoxLayout>
@ -13,6 +12,7 @@ class ObjectViewer;
class ModelViewer;
class ViewerWidget;
class GameRenderer;
class QGLContext;
class ViewerWindow : public QMainWindow
{

View File

@ -1,5 +1,5 @@
#include "DFFFramesTreeModel.hpp"
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <data/Skeleton.hpp>
DFFFramesTreeModel::DFFFramesTreeModel(Model *m, Skeleton* skel, QObject* parent)

View File

@ -2,7 +2,7 @@
#ifndef _DFFFRAMESTREEMODEL_HPP_
#define _DFFFRAMESTREEMODEL_HPP_
#include <QAbstractItemModel>
#include <engine/RWTypes.hpp>
#include <rw/types.hpp>
class Model;
class Skeleton;

View File

@ -1,9 +1,10 @@
#include "ModelViewer.hpp"
#include <widgets/ModelFramesWidget.hpp>
#include "ViewerWidget.hpp"
#include <data/Skeleton.hpp>
#include <objects/GameObject.hpp>
#include <QDebug>
#include <widgets/ModelFramesWidget.hpp>
#include <data/Skeleton.hpp>
#include <engine/Animator.hpp>
#include <objects/GameObject.hpp>
#include "ViewerWidget.hpp"
ModelViewer::ModelViewer(ViewerWidget* viewer, QWidget* parent, Qt::WindowFlags f)
: QWidget(parent, f), _world(nullptr), viewing(nullptr), skeleton(nullptr)
@ -14,10 +15,15 @@ ModelViewer::ModelViewer(ViewerWidget* viewer, QWidget* parent, Qt::WindowFlags
viewerWidget = viewer;
viewerWidget->setMinimumSize(250,250);
animationWidget = new AnimationListWidget;
connect(animationWidget, SIGNAL(selectedAnimationChanged(Animation*)),
SLOT(playAnimation(Animation*)));
frames = new ModelFramesWidget;
frames->setMaximumWidth(300);
mainSplit->addWidget(frames);
mainSplit->addWidget(animationWidget);
mainLayout->addWidget(mainSplit);
this->setLayout(mainLayout);
@ -58,3 +64,34 @@ void ModelViewer::showObject(uint16_t object)
skeleton = viewerWidget->currentObject()->skeleton;
frames->setModel(viewing, skeleton);
}
void ModelViewer::loadAnimations(const QString& file)
{
std::ifstream dfile(file.toStdString().c_str());
AnimationList anims;
if(dfile.is_open())
{
dfile.seekg(0, std::ios_base::end);
size_t length = dfile.tellg();
dfile.seekg(0);
char *file = new char[length];
dfile.read(file, length);
LoaderIFP loader;
if( loader.loadFromMemory(file) ) {
for(auto& f : loader.animations) {
anims.push_back(f);
}
}
delete[] file;
}
animationWidget->setAnimations(anims);
}
void ModelViewer::playAnimation(Animation* anim)
{
viewerWidget->currentObject()->animator->setAnimation(anim);
}

View File

@ -1,19 +1,20 @@
#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>
#include <engine/GameData.hpp>
#include <engine/GameWorld.hpp>
#include "AnimationListWidget.hpp"
class ViewerWidget;
class Model;
class Skeleton;
class ModelFramesWidget;
class Animation;
class ModelViewer : public QWidget
{
@ -28,6 +29,9 @@ class ModelViewer : public QWidget
ViewerWidget* viewerWidget;
ModelFramesWidget* frames;
AnimationList loadedAnimations;
AnimationListWidget *animationWidget;
public:
ModelViewer(ViewerWidget *viewer = 0, QWidget* parent = 0, Qt::WindowFlags f = 0);
@ -52,6 +56,9 @@ public slots:
void showObject(uint16_t object);
void showData(GameWorld* world);
void loadAnimations(const QString& file);
void playAnimation(Animation* anim);
};
#endif

View File

@ -3,7 +3,6 @@
#define _OBJECTVIEWER_HPP_
#include <engine/GameData.hpp>
#include <engine/GameWorld.hpp>
#include <QGLWidget>
#include <QTableView>
#include <QLabel>
#include <QGridLayout>

View File

@ -1,5 +1,5 @@
#include "ModelFramesWidget.hpp"
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <glm/gtx/string_cast.hpp>
void ModelFramesWidget::updateInfoBox(Model* model, ModelFrame *f)

View File

@ -4,7 +4,7 @@
#include <QDockWidget>
#include <QTreeView>
#include "models/DFFFramesTreeModel.hpp"
#include <engine/RWTypes.hpp>
#include <rw/types.hpp>
#include <QVBoxLayout>
#include <QLabel>