mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 03:12:36 +01:00
Improve rwviewer frame selection + view
* ViewerWidget now highlights selected non-model frames
This commit is contained in:
parent
1827b9cca3
commit
0f4152d099
@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
|
|
||||||
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), activeModel(nullptr), dummyObject(nullptr), currentObjectID(0),
|
: QGLWidget(parent, shareWidget, f), gworld(nullptr), activeModel(nullptr),
|
||||||
|
selectedFrame(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)
|
||||||
{
|
{
|
||||||
@ -25,18 +26,18 @@ struct WidgetVertex {
|
|||||||
float x, y, z;
|
float x, y, z;
|
||||||
static const AttributeList vertex_attributes() {
|
static const AttributeList vertex_attributes() {
|
||||||
return {
|
return {
|
||||||
{ATRS_Position, 2, sizeof(WidgetVertex), 0ul}
|
{ATRS_Position, 3, sizeof(WidgetVertex), 0ul}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<WidgetVertex> widgetVerts = {
|
std::vector<WidgetVertex> widgetVerts = {
|
||||||
{-1.f, 0.f, 0.f},
|
{-.5f, 0.f, 0.f},
|
||||||
{ 1.f, 0.f, 0.f},
|
{ .5f, 0.f, 0.f},
|
||||||
{ 0.f,-1.f, 0.f},
|
{ 0.f,-.5f, 0.f},
|
||||||
{ 0.f, 1.f, 0.f},
|
{ 0.f, .5f, 0.f},
|
||||||
{ 0.f, 0.f,-1.f},
|
{ 0.f, 0.f,-.5f},
|
||||||
{ 0.f, 0.f, 1.f}
|
{ 0.f, 0.f, .5f}
|
||||||
};
|
};
|
||||||
|
|
||||||
void ViewerWidget::initializeGL()
|
void ViewerWidget::initializeGL()
|
||||||
@ -51,6 +52,13 @@ void ViewerWidget::initializeGL()
|
|||||||
_frameWidgetGeom = new GeometryBuffer;
|
_frameWidgetGeom = new GeometryBuffer;
|
||||||
_frameWidgetGeom->uploadVertices(widgetVerts);
|
_frameWidgetGeom->uploadVertices(widgetVerts);
|
||||||
_frameWidgetDraw->addGeometry(_frameWidgetGeom);
|
_frameWidgetDraw->addGeometry(_frameWidgetGeom);
|
||||||
|
|
||||||
|
glGenTextures(1, &whiteTex);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, whiteTex);
|
||||||
|
GLuint tex = 0xFFFFFFFF;
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, &tex);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerWidget::resizeGL(int w, int h)
|
void ViewerWidget::resizeGL(int w, int h)
|
||||||
@ -112,7 +120,8 @@ void ViewerWidget::paintGL()
|
|||||||
r.getRenderer()->invalidate();
|
r.getRenderer()->invalidate();
|
||||||
|
|
||||||
r.setupRender();
|
r.setupRender();
|
||||||
if( model ) {
|
if( model )
|
||||||
|
{
|
||||||
r.renderModel(model, m, dummyObject);
|
r.renderModel(model, m, dummyObject);
|
||||||
|
|
||||||
drawFrameWidget(model->frames[model->rootFrameIdx]);
|
drawFrameWidget(model->frames[model->rootFrameIdx]);
|
||||||
@ -131,8 +140,18 @@ void ViewerWidget::drawFrameWidget(ModelFrame* f, const glm::mat4& m)
|
|||||||
dp.start = 0;
|
dp.start = 0;
|
||||||
dp.ambient = 1.f;
|
dp.ambient = 1.f;
|
||||||
dp.diffuse = 1.f;
|
dp.diffuse = 1.f;
|
||||||
dp.colour = {255, 255, 255, 255};
|
if( f == selectedFrame )
|
||||||
dp.textures = { 0 };
|
{
|
||||||
|
dp.colour = {255, 255, 0, 255};
|
||||||
|
// Sorry!
|
||||||
|
glLineWidth(10.f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dp.colour = {255, 255, 255, 255};
|
||||||
|
glLineWidth(1.f);
|
||||||
|
}
|
||||||
|
dp.textures = { whiteTex };
|
||||||
renderer->getRenderer()->drawArrays(thisM, _frameWidgetDraw, dp);
|
renderer->getRenderer()->drawArrays(thisM, _frameWidgetDraw, dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,6 +198,10 @@ void ViewerWidget::showModel(Model* model)
|
|||||||
activeModel = model;
|
activeModel = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewerWidget::selectFrame(ModelFrame* frame)
|
||||||
|
{
|
||||||
|
selectedFrame = frame;
|
||||||
|
}
|
||||||
|
|
||||||
void ViewerWidget::exportModel()
|
void ViewerWidget::exportModel()
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,7 @@ class ViewerWidget : public QGLWidget
|
|||||||
GameWorld* gworld;
|
GameWorld* gworld;
|
||||||
|
|
||||||
Model* activeModel;
|
Model* activeModel;
|
||||||
|
ModelFrame* selectedFrame;
|
||||||
GameObject* dummyObject;
|
GameObject* dummyObject;
|
||||||
quint16 currentObjectID;
|
quint16 currentObjectID;
|
||||||
|
|
||||||
@ -40,6 +41,8 @@ class ViewerWidget : public QGLWidget
|
|||||||
|
|
||||||
DrawBuffer* _frameWidgetDraw;
|
DrawBuffer* _frameWidgetDraw;
|
||||||
GeometryBuffer* _frameWidgetGeom;
|
GeometryBuffer* _frameWidgetGeom;
|
||||||
|
GLuint whiteTex;
|
||||||
|
|
||||||
void drawFrameWidget(ModelFrame* f, const glm::mat4& = glm::mat4(1.f));
|
void drawFrameWidget(ModelFrame* f, const glm::mat4& = glm::mat4(1.f));
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -59,6 +62,7 @@ public slots:
|
|||||||
|
|
||||||
void showItem(qint16 item);
|
void showItem(qint16 item);
|
||||||
void showModel(Model* model);
|
void showModel(Model* model);
|
||||||
|
void selectFrame(ModelFrame* frame);
|
||||||
|
|
||||||
void exportModel();
|
void exportModel();
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@ ModelViewer::ModelViewer(ViewerWidget* viewer, QWidget* parent, Qt::WindowFlags
|
|||||||
|
|
||||||
this->setLayout(mainLayout);
|
this->setLayout(mainLayout);
|
||||||
|
|
||||||
|
connect(frames, SIGNAL(selectedFrameChanged(ModelFrame*)),
|
||||||
|
viewerWidget, SLOT(selectFrame(ModelFrame*)));
|
||||||
setViewerWidget(viewerWidget);
|
setViewerWidget(viewerWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ void ModelFramesWidget::updateInfoBox(Model* model, ModelFrame *f)
|
|||||||
void ModelFramesWidget::selectedModelChanged(const QModelIndex & n, const QModelIndex &)
|
void ModelFramesWidget::selectedModelChanged(const QModelIndex & n, const QModelIndex &)
|
||||||
{
|
{
|
||||||
updateInfoBox( gmodel, (ModelFrame*) n.internalPointer() );
|
updateInfoBox( gmodel, (ModelFrame*) n.internalPointer() );
|
||||||
|
selectedFrameChanged( (ModelFrame*) n.internalPointer() );
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags)
|
ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags)
|
||||||
|
@ -32,6 +32,10 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void setModel(Model *model);
|
void setModel(Model *model);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void selectedFrameChanged(ModelFrame* frame);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user