This commit is contained in:
Balkron
2020-11-18 00:26:20 +05:00
4 changed files with 54 additions and 11 deletions

View File

@@ -95,6 +95,7 @@ void ModelViewer::setModel(std::string const& filename)
opengl::context::scoped_setter const _ (::gl, context());
makeCurrent();
PreviewRenderer::setModel(filename);
emit model_set(filename);
}
float ModelViewer::aspect_ratio() const
@@ -170,11 +171,11 @@ void ModelViewer::keyReleaseEvent(QKeyEvent* event)
void ModelViewer::focusOutEvent(QFocusEvent* event)
{
//moving = 0.0f;
//lookat = 0.0f;
// turn = 0.0f;
//strafing = 0.0f;
// updown = 0.0f;
moving = 0.0f;
lookat = 0.0f;
turn = 0.0f;
strafing = 0.0f;
updown = 0.0f;
}
void ModelViewer::keyPressEvent(QKeyEvent* event)
@@ -224,3 +225,25 @@ void ModelViewer::keyPressEvent(QKeyEvent* event)
updown = -_move_sensitivity;
}
}
QStringList ModelViewer::getDoodadSetNames(const std::string& filename)
{
QStringList names;
for (auto& wmo_instance : _wmo_instances)
{
if (wmo_instance.wmo->filename != filename)
{
continue;
}
for (auto& doodad_set : wmo_instance.wmo->doodadsets)
{
names.append(doodad_set.name);
}
break;
}
return std::move(names);
}

View File

@@ -11,6 +11,7 @@
#include <QPointF>
#include <QElapsedTimer>
#include <QTimer>
#include <QStringList>
#include <math/matrix_4x4.hpp>
#include <math/vector_3d.hpp>
@@ -36,10 +37,13 @@ namespace noggit
void setModel(std::string const& filename) override;
void setMoveSensitivity(float s) { _move_sensitivity = s / 30.0f; };
float getMoveSensitivity() { return _move_sensitivity; };
QStringList getDoodadSetNames(std::string const& filename);
signals:
void resized();
void sensitivity_changed();
void model_set(std::string const& filename);
private:

View File

@@ -91,14 +91,23 @@ AssetBrowserWidget::AssetBrowserWidget(QWidget *parent)
for (auto index : selected.indexes())
{
auto path = index.data(Qt::UserRole).toString();
if (path.endsWith(".wmo") || path.endsWith(".m2"))
if (path.endsWith(".m2") || path.endsWith(".wmo"))
{
ui->viewport->setModel(path.toStdString());
}
}
}
);
connect(ui->viewport, &ModelViewer::model_set
,[=] (const std::string& filename)
{
viewport_overlay_ui->doodadSetSelector->insertItems(0, ui->viewport->getDoodadSetNames(filename));
}
);
// Handle preview rendering and drag
connect(ui->listfileTree, &QTreeView::expanded
,[this] (const QModelIndex& index)
@@ -182,6 +191,13 @@ AssetBrowserWidget::AssetBrowserWidget(QWidget *parent)
}
);
connect(viewport_overlay_ui->cameraResetButton, &QPushButton::clicked
,[this]()
{
ui->viewport->resetCamera();
}
);
// Render toggles
connect(viewport_overlay_ui->toggleWMOButton, &QPushButton::clicked,
[this]() {ui->viewport->_draw_wmo.toggle();});

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1195</width>
<width>1300</width>
<height>792</height>
</rect>
</property>
@@ -94,14 +94,14 @@
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>15</horstretch>
<verstretch>0</verstretch>
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>20</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>280</width>
<width>400</width>
<height>0</height>
</size>
</property>