merge
commit
f42868cf3f
|
@ -84,10 +84,26 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0">
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SetDefaultConstraint</enum>
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="textureListWidget">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="Renderer::RendererGLWidget" name="openGLWidget">
|
<widget class="Renderer::RendererGLWidget" name="openGLWidget">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
|
@ -60,13 +60,13 @@ void InfoDisplayWidget::generateLayerForm()
|
||||||
emit requireRefreshElementWidget();
|
emit requireRefreshElementWidget();
|
||||||
emit requireRefreshPreview();
|
emit requireRefreshPreview();
|
||||||
});
|
});
|
||||||
scaleX->setValidator(new QDoubleValidator(0.001, 1000, 4, this));
|
scaleX->setValidator(new QDoubleValidator(-1000, 1000, 4, this));
|
||||||
connect(scaleX, &QLineEdit::textChanged, [=](QString content) {
|
connect(scaleX, &QLineEdit::textChanged, [=](QString content) {
|
||||||
this->displayLayer->property.scale = {content.toDouble(), this->displayLayer->property.scale.y()};
|
this->displayLayer->property.scale = {content.toDouble(), this->displayLayer->property.scale.y()};
|
||||||
emit requireRefreshElementWidget();
|
emit requireRefreshElementWidget();
|
||||||
emit requireRefreshPreview();
|
emit requireRefreshPreview();
|
||||||
});
|
});
|
||||||
scaleY->setValidator(new QDoubleValidator(0.001, 1000, 4, this));
|
scaleY->setValidator(new QDoubleValidator(-1000, 1000, 4, this));
|
||||||
connect(scaleY, &QLineEdit::textChanged, [=](QString content) {
|
connect(scaleY, &QLineEdit::textChanged, [=](QString content) {
|
||||||
this->displayLayer->property.scale = {this->displayLayer->property.scale.x(), content.toDouble()};
|
this->displayLayer->property.scale = {this->displayLayer->property.scale.x(), content.toDouble()};
|
||||||
emit requireRefreshElementWidget();
|
emit requireRefreshElementWidget();
|
||||||
|
|
|
@ -78,13 +78,14 @@ void LayerTreeWidget::popMenu(const QPoint &pos)
|
||||||
emit requireRefreshPreview();
|
emit requireRefreshPreview();
|
||||||
});
|
});
|
||||||
menu.addAction(QString::fromLocal8Bit("ÖØÃüÃû"), this, &LayerTreeWidget::onRenameEvent);
|
menu.addAction(QString::fromLocal8Bit("ÖØÃüÃû"), this, &LayerTreeWidget::onRenameEvent);
|
||||||
menu.addAction(QString::fromLocal8Bit("删除(保留子节点)"), this, [this]() {
|
if(typeid(*layer) == typeid(FolderLayerWrapper))
|
||||||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
menu.addAction(QString::fromLocal8Bit("删除(保留子节点)"), this, [this]() {
|
||||||
layer->delSelf();
|
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
||||||
layer->getParent()->removeChild(layer);
|
layer->delSelf();
|
||||||
this->refresh();
|
layer->getParent()->removeChild(layer);
|
||||||
emit requireRefreshPreview();
|
this->refresh();
|
||||||
});
|
emit requireRefreshPreview();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (typeid(*layer) == typeid(FolderLayerWrapper) && ((FolderLayerWrapper*)layer)->getReferencedBy() == -1) {
|
if (typeid(*layer) == typeid(FolderLayerWrapper) && ((FolderLayerWrapper*)layer)->getReferencedBy() == -1) {
|
||||||
menu.addAction(QString::fromLocal8Bit("´´½¨×éºÏÔªËØ"), this, [this]() {
|
menu.addAction(QString::fromLocal8Bit("´´½¨×éºÏÔªËØ"), this, [this]() {
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Renderer
|
||||||
glm::vec3 Position;
|
glm::vec3 Position;
|
||||||
glm::vec3 Normal;
|
glm::vec3 Normal;
|
||||||
glm::vec2 TexCoords;
|
glm::vec2 TexCoords;
|
||||||
Vertex(const aiVector3D& position, const aiVector3D& Normal, const aiVector3D& TexCoords);
|
Vertex(const aiVector3D& position, const aiVector3D& normal, const aiVector3D& texCoords);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Texture
|
struct Texture
|
||||||
|
|
|
@ -32,14 +32,12 @@ Model::Model(QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram,
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::draw() {
|
void Model::draw() {
|
||||||
//shaderProgram->bind();
|
|
||||||
for (auto& mesh : meshes) {
|
for (auto& mesh : meshes) {
|
||||||
mesh->draw();
|
mesh->draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::drawShadow() {
|
void Model::drawShadow() {
|
||||||
//shaderProgram->bind();
|
|
||||||
for (auto& mesh : meshes) {
|
for (auto& mesh : meshes) {
|
||||||
mesh->drawShadow();
|
mesh->drawShadow();
|
||||||
}
|
}
|
||||||
|
@ -55,7 +53,7 @@ void Renderer::Model::loadModel(QString path)
|
||||||
const aiScene* scene = importer.ReadFile(modelFile.absoluteFilePath().toUtf8(), aiProcess_Triangulate);
|
const aiScene* scene = importer.ReadFile(modelFile.absoluteFilePath().toUtf8(), aiProcess_Triangulate);
|
||||||
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
|
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
|
||||||
{
|
{
|
||||||
qCritical() << "ERROR::ASSIMP::" << importer.GetErrorString() << endl;
|
qCritical() << "ERROR::ASSIMP::" << importer.GetErrorString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << modelFile.absoluteFilePath() << "Loaded Successfully";
|
qDebug() << modelFile.absoluteFilePath() << "Loaded Successfully";
|
||||||
|
@ -63,9 +61,11 @@ void Renderer::Model::loadModel(QString path)
|
||||||
qDebug() << "NumMaterials: " << scene->mNumMaterials;
|
qDebug() << "NumMaterials: " << scene->mNumMaterials;
|
||||||
qDebug() << "NumTextures: " << scene->mNumTextures;
|
qDebug() << "NumTextures: " << scene->mNumTextures;
|
||||||
|
|
||||||
|
unloadModel();
|
||||||
|
|
||||||
|
|
||||||
if (QFile paintingConfigFile(directory.filePath(name + ".txt")); paintingConfigFile.open(QFile::ReadOnly | QIODevice::Text))
|
if (QFile paintingConfigFile(directory.filePath(name + ".txt")); paintingConfigFile.open(QFile::ReadOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
paintingMap.clear();
|
|
||||||
QTextStream stream(&paintingConfigFile);
|
QTextStream stream(&paintingConfigFile);
|
||||||
while (!stream.atEnd())
|
while (!stream.atEnd())
|
||||||
{
|
{
|
||||||
|
@ -81,6 +81,30 @@ void Renderer::Model::loadModel(QString path)
|
||||||
{
|
{
|
||||||
qWarning() << "Painting Config Not Found!";
|
qWarning() << "Painting Config Not Found!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
aiMatrix4x4 transform;
|
||||||
|
aiMatrix4x4::Scaling(aiVector3D(1 / 0.008), transform);
|
||||||
|
processNode(scene->mRootNode, scene, transform * scene->mRootNode->mTransformation);
|
||||||
|
AABB.clear();
|
||||||
|
AABB.emplace_back(minX, minY, minZ);
|
||||||
|
AABB.emplace_back(minX, minY, maxZ);
|
||||||
|
AABB.emplace_back(minX, maxY, minZ);
|
||||||
|
AABB.emplace_back(minX, maxY, maxZ);
|
||||||
|
AABB.emplace_back(maxX, minY, minZ);
|
||||||
|
AABB.emplace_back(maxX, minY, maxZ);
|
||||||
|
AABB.emplace_back(maxX, maxY, minZ);
|
||||||
|
AABB.emplace_back(maxX, maxY, maxZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::Model::unloadModel()
|
||||||
|
{
|
||||||
|
paintingMap.clear();
|
||||||
|
for(auto& i: paintingLoaded)
|
||||||
|
vtManager->deleteVirtualTexture(i.second);
|
||||||
|
paintingLoaded.clear();
|
||||||
|
texturesLoaded.clear();
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
minX = std::numeric_limits<float>::max();
|
minX = std::numeric_limits<float>::max();
|
||||||
maxX = std::numeric_limits<float>::min();
|
maxX = std::numeric_limits<float>::min();
|
||||||
|
@ -88,17 +112,6 @@ void Renderer::Model::loadModel(QString path)
|
||||||
maxY = std::numeric_limits<float>::min();
|
maxY = std::numeric_limits<float>::min();
|
||||||
minZ = std::numeric_limits<float>::max();
|
minZ = std::numeric_limits<float>::max();
|
||||||
maxZ = std::numeric_limits<float>::min();
|
maxZ = std::numeric_limits<float>::min();
|
||||||
aiMatrix4x4 transform;
|
|
||||||
aiMatrix4x4::Scaling(aiVector3D(1 / 0.008), transform);
|
|
||||||
processNode(scene->mRootNode, scene, transform * scene->mRootNode->mTransformation);
|
|
||||||
AABB.push_back(QVector3D(minX, minY, minZ));
|
|
||||||
AABB.push_back(QVector3D(minX, minY, maxZ));
|
|
||||||
AABB.push_back(QVector3D(minX, maxY, minZ));
|
|
||||||
AABB.push_back(QVector3D(minX, maxY, maxZ));
|
|
||||||
AABB.push_back(QVector3D(maxX, minY, minZ));
|
|
||||||
AABB.push_back(QVector3D(maxX, minY, maxZ));
|
|
||||||
AABB.push_back(QVector3D(maxX, maxY, minZ));
|
|
||||||
AABB.push_back(QVector3D(maxX, maxY, maxZ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::processNode(aiNode* node, const aiScene* scene, aiMatrix4x4 mat4)
|
void Model::processNode(aiNode* node, const aiScene* scene, aiMatrix4x4 mat4)
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace Renderer
|
||||||
void draw();
|
void draw();
|
||||||
void drawShadow();
|
void drawShadow();
|
||||||
void loadModel(QString path);
|
void loadModel(QString path);
|
||||||
|
void unloadModel();
|
||||||
Model(QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* paintingProgram, QOpenGLShaderProgram* shadowProgram, VirtualTextureManager* vtManager);
|
Model(QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* paintingProgram, QOpenGLShaderProgram* shadowProgram, VirtualTextureManager* vtManager);
|
||||||
private:
|
private:
|
||||||
QOpenGLContext* context = nullptr;
|
QOpenGLContext* context = nullptr;
|
||||||
|
@ -25,8 +26,8 @@ namespace Renderer
|
||||||
VirtualTextureManager* vtManager = nullptr;
|
VirtualTextureManager* vtManager = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param key BaseColor路径
|
* @brief key BaseColor路径 \n
|
||||||
* @param value json路径, 纹理坐标
|
* value json路径, 纹理坐标
|
||||||
*/
|
*/
|
||||||
std::unordered_map<std::string, std::tuple<std::string, glm::vec2, glm::vec2>> paintingMap;
|
std::unordered_map<std::string, std::tuple<std::string, glm::vec2, glm::vec2>> paintingMap;
|
||||||
std::unordered_map<std::string, GLuint> paintingLoaded;
|
std::unordered_map<std::string, GLuint> paintingLoaded;
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace Renderer
|
||||||
~RendererWidget();
|
~RendererWidget();
|
||||||
public slots:
|
public slots:
|
||||||
void currentTabChanged(int index);
|
void currentTabChanged(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::RendererWidgetClass ui;
|
Ui::RendererWidgetClass ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -76,7 +76,7 @@ Renderer::VirtualTextureManager::VirtualTextureManager(GladGLContext* glMain)
|
||||||
pageIdBufferMutex.lock();
|
pageIdBufferMutex.lock();
|
||||||
currentBuffer = 1 - currentBuffer;
|
currentBuffer = 1 - currentBuffer;
|
||||||
pageIdBufferMutex.unlock();
|
pageIdBufferMutex.unlock();
|
||||||
|
|
||||||
gl->BeginQuery(GL_TIME_ELAPSED, pageLoadTimeQuery);
|
gl->BeginQuery(GL_TIME_ELAPSED, pageLoadTimeQuery);
|
||||||
updatePages(pageIds);
|
updatePages(pageIds);
|
||||||
gl->EndQuery(GL_TIME_ELAPSED);
|
gl->EndQuery(GL_TIME_ELAPSED);
|
||||||
|
@ -152,8 +152,26 @@ std::uint16_t Renderer::VirtualTextureManager::createVirtualTexture(Painting pai
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
paintings.emplace_back(baseColor, metallicRoughness, painting.buffers);
|
if (const auto it = std::find_if(paintings.begin(), paintings.end(), [](const PaintingHandle& i) { return i.baseColor == 0; });
|
||||||
return paintings.size();
|
it != paintings.end())
|
||||||
|
{
|
||||||
|
*it = { baseColor, metallicRoughness, painting.buffers };
|
||||||
|
return it - paintings.begin() + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
paintings.emplace_back(baseColor, metallicRoughness, painting.buffers);
|
||||||
|
return paintings.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::VirtualTextureManager::deleteVirtualTexture(std::uint16_t id)
|
||||||
|
{
|
||||||
|
auto& painting = getPaintingHandle(id);
|
||||||
|
glMain->DeleteTextures(2, (GLuint*)&painting);
|
||||||
|
painting.baseColor = 0;
|
||||||
|
painting.metallicRoughness = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::PaintingHandle& Renderer::VirtualTextureManager::getPaintingHandle(std::uint16_t id)
|
Renderer::PaintingHandle& Renderer::VirtualTextureManager::getPaintingHandle(std::uint16_t id)
|
||||||
|
|
|
@ -24,11 +24,12 @@ namespace Renderer
|
||||||
VirtualTextureManager(GladGLContext* glMain);
|
VirtualTextureManager(GladGLContext* glMain);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief 创建彩绘虚拟纹理
|
||||||
* @param painting
|
* @param painting 彩绘
|
||||||
* @return 虚拟纹理id
|
* @return 虚拟纹理id
|
||||||
*/
|
*/
|
||||||
std::uint16_t createVirtualTexture(Painting painting);
|
std::uint16_t createVirtualTexture(Painting painting);
|
||||||
|
void deleteVirtualTexture(std::uint16_t id);
|
||||||
PaintingHandle& getPaintingHandle(std::uint16_t id);
|
PaintingHandle& getPaintingHandle(std::uint16_t id);
|
||||||
void tryUpdatePages(const std::vector<glm::u16vec2>& pageIds);
|
void tryUpdatePages(const std::vector<glm::u16vec2>& pageIds);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue