mirror of
https://github.com/redstrate/Novus.git
synced 2025-04-26 05:37:46 +00:00
Add a wireframe checkbox to MDLViewer
This commit is contained in:
parent
ab1d02b25a
commit
5c907b63da
5 changed files with 43 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
|||
#include <KLocalizedString>
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QCheckBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QHBoxLayout>
|
||||
|
@ -46,6 +47,14 @@ MainWindow::MainWindow(GameData *data)
|
|||
tabWidget->setMaximumHeight(150);
|
||||
|
||||
auto renderWidget = new QWidget();
|
||||
auto renderLayout = new QVBoxLayout();
|
||||
renderWidget->setLayout(renderLayout);
|
||||
|
||||
auto wireframeCheckbox = new QCheckBox(i18n("Wireframe"));
|
||||
connect(wireframeCheckbox, &QCheckBox::clicked, this, [this](bool checked) {
|
||||
part->setWireframe(checked);
|
||||
});
|
||||
renderLayout->addWidget(wireframeCheckbox);
|
||||
|
||||
tabWidget->addTab(renderWidget, i18nc("@title:tab", "Render"));
|
||||
tabWidget->setDocumentMode(true); // hide borders
|
||||
|
|
|
@ -310,4 +310,14 @@ void MDLPart::removeModel(const physis_MDL &mdl)
|
|||
Q_EMIT modelChanged();
|
||||
}
|
||||
|
||||
void MDLPart::setWireframe(bool wireframe)
|
||||
{
|
||||
renderer->wireframe = wireframe;
|
||||
}
|
||||
|
||||
bool MDLPart::wireframe() const
|
||||
{
|
||||
return renderer->wireframe;
|
||||
}
|
||||
|
||||
#include "moc_mdlpart.cpp"
|
|
@ -44,6 +44,9 @@ public:
|
|||
|
||||
std::function<void()> requestUpdate;
|
||||
|
||||
void setWireframe(bool wireframe);
|
||||
bool wireframe() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void modelChanged();
|
||||
void skeletonChanged();
|
||||
|
|
|
@ -111,7 +111,10 @@ public:
|
|||
|
||||
VkPipeline pipeline;
|
||||
VkPipeline skinnedPipeline;
|
||||
VkPipeline pipelineWireframe;
|
||||
VkPipeline skinnedPipelineWireframe;
|
||||
VkPipelineLayout pipelineLayout;
|
||||
bool wireframe = false;
|
||||
|
||||
std::tuple<VkBuffer, VkDeviceMemory> createBuffer(size_t size, VkBufferUsageFlags usageFlags);
|
||||
|
||||
|
|
|
@ -474,9 +474,17 @@ void Renderer::render(const std::vector<RenderModel> &models)
|
|||
|
||||
for (auto model : models) {
|
||||
if (model.skinned) {
|
||||
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, skinnedPipeline);
|
||||
if (wireframe) {
|
||||
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, skinnedPipelineWireframe);
|
||||
} else {
|
||||
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, skinnedPipeline);
|
||||
}
|
||||
} else {
|
||||
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||
if (wireframe) {
|
||||
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineWireframe);
|
||||
} else {
|
||||
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||
}
|
||||
}
|
||||
|
||||
// copy bone data
|
||||
|
@ -881,6 +889,14 @@ void Renderer::initPipeline()
|
|||
shaderStages[0] = skinnedVertexShaderStageInfo;
|
||||
|
||||
vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &createInfo, nullptr, &skinnedPipeline);
|
||||
|
||||
rasterizer.polygonMode = VK_POLYGON_MODE_LINE;
|
||||
|
||||
vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &createInfo, nullptr, &skinnedPipelineWireframe);
|
||||
|
||||
shaderStages[0] = vertexShaderStageInfo;
|
||||
|
||||
vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &createInfo, nullptr, &pipelineWireframe);
|
||||
}
|
||||
|
||||
VkShaderModule Renderer::createShaderModule(const uint32_t *code, const int length)
|
||||
|
|
Loading…
Add table
Reference in a new issue