diff --git a/dust3d_jezzasoft.xcf b/dust3d_jezzasoft.xcf new file mode 100644 index 00000000..c92d2f58 Binary files /dev/null and b/dust3d_jezzasoft.xcf differ diff --git a/resources.qrc b/resources.qrc index 32959135..25d7fade 100644 --- a/resources.qrc +++ b/resources.qrc @@ -4,5 +4,6 @@ resources/rotate.svg resources/zoomin.svg resources/zoomout.svg + resources/dust3d_jezzasoft.png \ No newline at end of file diff --git a/resources/dust3d_jezzasoft.png b/resources/dust3d_jezzasoft.png new file mode 100644 index 00000000..0e5d3fb8 Binary files /dev/null and b/resources/dust3d_jezzasoft.png differ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 440ccaa7..e87da7e6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "mainwindow.h" #include "skeletonwidget.h" @@ -93,10 +94,22 @@ MainWindow::MainWindow() modelRightLayout->addStretch(); + QLabel *dust3dJezzasoftLabel = new QLabel; + QImage dust3dJezzasoftImage; + dust3dJezzasoftImage.load(":/resources/dust3d_jezzasoft.png"); + dust3dJezzasoftLabel->setPixmap(QPixmap::fromImage(dust3dJezzasoftImage)); + + QVBoxLayout *mainLeftLayout = new QVBoxLayout; + mainLeftLayout->addStretch(); + mainLeftLayout->addWidget(dust3dJezzasoftLabel); + mainLeftLayout->setSpacing(0); + mainLeftLayout->setContentsMargins(0, 0, 0, 0); + SkeletonWidget *skeletonWidget = new SkeletonWidget(this); m_skeletonWidget = skeletonWidget; QHBoxLayout *modelPageLayout = new QHBoxLayout; + modelPageLayout->addLayout(mainLeftLayout); modelPageLayout->addWidget(skeletonWidget); //modelPageLayout->addLayout(modelRightLayout); diff --git a/src/mesh.cpp b/src/mesh.cpp index 68d9ce7b..8367d520 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -1,5 +1,6 @@ #include "mesh.h" #include "meshlite.h" +#include "theme.h" #include #define MAX_VERTICES_PER_FACE 100 @@ -60,9 +61,9 @@ Mesh::Mesh(void *meshlite, int meshId) : v->normX = edgeNormals[firstIndex + 0]; v->normY = edgeNormals[firstIndex + 1]; v->normZ = edgeNormals[firstIndex + 2]; - v->colorR = 0; - v->colorG = 0; - v->colorB = 0; + v->colorR = 0.0; + v->colorG = 0.0; + v->colorB = 0.0; } } @@ -78,6 +79,9 @@ Mesh::Mesh(void *meshlite, int meshId) : GLfloat *triangleNormals = new GLfloat[triangleCount * 3]; int loadedTriangleNormalItemCount = meshlite_get_triangle_normal_array(meshlite, triangleMesh, triangleNormals, triangleCount * 3); + float modelR = Theme::white.redF(); + float modelG = Theme::white.greenF(); + float modelB = Theme::white.blueF(); m_triangleVertexCount = triangleCount * 3; m_triangleVertices = new Vertex[m_triangleVertexCount * 3]; for (int i = 0; i < triangleCount; i++) { @@ -94,9 +98,9 @@ Mesh::Mesh(void *meshlite, int meshId) : v->normX = triangleNormals[firstIndex + 0]; v->normY = triangleNormals[firstIndex + 1]; v->normZ = triangleNormals[firstIndex + 2]; - v->colorR = 1.0; - v->colorG = 1.0; - v->colorB = 1.0; + v->colorR = modelR; + v->colorG = modelG; + v->colorB = modelB; } } diff --git a/src/skeletoneditgraphicsview.cpp b/src/skeletoneditgraphicsview.cpp index 92903dc9..97287f49 100644 --- a/src/skeletoneditgraphicsview.cpp +++ b/src/skeletoneditgraphicsview.cpp @@ -27,7 +27,7 @@ SkeletonEditGraphicsView::SkeletonEditGraphicsView(QWidget *parent) : m_backgroundLoaded(false), m_modelWidget(NULL), m_modelWidgetProxy(NULL), - m_combineEnabled(false), + m_combineEnabled(true), m_unionEnabled(true), m_subdivEnabled(false) { @@ -230,7 +230,10 @@ bool SkeletonEditGraphicsView::keyPress(QKeyEvent *event, const QPointF &scenePo } else if (event->key() == Qt::Key_S) { m_subdivEnabled = !m_subdivEnabled; emit nodesChanged(); - } else if (event->key() == Qt::Key_Delete || event->key() ==Qt::Key_Backspace) { + } else if (event->key() == Qt::Key_Tab) { + if (m_nextStartNodeItem) + setNextStartNodeItem(m_nextStartNodeItem->nextSidePair()); + } else if (event->key() == Qt::Key_Delete || event->key() ==Qt::Key_Backspace) { removeSelectedItems(); processed = true; } @@ -457,6 +460,7 @@ bool SkeletonEditGraphicsView::wheel(QWheelEvent *event, const QPointF &scenePos AddItemRadius(m_pendingNodeItem, delta); if (!m_inAddNodeMode && m_lastHoverNodeItem) { AddItemRadius(m_lastHoverNodeItem, delta); + AddItemRadius(m_lastHoverNodeItem->nextSidePair(), delta); processed = true; emit nodesChanged(); } diff --git a/src/skeletonsnapshot.cpp b/src/skeletonsnapshot.cpp index 5357d403..c829b64e 100644 --- a/src/skeletonsnapshot.cpp +++ b/src/skeletonsnapshot.cpp @@ -272,4 +272,11 @@ void SkeletonSnapshot::resolveRootNode() if (m_rootNode.isEmpty()) m_rootNode = findMaxNeighborNumberNode(); + + if (m_rootNode.isEmpty()) { + nodeIterator = nodes.begin(); + if (nodeIterator != nodes.end()) { + m_rootNode = nodeIterator->first; + } + } } diff --git a/src/skeletontomesh.cpp b/src/skeletontomesh.cpp index 463d7899..f8ae1567 100644 --- a/src/skeletontomesh.cpp +++ b/src/skeletontomesh.cpp @@ -83,9 +83,8 @@ void SkeletonToMesh::process() float y = (nodeIterator->second["y"].toFloat() - frontMiddleY) / canvasHeight; float z = (nextSidePair->second["x"].toFloat() - sideMiddleX) / canvasHeight; float r = nodeIterator->second["radius"].toFloat() / canvasHeight; - float t = nextSidePair->second["radius"].toFloat() / canvasHeight; - int bmeshNodeId = meshlite_bmesh_add_node(meshliteContext, bmeshId, x, y, z, r, t); - printf("meshlite_bmesh_add_node x:%f y:%f z:%f r:%f t:%f nodeName:%s bmeshNodeId:%d\n", x, y, z, r, t, nodeIterator->first.toUtf8().constData(), bmeshNodeId); + int bmeshNodeId = meshlite_bmesh_add_node(meshliteContext, bmeshId, x, y, z, r); + printf("meshlite_bmesh_add_node x:%f y:%f z:%f r:%f nodeName:%s bmeshNodeId:%d\n", x, y, z, r, nodeIterator->first.toUtf8().constData(), bmeshNodeId); bmeshNodeMap[nodeIterator->first] = bmeshNodeId; } @@ -116,15 +115,17 @@ void SkeletonToMesh::process() } else { mergedMeshId = mergeMeshs(meshliteContext, meshIds); } - if (subdivEnabled) { + if (combineEnabled) { if (mergedMeshId > 0) { + mergedMeshId = meshlite_combine_coplanar_faces(meshliteContext, mergedMeshId); + } + } + if (subdivEnabled) { + if (mergedMeshId > 0 && meshlite_is_triangulated_manifold(meshliteContext, mergedMeshId)) { mergedMeshId = meshlite_subdivide(meshliteContext, mergedMeshId); } } if (mergedMeshId > 0) { - if (combineEnabled) { - mergedMeshId = meshlite_combine_adj_faces(meshliteContext, mergedMeshId); - } m_mesh = new Mesh(meshliteContext, mergedMeshId); } } diff --git a/src/theme.cpp b/src/theme.cpp index 79685aef..2590a3e9 100644 --- a/src/theme.cpp +++ b/src/theme.cpp @@ -14,16 +14,17 @@ // White // 0xf7, 0xd9, 0xc8 -QColor Theme::red = QColor(0xff, 0xff, 0xff); -QColor Theme::green = QColor(0xff, 0xff, 0xff); +QColor Theme::red = QColor(0xfc, 0x66, 0x21); +QColor Theme::green = QColor(0xaa, 0xeb, 0xc4); QColor Theme::blue = QColor(0x2a, 0x5a, 0xac); +QColor Theme::white = QColor(0xf7, 0xd9, 0xc8); float Theme::normalAlpha = 96.0 / 255; float Theme::branchAlpha = 64.0 / 255; float Theme::checkedAlpha = 1.0; float Theme::edgeAlpha = 1.0; float Theme::fillAlpha = 50.0 / 255; -int Theme::skeletonNodeBorderSize = 2; -int Theme::skeletonEdgeWidth = 2; +int Theme::skeletonNodeBorderSize = 0; +int Theme::skeletonEdgeWidth = 0; std::map createSideColorNameMap() { std::map map; diff --git a/src/theme.h b/src/theme.h index 19e0229c..8bc81764 100644 --- a/src/theme.h +++ b/src/theme.h @@ -10,6 +10,7 @@ public: static QColor red; static QColor green; static QColor blue; + static QColor white; static float normalAlpha; static float checkedAlpha; static float branchAlpha; diff --git a/src/unionmesh.cpp b/src/unionmesh.cpp index 1444be05..37b265b3 100644 --- a/src/unionmesh.cpp +++ b/src/unionmesh.cpp @@ -22,12 +22,14 @@ // https://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2corefinement_mesh_union_8cpp-example.html#a2 // https://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2triangulate_faces_example_8cpp-example.html // https://github.com/CGAL/cgal/issues/2875 +// https://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2hausdorff_distance_remeshing_example_8cpp-example.html#a3 #include #include #include #include #include #include +#include typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef CGAL::Surface_mesh CgalMesh; @@ -120,6 +122,7 @@ CgalMesh *unionCgalMeshs(CgalMesh *first, CgalMesh *second) delete mesh; return NULL; } + //CGAL::Polygon_mesh_processing::isotropic_remeshing(mesh->faces(), 0.4, *mesh); } catch (...) { delete mesh; return NULL;