场景渲染增加纹理列表
parent
4be720a677
commit
9cc5466abc
|
@ -85,23 +85,63 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SetDefaultConstraint</enum>
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="textureListWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>260</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="tabPosition">
|
||||||
|
<enum>QTabWidget::West</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="textureTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>纹理</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="vboxLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="textureListWidget">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QListWidget{
|
||||||
|
border: 0
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -112,6 +112,11 @@ void Renderer::Model::unloadModel()
|
||||||
maxPos = glm::vec3(std::numeric_limits<float>::min());
|
maxPos = glm::vec3(std::numeric_limits<float>::min());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::unordered_map<std::string, std::tuple<std::string, glm::vec2, glm::vec2>>& Renderer::Model::getPaintingMap()
|
||||||
|
{
|
||||||
|
return paintingMap;
|
||||||
|
}
|
||||||
|
|
||||||
void Model::processNode(aiNode* node, const aiScene* scene, aiMatrix4x4 mat4)
|
void Model::processNode(aiNode* node, const aiScene* scene, aiMatrix4x4 mat4)
|
||||||
{
|
{
|
||||||
// 处理节点所有的网格(如果有的话)
|
// 处理节点所有的网格(如果有的话)
|
||||||
|
|
|
@ -10,13 +10,15 @@ namespace Renderer
|
||||||
class Model
|
class Model
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::vector<QVector3D> AABB;
|
Model(QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* paintingProgram, QOpenGLShaderProgram* shadowProgram, VirtualTextureManager* vtManager);
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
void drawShadow();
|
void drawShadow();
|
||||||
void loadModel(QString path);
|
void loadModel(QString path);
|
||||||
void unloadModel();
|
void unloadModel();
|
||||||
Model(QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* paintingProgram, QOpenGLShaderProgram* shadowProgram, VirtualTextureManager* vtManager);
|
const std::unordered_map<std::string, std::tuple<std::string, glm::vec2, glm::vec2>>& getPaintingMap();
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<QVector3D> AABB;
|
||||||
private:
|
private:
|
||||||
QOpenGLContext* context = nullptr;
|
QOpenGLContext* context = nullptr;
|
||||||
QOpenGLFunctions_4_5_Core* glFunc = nullptr;
|
QOpenGLFunctions_4_5_Core* glFunc = nullptr;
|
||||||
|
|
|
@ -73,6 +73,11 @@ void RendererGLWidget::stopTimer()
|
||||||
timerId = -1;
|
timerId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::unordered_map<std::string, std::tuple<std::string, glm::vec2, glm::vec2>>& Renderer::RendererGLWidget::getPaintingMap()
|
||||||
|
{
|
||||||
|
return model->getPaintingMap();
|
||||||
|
}
|
||||||
|
|
||||||
void RendererGLWidget::setModel(QString path)
|
void RendererGLWidget::setModel(QString path)
|
||||||
{
|
{
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
|
|
|
@ -25,6 +25,8 @@ namespace Renderer
|
||||||
|
|
||||||
void startTimer();
|
void startTimer();
|
||||||
void stopTimer();
|
void stopTimer();
|
||||||
|
const std::unordered_map<std::string, std::tuple<std::string, glm::vec2, glm::vec2>>& getPaintingMap();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setModel(QString path);
|
void setModel(QString path);
|
||||||
void setMainLightPitch(float pitch);
|
void setMainLightPitch(float pitch);
|
||||||
|
|
|
@ -10,33 +10,67 @@ Renderer::RendererWidget::RendererWidget(QWidget* parent)
|
||||||
|
|
||||||
auto openAction = new QAction(QStringLiteral("´ò¿ª"), ui.openButton);
|
auto openAction = new QAction(QStringLiteral("´ò¿ª"), ui.openButton);
|
||||||
auto saveAction = new QAction(QStringLiteral("±£´æ"), ui.openButton);
|
auto saveAction = new QAction(QStringLiteral("±£´æ"), ui.openButton);
|
||||||
|
auto refreshAction = new QAction(QStringLiteral("ÖØмÓÔØ"), ui.openButton);
|
||||||
auto testAction = new QAction(QStringLiteral("²âÊÔ"), ui.openButton);
|
auto testAction = new QAction(QStringLiteral("²âÊÔ"), ui.openButton);
|
||||||
auto test2Action = new QAction(QStringLiteral("²âÊÔ2"), ui.openButton);
|
auto test2Action = new QAction(QStringLiteral("²âÊÔ2"), ui.openButton);
|
||||||
ui.openButton->addMenuAction(openAction);
|
ui.openButton->addMenuAction(openAction);
|
||||||
ui.openButton->addMenuAction(saveAction);
|
ui.openButton->addMenuAction(saveAction);
|
||||||
|
ui.openButton->addMenuAction(refreshAction);
|
||||||
//ui.openButton->addMenuAction(testAction);
|
//ui.openButton->addMenuAction(testAction);
|
||||||
//ui.openButton->addMenuAction(test2Action);
|
//ui.openButton->addMenuAction(test2Action);
|
||||||
|
|
||||||
|
static QString modelFileName;
|
||||||
|
|
||||||
|
QObject::connect(openAction, &QAction::triggered, [&] {
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(this, QStringLiteral("´ò¿ªÄ£ÐÍ"), QString(), QStringLiteral("glTF 2.0 (*.gltf)"));
|
||||||
|
qDebug() << fileName;
|
||||||
|
if (fileName != QString())
|
||||||
|
{
|
||||||
|
modelFileName = fileName;
|
||||||
|
ui.openGLWidget->setModel(fileName);
|
||||||
|
QStringList list;
|
||||||
|
for (auto& i : ui.openGLWidget->getPaintingMap())
|
||||||
|
{
|
||||||
|
auto& [paintingPath, leftBottom, rightTop] = i.second;
|
||||||
|
list.append(QString::fromStdString(paintingPath));
|
||||||
|
}
|
||||||
|
ui.textureListWidget->clear();
|
||||||
|
ui.textureListWidget->addItems(list);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
QObject::connect(refreshAction, &QAction::triggered, [&] {
|
||||||
|
if (modelFileName != QString())
|
||||||
|
ui.openGLWidget->setModel(modelFileName);
|
||||||
|
});
|
||||||
|
QObject::connect(testAction, &QAction::triggered, [&] {
|
||||||
|
ui.openGLWidget->setModel("Models/Sponza/Sponza.gltf");
|
||||||
|
});
|
||||||
|
QObject::connect(test2Action, &QAction::triggered, [&] {
|
||||||
|
ui.openGLWidget->setModel("E:\\3D Objects\\Gate\\Gate.gltf");
|
||||||
|
});
|
||||||
|
|
||||||
|
QObject::connect(ui.tabWidget, &QTabWidget::tabBarClicked, [&] {
|
||||||
|
static bool hide = false;
|
||||||
|
static int maxWidth = ui.tabWidget->maximumWidth();
|
||||||
|
hide = !hide;
|
||||||
|
ui.tabWidget->setStyleSheet(hide
|
||||||
|
? "QTabBar::tab {background-color:rgba(0,0,0,0);} QTabBar::tab:hover{background-color: rgb(213, 213, 213);}"
|
||||||
|
: "QTabBar::tab:hover{background-color: rgb(213, 213, 213);}");
|
||||||
|
ui.tabWidget->setFixedWidth(hide ? ui.tabWidget->tabBar()->width() : maxWidth);
|
||||||
|
});
|
||||||
|
|
||||||
|
QObject::connect(ui.textureListWidget, &QListWidget::itemDoubleClicked, [&](QListWidgetItem* item) {
|
||||||
|
QString paintingPath = QFileInfo(modelFileName).dir().filePath(item->text());
|
||||||
|
qDebug() << paintingPath;
|
||||||
|
});
|
||||||
|
|
||||||
QObject::connect(ui.horizontalSlider, &QSlider::valueChanged,
|
QObject::connect(ui.horizontalSlider, &QSlider::valueChanged,
|
||||||
ui.openGLWidget, &Renderer::RendererGLWidget::setMainLightPitch);
|
ui.openGLWidget, &Renderer::RendererGLWidget::setMainLightPitch);
|
||||||
QObject::connect(ui.horizontalSlider_2, &QSlider::valueChanged,
|
QObject::connect(ui.horizontalSlider_2, &QSlider::valueChanged,
|
||||||
ui.openGLWidget, &Renderer::RendererGLWidget::setMainLightYaw);
|
ui.openGLWidget, &Renderer::RendererGLWidget::setMainLightYaw);
|
||||||
QObject::connect(ui.exposureSlider, &QSlider::valueChanged, [&](int value) {
|
QObject::connect(ui.exposureSlider, &QSlider::valueChanged, [&](int value) {
|
||||||
ui.openGLWidget->setExposure(value / 100.f);
|
ui.openGLWidget->setExposure(value / 100.f);
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(openAction, &QAction::triggered, [&] {
|
|
||||||
QString fileName = QFileDialog::getOpenFileName(this, QStringLiteral("´ò¿ªÄ£ÐÍ"), QString(), QStringLiteral("glTF 2.0 (*.gltf)"));
|
|
||||||
qDebug() << fileName;
|
|
||||||
if (fileName != QString())
|
|
||||||
ui.openGLWidget->setModel(fileName);
|
|
||||||
});
|
|
||||||
QObject::connect(testAction, &QAction::triggered, [&] {
|
|
||||||
ui.openGLWidget->setModel("Models/Sponza/Sponza.gltf");
|
|
||||||
});
|
|
||||||
QObject::connect(test2Action, &QAction::triggered, [&] {
|
|
||||||
ui.openGLWidget->setModel("E:\\3D Objects\\Gate\\Gate.gltf");
|
|
||||||
});
|
|
||||||
ui.horizontalSlider->setValue(105);
|
ui.horizontalSlider->setValue(105);
|
||||||
ui.horizontalSlider_2->setValue(80);
|
ui.horizontalSlider_2->setValue(80);
|
||||||
ui.exposureSlider->setValue(60);
|
ui.exposureSlider->setValue(60);
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Renderer
|
||||||
public slots:
|
public slots:
|
||||||
void currentTabChanged(int index);
|
void currentTabChanged(int index);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::RendererWidgetClass ui;
|
Ui::RendererWidgetClass ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -85,7 +85,7 @@ Renderer::VirtualTextureManager::VirtualTextureManager(GladGLContext* glMain)
|
||||||
//qDebug() << duration;
|
//qDebug() << duration;
|
||||||
pageLoadDuration += duration;
|
pageLoadDuration += duration;
|
||||||
}
|
}
|
||||||
std::this_thread::yield();
|
//std::this_thread::yield();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue