diff --git a/application/application.pro b/application/application.pro
index d44db070..36844107 100644
--- a/application/application.pro
+++ b/application/application.pro
@@ -155,17 +155,24 @@ HEADERS += sources/mesh_generator.h
SOURCES += sources/mesh_generator.cc
HEADERS += sources/mesh_result_post_processor.h
SOURCES += sources/mesh_result_post_processor.cc
-HEADERS += sources/model.h
-SOURCES += sources/model.cc
+HEADERS += sources/model_mesh.h
+SOURCES += sources/model_mesh.cc
HEADERS += sources/model_offscreen_render.h
SOURCES += sources/model_offscreen_render.cc
HEADERS += sources/model_opengl_program.h
SOURCES += sources/model_opengl_program.cc
HEADERS += sources/model_opengl_object.h
SOURCES += sources/model_opengl_object.cc
-HEADERS += sources/model_shader_vertex.h
+HEADERS += sources/model_opengl_vertex.h
HEADERS += sources/model_widget.h
SOURCES += sources/model_widget.cc
+HEADERS += sources/monochrome_mesh.h
+SOURCES += sources/monochrome_mesh.cc
+HEADERS += sources/monochrome_opengl_program.h
+SOURCES += sources/monochrome_opengl_program.cc
+HEADERS += sources/monochrome_opengl_object.h
+SOURCES += sources/monochrome_opengl_object.cc
+HEADERS += sources/monochrome_opengl_vertex.h
HEADERS += sources/part_preview_images_generator.h
SOURCES += sources/part_preview_images_generator.cc
HEADERS += sources/part_tree_widget.h
diff --git a/application/resources.qrc b/application/resources.qrc
index b596c8f9..7c35e22a 100644
--- a/application/resources.qrc
+++ b/application/resources.qrc
@@ -8,6 +8,10 @@
shaders/model.frag
shaders/model_core.vert
shaders/model_core.frag
+ shaders/monochrome.vert
+ shaders/monochrome.frag
+ shaders/monochrome_core.vert
+ shaders/monochrome_core.frag
resources/cedar_bridge_irradiance.dds
resources/cedar_bridge_specular.dds
resources/dust3d-vertical.png
diff --git a/application/shaders/monochrome.frag b/application/shaders/monochrome.frag
new file mode 100644
index 00000000..9be65eb8
--- /dev/null
+++ b/application/shaders/monochrome.frag
@@ -0,0 +1,9 @@
+#version 110
+varying vec3 pointPosition;
+varying vec3 pointColor;
+varying float pointAlpha;
+
+void main()
+{
+ gl_FragColor = vec4(pointColor, pointAlpha);
+}
diff --git a/application/shaders/monochrome.vert b/application/shaders/monochrome.vert
new file mode 100644
index 00000000..123122fc
--- /dev/null
+++ b/application/shaders/monochrome.vert
@@ -0,0 +1,19 @@
+#version 110
+attribute vec4 vertex;
+attribute vec3 color;
+attribute float alpha;
+uniform mat4 modelMatrix;
+uniform mat4 viewMatrix;
+uniform mat4 projectionMatrix;
+varying vec3 pointPosition;
+varying vec3 pointColor;
+varying float pointAlpha;
+
+void main()
+{
+ pointPosition = (modelMatrix * vertex).xyz;
+ pointColor = color;
+ pointAlpha = alpha;
+
+ gl_Position = projectionMatrix * viewMatrix * vec4(pointPosition, 1.0);
+}
diff --git a/application/shaders/monochrome_core.frag b/application/shaders/monochrome_core.frag
new file mode 100644
index 00000000..aba2a57f
--- /dev/null
+++ b/application/shaders/monochrome_core.frag
@@ -0,0 +1,8 @@
+#version 330
+in vec3 pointColor;
+in float pointAlpha;
+out vec4 fragColor;
+void main()
+{
+ fragColor = vec4(pointColor, pointAlpha);
+}
\ No newline at end of file
diff --git a/application/shaders/monochrome_core.vert b/application/shaders/monochrome_core.vert
new file mode 100644
index 00000000..ea3620f1
--- /dev/null
+++ b/application/shaders/monochrome_core.vert
@@ -0,0 +1,19 @@
+#version 330
+layout(location = 0) in vec4 vertex;
+layout(location = 1) in vec3 color;
+layout(location = 2) in float alpha;
+uniform mat4 modelMatrix;
+uniform mat4 viewMatrix;
+uniform mat4 projectionMatrix;
+out vec3 pointPosition;
+out vec3 pointColor;
+out float pointAlpha;
+
+void main()
+{
+ pointPosition = (modelMatrix * vertex).xyz;
+ pointColor = color;
+ pointAlpha = alpha;
+
+ gl_Position = projectionMatrix * viewMatrix * vec4(pointPosition, 1.0);
+}
\ No newline at end of file
diff --git a/application/sources/document.cc b/application/sources/document.cc
index 58528b6c..47c48d83 100644
--- a/application/sources/document.cc
+++ b/application/sources/document.cc
@@ -729,30 +729,38 @@ void Document::fromSnapshot(const dust3d::Snapshot &snapshot)
emit uncheckAll();
}
-Model *Document::takeResultMesh()
+ModelMesh *Document::takeResultMesh()
{
if (nullptr == m_resultMesh)
return nullptr;
- Model *resultMesh = new Model(*m_resultMesh);
+ ModelMesh *resultMesh = new ModelMesh(*m_resultMesh);
return resultMesh;
}
+MonochromeMesh *Document::takeWireframeMesh()
+{
+ if (nullptr == m_wireframeMesh)
+ return nullptr;
+ return new MonochromeMesh(*m_wireframeMesh);
+}
+
bool Document::isMeshGenerationSucceed()
{
return m_isMeshGenerationSucceed;
}
-Model *Document::takeResultTextureMesh()
+ModelMesh *Document::takeResultTextureMesh()
{
if (nullptr == m_resultTextureMesh)
return nullptr;
- Model *resultTextureMesh = new Model(*m_resultTextureMesh);
+ ModelMesh *resultTextureMesh = new ModelMesh(*m_resultTextureMesh);
return resultTextureMesh;
}
void Document::meshReady()
{
- Model *resultMesh = m_meshGenerator->takeResultMesh();
+ ModelMesh *resultMesh = m_meshGenerator->takeResultMesh();
+ m_wireframeMesh.reset(m_meshGenerator->takeWireframeMesh());
dust3d::Object *object = m_meshGenerator->takeObject();
bool isSuccessful = m_meshGenerator->isSuccessful();
@@ -772,7 +780,7 @@ void Document::meshReady()
for (auto &partId: m_meshGenerator->generatedPreviewPartIds()) {
auto part = partMap.find(partId);
if (part != partMap.end()) {
- Model *resultPartPreviewMesh = m_meshGenerator->takePartPreviewMesh(partId);
+ ModelMesh *resultPartPreviewMesh = m_meshGenerator->takePartPreviewMesh(partId);
part->second.updatePreviewMesh(resultPartPreviewMesh);
partPreviewsChanged = true;
}
@@ -1591,7 +1599,7 @@ void Document::materialPreviewsReady()
for (const auto &materialId: m_materialPreviewsGenerator->generatedPreviewMaterialIds()) {
auto material = materialMap.find(materialId);
if (material != materialMap.end()) {
- Model *resultPartPreviewMesh = m_materialPreviewsGenerator->takePreview(materialId);
+ ModelMesh *resultPartPreviewMesh = m_materialPreviewsGenerator->takePreview(materialId);
material->second.updatePreviewMesh(resultPartPreviewMesh);
emit materialPreviewChanged(materialId);
}
diff --git a/application/sources/document.h b/application/sources/document.h
index 1244b1af..2cda209e 100644
--- a/application/sources/document.h
+++ b/application/sources/document.h
@@ -14,7 +14,8 @@
#include
#include
#include
-#include "model.h"
+#include "model_mesh.h"
+#include "monochrome_mesh.h"
#include "theme.h"
#include "skeleton_document.h"
#include "material_layer.h"
@@ -44,20 +45,20 @@ public:
QString name;
bool dirty = true;
std::vector layers;
- void updatePreviewMesh(Model *previewMesh)
+ void updatePreviewMesh(ModelMesh *previewMesh)
{
delete m_previewMesh;
m_previewMesh = previewMesh;
}
- Model *takePreviewMesh() const
+ ModelMesh *takePreviewMesh() const
{
if (nullptr == m_previewMesh)
return nullptr;
- return new Model(*m_previewMesh);
+ return new ModelMesh(*m_previewMesh);
}
private:
Q_DISABLE_COPY(Material);
- Model *m_previewMesh = nullptr;
+ ModelMesh *m_previewMesh = nullptr;
};
enum class DocumentToSnapshotFor
@@ -133,8 +134,8 @@ public: // need initialize
QImage *textureAmbientOcclusionImage = nullptr;
QByteArray *textureAmbientOcclusionImageByteArray = nullptr;
bool weldEnabled = true;
- float brushMetalness = Model::m_defaultMetalness;
- float brushRoughness = Model::m_defaultRoughness;
+ float brushMetalness = ModelMesh::m_defaultMetalness;
+ float brushRoughness = ModelMesh::m_defaultRoughness;
public:
Document();
~Document();
@@ -160,11 +161,12 @@ public:
};
void addFromSnapshot(const dust3d::Snapshot &snapshot, enum SnapshotSource source=SnapshotSource::Paste);
const Material *findMaterial(dust3d::Uuid materialId) const;
- Model *takeResultMesh();
- Model *takePaintedMesh();
+ ModelMesh *takeResultMesh();
+ MonochromeMesh *takeWireframeMesh();
+ ModelMesh *takePaintedMesh();
bool isMeshGenerationSucceed();
- Model *takeResultTextureMesh();
- Model *takeResultRigWeightMesh();
+ ModelMesh *takeResultTextureMesh();
+ ModelMesh *takeResultRigWeightMesh();
void updateTurnaround(const QImage &image);
void clearTurnaround();
void updateTextureImage(QImage *image);
@@ -239,7 +241,8 @@ private:
bool m_isResultMeshObsolete = false;
MeshGenerator *m_meshGenerator = nullptr;
- Model *m_resultMesh = nullptr;
+ ModelMesh *m_resultMesh = nullptr;
+ std::unique_ptr m_wireframeMesh;
bool m_isMeshGenerationSucceed = true;
int m_batchChangeRefCount = 0;
dust3d::Object *m_currentObject = nullptr;
@@ -248,7 +251,7 @@ private:
bool m_isPostProcessResultObsolete = false;
MeshResultPostProcessor *m_postProcessor = nullptr;
dust3d::Object *m_postProcessedObject = new dust3d::Object;
- Model *m_resultTextureMesh = nullptr;
+ ModelMesh *m_resultTextureMesh = nullptr;
unsigned long long m_textureImageUpdateVersion = 0;
bool m_smoothNormal = false;
MaterialPreviewsGenerator *m_materialPreviewsGenerator = nullptr;
diff --git a/application/sources/document_window.cc b/application/sources/document_window.cc
index 952bb70c..c54c8e74 100644
--- a/application/sources/document_window.cc
+++ b/application/sources/document_window.cc
@@ -423,7 +423,7 @@ DocumentWindow::DocumentWindow()
m_toggleColorAction = new QAction(tr("Toggle Color"), this);
connect(m_toggleColorAction, &QAction::triggered, [&]() {
m_modelRemoveColor = !m_modelRemoveColor;
- Model *mesh = nullptr;
+ ModelMesh *mesh = nullptr;
if (m_document->isMeshGenerating() ||
m_document->isPostProcessing() ||
m_document->isTextureGenerating()) {
@@ -738,6 +738,7 @@ DocumentWindow::DocumentWindow()
if (m_modelRemoveColor && resultMesh)
resultMesh->removeColor();
m_modelRenderWidget->updateMesh(resultMesh);
+ m_modelRenderWidget->updateWireframeMesh(m_document->takeWireframeMesh());
});
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::cursorChanged, [=]() {
@@ -1027,7 +1028,7 @@ void DocumentWindow::openPathAs(const QString &path, const QString &asName)
QByteArray fileData = file.readAll();
dust3d::Ds3FileReader ds3Reader((const std::uint8_t *)fileData.data(), fileData.size());
- for (int i = 0; i < ds3Reader.items().size(); ++i) {
+ for (int i = 0; i < (int)ds3Reader.items().size(); ++i) {
const dust3d::Ds3ReaderItem &item = ds3Reader.items()[i];
qDebug() << "[" << i << "]item.name:" << item.name << "item.type:" << item.type;
if (item.type == "asset") {
@@ -1045,7 +1046,7 @@ void DocumentWindow::openPathAs(const QString &path, const QString &asName)
}
}
- for (int i = 0; i < ds3Reader.items().size(); ++i) {
+ for (int i = 0; i < (int)ds3Reader.items().size(); ++i) {
const dust3d::Ds3ReaderItem &item = ds3Reader.items()[i];
if (item.type == "model") {
std::vector data;
@@ -1124,7 +1125,7 @@ void DocumentWindow::exportObjResult()
void DocumentWindow::exportObjToFilename(const QString &filename)
{
QApplication::setOverrideCursor(Qt::WaitCursor);
- Model *resultMesh = m_document->takeResultMesh();
+ ModelMesh *resultMesh = m_document->takeResultMesh();
if (nullptr != resultMesh) {
resultMesh->exportAsObj(filename);
delete resultMesh;
@@ -1534,13 +1535,13 @@ void DocumentWindow::updateRecentFileActions()
{
QStringList files = Preferences::instance().recentFileList();
- for (int i = 0; i < files.size() && i < m_recentFileActions.size(); ++i) {
+ for (int i = 0; i < (int)files.size() && i < (int)m_recentFileActions.size(); ++i) {
QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
m_recentFileActions[i]->setText(text);
m_recentFileActions[i]->setData(files[i]);
m_recentFileActions[i]->setVisible(true);
}
- for (int j = files.size(); j < m_recentFileActions.size(); ++j)
+ for (int j = files.size(); j < (int)m_recentFileActions.size(); ++j)
m_recentFileActions[j]->setVisible(false);
m_recentFileSeparatorAction->setVisible(files.size() > 0);
diff --git a/application/sources/glb_file.cc b/application/sources/glb_file.cc
index 00998384..a02a55f0 100644
--- a/application/sources/glb_file.cc
+++ b/application/sources/glb_file.cc
@@ -7,7 +7,7 @@
#include
#include "glb_file.h"
#include "version.h"
-#include "model.h"
+#include "model_mesh.h"
bool GlbFileWriter::m_enableComment = false;
@@ -79,8 +79,8 @@ GlbFileWriter::GlbFileWriter(dust3d::Object &object,
m_json["meshes"][0]["primitives"][primitiveIndex]["attributes"]["TEXCOORD_0"] = bufferViewIndex + (++attributeIndex);
int textureIndex = 0;
m_json["materials"][primitiveIndex]["pbrMetallicRoughness"]["baseColorTexture"]["index"] = textureIndex++;
- m_json["materials"][primitiveIndex]["pbrMetallicRoughness"]["metallicFactor"] = Model::m_defaultMetalness;
- m_json["materials"][primitiveIndex]["pbrMetallicRoughness"]["roughnessFactor"] = Model::m_defaultRoughness;
+ m_json["materials"][primitiveIndex]["pbrMetallicRoughness"]["metallicFactor"] = ModelMesh::m_defaultMetalness;
+ m_json["materials"][primitiveIndex]["pbrMetallicRoughness"]["roughnessFactor"] = ModelMesh::m_defaultRoughness;
if (object.alphaEnabled)
m_json["materials"][primitiveIndex]["alphaMode"] = "BLEND";
if (normalImage) {
diff --git a/application/sources/material_previews_generator.cc b/application/sources/material_previews_generator.cc
index dd1949fe..0cdf2e51 100644
--- a/application/sources/material_previews_generator.cc
+++ b/application/sources/material_previews_generator.cc
@@ -31,9 +31,9 @@ const std::set &MaterialPreviewsGenerator::generatedPreviewMateria
return m_generatedMaterialIds;
}
-Model *MaterialPreviewsGenerator::takePreview(dust3d::Uuid materialId)
+ModelMesh *MaterialPreviewsGenerator::takePreview(dust3d::Uuid materialId)
{
- Model *resultMesh = m_previews[materialId];
+ ModelMesh *resultMesh = m_previews[materialId];
m_previews[materialId] = nullptr;
return resultMesh;
}
@@ -102,9 +102,9 @@ void MaterialPreviewsGenerator::generate()
}
}
textureGenerator->generate();
- Model *texturedResultMesh = textureGenerator->takeResultMesh();
+ ModelMesh *texturedResultMesh = textureGenerator->takeResultMesh();
if (nullptr != texturedResultMesh) {
- m_previews[material.first] = new Model(*texturedResultMesh);
+ m_previews[material.first] = new ModelMesh(*texturedResultMesh);
m_generatedMaterialIds.insert(material.first);
delete texturedResultMesh;
}
diff --git a/application/sources/material_previews_generator.h b/application/sources/material_previews_generator.h
index df156002..b6161694 100644
--- a/application/sources/material_previews_generator.h
+++ b/application/sources/material_previews_generator.h
@@ -4,7 +4,7 @@
#include
#include