Restructure the code base

Move the core function code to a dedicate folder under namespace dust3d.
Leave the application and UI code to application folder.
Remove CGAL, use our own mesh boolean algorithm and triangulating code, should have less chance to crash on bad meshes.
The overall performance of mesh combining is improved since some mesh validating code for CGAL is removed.
master
huxingyi 2021-11-18 22:58:01 +08:00
parent c4936fd900
commit 8e5d622db7
10390 changed files with 59698 additions and 2201908 deletions

46
.gitignore vendored
View File

@ -1,3 +1,45 @@
moc_*
# Node artifact files
node_modules/
dist/
# Compiled Java class files
*.class
# Compiled Python bytecode
*.py[cod]
# Log files
*.log
# Package files
*.jar
# Maven
target/
dist/
# JetBrains IDE
.idea/
# Unit test reports
TEST*.xml
# Generated by MacOS
.DS_Store
*.o
# Generated by Windows
Thumbs.db
# Applications
*.app
*.exe
*.war
# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv

View File

@ -1,116 +0,0 @@
# Reference: https://andrewdolby.com/articles/2016/continuous-deployment-for-qt-applications/
notifications:
email: false
os: osx
language: cpp
matrix:
include:
- if: tag IS present
- os: linux
dist: xenial
sudo: required
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- os: osx
compiler: clang
osx_image: xcode9.3
install:
# (Linux) Prepare build environment
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository --yes ppa:beineri/opt-qt591-xenial; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt install cmake; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libgl-dev; fi
# (Linux) Install CGAL
# (Linux) First install a maybe old version CGAL to resolve dependencies
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libcgal-dev; fi
# (Linux) Build CGAL from source
- wget https://github.com/CGAL/cgal/releases/download/v5.1/CGAL-5.1.zip
- unzip CGAL-5.1.zip
- cd CGAL-5.1
- mkdir build
- cd build
- cmake ../
- make
- sudo make install
- cd "$TRAVIS_BUILD_DIR"
# Build Instant-Meshes from source
- cd thirdparty/instant-meshes
- mkdir build
- cd build
- cmake ../
- make -j 4
- cd "$TRAVIS_BUILD_DIR"
# (Mac) Install Qt5
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then HOMEBREW_VERBOSE_USING_DOTS=1 brew reinstall --verbose qt; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/usr/local/opt/qt/bin:$(brew --prefix)/bin:$PATH"; fi
# (Linux) Install Qt5
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install qt59base qt59tools --force-yes; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then source /opt/qt59/bin/qt59-env.sh; fi
script:
# Build Dust3D
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then qmake -config release || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then qmake -config release || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make CXX="g++ -fext-numeric-literals" || travis_terminate 1; fi
# Prepare tag name
- export TAG="$TRAVIS_TAG"
- if [[ "$TAG" == "" ]]; then export TAG=unstable; fi
- export BRANCH="$TRAVIS_BRANCH"
- if [[ "$BRANCH" == "$TAG" ]]; then export BRANCH=master; fi
# (Mac) Prepare dmg
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mv dust3d.app dust3d-$TAG.app || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then macdeployqt dust3d-$TAG.app -dmg || travis_terminate 1; fi
# (Linux) Prepare AppImage
# References:
# https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html
# https://packages.ubuntu.com/search?suite=trusty&arch=amd64&mode=exactfilename&searchon=contents&keywords=libstdc%2B%2B.so.6
# https://github.com/darealshinji/AppImageKit-checkrt/issues/1
# https://github.com/darealshinji/AppImageKit-checkrt/releases/download/continuous/AppRun-patched-x86_64
# https://github.com/darealshinji/AppImageKit-checkrt/releases/download/continuous/exec-x86_64.so
# https://github.com/probonopd/audacity/blob/AppImage/.travis.yml
# https://discourse.appimage.org/t/im-a-big-fan-of-this-but-graphics-driver-libstdc-conflict/171
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir -p appdir/usr/share/metainfo || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir -p appdir/usr/share/applications || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir -p appdir/usr/bin || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir -p appdir/usr/optional/libstdc++ || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ldd --version; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ls /usr/lib/x86_64-linux-gnu/ | grep libstdc; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 appdir/usr/optional/libstdc++/libstdc++.so.6 || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./ci/exec-x86_64.so appdir/usr/optional/exec.so || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./ci/dust3d.png appdir/dust3d.png || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./ci/dust3d.appdata.xml appdir/usr/share/metainfo/dust3d.appdata.xml || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./dust3d appdir/usr/bin/dust3d || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./ci/dust3d.desktop appdir/usr/share/applications/dust3d.desktop || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then chmod a+x ./ci/linuxdeployqt.AppImage || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then unset QTDIR; unset QT_PLUGIN_PATH ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./ci/linuxdeployqt.AppImage appdir/usr/share/applications/dust3d.desktop -bundle-non-qt-libs -verbose=2 || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then rm appdir/AppRun || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./ci/AppRun-patched-x86_64 appdir/AppRun || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then chmod a+x appdir/AppRun || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./ci/linuxdeployqt.AppImage --appimage-extract || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export PATH=$(readlink -f ./squashfs-root/usr/bin):$PATH || travis_terminate 1; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then rm -v "./appdir/usr/lib/libxcb-dri2.so"* "./appdir/usr/lib/libxcb-dri3.so"*; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./squashfs-root/usr/bin/appimagetool -g ./appdir/ dust3d-$TAG.AppImage || travis_terminate 1; fi
# Distribute
- if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then echo "No distribution on pull request"; fi
- if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then travis_terminate 0; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sh ci/upload-github-release-asset.sh github_api_token=${my_auth_token} branch=$BRANCH owner=huxingyi repo=dust3d tag=$TAG filename=dust3d-$TAG.dmg; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then bash ci/upload-github-release-asset.sh github_api_token=${my_auth_token} branch=$BRANCH owner=huxingyi repo=dust3d tag=$TAG filename=dust3d-$TAG.AppImage; fi

1
BUILD
View File

@ -1 +0,0 @@
http://docs.dust3d.org/en/latest/builds.html

331
application/application.pro Normal file
View File

@ -0,0 +1,331 @@
QT += core gui opengl widgets svg network
TARGET = dust3d
TEMPLATE = app
HUMAN_VERSION = "1.0.0-rc.7"
VERSION = 1.0.0.37
QMAKE_TARGET_COMPANY = Dust3D
QMAKE_TARGET_PRODUCT = Dust3D
QMAKE_TARGET_DESCRIPTION = "Dust3D is a cross-platform open-source 3D modeling software"
QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2018-2021 Dust3D Project. All Rights Reserved."
HOMEPAGE_URL = "https://dust3d.org/"
REPOSITORY_URL = "https://github.com/huxingyi/dust3d"
ISSUES_URL = "https://github.com/huxingyi/dust3d/issues"
REFERENCE_GUIDE_URL = "https://docs.dust3d.org"
UPDATES_CHECKER_URL = "https://dust3d.org/dust3d-updateinfo.xml"
DEFINES += QT_MESSAGELOGCONTEXT
DEFINES += _USE_MATH_DEFINES
CONFIG += object_parallel_to_source
CONFIG += no_batch
CONFIG(release, debug|release) {
win32 {
QMAKE_CXXFLAGS += /MP
QMAKE_CXXFLAGS += /O2
QMAKE_CXXFLAGS += /bigobj
CONFIG += force_debug_info
}
macx {
QMAKE_CXXFLAGS_RELEASE -= -O
QMAKE_CXXFLAGS_RELEASE -= -O1
QMAKE_CXXFLAGS_RELEASE -= -O2
QMAKE_CXXFLAGS_RELEASE += -O3
}
unix:!macx {
QMAKE_CXXFLAGS_RELEASE -= -O
QMAKE_CXXFLAGS_RELEASE -= -O1
QMAKE_CXXFLAGS_RELEASE -= -O2
QMAKE_CXXFLAGS_RELEASE += -O3
}
}
PLATFORM = "Unknown"
macx {
PLATFORM = "MacOS"
}
win32 {
PLATFORM = "Win32"
}
unix:!macx {
PLATFORM = "Linux"
}
DEFINES += "PROJECT_DEFINED_APP_COMPANY=\"\\\"$$QMAKE_TARGET_COMPANY\\\"\""
DEFINES += "PROJECT_DEFINED_APP_NAME=\"\\\"$$QMAKE_TARGET_PRODUCT\\\"\""
DEFINES += "PROJECT_DEFINED_APP_VER=\"\\\"$$VERSION\\\"\""
DEFINES += "PROJECT_DEFINED_APP_HUMAN_VER=\"\\\"$$HUMAN_VERSION\\\"\""
DEFINES += "PROJECT_DEFINED_APP_HOMEPAGE_URL=\"\\\"$$HOMEPAGE_URL\\\"\""
DEFINES += "PROJECT_DEFINED_APP_REPOSITORY_URL=\"\\\"$$REPOSITORY_URL\\\"\""
DEFINES += "PROJECT_DEFINED_APP_ISSUES_URL=\"\\\"$$ISSUES_URL\\\"\""
DEFINES += "PROJECT_DEFINED_APP_REFERENCE_GUIDE_URL=\"\\\"$$REFERENCE_GUIDE_URL\\\"\""
DEFINES += "PROJECT_DEFINED_APP_UPDATES_CHECKER_URL=\"\\\"$$UPDATES_CHECKER_URL\\\"\""
DEFINES += "PROJECT_DEFINED_APP_PLATFORM=\"\\\"$$PLATFORM\\\"\""
OBJECTS_DIR = obj
MOC_DIR = moc
win32 {
RC_FILE = $${SOURCE_ROOT}dust3d.rc
}
macx {
ICON = $${SOURCE_ROOT}dust3d.icns
RESOURCE_FILES.files = $$ICON
RESOURCE_FILES.path = Contents/Resources
QMAKE_BUNDLE_DATA += RESOURCE_FILES
}
RESOURCES += resources.qrc
DEFINES += BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE
win32 {
isEmpty(BOOST_INCLUDEDIR) {
BOOST_INCLUDEDIR = $$(BOOST_INCLUDEDIR)
}
isEmpty(BOOST_INCLUDEDIR) {
error("No BOOST_INCLUDEDIR define found in environment variables")
}
}
macx {
BOOST_INCLUDEDIR = /usr/local/opt/boost/include
}
unix:!macx {
BOOST_INCLUDEDIR = /usr/local/include
}
INCLUDEPATH += $$BOOST_INCLUDEDIR
INCLUDEPATH += ../
INCLUDEPATH += ../third_party
INCLUDEPATH += ../third_party/rapidxml-1.13
INCLUDEPATH += ../third_party/earcut.hpp/include
INCLUDEPATH += ../third_party/eigen
INCLUDEPATH += ../third_party/libigl/include
INCLUDEPATH += ../third_party/lodepng
include(third_party/QtAwesome/QtAwesome/QtAwesome.pri)
HEADERS += sources/about_widget.h
SOURCES += sources/about_widget.cc
HEADERS += sources/ccd_ik_resolver.h
SOURCES += sources/ccd_ik_resolver.cc
HEADERS += sources/cut_face_preview.h
SOURCES += sources/cut_face_preview.cc
HEADERS += sources/dds_file.h
SOURCES += sources/dds_file.cc
HEADERS += sources/debug.h
SOURCES += sources/debug.cc
HEADERS += sources/document.h
SOURCES += sources/document.cc
HEADERS += sources/document_saver.h
SOURCES += sources/document_saver.cc
HEADERS += sources/document_window.h
SOURCES += sources/document_window.cc
HEADERS += sources/fbx_file.h
SOURCES += sources/fbx_file.cc
HEADERS += sources/float_number_widget.h
SOURCES += sources/float_number_widget.cc
HEADERS += sources/flow_layout.h
SOURCES += sources/flow_layout.cc
HEADERS += sources/glb_file.h
SOURCES += sources/glb_file.cc
HEADERS += sources/graphics_container_widget.h
SOURCES += sources/graphics_container_widget.cc
HEADERS += sources/horizontal_line_widget.h
SOURCES += sources/horizontal_line_widget.cc
HEADERS += sources/image_forever.h
SOURCES += sources/image_forever.cc
HEADERS += sources/image_preview_widget.h
SOURCES += sources/image_preview_widget.cc
HEADERS += sources/info_label.h
SOURCES += sources/info_label.cc
HEADERS += sources/int_number_widget.h
SOURCES += sources/int_number_widget.cc
HEADERS += sources/log_browser.h
SOURCES += sources/log_browser.cc
HEADERS += sources/log_browser_dialog.h
SOURCES += sources/log_browser_dialog.cc
SOURCES += sources/main.cc
HEADERS += sources/material.h
SOURCES += sources/material.cc
HEADERS += sources/material_edit_widget.h
SOURCES += sources/material_edit_widget.cc
HEADERS += sources/material_layer.h
SOURCES += sources/material_layer.cc
HEADERS += sources/material_list_widget.h
SOURCES += sources/material_list_widget.cc
HEADERS += sources/material_manage_widget.h
SOURCES += sources/material_manage_widget.cc
HEADERS += sources/material_previews_generator.h
SOURCES += sources/material_previews_generator.cc
HEADERS += sources/material_widget.h
SOURCES += sources/material_widget.cc
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_binder.h
SOURCES += sources/model_mesh_binder.cc
HEADERS += sources/model_offscreen_render.h
SOURCES += sources/model_offscreen_render.cc
HEADERS += sources/model_shader_program.h
SOURCES += sources/model_shader_program.cc
HEADERS += sources/model_shader_vertex.h
HEADERS += sources/model_widget.h
SOURCES += sources/model_widget.cc
HEADERS += sources/part_preview_images_generator.h
SOURCES += sources/part_preview_images_generator.cc
HEADERS += sources/part_tree_widget.h
SOURCES += sources/part_tree_widget.cc
HEADERS += sources/part_widget.h
SOURCES += sources/part_widget.cc
HEADERS += sources/preferences.h
SOURCES += sources/preferences.cc
HEADERS += sources/skeleton_document.h
SOURCES += sources/skeleton_document.cc
HEADERS += sources/skeleton_graphics_widget.h
SOURCES += sources/skeleton_graphics_widget.cc
HEADERS += sources/skeleton_ik_mover.h
SOURCES += sources/skeleton_ik_mover.cc
HEADERS += sources/spinnable_toolbar_icon.h
SOURCES += sources/spinnable_toolbar_icon.cc
HEADERS += sources/texture_generator.h
SOURCES += sources/texture_generator.cc
HEADERS += sources/theme.h
SOURCES += sources/theme.cc
HEADERS += sources/toolbar_button.h
SOURCES += sources/toolbar_button.cc
HEADERS += sources/turnaround_loader.h
SOURCES += sources/turnaround_loader.cc
HEADERS += sources/updates_check_widget.h
SOURCES += sources/updates_check_widget.cc
HEADERS += sources/updates_checker.h
SOURCES += sources/updates_checker.cc
HEADERS += sources/version.h
INCLUDEPATH += third_party/QtWaitingSpinner
SOURCES += third_party/QtWaitingSpinner/waitingspinnerwidget.cpp
HEADERS += third_party/QtWaitingSpinner/waitingspinnerwidget.h
INCLUDEPATH += third_party/fbx/src
SOURCES += third_party/fbx/src/fbxdocument.cpp
HEADERS += third_party/fbx/src/fbxdocument.h
SOURCES += third_party/fbx/src/fbxnode.cpp
HEADERS += third_party/fbx/src/fbxnode.h
SOURCES += third_party/fbx/src/fbxproperty.cpp
HEADERS += third_party/fbx/src/fbxproperty.h
SOURCES += third_party/fbx/src/fbxutil.cpp
HEADERS += third_party/fbx/src/fbxutil.h
INCLUDEPATH += third_party/json
INCLUDEPATH += third_party/miniz
SOURCES += third_party/miniz/miniz.c
HEADERS += third_party/miniz/miniz.h
HEADERS += ../dust3d/base/axis_aligned_bounding_box.h
HEADERS += ../dust3d/base/axis_aligned_bounding_box_tree.h
SOURCES += ../dust3d/base/axis_aligned_bounding_box_tree.cc
HEADERS += ../dust3d/base/color.h
HEADERS += ../dust3d/base/combine_mode.h
SOURCES += ../dust3d/base/combine_mode.cc
HEADERS += ../dust3d/base/cut_face.h
SOURCES += ../dust3d/base/cut_face.cc
HEADERS += ../dust3d/base/debug.h
HEADERS += ../dust3d/base/ds3_file.h
SOURCES += ../dust3d/base/ds3_file.cc
HEADERS += ../dust3d/base/math.h
HEADERS += ../dust3d/base/matrix4x4.h
HEADERS += ../dust3d/base/object.h
HEADERS += ../dust3d/base/part_base.h
SOURCES += ../dust3d/base/part_base.cc
HEADERS += ../dust3d/base/part_target.h
SOURCES += ../dust3d/base/part_target.cc
HEADERS += ../dust3d/base/position_key.h
SOURCES += ../dust3d/base/position_key.cc
HEADERS += ../dust3d/base/quaternion.h
HEADERS += ../dust3d/base/rectangle.h
HEADERS += ../dust3d/base/snapshot.h
HEADERS += ../dust3d/base/snapshot_xml.h
SOURCES += ../dust3d/base/snapshot_xml.cc
HEADERS += ../dust3d/base/string.h
SOURCES += ../dust3d/base/string.cc
HEADERS += ../dust3d/base/texture_type.h
SOURCES += ../dust3d/base/texture_type.cc
HEADERS += ../dust3d/base/vector3.h
SOURCES += ../dust3d/base/vector3.cc
HEADERS += ../dust3d/base/vector2.h
HEADERS += ../dust3d/base/uuid.h
HEADERS += ../dust3d/mesh/box_mesh.h
SOURCES += ../dust3d/mesh/box_mesh.cc
HEADERS += ../dust3d/mesh/centripetal_catmull_rom_spline.h
SOURCES += ../dust3d/mesh/centripetal_catmull_rom_spline.cc
HEADERS += ../dust3d/mesh/solid_mesh.h
SOURCES += ../dust3d/mesh/solid_mesh.cc
HEADERS += ../dust3d/mesh/solid_mesh_boolean_operation.h
SOURCES += ../dust3d/mesh/solid_mesh_boolean_operation.cc
HEADERS += ../dust3d/mesh/hole_stitcher.h
SOURCES += ../dust3d/mesh/hole_stitcher.cc
HEADERS += ../dust3d/mesh/hole_wrapper.h
SOURCES += ../dust3d/mesh/hole_wrapper.cc
HEADERS += ../dust3d/mesh/isotropic_halfedge_mesh.h
SOURCES += ../dust3d/mesh/isotropic_halfedge_mesh.cc
HEADERS += ../dust3d/mesh/isotropic_remesher.h
SOURCES += ../dust3d/mesh/isotropic_remesher.cc
HEADERS += ../dust3d/mesh/mesh_combiner.h
SOURCES += ../dust3d/mesh/mesh_combiner.cc
HEADERS += ../dust3d/mesh/mesh_generator.h
SOURCES += ../dust3d/mesh/mesh_generator.cc
HEADERS += ../dust3d/mesh/mesh_recombiner.h
SOURCES += ../dust3d/mesh/mesh_recombiner.cc
HEADERS += ../dust3d/mesh/mesh_stroketifier.h
SOURCES += ../dust3d/mesh/mesh_stroketifier.cc
HEADERS += ../dust3d/mesh/re_triangulator.h
SOURCES += ../dust3d/mesh/re_triangulator.cc
HEADERS += ../dust3d/mesh/resolve_triangle_source_node.h
SOURCES += ../dust3d/mesh/resolve_triangle_source_node.cc
HEADERS += ../dust3d/mesh/resolve_triangle_tangent.h
SOURCES += ../dust3d/mesh/resolve_triangle_tangent.cc
HEADERS += ../dust3d/mesh/smooth_normal.h
SOURCES += ../dust3d/mesh/smooth_normal.cc
HEADERS += ../dust3d/mesh/stroke_mesh_builder.h
SOURCES += ../dust3d/mesh/stroke_mesh_builder.cc
HEADERS += ../dust3d/mesh/stroke_modifier.h
SOURCES += ../dust3d/mesh/stroke_modifier.cc
HEADERS += ../dust3d/mesh/triangulate.h
SOURCES += ../dust3d/mesh/triangulate.cc
HEADERS += ../dust3d/mesh/trim_vertices.h
SOURCES += ../dust3d/mesh/trim_vertices.cc
HEADERS += ../dust3d/mesh/weld_vertices.h
SOURCES += ../dust3d/mesh/weld_vertices.cc
HEADERS += ../dust3d/util/obj.h
SOURCES += ../dust3d/util/obj.cc
HEADERS += ../dust3d/uv/chart_packer.h
SOURCES += ../dust3d/uv/chart_packer.cc
HEADERS += ../dust3d/uv/max_rectangles.h
SOURCES += ../dust3d/uv/max_rectangles.cc
HEADERS += ../dust3d/uv/parametrize.h
SOURCES += ../dust3d/uv/parametrize.cc
HEADERS += ../dust3d/uv/triangulate.h
SOURCES += ../dust3d/uv/triangulate.cc
HEADERS += ../dust3d/uv/unwrap_uv.h
SOURCES += ../dust3d/uv/unwrap_uv.cc
HEADERS += ../dust3d/uv/uv_mesh_data_type.h
SOURCES += ../dust3d/uv/uv_mesh_data_type.cc
HEADERS += ../dust3d/uv/uv_unwrapper.h
SOURCES += ../dust3d/uv/uv_unwrapper.cc
HEADERS += ../third_party/GuigueDevillers03/tri_tri_intersect.h
SOURCES += ../third_party/GuigueDevillers03/tri_tri_intersect.c
HEADERS += ../third_party/lodepng/lodepng.h
SOURCES += ../third_party/lodepng/lodepng.cpp
win32 {
LIBS += -luser32
LIBS += -lopengl32
}

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

40
application/resources.qrc Normal file
View File

@ -0,0 +1,40 @@
<RCC>
<qresource prefix="/">
<file alias="ACKNOWLEDGEMENTS.html">../ACKNOWLEDGEMENTS.html</file>
<file alias="AUTHORS">../AUTHORS</file>
<file alias="CONTRIBUTORS">../CONTRIBUTORS</file>
<file alias="SUPPORTERS">../SUPPORTERS</file>
<file>shaders/model.vert</file>
<file>shaders/model.frag</file>
<file>shaders/model_core.vert</file>
<file>shaders/model_core.frag</file>
<file>resources/cedar_bridge_irradiance.dds</file>
<file>resources/cedar_bridge_specular.dds</file>
<file>resources/dust3d-vertical.png</file>
<file>resources/toolbar_add.svg</file>
<file>resources/toolbar_pointer.svg</file>
<file>resources/toolbar_x.svg</file>
<file>resources/toolbar_x_disabled.svg</file>
<file>resources/toolbar_y.svg</file>
<file>resources/toolbar_y_disabled.svg</file>
<file>resources/toolbar_z.svg</file>
<file>resources/toolbar_z_disabled.svg</file>
<file>resources/toolbar_radius.svg</file>
<file>resources/toolbar_radius_disabled.svg</file>
<file>resources/material-demo-model.ds3</file>
<file>resources/model-addax.ds3</file>
<file>resources/model-bicycle.ds3</file>
<file>resources/model-dog.ds3</file>
<file>resources/model-cat.ds3</file>
<file>resources/model-giraffe.ds3</file>
<file>resources/model-meerkat.ds3</file>
<file>resources/model-mosquito.ds3</file>
<file>resources/model-screwdriver.ds3</file>
<file>resources/model-seagull.ds3</file>
<file>resources/tree-branch-closed.png</file>
<file>resources/tree-branch-end.png</file>
<file>resources/tree-branch-more.png</file>
<file>resources/tree-branch-open.png</file>
<file>resources/tree-vline.png</file>
</qresource>
</RCC>

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

File diff suppressed because it is too large Load Diff

View File

@ -1,124 +1,129 @@
DUST3D 1.0 xml 0000000193
<?xml version="1.0" encoding="UTF-8"?>
<ds3>
<model name="model.xml" offset="0" size="19140"/>
<asset name="canvas.png" offset="19140" size="163519"/>
<model name="model.xml" offset="0" size="18158"/>
<asset name="canvas.png" offset="18158" size="163519"/>
</ds3>
<?xml version="1.0" encoding="UTF-8"?>
<canvas originX="0.832218" originY="0.430706" originZ="2.51087" rigType="Animal">
<canvas originX="0.832218" originY="0.430706" originZ="2.510870">
<nodes>
<node id="{00fde052-9d4e-448e-9682-f5ed93434e0c}" partId="{52c57fba-89d2-4bb0-a9e8-17d96dda6f04}" radius="0.0182927" x="0.872962" y="0.190653" z="2.37365"/>
<node boneMark="Joint" id="{091f00c6-a346-44ce-b2f0-905256644b35}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" radius="0.0108696" x="1.00543" y="0.412463" z="2.1875"/>
<node id="{1021605a-1c1a-4266-83bb-761abfcaebd4}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" radius="0.020763" x="0.856744" y="0.230353" z="2.29388"/>
<node boneMark="Joint" id="{18e00014-6fd3-4f46-b474-25a98ad0a5a5}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.0271739" x="0.831522" y="0.524457" z="2.98098"/>
<node boneMark="Joint" id="{1ef138ab-f1c0-416c-af05-b988dc62c9ec}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.0597826" x="0.831522" y="0.475543" z="2.91848"/>
<node id="{3ccfd176-17d3-4e5e-9a66-7973b67a9b7d}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.076087" x="0.831522" y="0.290761" z="2.4375"/>
<node id="{45fa4407-c043-4aba-907d-4c84d16ba5e5}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" radius="0.0108696" x="1.00543" y="0.670615" z="2.13587"/>
<node id="{4fc24460-bb11-492b-95d5-3df726947c9a}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.0466936" x="0.831522" y="0.228261" z="2.2962"/>
<node id="{551efaf5-ae0d-4700-9e9f-acae50c9ba96}" partId="{4997addf-2435-4f34-9df4-ee1c7d24a5f6}" radius="0.0308874" x="0.831522" y="0.273312" z="2.18007"/>
<node boneMark="Joint" id="{59f24f88-0441-418f-8d8d-4d30d4b5015b}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" radius="0.0108696" x="1.28533" y="0.741848" z="2.86141"/>
<node id="{5c63c4df-8f54-4fef-933a-f975973d0e0e}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" radius="0.0127174" x="1.07609" y="0.75" z="2.66033"/>
<node id="{60de62dd-338e-425a-9b83-ed0776bb380a}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.0163044" x="0.831522" y="0.274457" z="2.11617"/>
<node id="{67ed5a94-e749-46d1-8ccf-2b33a3e878d6}" partId="{4997addf-2435-4f34-9df4-ee1c7d24a5f6}" radius="0.0180256" x="0.831522" y="0.345109" z="2.18328"/>
<node boneMark="Tail" id="{6a47f6ac-e4a8-4e5d-9000-b4c0dfb999a3}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.0625" x="0.831522" y="0.315217" z="2.50815"/>
<node id="{71b0f00a-6909-4121-bf1d-83b0a64eab41}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" radius="0.0127174" x="1.21196" y="0.866848" z="2.78261"/>
<node boneMark="Neck" id="{71ff2d8c-862c-4b06-aa8e-6d89afc335fd}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.0244565" x="0.831522" y="0.277174" z="2.2337"/>
<node id="{83aaf66e-e525-42d1-b8fe-3f1772fe57ef}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" radius="0.0190217" x="0.869565" y="0.269206" z="2.45295"/>
<node boneMark="Limb" id="{8aaa9417-0abe-4616-9ef3-01de9803cfe2}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" radius="0.0190217" x="1.13859" y="0.38587" z="2.46624"/>
<node id="{8e680f16-9603-40de-9a5e-90a849ff05f6}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" radius="0.0247478" x="0.852865" y="0.21718" z="2.37005"/>
<node id="{95b3fc4e-9bab-4b12-80c0-a875649ca4aa}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" radius="0.0108696" x="1.16033" y="0.847245" z="2.01087"/>
<node id="{96f55ae2-c07f-4637-b8b6-4b7d4c2b209a}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.0438766" x="0.831522" y="0.271739" z="2.17935"/>
<node boneMark="Joint" id="{98a8ed94-50ed-43d3-85cf-7968f5e260da}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" radius="0.0108696" x="0.980978" y="0.453804" z="2.78533"/>
<node boneMark="Limb" id="{9b835bb3-040c-4f5f-9993-4240128e0297}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" radius="0.0222283" x="0.948369" y="0.349185" z="2.39368"/>
<node id="{a0e15099-f840-47fe-b7cc-76e2821f82c8}" partId="{52c57fba-89d2-4bb0-a9e8-17d96dda6f04}" radius="0.0689289" x="0.916609" y="0.226513" z="2.64565"/>
<node id="{a64dcc04-41eb-4d71-b95a-9fb7dacc3350}" partId="{52c57fba-89d2-4bb0-a9e8-17d96dda6f04}" radius="0.0271739" x="0.870884" y="0.191146" z="2.41539"/>
<node id="{abfebd7d-3a35-41c8-adee-06aced895298}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" radius="0.0108696" x="1.1087" y="0.779311" z="2.06793"/>
<node id="{ac99b0c2-942c-446e-a0bf-7210382e66a5}" partId="{4997addf-2435-4f34-9df4-ee1c7d24a5f6}" radius="0.005" x="0.831522" y="0.559285" z="2.20502"/>
<node boneMark="Joint" id="{b0c0ad56-ba00-4999-8adb-466c6d7185ba}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.0597826" x="0.831522" y="0.32337" z="2.61141"/>
<node boneMark="Joint" id="{bfb2b58d-773e-4636-a95f-f036139f6d9b}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.0108696" x="0.831522" y="0.244565" z="2.04348"/>
<node boneMark="Joint" id="{cc6c7d03-156f-455f-8456-0b6438e1f6ef}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" radius="0.0108696" x="1.1875" y="0.874419" z="1.94293"/>
<node id="{d45a860c-f9ec-41bb-868e-3bdc3cf04e8d}" partId="{4997addf-2435-4f34-9df4-ee1c7d24a5f6}" radius="0.0125908" x="0.831522" y="0.448867" z="2.19144"/>
<node id="{d6d1a24b-f3b8-478d-9989-feda57a2ee32}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.0108696" x="0.831522" y="0.263587" z="2.0788"/>
<node boneMark="Joint" id="{dacc2607-14f6-4c36-a20a-31d5b57d1488}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.0597826" x="0.831522" y="0.350543" z="2.73098"/>
<node boneMark="Joint" id="{deb5ae03-03f6-4e0c-a275-fa681b60b379}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" radius="0.0127174" x="1.23098" y="0.899456" z="2.85055"/>
<node boneMark="Joint" id="{df279fce-55a5-4c68-bb96-feefc9a068c8}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" radius="0.0127174" x="0.972826" y="0.538044" z="2.55163"/>
<node id="{e1fa1f4c-8426-4dc1-afc1-3f8dee8f1641}" partId="{52c57fba-89d2-4bb0-a9e8-17d96dda6f04}" radius="0.107635" x="0.940221" y="0.294171" z="2.87398"/>
<node id="{e9410d86-9d17-41a5-9b55-8587d1e93ea3}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" radius="0.0108696" x="1.45652" y="0.913043" z="3.05163"/>
<node boneMark="Joint" id="{e9d3ac47-6d17-4439-8176-9c51498f8cf0}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" radius="0.0108696" x="1.01359" y="0.470109" z="2.50428"/>
<node boneMark="Joint" id="{f1a99c28-4dd0-45f5-9dc4-769ff13d2fda}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" radius="0.0190217" x="1.01359" y="0.417897" z="2.35598"/>
<node boneMark="Joint" id="{f2677136-fe7c-4157-bf6e-01f0f51ef4ff}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.0597826" x="0.831522" y="0.407609" z="2.84239"/>
<node boneMark="Joint" id="{f5447f26-5f45-4192-97a8-0d6cc635a19b}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" radius="0.0108696" x="1.5" y="0.9375" z="3.11685"/>
<node id="{f6045c8a-b651-425b-86d6-4656ed9d9081}" partId="{52c57fba-89d2-4bb0-a9e8-17d96dda6f04}" radius="0.0597826" x="1.01505" y="0.360815" z="3.07335"/>
<node id="{f845abe2-f311-47be-8c61-8b0fa1fa98d2}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" radius="0.0108696" x="1.40761" y="0.858696" z="2.96467"/>
<node id="{f9dad8ee-47b7-4fb4-aa7a-846995320792}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" radius="0.0682336" x="0.831522" y="0.214674" z="2.37228"/>
<node boneMark="Limb" id="{fa1a535e-4d99-42a8-930c-2143b1d124eb}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" radius="0.0217391" x="1.02717" y="0.347245" z="2.32065"/>
<node id="{fb6417cf-c962-41fd-ac81-20e8b427ab2e}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" radius="0.01" x="1.17391" y="0.826087" z="2.72283"/>
<node boneMark="Joint" id="{fd9f1818-8101-4850-a420-55f72567c639}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" radius="0.0127174" x="1.02174" y="0.470109" z="2.44022"/>
<node id="{fdfccd5b-e3a1-4ed3-8e26-2db335c6b683}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" radius="0.0188359" x="1.1087" y="0.380435" z="2.40761"/>
<node id="{00fde052-9d4e-448e-9682-f5ed93434e0c}" partId="{bdfe4a54-d819-47dd-ab78-bc8f7262bc01}" radius="0.018293" x="0.872962" y="0.190653" z="2.373650"/>
<node id="{091f00c6-a346-44ce-b2f0-905256644b35}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" radius="0.010870" x="1.005430" y="0.412463" z="2.187500"/>
<node id="{1021605a-1c1a-4266-83bb-761abfcaebd4}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" radius="0.020763" x="0.856744" y="0.230353" z="2.293880"/>
<node id="{18e00014-6fd3-4f46-b474-25a98ad0a5a5}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.027174" x="0.831522" y="0.524457" z="2.980980"/>
<node id="{1ef138ab-f1c0-416c-af05-b988dc62c9ec}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.059783" x="0.831522" y="0.475543" z="2.918480"/>
<node id="{3ccfd176-17d3-4e5e-9a66-7973b67a9b7d}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.076087" x="0.831522" y="0.290761" z="2.437500"/>
<node id="{45fa4407-c043-4aba-907d-4c84d16ba5e5}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" radius="0.010870" x="1.005430" y="0.670615" z="2.135870"/>
<node id="{4fc24460-bb11-492b-95d5-3df726947c9a}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.046694" x="0.831522" y="0.228261" z="2.296200"/>
<node id="{551efaf5-ae0d-4700-9e9f-acae50c9ba96}" partId="{016ff2cf-5436-4878-ac3d-c3e068b09a35}" radius="0.030887" x="0.831522" y="0.273312" z="2.180070"/>
<node id="{59f24f88-0441-418f-8d8d-4d30d4b5015b}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" radius="0.010870" x="1.285330" y="0.741848" z="2.861410"/>
<node id="{5c63c4df-8f54-4fef-933a-f975973d0e0e}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" radius="0.012717" x="1.076090" y="0.750000" z="2.660330"/>
<node id="{60de62dd-338e-425a-9b83-ed0776bb380a}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.016304" x="0.831522" y="0.274457" z="2.116170"/>
<node id="{67ed5a94-e749-46d1-8ccf-2b33a3e878d6}" partId="{016ff2cf-5436-4878-ac3d-c3e068b09a35}" radius="0.018026" x="0.831522" y="0.345109" z="2.183280"/>
<node id="{6a47f6ac-e4a8-4e5d-9000-b4c0dfb999a3}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.062500" x="0.831522" y="0.315217" z="2.508150"/>
<node id="{71b0f00a-6909-4121-bf1d-83b0a64eab41}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" radius="0.012717" x="1.211960" y="0.866848" z="2.782610"/>
<node id="{71ff2d8c-862c-4b06-aa8e-6d89afc335fd}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.024456" x="0.831522" y="0.277174" z="2.233700"/>
<node id="{83aaf66e-e525-42d1-b8fe-3f1772fe57ef}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" radius="0.019022" x="0.869565" y="0.269206" z="2.452950"/>
<node id="{8aaa9417-0abe-4616-9ef3-01de9803cfe2}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" radius="0.019022" x="1.138590" y="0.385870" z="2.466240"/>
<node id="{8e680f16-9603-40de-9a5e-90a849ff05f6}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" radius="0.024748" x="0.852865" y="0.217180" z="2.370050"/>
<node id="{95b3fc4e-9bab-4b12-80c0-a875649ca4aa}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" radius="0.010870" x="1.160330" y="0.847245" z="2.010870"/>
<node id="{96f55ae2-c07f-4637-b8b6-4b7d4c2b209a}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.043877" x="0.831522" y="0.271739" z="2.179350"/>
<node id="{98a8ed94-50ed-43d3-85cf-7968f5e260da}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" radius="0.010870" x="0.980978" y="0.453804" z="2.785330"/>
<node id="{9b835bb3-040c-4f5f-9993-4240128e0297}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" radius="0.022228" x="0.948369" y="0.349185" z="2.393680"/>
<node id="{a0e15099-f840-47fe-b7cc-76e2821f82c8}" partId="{bdfe4a54-d819-47dd-ab78-bc8f7262bc01}" radius="0.068929" x="0.916609" y="0.226513" z="2.645650"/>
<node id="{a64dcc04-41eb-4d71-b95a-9fb7dacc3350}" partId="{bdfe4a54-d819-47dd-ab78-bc8f7262bc01}" radius="0.027174" x="0.870884" y="0.191146" z="2.415390"/>
<node id="{abfebd7d-3a35-41c8-adee-06aced895298}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" radius="0.010870" x="1.108700" y="0.779311" z="2.067930"/>
<node id="{ac99b0c2-942c-446e-a0bf-7210382e66a5}" partId="{016ff2cf-5436-4878-ac3d-c3e068b09a35}" radius="0.005000" x="0.831522" y="0.559285" z="2.205020"/>
<node id="{b0c0ad56-ba00-4999-8adb-466c6d7185ba}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.059783" x="0.831522" y="0.323370" z="2.611410"/>
<node id="{bfb2b58d-773e-4636-a95f-f036139f6d9b}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.010870" x="0.831522" y="0.244565" z="2.043480"/>
<node id="{cc6c7d03-156f-455f-8456-0b6438e1f6ef}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" radius="0.010870" x="1.187500" y="0.874419" z="1.942930"/>
<node id="{d45a860c-f9ec-41bb-868e-3bdc3cf04e8d}" partId="{016ff2cf-5436-4878-ac3d-c3e068b09a35}" radius="0.012591" x="0.831522" y="0.448867" z="2.191440"/>
<node id="{d6d1a24b-f3b8-478d-9989-feda57a2ee32}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.010870" x="0.831522" y="0.263587" z="2.078800"/>
<node id="{dacc2607-14f6-4c36-a20a-31d5b57d1488}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.059783" x="0.831522" y="0.350543" z="2.730980"/>
<node id="{deb5ae03-03f6-4e0c-a275-fa681b60b379}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" radius="0.012717" x="1.230980" y="0.899456" z="2.850550"/>
<node id="{df279fce-55a5-4c68-bb96-feefc9a068c8}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" radius="0.012717" x="0.972826" y="0.538044" z="2.551630"/>
<node id="{e1fa1f4c-8426-4dc1-afc1-3f8dee8f1641}" partId="{bdfe4a54-d819-47dd-ab78-bc8f7262bc01}" radius="0.107635" x="0.940221" y="0.294171" z="2.873980"/>
<node id="{e9410d86-9d17-41a5-9b55-8587d1e93ea3}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" radius="0.010870" x="1.456520" y="0.913043" z="3.051630"/>
<node id="{e9d3ac47-6d17-4439-8176-9c51498f8cf0}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" radius="0.010870" x="1.013590" y="0.470109" z="2.504280"/>
<node id="{f1a99c28-4dd0-45f5-9dc4-769ff13d2fda}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" radius="0.019022" x="1.013590" y="0.417897" z="2.355980"/>
<node id="{f2677136-fe7c-4157-bf6e-01f0f51ef4ff}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.059783" x="0.831522" y="0.407609" z="2.842390"/>
<node id="{f5447f26-5f45-4192-97a8-0d6cc635a19b}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" radius="0.010870" x="1.500000" y="0.937500" z="3.116850"/>
<node id="{f6045c8a-b651-425b-86d6-4656ed9d9081}" partId="{bdfe4a54-d819-47dd-ab78-bc8f7262bc01}" radius="0.059783" x="1.015050" y="0.360815" z="3.073350"/>
<node id="{f845abe2-f311-47be-8c61-8b0fa1fa98d2}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" radius="0.010870" x="1.407610" y="0.858696" z="2.964670"/>
<node id="{f9dad8ee-47b7-4fb4-aa7a-846995320792}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" radius="0.068234" x="0.831522" y="0.214674" z="2.372280"/>
<node id="{fa1a535e-4d99-42a8-930c-2143b1d124eb}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" radius="0.021739" x="1.027170" y="0.347245" z="2.320650"/>
<node id="{fb6417cf-c962-41fd-ac81-20e8b427ab2e}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" radius="0.010000" x="1.173910" y="0.826087" z="2.722830"/>
<node id="{fd9f1818-8101-4850-a420-55f72567c639}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" radius="0.012717" x="1.021740" y="0.470109" z="2.440220"/>
<node id="{fdfccd5b-e3a1-4ed3-8e26-2db335c6b683}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" radius="0.018836" x="1.108700" y="0.380435" z="2.407610"/>
</nodes>
<edges>
<edge from="{60de62dd-338e-425a-9b83-ed0776bb380a}" id="{004e3284-50b1-4c43-ae03-351057f72d34}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" to="{d6d1a24b-f3b8-478d-9989-feda57a2ee32}"/>
<edge from="{1021605a-1c1a-4266-83bb-761abfcaebd4}" id="{0569f362-f47c-485c-a6a9-6e3481b21a90}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" to="{fa1a535e-4d99-42a8-930c-2143b1d124eb}"/>
<edge from="{f1a99c28-4dd0-45f5-9dc4-769ff13d2fda}" id="{0a8be92c-5977-4471-b2d3-5009eda7df2e}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" to="{091f00c6-a346-44ce-b2f0-905256644b35}"/>
<edge from="{5c63c4df-8f54-4fef-933a-f975973d0e0e}" id="{0b30676d-4c10-4c4b-aa73-04a7a42a1b7f}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" to="{fb6417cf-c962-41fd-ac81-20e8b427ab2e}"/>
<edge from="{df279fce-55a5-4c68-bb96-feefc9a068c8}" id="{0b6366a7-a16e-4f6f-a0f7-13d1dfa5f591}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" to="{5c63c4df-8f54-4fef-933a-f975973d0e0e}"/>
<edge from="{b0c0ad56-ba00-4999-8adb-466c6d7185ba}" id="{0d2b5542-fbb8-4aa9-a0cb-c2517dcf1aa9}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" to="{dacc2607-14f6-4c36-a20a-31d5b57d1488}"/>
<edge from="{96f55ae2-c07f-4637-b8b6-4b7d4c2b209a}" id="{0e321006-a9ad-4bd1-9429-80e9b4781c3e}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" to="{71ff2d8c-862c-4b06-aa8e-6d89afc335fd}"/>
<edge from="{67ed5a94-e749-46d1-8ccf-2b33a3e878d6}" id="{10582139-843f-4591-bc63-1e9ae19c6d42}" partId="{4997addf-2435-4f34-9df4-ee1c7d24a5f6}" to="{d45a860c-f9ec-41bb-868e-3bdc3cf04e8d}"/>
<edge from="{45fa4407-c043-4aba-907d-4c84d16ba5e5}" id="{22253314-b363-4698-a072-c0a5ba0ac000}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" to="{abfebd7d-3a35-41c8-adee-06aced895298}"/>
<edge from="{f9dad8ee-47b7-4fb4-aa7a-846995320792}" id="{23fcdae1-af2b-4420-a761-63f3d0d203b4}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" to="{3ccfd176-17d3-4e5e-9a66-7973b67a9b7d}"/>
<edge from="{8aaa9417-0abe-4616-9ef3-01de9803cfe2}" id="{35fca7ae-1411-4125-a29d-c977e60c2026}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" to="{e9d3ac47-6d17-4439-8176-9c51498f8cf0}"/>
<edge from="{fdfccd5b-e3a1-4ed3-8e26-2db335c6b683}" id="{3a69636f-46a5-4363-88a3-afa75c303fb7}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" to="{fd9f1818-8101-4850-a420-55f72567c639}"/>
<edge from="{f2677136-fe7c-4157-bf6e-01f0f51ef4ff}" id="{3af2982e-d86f-492c-b9e0-ef4f5c0af53d}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" to="{1ef138ab-f1c0-416c-af05-b988dc62c9ec}"/>
<edge from="{d45a860c-f9ec-41bb-868e-3bdc3cf04e8d}" id="{3d874434-2913-4166-8e6e-712a47e44db0}" partId="{4997addf-2435-4f34-9df4-ee1c7d24a5f6}" to="{ac99b0c2-942c-446e-a0bf-7210382e66a5}"/>
<edge from="{f845abe2-f311-47be-8c61-8b0fa1fa98d2}" id="{4dfeb7b4-4426-418f-b85f-c14da4d296f2}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" to="{e9410d86-9d17-41a5-9b55-8587d1e93ea3}"/>
<edge from="{6a47f6ac-e4a8-4e5d-9000-b4c0dfb999a3}" id="{566cd759-190b-4374-b57d-1ef8ed54cb45}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" to="{b0c0ad56-ba00-4999-8adb-466c6d7185ba}"/>
<edge from="{dacc2607-14f6-4c36-a20a-31d5b57d1488}" id="{5b0805fc-6b71-4a8f-9318-4dd3df63f718}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" to="{f2677136-fe7c-4157-bf6e-01f0f51ef4ff}"/>
<edge from="{a64dcc04-41eb-4d71-b95a-9fb7dacc3350}" id="{63dac02d-b2f8-4ebc-98c4-54fcea0d9798}" partId="{52c57fba-89d2-4bb0-a9e8-17d96dda6f04}" to="{00fde052-9d4e-448e-9682-f5ed93434e0c}"/>
<edge from="{60de62dd-338e-425a-9b83-ed0776bb380a}" id="{67bd7a5e-4002-418c-ad41-f8827056d936}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" to="{96f55ae2-c07f-4637-b8b6-4b7d4c2b209a}"/>
<edge from="{95b3fc4e-9bab-4b12-80c0-a875649ca4aa}" id="{67d3a132-f6f4-4c39-93fd-53d66a5df4ab}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" to="{cc6c7d03-156f-455f-8456-0b6438e1f6ef}"/>
<edge from="{a0e15099-f840-47fe-b7cc-76e2821f82c8}" id="{6cc8a10c-58e8-4833-98f3-d1bba4461f34}" partId="{52c57fba-89d2-4bb0-a9e8-17d96dda6f04}" to="{e1fa1f4c-8426-4dc1-afc1-3f8dee8f1641}"/>
<edge from="{a64dcc04-41eb-4d71-b95a-9fb7dacc3350}" id="{720d02e7-45a3-4659-a779-2b775f58d61f}" partId="{52c57fba-89d2-4bb0-a9e8-17d96dda6f04}" to="{a0e15099-f840-47fe-b7cc-76e2821f82c8}"/>
<edge from="{e9410d86-9d17-41a5-9b55-8587d1e93ea3}" id="{748ecd4b-ecaa-4707-9d1b-eba56429b77a}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" to="{f5447f26-5f45-4192-97a8-0d6cc635a19b}"/>
<edge from="{e1fa1f4c-8426-4dc1-afc1-3f8dee8f1641}" id="{76dd8ca8-896a-4899-acff-c60f42725d45}" partId="{52c57fba-89d2-4bb0-a9e8-17d96dda6f04}" to="{f6045c8a-b651-425b-86d6-4656ed9d9081}"/>
<edge from="{091f00c6-a346-44ce-b2f0-905256644b35}" id="{7cd9de86-8db5-4672-9d73-e813f5cad9a9}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" to="{45fa4407-c043-4aba-907d-4c84d16ba5e5}"/>
<edge from="{abfebd7d-3a35-41c8-adee-06aced895298}" id="{7de5e8e0-24ff-4b64-9047-4bd8f4855506}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" to="{95b3fc4e-9bab-4b12-80c0-a875649ca4aa}"/>
<edge from="{8e680f16-9603-40de-9a5e-90a849ff05f6}" id="{8a744155-4a9f-446d-a39e-713fdd134426}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" to="{9b835bb3-040c-4f5f-9993-4240128e0297}"/>
<edge from="{fa1a535e-4d99-42a8-930c-2143b1d124eb}" id="{a439f439-4dba-488b-b4ee-d38b19fc4fcf}" partId="{d04ab937-945f-4b67-9667-a144a29ae0e9}" to="{f1a99c28-4dd0-45f5-9dc4-769ff13d2fda}"/>
<edge from="{fd9f1818-8101-4850-a420-55f72567c639}" id="{a6357a12-14ba-4dc4-846b-4be892746e6a}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" to="{df279fce-55a5-4c68-bb96-feefc9a068c8}"/>
<edge from="{71ff2d8c-862c-4b06-aa8e-6d89afc335fd}" id="{ab708822-ad92-4977-b209-b1103a334e82}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" to="{4fc24460-bb11-492b-95d5-3df726947c9a}"/>
<edge from="{1ef138ab-f1c0-416c-af05-b988dc62c9ec}" id="{b17d6b41-898c-46db-8d88-1117bc53c627}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" to="{18e00014-6fd3-4f46-b474-25a98ad0a5a5}"/>
<edge from="{71b0f00a-6909-4121-bf1d-83b0a64eab41}" id="{c232a9eb-fda5-4938-82da-c807c021b102}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" to="{deb5ae03-03f6-4e0c-a275-fa681b60b379}"/>
<edge from="{9b835bb3-040c-4f5f-9993-4240128e0297}" id="{caaaf017-8034-4deb-ac06-b5052603bd6e}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" to="{fdfccd5b-e3a1-4ed3-8e26-2db335c6b683}"/>
<edge from="{d6d1a24b-f3b8-478d-9989-feda57a2ee32}" id="{cb1c1ed1-eb5b-4622-b491-2b454836600b}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" to="{bfb2b58d-773e-4636-a95f-f036139f6d9b}"/>
<edge from="{83aaf66e-e525-42d1-b8fe-3f1772fe57ef}" id="{cb880891-b7e8-4592-ab80-fd165c70eccb}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" to="{8aaa9417-0abe-4616-9ef3-01de9803cfe2}"/>
<edge from="{98a8ed94-50ed-43d3-85cf-7968f5e260da}" id="{d102fa2e-afb6-4f0c-910a-2952dea4781c}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" to="{59f24f88-0441-418f-8d8d-4d30d4b5015b}"/>
<edge from="{e9d3ac47-6d17-4439-8176-9c51498f8cf0}" id="{d55b2dbc-4c3a-4c52-9c2c-16127e00a889}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" to="{98a8ed94-50ed-43d3-85cf-7968f5e260da}"/>
<edge from="{3ccfd176-17d3-4e5e-9a66-7973b67a9b7d}" id="{d89420d6-ffca-4dd4-a5b5-2ff9b8618b01}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" to="{6a47f6ac-e4a8-4e5d-9000-b4c0dfb999a3}"/>
<edge from="{67ed5a94-e749-46d1-8ccf-2b33a3e878d6}" id="{e99f5404-7dce-4770-aac9-22ad610b4420}" partId="{4997addf-2435-4f34-9df4-ee1c7d24a5f6}" to="{551efaf5-ae0d-4700-9e9f-acae50c9ba96}"/>
<edge from="{59f24f88-0441-418f-8d8d-4d30d4b5015b}" id="{ee50292f-d21a-4ba6-8e31-d2f9fb577398}" partId="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" to="{f845abe2-f311-47be-8c61-8b0fa1fa98d2}"/>
<edge from="{fb6417cf-c962-41fd-ac81-20e8b427ab2e}" id="{f1d56833-ff9a-44d7-a337-76eb68549678}" partId="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" to="{71b0f00a-6909-4121-bf1d-83b0a64eab41}"/>
<edge from="{4fc24460-bb11-492b-95d5-3df726947c9a}" id="{fc919b1d-e12b-42d0-a3af-fc36c8c78ef4}" partId="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" to="{f9dad8ee-47b7-4fb4-aa7a-846995320792}"/>
<edge from="{60de62dd-338e-425a-9b83-ed0776bb380a}" id="{004e3284-50b1-4c43-ae03-351057f72d34}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" to="{d6d1a24b-f3b8-478d-9989-feda57a2ee32}"/>
<edge from="{1021605a-1c1a-4266-83bb-761abfcaebd4}" id="{0569f362-f47c-485c-a6a9-6e3481b21a90}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" to="{fa1a535e-4d99-42a8-930c-2143b1d124eb}"/>
<edge from="{f1a99c28-4dd0-45f5-9dc4-769ff13d2fda}" id="{0a8be92c-5977-4471-b2d3-5009eda7df2e}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" to="{091f00c6-a346-44ce-b2f0-905256644b35}"/>
<edge from="{5c63c4df-8f54-4fef-933a-f975973d0e0e}" id="{0b30676d-4c10-4c4b-aa73-04a7a42a1b7f}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" to="{fb6417cf-c962-41fd-ac81-20e8b427ab2e}"/>
<edge from="{df279fce-55a5-4c68-bb96-feefc9a068c8}" id="{0b6366a7-a16e-4f6f-a0f7-13d1dfa5f591}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" to="{5c63c4df-8f54-4fef-933a-f975973d0e0e}"/>
<edge from="{b0c0ad56-ba00-4999-8adb-466c6d7185ba}" id="{0d2b5542-fbb8-4aa9-a0cb-c2517dcf1aa9}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" to="{dacc2607-14f6-4c36-a20a-31d5b57d1488}"/>
<edge from="{96f55ae2-c07f-4637-b8b6-4b7d4c2b209a}" id="{0e321006-a9ad-4bd1-9429-80e9b4781c3e}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" to="{71ff2d8c-862c-4b06-aa8e-6d89afc335fd}"/>
<edge from="{67ed5a94-e749-46d1-8ccf-2b33a3e878d6}" id="{10582139-843f-4591-bc63-1e9ae19c6d42}" partId="{016ff2cf-5436-4878-ac3d-c3e068b09a35}" to="{d45a860c-f9ec-41bb-868e-3bdc3cf04e8d}"/>
<edge from="{45fa4407-c043-4aba-907d-4c84d16ba5e5}" id="{22253314-b363-4698-a072-c0a5ba0ac000}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" to="{abfebd7d-3a35-41c8-adee-06aced895298}"/>
<edge from="{f9dad8ee-47b7-4fb4-aa7a-846995320792}" id="{23fcdae1-af2b-4420-a761-63f3d0d203b4}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" to="{3ccfd176-17d3-4e5e-9a66-7973b67a9b7d}"/>
<edge from="{8aaa9417-0abe-4616-9ef3-01de9803cfe2}" id="{35fca7ae-1411-4125-a29d-c977e60c2026}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" to="{e9d3ac47-6d17-4439-8176-9c51498f8cf0}"/>
<edge from="{fdfccd5b-e3a1-4ed3-8e26-2db335c6b683}" id="{3a69636f-46a5-4363-88a3-afa75c303fb7}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" to="{fd9f1818-8101-4850-a420-55f72567c639}"/>
<edge from="{f2677136-fe7c-4157-bf6e-01f0f51ef4ff}" id="{3af2982e-d86f-492c-b9e0-ef4f5c0af53d}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" to="{1ef138ab-f1c0-416c-af05-b988dc62c9ec}"/>
<edge from="{d45a860c-f9ec-41bb-868e-3bdc3cf04e8d}" id="{3d874434-2913-4166-8e6e-712a47e44db0}" partId="{016ff2cf-5436-4878-ac3d-c3e068b09a35}" to="{ac99b0c2-942c-446e-a0bf-7210382e66a5}"/>
<edge from="{f845abe2-f311-47be-8c61-8b0fa1fa98d2}" id="{4dfeb7b4-4426-418f-b85f-c14da4d296f2}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" to="{e9410d86-9d17-41a5-9b55-8587d1e93ea3}"/>
<edge from="{6a47f6ac-e4a8-4e5d-9000-b4c0dfb999a3}" id="{566cd759-190b-4374-b57d-1ef8ed54cb45}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" to="{b0c0ad56-ba00-4999-8adb-466c6d7185ba}"/>
<edge from="{dacc2607-14f6-4c36-a20a-31d5b57d1488}" id="{5b0805fc-6b71-4a8f-9318-4dd3df63f718}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" to="{f2677136-fe7c-4157-bf6e-01f0f51ef4ff}"/>
<edge from="{a64dcc04-41eb-4d71-b95a-9fb7dacc3350}" id="{63dac02d-b2f8-4ebc-98c4-54fcea0d9798}" partId="{bdfe4a54-d819-47dd-ab78-bc8f7262bc01}" to="{00fde052-9d4e-448e-9682-f5ed93434e0c}"/>
<edge from="{60de62dd-338e-425a-9b83-ed0776bb380a}" id="{67bd7a5e-4002-418c-ad41-f8827056d936}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" to="{96f55ae2-c07f-4637-b8b6-4b7d4c2b209a}"/>
<edge from="{95b3fc4e-9bab-4b12-80c0-a875649ca4aa}" id="{67d3a132-f6f4-4c39-93fd-53d66a5df4ab}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" to="{cc6c7d03-156f-455f-8456-0b6438e1f6ef}"/>
<edge from="{a0e15099-f840-47fe-b7cc-76e2821f82c8}" id="{6cc8a10c-58e8-4833-98f3-d1bba4461f34}" partId="{bdfe4a54-d819-47dd-ab78-bc8f7262bc01}" to="{e1fa1f4c-8426-4dc1-afc1-3f8dee8f1641}"/>
<edge from="{a64dcc04-41eb-4d71-b95a-9fb7dacc3350}" id="{720d02e7-45a3-4659-a779-2b775f58d61f}" partId="{bdfe4a54-d819-47dd-ab78-bc8f7262bc01}" to="{a0e15099-f840-47fe-b7cc-76e2821f82c8}"/>
<edge from="{e9410d86-9d17-41a5-9b55-8587d1e93ea3}" id="{748ecd4b-ecaa-4707-9d1b-eba56429b77a}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" to="{f5447f26-5f45-4192-97a8-0d6cc635a19b}"/>
<edge from="{e1fa1f4c-8426-4dc1-afc1-3f8dee8f1641}" id="{76dd8ca8-896a-4899-acff-c60f42725d45}" partId="{bdfe4a54-d819-47dd-ab78-bc8f7262bc01}" to="{f6045c8a-b651-425b-86d6-4656ed9d9081}"/>
<edge from="{091f00c6-a346-44ce-b2f0-905256644b35}" id="{7cd9de86-8db5-4672-9d73-e813f5cad9a9}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" to="{45fa4407-c043-4aba-907d-4c84d16ba5e5}"/>
<edge from="{abfebd7d-3a35-41c8-adee-06aced895298}" id="{7de5e8e0-24ff-4b64-9047-4bd8f4855506}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" to="{95b3fc4e-9bab-4b12-80c0-a875649ca4aa}"/>
<edge from="{8e680f16-9603-40de-9a5e-90a849ff05f6}" id="{8a744155-4a9f-446d-a39e-713fdd134426}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" to="{9b835bb3-040c-4f5f-9993-4240128e0297}"/>
<edge from="{fa1a535e-4d99-42a8-930c-2143b1d124eb}" id="{a439f439-4dba-488b-b4ee-d38b19fc4fcf}" partId="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" to="{f1a99c28-4dd0-45f5-9dc4-769ff13d2fda}"/>
<edge from="{fd9f1818-8101-4850-a420-55f72567c639}" id="{a6357a12-14ba-4dc4-846b-4be892746e6a}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" to="{df279fce-55a5-4c68-bb96-feefc9a068c8}"/>
<edge from="{71ff2d8c-862c-4b06-aa8e-6d89afc335fd}" id="{ab708822-ad92-4977-b209-b1103a334e82}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" to="{4fc24460-bb11-492b-95d5-3df726947c9a}"/>
<edge from="{1ef138ab-f1c0-416c-af05-b988dc62c9ec}" id="{b17d6b41-898c-46db-8d88-1117bc53c627}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" to="{18e00014-6fd3-4f46-b474-25a98ad0a5a5}"/>
<edge from="{71b0f00a-6909-4121-bf1d-83b0a64eab41}" id="{c232a9eb-fda5-4938-82da-c807c021b102}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" to="{deb5ae03-03f6-4e0c-a275-fa681b60b379}"/>
<edge from="{9b835bb3-040c-4f5f-9993-4240128e0297}" id="{caaaf017-8034-4deb-ac06-b5052603bd6e}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" to="{fdfccd5b-e3a1-4ed3-8e26-2db335c6b683}"/>
<edge from="{d6d1a24b-f3b8-478d-9989-feda57a2ee32}" id="{cb1c1ed1-eb5b-4622-b491-2b454836600b}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" to="{bfb2b58d-773e-4636-a95f-f036139f6d9b}"/>
<edge from="{83aaf66e-e525-42d1-b8fe-3f1772fe57ef}" id="{cb880891-b7e8-4592-ab80-fd165c70eccb}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" to="{8aaa9417-0abe-4616-9ef3-01de9803cfe2}"/>
<edge from="{98a8ed94-50ed-43d3-85cf-7968f5e260da}" id="{d102fa2e-afb6-4f0c-910a-2952dea4781c}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" to="{59f24f88-0441-418f-8d8d-4d30d4b5015b}"/>
<edge from="{e9d3ac47-6d17-4439-8176-9c51498f8cf0}" id="{d55b2dbc-4c3a-4c52-9c2c-16127e00a889}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" to="{98a8ed94-50ed-43d3-85cf-7968f5e260da}"/>
<edge from="{3ccfd176-17d3-4e5e-9a66-7973b67a9b7d}" id="{d89420d6-ffca-4dd4-a5b5-2ff9b8618b01}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" to="{6a47f6ac-e4a8-4e5d-9000-b4c0dfb999a3}"/>
<edge from="{67ed5a94-e749-46d1-8ccf-2b33a3e878d6}" id="{e99f5404-7dce-4770-aac9-22ad610b4420}" partId="{016ff2cf-5436-4878-ac3d-c3e068b09a35}" to="{551efaf5-ae0d-4700-9e9f-acae50c9ba96}"/>
<edge from="{59f24f88-0441-418f-8d8d-4d30d4b5015b}" id="{ee50292f-d21a-4ba6-8e31-d2f9fb577398}" partId="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" to="{f845abe2-f311-47be-8c61-8b0fa1fa98d2}"/>
<edge from="{fb6417cf-c962-41fd-ac81-20e8b427ab2e}" id="{f1d56833-ff9a-44d7-a337-76eb68549678}" partId="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" to="{71b0f00a-6909-4121-bf1d-83b0a64eab41}"/>
<edge from="{4fc24460-bb11-492b-95d5-3df726947c9a}" id="{fc919b1d-e12b-42d0-a3af-fc36c8c78ef4}" partId="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" to="{f9dad8ee-47b7-4fb4-aa7a-846995320792}"/>
</edges>
<parts>
<part chamfered="false" color="#ffaeb0b0" countershaded="true" disabled="false" id="{4997addf-2435-4f34-9df4-ee1c7d24a5f6}" locked="false" rounded="true" subdived="true" visible="true" xMirrored="false"/>
<part base="Average" chamfered="false" color="#c5aeb0b0" cutRotation="-0.44" deformUnified="true" deformWidth="0.11" disabled="false" id="{52c57fba-89d2-4bb0-a9e8-17d96dda6f04}" locked="false" rounded="true" subdived="false" visible="true" xMirrored="true"/>
<part chamfered="false" color="#ffaeb0b0" disabled="false" id="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" locked="false" rounded="false" subdived="false" visible="true" xMirrored="true"/>
<part chamfered="false" color="#ffaeb0b0" countershaded="true" disabled="false" id="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" locked="false" rounded="true" subdived="true" visible="true" xMirrored="false"/>
<part chamfered="false" color="#ffaeb0b0" disabled="false" id="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" locked="false" rounded="false" subdived="false" visible="true" xMirrored="true"/>
<part chamfered="false" color="#ffaeb0b0" disabled="false" id="{d04ab937-945f-4b67-9667-a144a29ae0e9}" locked="false" rounded="false" subdived="false" visible="true" xMirrored="true"/>
<part chamfered="false" countershaded="true" disabled="false" id="{016ff2cf-5436-4878-ac3d-c3e068b09a35}" locked="false" rounded="true" subdived="true" visible="true" xMirrored="false"/>
<part chamfered="false" disabled="false" id="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" locked="false" rounded="false" subdived="false" visible="true" xMirrored="true"/>
<part chamfered="false" countershaded="true" disabled="false" id="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" locked="false" rounded="true" subdived="true" visible="true" xMirrored="false"/>
<part base="Average" chamfered="false" cutRotation="-0.440000" deformUnified="true" deformWidth="0.110000" disabled="false" id="{bdfe4a54-d819-47dd-ab78-bc8f7262bc01}" locked="false" rounded="true" subdived="false" visible="true" xMirrored="true"/>
<part chamfered="false" disabled="false" id="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" locked="false" rounded="false" subdived="false" visible="true" xMirrored="true"/>
<part chamfered="false" disabled="false" id="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" locked="false" rounded="false" subdived="false" visible="true" xMirrored="true"/>
</parts>
<components>
<component combineMode="Normal" expanded="false" id="{940d25d1-1fb9-40a3-a203-d7fd764d400c}" linkData="{d04ab937-945f-4b67-9667-a144a29ae0e9}" linkDataType="partId"/>
<component combineMode="Normal" expanded="false" id="{41260d2b-c3e7-4156-9630-03595453f3f7}" linkData="{8545ec00-3fec-4bb5-aeb8-79850f846ef2}" linkDataType="partId"/>
<component combineMode="Normal" expanded="false" id="{339ac492-a58e-4ddb-b34d-c44adc9d68be}" linkData="{a85ee6f4-0813-4e23-8430-eeedb08f3b7d}" linkDataType="partId"/>
<component combineMode="Normal" expanded="false" id="{956d448e-721e-4a42-a687-4c85db687893}" linkData="{52c57fba-89d2-4bb0-a9e8-17d96dda6f04}" linkDataType="partId"/>
<component combineMode="Normal" expanded="false" id="{e0ec89c9-ca82-4c27-998b-013189600f37}" linkData="{8eb40b25-f5d1-42b6-9906-db2f81a37f4f}" linkDataType="partId"/>
<component combineMode="Normal" expanded="false" id="{3e48354e-984f-431c-be46-d77146ac3d43}" linkData="{4997addf-2435-4f34-9df4-ee1c7d24a5f6}" linkDataType="partId"/>
<component combineMode="Normal" expanded="false" id="{5db74b41-e89a-47d2-b17d-8a926ae35970}" linkData="{ff325d75-acd9-4cda-bdbf-69c571e70d24}" linkDataType="partId">
</component>
<component combineMode="Normal" expanded="false" id="{769c28e8-d55d-495c-845d-ab5cdf52edc3}" linkData="{97b2ce4d-c5fc-4db1-8ee3-a613aa43819c}" linkDataType="partId">
</component>
<component combineMode="Normal" expanded="false" id="{86d269ef-f665-456c-b76f-51b074894154}" linkData="{fd4558ba-6844-4bb3-a8b7-07a38aaa285c}" linkDataType="partId">
</component>
<component combineMode="Normal" expanded="false" id="{593b937a-0285-4585-bd04-70948acd85ff}" linkData="{bdfe4a54-d819-47dd-ab78-bc8f7262bc01}" linkDataType="partId">
</component>
<component combineMode="Normal" expanded="false" id="{d5294ea8-1bc3-401b-88de-91151acaf2a4}" linkData="{a00ba03f-2adb-4cfd-9530-497ff16b1d5c}" linkDataType="partId">
</component>
<component combineMode="Normal" expanded="false" id="{534bdb14-cb78-4a41-a6e2-680f0b4a76bf}" linkData="{016ff2cf-5436-4878-ac3d-c3e068b09a35}" linkDataType="partId">
</component>
</components>
<materials/>
<poses/>
<motions/>
<materials>
</materials>
</canvas>
‰PNG


View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64.0px"
height="64.0px"
viewBox="0 0 64.0 64.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="toolbar_add.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview14"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
inkscape:zoom="2.8578563"
inkscape:cx="41.464646"
inkscape:cy="7.873034"
inkscape:window-width="1920"
inkscape:window-height="991"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid20" />
</sodipodi:namedview>
<defs
id="defs9" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:#f7d9c8;fill-rule:evenodd"
id="rect69"
width="15"
height="55"
x="25"
y="5" />
<rect
style="fill:#f7d9c8;fill-rule:evenodd"
id="rect71"
width="55"
height="15"
x="5"
y="25" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64.0px"
height="64.0px"
viewBox="0 0 64.0 64.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="toolbar_pointer.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview14"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
inkscape:zoom="2.8578563"
inkscape:cx="41.464646"
inkscape:cy="7.6980778"
inkscape:window-width="1482"
inkscape:window-height="1020"
inkscape:window-x="866"
inkscape:window-y="6"
inkscape:window-maximized="0"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid20" />
</sodipodi:namedview>
<defs
id="defs9" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:#f7d9c8;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 15,5 V 55 L 25,35 40,60 50,55 35,30 h 20 z"
id="path978"
sodipodi:nodetypes="cccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64.0px"
height="64.0px"
viewBox="0 0 64.0 64.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="toolbar_radius.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview14"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
inkscape:zoom="2.8578563"
inkscape:cx="41.464646"
inkscape:cy="7.1732088"
inkscape:window-width="1920"
inkscape:window-height="991"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid20" />
</sodipodi:namedview>
<defs
id="defs9" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
id="path1006"
style="fill:#f7d9c8;stroke:none;stroke-opacity:1;fill-opacity:1"
d="M 32.251953 5.4511719 A 27.5 27.5 0 0 0 4.7519531 32.951172 A 27.5 27.5 0 0 0 32.251953 60.451172 A 27.5 27.5 0 0 0 59.751953 32.951172 A 27.5 27.5 0 0 0 32.251953 5.4511719 z M 32.039062 10.763672 A 22.113844 22.113844 0 0 1 54.152344 32.876953 A 22.113844 22.113844 0 0 1 32.039062 54.992188 A 22.113844 22.113844 0 0 1 9.9257812 32.876953 A 22.113844 22.113844 0 0 1 32.039062 10.763672 z " />
<rect
style="fill:#f7d9c8;fill-opacity:1;stroke:none;stroke-opacity:1"
id="rect1427"
width="5"
height="5"
x="30"
y="30" />
<rect
style="fill:#f7d9c8;fill-opacity:1;stroke:none;stroke-opacity:1"
id="rect1429"
width="5"
height="5"
x="30"
y="40" />
<rect
style="fill:#f7d9c8;fill-opacity:1;stroke:none;stroke-opacity:1"
id="rect1431"
width="5"
height="5"
x="30"
y="50" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64.0px"
height="64.0px"
viewBox="0 0 64.0 64.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="toolbar_radius.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview14"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
inkscape:zoom="2.8578563"
inkscape:cx="41.464646"
inkscape:cy="7.1732088"
inkscape:window-width="1920"
inkscape:window-height="991"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid20" />
</sodipodi:namedview>
<defs
id="defs9" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
id="path1006"
style="fill:#252525;stroke:none;stroke-opacity:1;fill-opacity:1"
d="M 32.251953 5.4511719 A 27.5 27.5 0 0 0 4.7519531 32.951172 A 27.5 27.5 0 0 0 32.251953 60.451172 A 27.5 27.5 0 0 0 59.751953 32.951172 A 27.5 27.5 0 0 0 32.251953 5.4511719 z M 32.039062 10.763672 A 22.113844 22.113844 0 0 1 54.152344 32.876953 A 22.113844 22.113844 0 0 1 32.039062 54.992188 A 22.113844 22.113844 0 0 1 9.9257812 32.876953 A 22.113844 22.113844 0 0 1 32.039062 10.763672 z " />
<rect
style="fill:#252525;fill-opacity:1;stroke:none;stroke-opacity:1"
id="rect1427"
width="5"
height="5"
x="30"
y="30" />
<rect
style="fill:#252525;fill-opacity:1;stroke:none;stroke-opacity:1"
id="rect1429"
width="5"
height="5"
x="30"
y="40" />
<rect
style="fill:#252525;fill-opacity:1;stroke:none;stroke-opacity:1"
id="rect1431"
width="5"
height="5"
x="30"
y="50" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64.0px"
height="64.0px"
viewBox="0 0 64.0 64.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="toolbar_x.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview14"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
inkscape:zoom="2.8578563"
inkscape:cx="41.464646"
inkscape:cy="7.8730341"
inkscape:window-width="1920"
inkscape:window-height="991"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid20" />
</sodipodi:namedview>
<defs
id="defs9" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
aria-label="X"
transform="scale(1.0997162,0.90932551)"
id="text14036"
style="font-size:89.5094px;line-height:1.25;font-family:Consolas;-inkscape-font-specification:Consolas;fill:#fc6621;stroke-width:2.23773">
<path
d="M 53.64687,64.431664 H 43.813074 L 29.914642,41.355021 15.972504,64.431664 H 6.2698246 L 25.281831,35.236215 7.7995263,7.3082333 H 17.021442 L 30.089465,28.811468 43.244899,7.3082333 H 52.20458 L 34.67857,34.886569 Z"
id="path824" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64.0px"
height="64.0px"
viewBox="0 0 64.0 64.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="toolbar_x.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview14"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
inkscape:zoom="2.8578563"
inkscape:cx="41.464646"
inkscape:cy="7.8730341"
inkscape:window-width="1920"
inkscape:window-height="991"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid20" />
</sodipodi:namedview>
<defs
id="defs9" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
aria-label="X"
transform="scale(1.0997162,0.90932551)"
id="text14036"
style="font-size:89.5094px;line-height:1.25;font-family:Consolas;-inkscape-font-specification:Consolas;fill:#252525;stroke-width:2.23773">
<path
d="M 53.64687,64.431664 H 43.813074 L 29.914642,41.355021 15.972504,64.431664 H 6.2698246 L 25.281831,35.236215 7.7995263,7.3082333 H 17.021442 L 30.089465,28.811468 43.244899,7.3082333 H 52.20458 L 34.67857,34.886569 Z"
id="path824" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64.0px"
height="64.0px"
viewBox="0 0 64.0 64.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="toolbar_y.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview14"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
inkscape:zoom="2.8578563"
inkscape:cx="41.464646"
inkscape:cy="7.8730341"
inkscape:window-width="1920"
inkscape:window-height="991"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid20" />
</sodipodi:namedview>
<defs
id="defs9" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
aria-label="Y"
transform="scale(1.0997162,0.90932551)"
id="text14036"
style="font-size:89.5094px;line-height:1.25;font-family:Consolas;-inkscape-font-specification:Consolas;fill:#0da9f1;stroke-width:2.23773">
<path
d="M 54.695808,7.3082333 34.022983,44.021073 V 64.431664 H 26.155946 V 43.84625 L 5.4831209,7.3082333 H 14.87986 l 11.363498,20.8913537 4.195753,8.391506 3.846107,-7.604802 11.494615,-21.6780577 z"
id="path824" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64.0px"
height="64.0px"
viewBox="0 0 64.0 64.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="toolbar_y.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview14"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
inkscape:zoom="2.8578563"
inkscape:cx="41.464646"
inkscape:cy="7.8730341"
inkscape:window-width="1920"
inkscape:window-height="991"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid20" />
</sodipodi:namedview>
<defs
id="defs9" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
aria-label="Y"
transform="scale(1.0997162,0.90932551)"
id="text14036"
style="font-size:89.5094px;line-height:1.25;font-family:Consolas;-inkscape-font-specification:Consolas;fill:#252525;stroke-width:2.23773">
<path
d="M 54.695808,7.3082333 34.022983,44.021073 V 64.431664 H 26.155946 V 43.84625 L 5.4831209,7.3082333 H 14.87986 l 11.363498,20.8913537 4.195753,8.391506 3.846107,-7.604802 11.494615,-21.6780577 z"
id="path824" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64.0px"
height="64.0px"
viewBox="0 0 64.0 64.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="toolbar_z.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview14"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
inkscape:zoom="2.8578563"
inkscape:cx="41.464646"
inkscape:cy="7.8730341"
inkscape:window-width="1920"
inkscape:window-height="991"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid20" />
</sodipodi:namedview>
<defs
id="defs9" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
aria-label="Z"
transform="scale(1.0997162,0.90932551)"
id="text14036"
style="font-size:89.5094px;line-height:1.25;font-family:Consolas;-inkscape-font-specification:Consolas;fill:#aaebc4;stroke-width:2.23773">
<path
d="M 49.232588,13.42704 20.080845,57.176507 h 29.719918 v 7.255157 H 10.33446 V 58.618797 L 39.661026,14.388567 H 11.121164 V 7.3082333 h 38.111424 z"
id="path5386" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64.0px"
height="64.0px"
viewBox="0 0 64.0 64.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="toolbar_z.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview14"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
inkscape:zoom="2.8578563"
inkscape:cx="41.464646"
inkscape:cy="7.8730341"
inkscape:window-width="1920"
inkscape:window-height="991"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid20" />
</sodipodi:namedview>
<defs
id="defs9" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
aria-label="Z"
transform="scale(1.0997162,0.90932551)"
id="text14036"
style="font-size:89.5094px;line-height:1.25;font-family:Consolas;-inkscape-font-specification:Consolas;fill:#252525;stroke-width:2.23773">
<path
d="M 49.232588,13.42704 20.080845,57.176507 h 29.719918 v 7.255157 H 10.33446 V 58.618797 L 39.661026,14.388567 H 11.121164 V 7.3082333 h 38.111424 z"
id="path5386" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 322 B

After

Width:  |  Height:  |  Size: 322 B

View File

Before

Width:  |  Height:  |  Size: 235 B

After

Width:  |  Height:  |  Size: 235 B

View File

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 258 B

View File

Before

Width:  |  Height:  |  Size: 323 B

After

Width:  |  Height:  |  Size: 323 B

View File

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View File

@ -0,0 +1,538 @@
#version 110
/****************************************************************************
**
** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
float exposure;
float gamma;
varying vec3 vert;
varying vec3 vertRaw;
varying vec3 vertNormal;
varying vec3 vertColor;
varying vec2 vertTexCoord;
varying float vertMetalness;
varying float vertRoughness;
varying vec3 cameraPos;
varying vec3 firstLightPos;
varying vec3 secondLightPos;
varying vec3 thirdLightPos;
varying float vertAlpha;
uniform sampler2D textureId;
uniform int textureEnabled;
uniform sampler2D normalMapId;
uniform int normalMapEnabled;
uniform sampler2D metalnessRoughnessAmbientOcclusionMapId;
uniform int metalnessMapEnabled;
uniform int roughnessMapEnabled;
uniform int ambientOcclusionMapEnabled;
uniform int mousePickEnabled;
uniform vec3 mousePickTargetPosition;
uniform float mousePickRadius;
uniform int toonShadingEnabled;
uniform int renderPurpose;
uniform int toonEdgeEnabled;
uniform float screenWidth;
uniform float screenHeight;
uniform sampler2D toonNormalMapId;
uniform sampler2D toonDepthMapId;
const int MAX_LIGHTS = 8;
const int TYPE_POINT = 0;
const int TYPE_DIRECTIONAL = 1;
const int TYPE_SPOT = 2;
struct Light {
int type;
vec3 position;
vec3 color;
float intensity;
vec3 direction;
float constantAttenuation;
float linearAttenuation;
float quadraticAttenuation;
float cutOffAngle;
};
int lightCount;
Light lights[MAX_LIGHTS];
float sobel_v[9];
float sobel_h[9];
float normalEdgeSobel()
{
sobel_v[0] = -1.0;
sobel_v[1] = 0.0;
sobel_v[2] = 1.0;
sobel_v[3] = -2.0;
sobel_v[4] = 0.0;
sobel_v[5] = 2.0;
sobel_v[6] = -1.0;
sobel_v[7] = 0.0;
sobel_v[8] = 1.0;
sobel_h[0] = -1.0;
sobel_h[1] = -2.0;
sobel_h[2] = -1.0;
sobel_h[3] = 0.0;
sobel_h[4] = 0.0;
sobel_h[5] = 0.0;
sobel_h[6] = 1.0;
sobel_h[7] = 2.0;
sobel_h[8] = 1.0;
// vec2 coord = gl_TexCoord[0].st;
vec2 coord = vec2(gl_FragCoord.x / screenWidth - 1.0, 1.0 - gl_FragCoord.y / screenHeight);
//float len = length(coord);
float sx = 1.0 / screenWidth;
float sy = 1.0 / screenHeight;
float n[9];
vec3 ref = vec3(1.0, 1.0, 1.0);
n[0] = dot(texture2D(toonNormalMapId, vec2(coord.x - sx, coord.y - sy)).rgb, ref);
n[1] = dot(texture2D(toonNormalMapId, vec2(coord.x, coord.y - sy)).rgb, ref);
n[2] = dot(texture2D(toonNormalMapId, vec2(coord.x + sx, coord.y - sy)).rgb, ref);
n[3] = dot(texture2D(toonNormalMapId, vec2(coord.x - sx, coord.y)).rgb, ref);
n[4] = dot(texture2D(toonNormalMapId, vec2(coord.x, coord.y)).rgb, ref);
n[5] = dot(texture2D(toonNormalMapId, vec2(coord.x + sx, coord.y)).rgb, ref);
n[6] = dot(texture2D(toonNormalMapId, vec2(coord.x - sx, coord.y + sy)).rgb, ref);
n[7] = dot(texture2D(toonNormalMapId, vec2(coord.x, coord.y + sy)).rgb, ref);
n[8] = dot(texture2D(toonNormalMapId, vec2(coord.x + sx, coord.y + sy)).rgb, ref);
float v, h;
v = 0.0;
h = 0.0;
for (int i = 0; i < 9; ++i) {
v += sobel_v[i] * n[i];
h += sobel_h[i] * n[i];
}
float enhanceFactor = 1.0;
float r = sqrt(v * v * enhanceFactor + h * h * enhanceFactor);
return smoothstep(0.0, 1.0, r);
}
float depthEdgeSobel()
{
sobel_v[0] = -1.0;
sobel_v[1] = 0.0;
sobel_v[2] = 1.0;
sobel_v[3] = -2.0;
sobel_v[4] = 0.0;
sobel_v[5] = 2.0;
sobel_v[6] = -1.0;
sobel_v[7] = 0.0;
sobel_v[8] = 1.0;
sobel_h[0] = -1.0;
sobel_h[1] = -2.0;
sobel_h[2] = -1.0;
sobel_h[3] = 0.0;
sobel_h[4] = 0.0;
sobel_h[5] = 0.0;
sobel_h[6] = 1.0;
sobel_h[7] = 2.0;
sobel_h[8] = 1.0;
// vec2 coord = gl_TexCoord[0].st;
vec2 coord = vec2(gl_FragCoord.x / screenWidth - 1.0, 1.0 - gl_FragCoord.y / screenHeight);
//float len = length(coord);
float sx = 1.0 / screenWidth;
float sy = 1.0 / screenHeight;
float n[9];
n[0] = texture2D(toonDepthMapId, vec2(coord.x - sx, coord.y - sy)).r;
n[1] = texture2D(toonDepthMapId, vec2(coord.x, coord.y - sy)).r;
n[2] = texture2D(toonDepthMapId, vec2(coord.x + sx, coord.y - sy)).r;
n[3] = texture2D(toonDepthMapId, vec2(coord.x - sx, coord.y)).r;
n[4] = texture2D(toonDepthMapId, vec2(coord.x, coord.y)).r;
n[5] = texture2D(toonDepthMapId, vec2(coord.x + sx, coord.y)).r;
n[6] = texture2D(toonDepthMapId, vec2(coord.x - sx, coord.y + sy)).r;
n[7] = texture2D(toonDepthMapId, vec2(coord.x, coord.y + sy)).r;
n[8] = texture2D(toonDepthMapId, vec2(coord.x + sx, coord.y + sy)).r;
float v, h;
v = 0.0;
h = 0.0;
for (int i = 0; i < 9; ++i) {
v += sobel_v[i] * n[i];
h += sobel_h[i] * n[i];
}
float enhanceFactor = 10.0;
float r = sqrt(v * v * enhanceFactor + h * h * enhanceFactor);
return smoothstep(0.0, 1.0, r);
}
float remapRoughness(const in float roughness)
{
// As per page 14 of
// http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
// we remap the roughness to give a more perceptually linear response
// of "bluriness" as a function of the roughness specified by the user.
// r = roughness^2
float maxSpecPower;
float minRoughness;
maxSpecPower = 999999.0;
minRoughness = sqrt(2.0 / (maxSpecPower + 2.0));
return max(roughness * roughness, minRoughness);
}
float normalDistribution(const in vec3 n, const in vec3 h, const in float alpha)
{
// Blinn-Phong approximation - see
// http://graphicrants.blogspot.co.uk/2013/08/specular-brdf-reference.html
float specPower = 2.0 / (alpha * alpha) - 2.0;
return (specPower + 2.0) / (2.0 * 3.14159) * pow(max(dot(n, h), 0.0), specPower);
}
vec3 fresnelFactor(const in vec3 color, const in float cosineFactor)
{
// Calculate the Fresnel effect value
vec3 f = color;
vec3 F = f + (1.0 - f) * pow(1.0 - cosineFactor, 5.0);
return clamp(F, f, vec3(1.0));
}
float geometricModel(const in float lDotN,
const in float vDotN,
const in vec3 h)
{
// Implicit geometric model (equal to denominator in specular model).
// This currently assumes that there is no attenuation by geometric shadowing or
// masking according to the microfacet theory.
return lDotN * vDotN;
}
vec3 specularModel(const in vec3 F0,
const in float sDotH,
const in float sDotN,
const in float vDotN,
const in vec3 n,
const in vec3 h)
{
// Clamp sDotN and vDotN to small positive value to prevent the
// denominator in the reflection equation going to infinity. Balance this
// by using the clamped values in the geometric factor function to
// avoid ugly seams in the specular lighting.
float sDotNPrime = max(sDotN, 0.001);
float vDotNPrime = max(vDotN, 0.001);
vec3 F = fresnelFactor(F0, sDotH);
float G = geometricModel(sDotNPrime, vDotNPrime, h);
vec3 cSpec = F * G / (4.0 * sDotNPrime * vDotNPrime);
return clamp(cSpec, vec3(0.0), vec3(1.0));
}
vec3 pbrModel(const in int lightIndex,
const in vec3 wPosition,
const in vec3 wNormal,
const in vec3 wView,
const in vec3 baseColor,
const in float metalness,
const in float alpha,
const in float ambientOcclusion)
{
// Calculate some useful quantities
vec3 n = wNormal;
vec3 s = vec3(0.0);
vec3 v = wView;
vec3 h = vec3(0.0);
float vDotN = dot(v, n);
float sDotN = 0.0;
float sDotH = 0.0;
float att = 1.0;
if (lights[lightIndex].type != TYPE_DIRECTIONAL) {
// Point and Spot lights
vec3 sUnnormalized = vec3(lights[lightIndex].position) - wPosition;
s = normalize(sUnnormalized);
// Calculate the attenuation factor
sDotN = dot(s, n);
if (sDotN > 0.0) {
if (lights[lightIndex].constantAttenuation != 0.0
|| lights[lightIndex].linearAttenuation != 0.0
|| lights[lightIndex].quadraticAttenuation != 0.0) {
float dist = length(sUnnormalized);
att = 1.0 / (lights[lightIndex].constantAttenuation +
lights[lightIndex].linearAttenuation * dist +
lights[lightIndex].quadraticAttenuation * dist * dist);
}
// The light direction is in world space already
if (lights[lightIndex].type == TYPE_SPOT) {
// Check if fragment is inside or outside of the spot light cone
if (degrees(acos(dot(-s, lights[lightIndex].direction))) > lights[lightIndex].cutOffAngle)
sDotN = 0.0;
}
}
} else {
// Directional lights
// The light direction is in world space already
s = normalize(-lights[lightIndex].direction);
sDotN = dot(s, n);
}
h = normalize(s + v);
sDotH = dot(s, h);
// Calculate diffuse component
vec3 diffuseColor = (1.0 - metalness) * baseColor * lights[lightIndex].color;
vec3 diffuse = diffuseColor * max(sDotN, 0.0) / 3.14159;
// Calculate specular component
vec3 dielectricColor = vec3(0.04);
vec3 F0 = mix(dielectricColor, baseColor, metalness);
vec3 specularFactor = vec3(0.0);
if (sDotN > 0.0) {
specularFactor = specularModel(F0, sDotH, sDotN, vDotN, n, h);
specularFactor *= normalDistribution(n, h, alpha);
}
vec3 specularColor = lights[lightIndex].color;
vec3 specular = specularColor * specularFactor;
// Blend between diffuse and specular to conserver energy
vec3 color = att * lights[lightIndex].intensity * (specular + diffuse * (vec3(1.0) - specular));
// Reduce by ambient occlusion amount
color *= ambientOcclusion;
return color;
}
vec3 toneMap(const in vec3 c)
{
return c / (c + vec3(1.0));
}
vec3 gammaCorrect(const in vec3 color)
{
return pow(color, vec3(1.0 / gamma));
}
// http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
vec4 metalRoughFunction(const in vec4 baseColor,
const in float metalness,
const in float roughness,
const in float ambientOcclusion,
const in vec3 worldPosition,
const in vec3 worldView,
const in vec3 worldNormal)
{
vec3 cLinear = vec3(0.0);
// Remap roughness for a perceptually more linear correspondence
float alpha = remapRoughness(roughness);
if (toonShadingEnabled != 1) {
for (int i = 0; i < lightCount; ++i) {
cLinear += pbrModel(i,
worldPosition,
worldNormal,
worldView,
baseColor.rgb,
metalness,
alpha,
ambientOcclusion);
}
} else {
float intensity;
intensity = dot(vec3(1.0, 1.0, 1.0), worldNormal);
vec3 hsv = rgb2hsv(baseColor.rgb);
if (intensity > 0.966)
cLinear = hsv2rgb(vec3(hsv.r, hsv.g, hsv.b * 2.0));
else
cLinear = hsv2rgb(vec3(hsv.r, hsv.g, hsv.b * 0.1));
if (toonEdgeEnabled > 0) {
float depthEdge = depthEdgeSobel();
float normalEdge = normalEdgeSobel();
if (depthEdge >= 0.009 || normalEdge >= 0.7) {
cLinear = hsv2rgb(vec3(hsv.r, hsv.g, hsv.b * 0.02));
} else if (toonEdgeEnabled == 2) {
return vec4(0.0, 0.0, 0.0, 0.0);
}
}
}
// Apply exposure correction
cLinear *= pow(2.0, exposure);
// Apply simple (Reinhard) tonemap transform to get into LDR range [0, 1]
vec3 cToneMapped = toneMap(cLinear);
// Apply gamma correction prior to display
vec3 cGamma = gammaCorrect(cToneMapped);
return vec4(cGamma, baseColor.a);
}
void main()
{
// FIXME: don't hard code here
exposure = 1.0;
gamma = 2.2;
// Light settings:
// https://doc-snapshots.qt.io/qt5-5.12/qt3d-pbr-materials-lights-qml.html
lightCount = 3;
// Key light
lights[0].type = TYPE_POINT;
lights[0].position = firstLightPos;
lights[0].color = vec3(1.0, 1.0, 1.0);
lights[0].intensity = 3.0;
lights[0].constantAttenuation = 0.0;
lights[0].linearAttenuation = 0.0;
lights[0].quadraticAttenuation = 0.0;
// Fill light
lights[1].type = TYPE_POINT;
lights[1].position = secondLightPos;
lights[1].color = vec3(1.0, 1.0, 1.0);
lights[1].intensity = 1.0;
lights[1].constantAttenuation = 0.0;
lights[1].linearAttenuation = 0.0;
lights[1].quadraticAttenuation = 0.0;
// Rim light
lights[2].type = TYPE_POINT;
lights[2].position = thirdLightPos;
lights[2].color = vec3(1.0, 1.0, 1.0);
lights[2].intensity = 0.5;
lights[2].constantAttenuation = 0.0;
lights[2].linearAttenuation = 0.0;
lights[2].quadraticAttenuation = 0.0;
vec3 color = vertColor;
float alpha = vertAlpha;
if (textureEnabled == 1) {
vec4 textColor = texture2D(textureId, vertTexCoord);
color = textColor.rgb;
alpha = textColor.a;
}
if (mousePickEnabled == 1) {
float dist = distance(mousePickTargetPosition, vertRaw);
if (dist <= mousePickRadius && dist >= mousePickRadius * 0.9) {
color = color + vec3(0.99, 0.4, 0.13);
}
}
color = pow(color, vec3(gamma));
vec3 normal = vertNormal;
if (normalMapEnabled == 1) {
normal = texture2D(normalMapId, vertTexCoord).rgb;
normal = normalize(normal * 2.0 - 1.0);
}
// Red: Ambient Occlusion
// Green: Roughness
// Blue: Metallic
float metalness = vertMetalness;
if (metalnessMapEnabled == 1) {
metalness = texture2D(metalnessRoughnessAmbientOcclusionMapId, vertTexCoord).b;
}
float roughness = vertRoughness;
if (roughnessMapEnabled == 1) {
roughness = texture2D(metalnessRoughnessAmbientOcclusionMapId, vertTexCoord).g;
}
float ambientOcclusion = 1.0;
if (ambientOcclusionMapEnabled == 1) {
ambientOcclusion = texture2D(metalnessRoughnessAmbientOcclusionMapId, vertTexCoord).r;
}
roughness = min(0.99, roughness);
metalness = min(0.99, metalness);
if (renderPurpose == 0) {
gl_FragColor = metalRoughFunction(vec4(color, alpha),
metalness,
roughness,
ambientOcclusion,
vert,
normalize(cameraPos - vert),
normal);
} else if (renderPurpose == 1) {
gl_FragColor = vec4(normal, 1.0);
} else if (renderPurpose == 2) {
gl_FragColor = vec4(vec3(gl_FragCoord.w), 1.0);
}
}

View File

@ -0,0 +1,652 @@
#version 330
/****************************************************************************
**
** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
float exposure;
float gamma;
in vec3 vert;
in vec3 vertRaw;
in vec3 vertNormal;
in vec3 vertColor;
in vec2 vertTexCoord;
in float vertMetalness;
in float vertRoughness;
in vec3 cameraPos;
in vec3 firstLightPos;
in vec3 secondLightPos;
in vec3 thirdLightPos;
in float vertAlpha;
out vec4 fragColor;
uniform sampler2D textureId;
uniform int textureEnabled;
uniform sampler2D normalMapId;
uniform int normalMapEnabled;
uniform sampler2D metalnessRoughnessAmbientOcclusionMapId;
uniform int metalnessMapEnabled;
uniform int roughnessMapEnabled;
uniform int ambientOcclusionMapEnabled;
uniform int mousePickEnabled;
uniform vec3 mousePickTargetPosition;
uniform float mousePickRadius;
uniform samplerCube environmentIrradianceMapId;
uniform int environmentIrradianceMapEnabled;
uniform samplerCube environmentSpecularMapId;
uniform int environmentSpecularMapEnabled;
uniform int toonShadingEnabled;
uniform int renderPurpose;
uniform int toonEdgeEnabled;
uniform float screenWidth;
uniform float screenHeight;
uniform sampler2D toonNormalMapId;
uniform sampler2D toonDepthMapId;
const int MAX_LIGHTS = 8;
const int TYPE_POINT = 0;
const int TYPE_DIRECTIONAL = 1;
const int TYPE_SPOT = 2;
struct Light {
int type;
vec3 position;
vec3 color;
float intensity;
vec3 direction;
float constantAttenuation;
float linearAttenuation;
float quadraticAttenuation;
float cutOffAngle;
};
int lightCount;
Light lights[MAX_LIGHTS];
float sobel_v[9];
float sobel_h[9];
float normalEdgeSobel()
{
sobel_v[0] = -1.0;
sobel_v[1] = 0.0;
sobel_v[2] = 1.0;
sobel_v[3] = -2.0;
sobel_v[4] = 0.0;
sobel_v[5] = 2.0;
sobel_v[6] = -1.0;
sobel_v[7] = 0.0;
sobel_v[8] = 1.0;
sobel_h[0] = -1.0;
sobel_h[1] = -2.0;
sobel_h[2] = -1.0;
sobel_h[3] = 0.0;
sobel_h[4] = 0.0;
sobel_h[5] = 0.0;
sobel_h[6] = 1.0;
sobel_h[7] = 2.0;
sobel_h[8] = 1.0;
// vec2 coord = gl_TexCoord[0].st;
vec2 coord = vec2(gl_FragCoord.x / screenWidth, 1.0 - gl_FragCoord.y / screenHeight);
//float len = length(coord);
float sx = 1.0 / screenWidth;
float sy = 1.0 / screenHeight;
float n[9];
vec3 ref = vec3(1.0, 1.0, 1.0);
n[0] = dot(texture(toonNormalMapId, vec2(coord.x - sx, coord.y - sy)).rgb, ref);
n[1] = dot(texture(toonNormalMapId, vec2(coord.x, coord.y - sy)).rgb, ref);
n[2] = dot(texture(toonNormalMapId, vec2(coord.x + sx, coord.y - sy)).rgb, ref);
n[3] = dot(texture(toonNormalMapId, vec2(coord.x - sx, coord.y)).rgb, ref);
n[4] = dot(texture(toonNormalMapId, vec2(coord.x, coord.y)).rgb, ref);
n[5] = dot(texture(toonNormalMapId, vec2(coord.x + sx, coord.y)).rgb, ref);
n[6] = dot(texture(toonNormalMapId, vec2(coord.x - sx, coord.y + sy)).rgb, ref);
n[7] = dot(texture(toonNormalMapId, vec2(coord.x, coord.y + sy)).rgb, ref);
n[8] = dot(texture(toonNormalMapId, vec2(coord.x + sx, coord.y + sy)).rgb, ref);
float v, h;
v = 0.0;
h = 0.0;
for (int i = 0; i < 9; ++i) {
v += sobel_v[i] * n[i];
h += sobel_h[i] * n[i];
}
float enhanceFactor = 1.0;
float r = sqrt(v * v * enhanceFactor + h * h * enhanceFactor);
return smoothstep(0.0, 1.0, r);
}
float depthEdgeSobel()
{
sobel_v[0] = -1;
sobel_v[1] = 0;
sobel_v[2] = 1;
sobel_v[3] = -2;
sobel_v[4] = 0;
sobel_v[5] = 2;
sobel_v[6] = -1;
sobel_v[7] = 0;
sobel_v[8] = 1;
sobel_h[0] = -1;
sobel_h[1] = -2;
sobel_h[2] = -1;
sobel_h[3] = 0;
sobel_h[4] = 0;
sobel_h[5] = 0;
sobel_h[6] = 1;
sobel_h[7] = 2;
sobel_h[8] = 1;
// vec2 coord = gl_TexCoord[0].st;
vec2 coord = vec2(gl_FragCoord.x / screenWidth, 1.0 - gl_FragCoord.y / screenHeight);
//float len = length(coord);
float sx = 1.0 / screenWidth;
float sy = 1.0 / screenHeight;
float n[9];
n[0] = texture(toonDepthMapId, vec2(coord.x - sx, coord.y - sy)).r;
n[1] = texture(toonDepthMapId, vec2(coord.x, coord.y - sy)).r;
n[2] = texture(toonDepthMapId, vec2(coord.x + sx, coord.y - sy)).r;
n[3] = texture(toonDepthMapId, vec2(coord.x - sx, coord.y)).r;
n[4] = texture(toonDepthMapId, vec2(coord.x, coord.y)).r;
n[5] = texture(toonDepthMapId, vec2(coord.x + sx, coord.y)).r;
n[6] = texture(toonDepthMapId, vec2(coord.x - sx, coord.y + sy)).r;
n[7] = texture(toonDepthMapId, vec2(coord.x, coord.y + sy)).r;
n[8] = texture(toonDepthMapId, vec2(coord.x + sx, coord.y + sy)).r;
float v, h;
v = 0.0;
h = 0.0;
for (int i = 0; i < 9; ++i) {
v += sobel_v[i] * n[i];
h += sobel_h[i] * n[i];
}
float enhanceFactor = 10.0;
float r = sqrt(v * v * enhanceFactor + h * h * enhanceFactor);
return smoothstep(0.0, 1.0, r);
}
int mipLevelCount(const in samplerCube cube)
{
int baseSize = textureSize(cube, 0).x;
int nMips = int(log2(float(baseSize > 0 ? baseSize : 1))) + 1;
return nMips;
}
float remapRoughness(const in float roughness)
{
// As per page 14 of
// http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
// we remap the roughness to give a more perceptually linear response
// of "bluriness" as a function of the roughness specified by the user.
// r = roughness^2
float maxSpecPower;
float minRoughness;
maxSpecPower = 999999.0;
minRoughness = sqrt(2.0 / (maxSpecPower + 2.0));
return max(roughness * roughness, minRoughness);
}
float alphaToMipLevel(float alpha)
{
float specPower = 2.0 / (alpha * alpha) - 2.0;
// We use the mip level calculation from Lys' default power drop, which in
// turn is a slight modification of that used in Marmoset Toolbag. See
// https://docs.knaldtech.com/doku.php?id=specular_lys for details.
// For now we assume a max specular power of 999999 which gives
// maxGlossiness = 1.
const float k0 = 0.00098;
const float k1 = 0.9921;
float glossiness = (pow(2.0, -10.0 / sqrt(specPower)) - k0) / k1;
// TODO: Optimize by doing this on CPU and set as
// uniform int environmentSpecularMapIdMipLevels say (if present in shader).
// Lookup the number of mips in the specular envmap
int mipLevels = mipLevelCount(environmentSpecularMapId);
// Offset of smallest miplevel we should use (corresponds to specular
// power of 1). I.e. in the 32x32 sized mip.
const float mipOffset = 5.0;
// The final factor is really 1 - g / g_max but as mentioned above g_max
// is 1 by definition here so we can avoid the division. If we make the
// max specular power for the spec map configurable, this will need to
// be handled properly.
float mipLevel = (mipLevels - 1.0 - mipOffset) * (1.0 - glossiness);
return mipLevel;
}
float normalDistribution(const in vec3 n, const in vec3 h, const in float alpha)
{
// Blinn-Phong approximation - see
// http://graphicrants.blogspot.co.uk/2013/08/specular-brdf-reference.html
float specPower = 2.0 / (alpha * alpha) - 2.0;
return (specPower + 2.0) / (2.0 * 3.14159) * pow(max(dot(n, h), 0.0), specPower);
}
vec3 fresnelFactor(const in vec3 color, const in float cosineFactor)
{
// Calculate the Fresnel effect value
vec3 f = color;
vec3 F = f + (1.0 - f) * pow(1.0 - cosineFactor, 5.0);
return clamp(F, f, vec3(1.0));
}
float geometricModel(const in float lDotN,
const in float vDotN,
const in vec3 h)
{
// Implicit geometric model (equal to denominator in specular model).
// This currently assumes that there is no attenuation by geometric shadowing or
// masking according to the microfacet theory.
return lDotN * vDotN;
}
vec3 specularModel(const in vec3 F0,
const in float sDotH,
const in float sDotN,
const in float vDotN,
const in vec3 n,
const in vec3 h)
{
// Clamp sDotN and vDotN to small positive value to prevent the
// denominator in the reflection equation going to infinity. Balance this
// by using the clamped values in the geometric factor function to
// avoid ugly seams in the specular lighting.
float sDotNPrime = max(sDotN, 0.001);
float vDotNPrime = max(vDotN, 0.001);
vec3 F = fresnelFactor(F0, sDotH);
float G = geometricModel(sDotNPrime, vDotNPrime, h);
vec3 cSpec = F * G / (4.0 * sDotNPrime * vDotNPrime);
return clamp(cSpec, vec3(0.0), vec3(1.0));
}
vec3 pbrModel(const in int lightIndex,
const in vec3 wPosition,
const in vec3 wNormal,
const in vec3 wView,
const in vec3 baseColor,
const in float metalness,
const in float alpha,
const in float ambientOcclusion)
{
// Calculate some useful quantities
vec3 n = wNormal;
vec3 s = vec3(0.0);
vec3 v = wView;
vec3 h = vec3(0.0);
float vDotN = dot(v, n);
float sDotN = 0.0;
float sDotH = 0.0;
float att = 1.0;
if (lights[lightIndex].type != TYPE_DIRECTIONAL) {
// Point and Spot lights
vec3 sUnnormalized = vec3(lights[lightIndex].position) - wPosition;
s = normalize(sUnnormalized);
// Calculate the attenuation factor
sDotN = dot(s, n);
if (sDotN > 0.0) {
if (lights[lightIndex].constantAttenuation != 0.0
|| lights[lightIndex].linearAttenuation != 0.0
|| lights[lightIndex].quadraticAttenuation != 0.0) {
float dist = length(sUnnormalized);
att = 1.0 / (lights[lightIndex].constantAttenuation +
lights[lightIndex].linearAttenuation * dist +
lights[lightIndex].quadraticAttenuation * dist * dist);
}
// The light direction is in world space already
if (lights[lightIndex].type == TYPE_SPOT) {
// Check if fragment is inside or outside of the spot light cone
if (degrees(acos(dot(-s, lights[lightIndex].direction))) > lights[lightIndex].cutOffAngle)
sDotN = 0.0;
}
}
} else {
// Directional lights
// The light direction is in world space already
s = normalize(-lights[lightIndex].direction);
sDotN = dot(s, n);
}
h = normalize(s + v);
sDotH = dot(s, h);
// Calculate diffuse component
vec3 diffuseColor = (1.0 - metalness) * baseColor * lights[lightIndex].color;
vec3 diffuse = diffuseColor * max(sDotN, 0.0) / 3.14159;
// Calculate specular component
vec3 dielectricColor = vec3(0.04);
vec3 F0 = mix(dielectricColor, baseColor, metalness);
vec3 specularFactor = vec3(0.0);
if (sDotN > 0.0) {
specularFactor = specularModel(F0, sDotH, sDotN, vDotN, n, h);
specularFactor *= normalDistribution(n, h, alpha);
}
vec3 specularColor = lights[lightIndex].color;
vec3 specular = specularColor * specularFactor;
// Blend between diffuse and specular to conserver energy
vec3 color = att * lights[lightIndex].intensity * (specular + diffuse * (vec3(1.0) - specular));
// Reduce by ambient occlusion amount
color *= ambientOcclusion;
return color;
}
vec3 pbrIblModel(const in vec3 wNormal,
const in vec3 wView,
const in vec3 baseColor,
const in float metalness,
const in float alpha,
const in float ambientOcclusion)
{
// Calculate reflection direction of view vector about surface normal
// vector in world space. This is used in the fragment shader to sample
// from the environment textures for a light source. This is equivalent
// to the l vector for punctual light sources. Armed with this, calculate
// the usual factors needed
vec3 n = wNormal;
vec3 l = reflect(-wView, n);
vec3 v = wView;
vec3 h = normalize(l + v);
float vDotN = dot(v, n);
float lDotN = dot(l, n);
float lDotH = dot(l, h);
// Calculate diffuse component
vec3 diffuseColor = (1.0 - metalness) * baseColor;
vec3 diffuse = diffuseColor * texture(environmentIrradianceMapId, l).rgb;
// Calculate specular component
vec3 dielectricColor = vec3(0.04);
vec3 F0 = mix(dielectricColor, baseColor, metalness);
vec3 specularFactor = specularModel(F0, lDotH, lDotN, vDotN, n, h);
float lod = alphaToMipLevel(alpha);
//#define DEBUG_SPECULAR_LODS
#ifdef DEBUG_SPECULAR_LODS
if (lod > 7.0)
return vec3(1.0, 0.0, 0.0);
else if (lod > 6.0)
return vec3(1.0, 0.333, 0.0);
else if (lod > 5.0)
return vec3(1.0, 1.0, 0.0);
else if (lod > 4.0)
return vec3(0.666, 1.0, 0.0);
else if (lod > 3.0)
return vec3(0.0, 1.0, 0.666);
else if (lod > 2.0)
return vec3(0.0, 0.666, 1.0);
else if (lod > 1.0)
return vec3(0.0, 0.0, 1.0);
else if (lod > 0.0)
return vec3(1.0, 0.0, 1.0);
#endif
vec3 specularSkyColor = textureLod(environmentSpecularMapId, l, lod).rgb;
vec3 specular = specularSkyColor * specularFactor;
// Blend between diffuse and specular to conserve energy
vec3 color = specular + diffuse * (vec3(1.0) - specularFactor);
// Reduce by ambient occlusion amount
color *= ambientOcclusion;
return color;
}
vec3 toneMap(const in vec3 c)
{
return c / (c + vec3(1.0));
}
vec3 gammaCorrect(const in vec3 color)
{
return pow(color, vec3(1.0 / gamma));
}
// http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
vec4 metalRoughFunction(const in vec4 baseColor,
const in float metalness,
const in float roughness,
const in float ambientOcclusion,
const in vec3 worldPosition,
const in vec3 worldView,
const in vec3 worldNormal)
{
vec3 cLinear = vec3(0.0);
// Remap roughness for a perceptually more linear correspondence
float alpha = remapRoughness(roughness);
if (toonShadingEnabled != 1) {
if (environmentIrradianceMapEnabled == 1) {
cLinear += pbrIblModel(worldNormal,
worldView,
baseColor.rgb,
metalness,
alpha,
ambientOcclusion);
}
for (int i = 0; i < lightCount; ++i) {
cLinear += pbrModel(i,
worldPosition,
worldNormal,
worldView,
baseColor.rgb,
metalness,
alpha,
ambientOcclusion);
}
} else {
float intensity;
intensity = dot(vec3(1.0, 1.0, 1.0), worldNormal);
vec3 hsv = rgb2hsv(baseColor.rgb);
if (intensity > 0.966)
cLinear = hsv2rgb(vec3(hsv.r, hsv.g, hsv.b * 2.0));
else
cLinear = hsv2rgb(vec3(hsv.r, hsv.g, hsv.b * 0.1));
if (toonEdgeEnabled > 0) {
float depthEdge = depthEdgeSobel();
float normalEdge = normalEdgeSobel();
if (depthEdge >= 0.009 || normalEdge >= 0.7) {
cLinear = hsv2rgb(vec3(hsv.r, hsv.g, hsv.b * 0.02));
} else if (toonEdgeEnabled == 2) {
return vec4(0.0, 0.0, 0.0, 0.0);
}
}
}
// Apply exposure correction
cLinear *= pow(2.0, exposure);
// Apply simple (Reinhard) tonemap transform to get into LDR range [0, 1]
vec3 cToneMapped = toneMap(cLinear);
// Apply gamma correction prior to display
vec3 cGamma = gammaCorrect(cToneMapped);
return vec4(cGamma, baseColor.a);
}
void main()
{
// FIXME: don't hard code here
exposure = 1.0;
gamma = 2.2;
// Light settings:
// https://doc-snapshots.qt.io/qt5-5.12/qt3d-pbr-materials-lights-qml.html
lightCount = 3;
// Key light
lights[0].type = TYPE_POINT;
lights[0].position = firstLightPos;
lights[0].color = vec3(1.0, 1.0, 1.0);
lights[0].intensity = 3.0;
lights[0].constantAttenuation = 1.0;
lights[0].linearAttenuation = 0.0;
lights[0].quadraticAttenuation = 0.0025;
// Fill light
lights[1].type = TYPE_POINT;
lights[1].position = secondLightPos;
lights[1].color = vec3(1.0, 1.0, 1.0);
lights[1].intensity = 0.1;
lights[1].constantAttenuation = 0.0;
lights[1].linearAttenuation = 0.0;
lights[1].quadraticAttenuation = 0.0;
// Rim light
lights[2].type = TYPE_POINT;
lights[2].position = thirdLightPos;
lights[2].color = vec3(1.0, 1.0, 1.0);
lights[2].intensity = 0.05;
lights[2].constantAttenuation = 0.0;
lights[2].linearAttenuation = 0.0;
lights[2].quadraticAttenuation = 0.0;
vec3 color = vertColor;
float alpha = vertAlpha;
if (textureEnabled == 1) {
vec4 textColor = texture(textureId, vertTexCoord);
color = textColor.rgb;
alpha = textColor.a;
}
if (mousePickEnabled == 1) {
float dist = distance(mousePickTargetPosition, vertRaw);
if (dist <= mousePickRadius && dist >= mousePickRadius * 0.9) {
color = color + vec3(0.99, 0.4, 0.13);
}
}
color = pow(color, vec3(gamma));
vec3 normal = vertNormal;
if (normalMapEnabled == 1) {
normal = texture(normalMapId, vertTexCoord).rgb;
normal = normalize(normal * 2.0 - 1.0);
}
// Red: Ambient Occlusion
// Green: Roughness
// Blue: Metallic
float metalness = vertMetalness;
if (metalnessMapEnabled == 1) {
metalness = texture(metalnessRoughnessAmbientOcclusionMapId, vertTexCoord).b;
}
float roughness = vertRoughness;
if (roughnessMapEnabled == 1) {
roughness = texture(metalnessRoughnessAmbientOcclusionMapId, vertTexCoord).g;
}
float ambientOcclusion = 1.0;
if (ambientOcclusionMapEnabled == 1) {
ambientOcclusion = texture(metalnessRoughnessAmbientOcclusionMapId, vertTexCoord).r;
}
roughness = min(0.99, roughness);
if (environmentIrradianceMapEnabled != 1) {
metalness = min(0.99, metalness);
}
if (renderPurpose == 0) {
fragColor = metalRoughFunction(vec4(color, alpha),
metalness,
roughness,
ambientOcclusion,
vert,
normalize(cameraPos - vert),
normal);
} else if (renderPurpose == 1) {
fragColor = vec4(normal, 1.0);
} else if (renderPurpose == 2) {
fragColor = vec4(vec3(gl_FragCoord.w), 1.0);
}
}

View File

@ -0,0 +1,21 @@
#include <QTextEdit>
#include <QVBoxLayout>
#include <QOpenGLFunctions>
#include "about_widget.h"
#include "version.h"
AboutWidget::AboutWidget()
{
QTextEdit *versionInfoLabel = new QTextEdit;
versionInfoLabel->setText(QString("%1 %2 (version: %3 build: %4 %5)\nopengl: %6 shader: %7 core: %8").arg(APP_NAME).arg(APP_HUMAN_VER).arg(APP_VER).arg(__DATE__).arg(__TIME__).arg((char *)glGetString(GL_VERSION)).arg((char *)glGetString(GL_SHADING_LANGUAGE_VERSION)).arg(QSurfaceFormat::defaultFormat().profile() == QSurfaceFormat::CoreProfile ? "true" : "false"));
versionInfoLabel->setReadOnly(true);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(versionInfoLabel);
setLayout(mainLayout);
setFixedSize(QSize(350, 100));
setWindowTitle(applicationTitle(tr("About")));
}

View File

@ -0,0 +1,13 @@
#ifndef DUST3D_APPLICATION_ABOUT_WIDGET_H_
#define DUST3D_APPLICATION_ABOUT_WIDGET_H_
#include <QDialog>
class AboutWidget : public QDialog
{
Q_OBJECT
public:
AboutWidget();
};
#endif

View File

@ -0,0 +1,129 @@
#include <QtGlobal>
#include <QMatrix4x4>
#include <QDebug>
#include <cmath>
#include <QtMath>
#include "ccd_ik_resolver.h"
CcdIkSolver::CcdIkSolver()
{
}
void CcdIkSolver::setSolveFrom(int fromNodeIndex)
{
m_fromNodeIndex = fromNodeIndex;
}
void CcdIkSolver::setNodeHingeConstraint(int nodeIndex,
const QVector3D &axis, double minLimitDegrees, double maxLimitDegrees)
{
auto &node = m_nodes[nodeIndex];
node.axis = axis;
node.minLimitDegrees = minLimitDegrees;
node.maxLimitDegrees = maxLimitDegrees;
}
void CcdIkSolver::setMaxRound(int maxRound)
{
m_maxRound = maxRound;
}
void CcdIkSolver::setDistanceThreshod(float threshold)
{
m_distanceThreshold2 = threshold * threshold;
}
int CcdIkSolver::addNodeInOrder(const QVector3D &position)
{
CcdIkNode node;
node.position = position;
int nodeCount = m_nodes.size();
m_nodes.push_back(node);
return nodeCount;
}
void CcdIkSolver::solveTo(const QVector3D &position)
{
//qDebug() << "solveTo:" << position;
m_destination = position;
float lastDistance2 = 0;
for (int i = 0; i < m_maxRound; i++) {
const auto &endEffector = m_nodes[m_nodes.size() - 1];
float distance2 = (endEffector.position - m_destination).lengthSquared();
//qDebug() << "Round:" << i << " distance2:" << distance2;
if (distance2 <= m_distanceThreshold2)
break;
if (lastDistance2 > 0 && fabs(distance2 - lastDistance2) <= m_distanceCeaseThreshold2)
break;
lastDistance2 = distance2;
iterate();
}
}
const QVector3D &CcdIkSolver::getNodeSolvedPosition(int index)
{
Q_ASSERT(index >= 0 && index < (int)m_nodes.size());
return m_nodes[index].position;
}
int CcdIkSolver::getNodeCount()
{
return (int)m_nodes.size();
}
float CcdIkSolver::angleInRangle360BetweenTwoVectors(QVector3D a, QVector3D b, QVector3D planeNormal)
{
float degrees = acos(QVector3D::dotProduct(a, b)) * 180.0 / M_PI;
QVector3D direct = QVector3D::crossProduct(a, b);
if (QVector3D::dotProduct(direct, planeNormal) < 0)
return 360 - degrees;
return degrees;
}
void CcdIkSolver::iterate()
{
auto rotateChildren = [&](const QQuaternion &quaternion, int i) {
const auto &origin = m_nodes[i];
for (size_t j = i + 1; j <= m_nodes.size() - 1; j++) {
auto &next = m_nodes[j];
const auto offset = next.position - origin.position;
next.position = origin.position + quaternion.rotatedVector(offset);
}
};
for (int i = m_nodes.size() - 2; i >= m_fromNodeIndex; i--) {
const auto &origin = m_nodes[i];
const auto &endEffector = m_nodes[m_nodes.size() - 1];
QVector3D from = (endEffector.position - origin.position).normalized();
QVector3D to = (m_destination - origin.position).normalized();
auto quaternion = QQuaternion::rotationTo(from, to);
rotateChildren(quaternion, i);
if (origin.axis.isNull())
continue;
QVector3D oldAxis = origin.axis;
QVector3D newAxis = quaternion.rotatedVector(oldAxis);
auto hingQuaternion = QQuaternion::rotationTo(newAxis, oldAxis);
rotateChildren(hingQuaternion, i);
// TODO: Support angle limit for other axis
int parentIndex = i - 1;
if (parentIndex < 0)
continue;
int childIndex = i + 1;
if (childIndex >= m_nodes.size())
continue;
const auto &parent = m_nodes[parentIndex];
const auto &child = m_nodes[childIndex];
QVector3D angleFrom = (QVector3D(0.0, parent.position.y(), parent.position.z()) -
QVector3D(0.0, origin.position.y(), origin.position.z())).normalized();
QVector3D angleTo = (QVector3D(0.0, child.position.y(), child.position.z()) -
QVector3D(0.0, origin.position.y(), origin.position.z())).normalized();
float degrees = angleInRangle360BetweenTwoVectors(angleFrom, angleTo, QVector3D(1.0, 0.0, 0.0));
if (degrees < origin.minLimitDegrees) {
auto quaternion = QQuaternion::fromAxisAndAngle(QVector3D(1.0, 0.0, 0.0), origin.minLimitDegrees - degrees);
rotateChildren(quaternion, i);
} else if (degrees > origin.maxLimitDegrees) {
auto quaternion = QQuaternion::fromAxisAndAngle(QVector3D(-1.0, 0.0, 0.0), degrees - origin.maxLimitDegrees);
rotateChildren(quaternion, i);
}
}
}

View File

@ -0,0 +1,41 @@
#ifndef DUST3D_APPLICATION_CCD_IK_SOLVER_H_
#define DUST3D_APPLICATION_CCD_IK_SOLVER_H_
#include <vector>
#include <QVector3D>
#include <QQuaternion>
struct CcdIkNode
{
QVector3D position;
QVector3D axis;
double minLimitDegrees;
double maxLimitDegrees;
};
class CcdIkSolver
{
public:
CcdIkSolver();
void setMaxRound(int maxRound);
void setDistanceThreshod(float threshold);
int addNodeInOrder(const QVector3D &position);
void solveTo(const QVector3D &position);
const QVector3D &getNodeSolvedPosition(int index);
int getNodeCount();
void setNodeHingeConstraint(int nodeIndex,
const QVector3D &axis, double minLimitDegrees, double maxLimitDegrees);
void setSolveFrom(int fromNodeIndex);
private:
float angleInRangle360BetweenTwoVectors(QVector3D a, QVector3D b, QVector3D planeNormal);
void iterate();
std::vector<CcdIkNode> m_nodes;
QVector3D m_destination;
int m_maxRound = 4;
float m_distanceThreshold2 = 0.001 * 0.001;
float m_distanceCeaseThreshold2 = 0.001 * 0.001;
int m_fromNodeIndex = 0;
};
#endif

View File

@ -0,0 +1,56 @@
#include <QPainter>
#include "cut_face_preview.h"
#include "theme.h"
static std::map<int, QImage *> g_standardCutFaceMap;
QImage *buildCutFaceTemplatePreviewImage(const std::vector<dust3d::Vector2> &cutTemplate)
{
QImage *image = new QImage(Theme::partPreviewImageSize, Theme::partPreviewImageSize, QImage::Format_ARGB32);
image->fill(Qt::transparent);
if (cutTemplate.empty())
return image;
QPainter painter;
painter.begin(image);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing);
QPen pen(Theme::red, 2);
painter.setPen(pen);
QBrush brush;
brush.setColor(Theme::white);
brush.setStyle(Qt::SolidPattern);
painter.setBrush(brush);
const float scale = 0.7f;
QPolygon polygon;
for (int i = 0; i <= cutTemplate.size(); ++i) {
const auto &it = cutTemplate[i % cutTemplate.size()];
polygon.append(QPoint((it.x() * scale + 1.0) * 0.5 * Theme::partPreviewImageSize,
(it.y() * scale + 1.0) * 0.5 * Theme::partPreviewImageSize));
}
QPainterPath path;
path.addPolygon(polygon);
painter.fillPath(path, brush);
painter.drawPath(path);
painter.end();
return image;
}
const QImage *cutFacePreviewImage(dust3d::CutFace cutFace)
{
auto findItem = g_standardCutFaceMap.find((int)cutFace);
if (findItem != g_standardCutFaceMap.end())
return findItem->second;
std::vector<dust3d::Vector2> cutTemplate = dust3d::CutFaceToPoints(cutFace);
QImage *image = buildCutFaceTemplatePreviewImage(cutTemplate);
g_standardCutFaceMap.insert({(int)cutFace, image});
return image;
}

View File

@ -0,0 +1,10 @@
#ifndef DUST3D_APPLICATION_CUT_FACE_PREVIEW_H_
#define DUST3D_APPLICATION_CUT_FACE_PREVIEW_H_
#include <QImage>
#include <dust3d/base/cut_face.h>
QImage *buildCutFaceTemplatePreviewImage(const std::vector<dust3d::Vector2> &cutTemplate);
const QImage *cutFacePreviewImage(dust3d::CutFace cutFace);
#endif

View File

@ -0,0 +1,523 @@
#include <QtGlobal>
#include <QFile>
#include <QDebug>
#include <QtEndian>
#include <QByteArray>
#include <QOpenGLPixelTransferOptions>
#include "dds_file.h"
#ifndef _WIN32
typedef quint32 DWORD;
typedef quint32 UINT;
#endif
// DDS data struct copy from
// https://docs.microsoft.com/en-us/windows/win32/direct3ddds/dx-graphics-dds-pguide
typedef struct {
DWORD dwSize;
DWORD dwFlags;
DWORD dwFourCC;
DWORD dwRGBBitCount;
DWORD dwRBitMask;
DWORD dwGBitMask;
DWORD dwBBitMask;
DWORD dwABitMask;
} DDS_PIXELFORMAT;
typedef enum {
DDSCAPS2_CUBEMAP = 0x200,
DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
DDSCAPS2_VOLUME = 0x200000
} DDS_CAPS2_FLAGS;
typedef struct {
DWORD dwSize;
DWORD dwFlags;
DWORD dwHeight;
DWORD dwWidth;
DWORD dwPitchOrLinearSize;
DWORD dwDepth;
DWORD dwMipMapCount;
DWORD dwReserved1[11];
DDS_PIXELFORMAT ddspf;
DWORD dwCaps;
DWORD dwCaps2;
DWORD dwCaps3;
DWORD dwCaps4;
DWORD dwReserved2;
} DDS_HEADER;
typedef enum {
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R32G32B32A32_TYPELESS,
DXGI_FORMAT_R32G32B32A32_FLOAT,
DXGI_FORMAT_R32G32B32A32_UINT,
DXGI_FORMAT_R32G32B32A32_SINT,
DXGI_FORMAT_R32G32B32_TYPELESS,
DXGI_FORMAT_R32G32B32_FLOAT,
DXGI_FORMAT_R32G32B32_UINT,
DXGI_FORMAT_R32G32B32_SINT,
DXGI_FORMAT_R16G16B16A16_TYPELESS,
DXGI_FORMAT_R16G16B16A16_FLOAT,
DXGI_FORMAT_R16G16B16A16_UNORM,
DXGI_FORMAT_R16G16B16A16_UINT,
DXGI_FORMAT_R16G16B16A16_SNORM,
DXGI_FORMAT_R16G16B16A16_SINT,
DXGI_FORMAT_R32G32_TYPELESS,
DXGI_FORMAT_R32G32_FLOAT,
DXGI_FORMAT_R32G32_UINT,
DXGI_FORMAT_R32G32_SINT,
DXGI_FORMAT_R32G8X24_TYPELESS,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT,
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS,
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT,
DXGI_FORMAT_R10G10B10A2_TYPELESS,
DXGI_FORMAT_R10G10B10A2_UNORM,
DXGI_FORMAT_R10G10B10A2_UINT,
DXGI_FORMAT_R11G11B10_FLOAT,
DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UINT,
DXGI_FORMAT_R8G8B8A8_SNORM,
DXGI_FORMAT_R8G8B8A8_SINT,
DXGI_FORMAT_R16G16_TYPELESS,
DXGI_FORMAT_R16G16_FLOAT,
DXGI_FORMAT_R16G16_UNORM,
DXGI_FORMAT_R16G16_UINT,
DXGI_FORMAT_R16G16_SNORM,
DXGI_FORMAT_R16G16_SINT,
DXGI_FORMAT_R32_TYPELESS,
DXGI_FORMAT_D32_FLOAT,
DXGI_FORMAT_R32_FLOAT,
DXGI_FORMAT_R32_UINT,
DXGI_FORMAT_R32_SINT,
DXGI_FORMAT_R24G8_TYPELESS,
DXGI_FORMAT_D24_UNORM_S8_UINT,
DXGI_FORMAT_R24_UNORM_X8_TYPELESS,
DXGI_FORMAT_X24_TYPELESS_G8_UINT,
DXGI_FORMAT_R8G8_TYPELESS,
DXGI_FORMAT_R8G8_UNORM,
DXGI_FORMAT_R8G8_UINT,
DXGI_FORMAT_R8G8_SNORM,
DXGI_FORMAT_R8G8_SINT,
DXGI_FORMAT_R16_TYPELESS,
DXGI_FORMAT_R16_FLOAT,
DXGI_FORMAT_D16_UNORM,
DXGI_FORMAT_R16_UNORM,
DXGI_FORMAT_R16_UINT,
DXGI_FORMAT_R16_SNORM,
DXGI_FORMAT_R16_SINT,
DXGI_FORMAT_R8_TYPELESS,
DXGI_FORMAT_R8_UNORM,
DXGI_FORMAT_R8_UINT,
DXGI_FORMAT_R8_SNORM,
DXGI_FORMAT_R8_SINT,
DXGI_FORMAT_A8_UNORM,
DXGI_FORMAT_R1_UNORM,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP,
DXGI_FORMAT_R8G8_B8G8_UNORM,
DXGI_FORMAT_G8R8_G8B8_UNORM,
DXGI_FORMAT_BC1_TYPELESS,
DXGI_FORMAT_BC1_UNORM,
DXGI_FORMAT_BC1_UNORM_SRGB,
DXGI_FORMAT_BC2_TYPELESS,
DXGI_FORMAT_BC2_UNORM,
DXGI_FORMAT_BC2_UNORM_SRGB,
DXGI_FORMAT_BC3_TYPELESS,
DXGI_FORMAT_BC3_UNORM,
DXGI_FORMAT_BC3_UNORM_SRGB,
DXGI_FORMAT_BC4_TYPELESS,
DXGI_FORMAT_BC4_UNORM,
DXGI_FORMAT_BC4_SNORM,
DXGI_FORMAT_BC5_TYPELESS,
DXGI_FORMAT_BC5_UNORM,
DXGI_FORMAT_BC5_SNORM,
DXGI_FORMAT_B5G6R5_UNORM,
DXGI_FORMAT_B5G5R5A1_UNORM,
DXGI_FORMAT_B8G8R8A8_UNORM,
DXGI_FORMAT_B8G8R8X8_UNORM,
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM,
DXGI_FORMAT_B8G8R8A8_TYPELESS,
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB,
DXGI_FORMAT_B8G8R8X8_TYPELESS,
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB,
DXGI_FORMAT_BC6H_TYPELESS,
DXGI_FORMAT_BC6H_UF16,
DXGI_FORMAT_BC6H_SF16,
DXGI_FORMAT_BC7_TYPELESS,
DXGI_FORMAT_BC7_UNORM,
DXGI_FORMAT_BC7_UNORM_SRGB,
DXGI_FORMAT_AYUV,
DXGI_FORMAT_Y410,
DXGI_FORMAT_Y416,
DXGI_FORMAT_NV12,
DXGI_FORMAT_P010,
DXGI_FORMAT_P016,
DXGI_FORMAT_420_OPAQUE,
DXGI_FORMAT_YUY2,
DXGI_FORMAT_Y210,
DXGI_FORMAT_Y216,
DXGI_FORMAT_NV11,
DXGI_FORMAT_AI44,
DXGI_FORMAT_IA44,
DXGI_FORMAT_P8,
DXGI_FORMAT_A8P8,
DXGI_FORMAT_B4G4R4A4_UNORM,
DXGI_FORMAT_P208,
DXGI_FORMAT_V208,
DXGI_FORMAT_V408,
DXGI_FORMAT_FORCE_UINT
} DXGI_FORMAT;
static const char *DxgiFormatToString(DXGI_FORMAT dxgiFormat)
{
static const char *names[] = {
"DXGI_FORMAT_UNKNOWN",
"DXGI_FORMAT_R32G32B32A32_TYPELESS",
"DXGI_FORMAT_R32G32B32A32_FLOAT",
"DXGI_FORMAT_R32G32B32A32_UINT",
"DXGI_FORMAT_R32G32B32A32_SINT",
"DXGI_FORMAT_R32G32B32_TYPELESS",
"DXGI_FORMAT_R32G32B32_FLOAT",
"DXGI_FORMAT_R32G32B32_UINT",
"DXGI_FORMAT_R32G32B32_SINT",
"DXGI_FORMAT_R16G16B16A16_TYPELESS",
"DXGI_FORMAT_R16G16B16A16_FLOAT",
"DXGI_FORMAT_R16G16B16A16_UNORM",
"DXGI_FORMAT_R16G16B16A16_UINT",
"DXGI_FORMAT_R16G16B16A16_SNORM",
"DXGI_FORMAT_R16G16B16A16_SINT",
"DXGI_FORMAT_R32G32_TYPELESS",
"DXGI_FORMAT_R32G32_FLOAT",
"DXGI_FORMAT_R32G32_UINT",
"DXGI_FORMAT_R32G32_SINT",
"DXGI_FORMAT_R32G8X24_TYPELESS",
"DXGI_FORMAT_D32_FLOAT_S8X24_UINT",
"DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS",
"DXGI_FORMAT_X32_TYPELESS_G8X24_UINT",
"DXGI_FORMAT_R10G10B10A2_TYPELESS",
"DXGI_FORMAT_R10G10B10A2_UNORM",
"DXGI_FORMAT_R10G10B10A2_UINT",
"DXGI_FORMAT_R11G11B10_FLOAT",
"DXGI_FORMAT_R8G8B8A8_TYPELESS",
"DXGI_FORMAT_R8G8B8A8_UNORM",
"DXGI_FORMAT_R8G8B8A8_UNORM_SRGB",
"DXGI_FORMAT_R8G8B8A8_UINT",
"DXGI_FORMAT_R8G8B8A8_SNORM",
"DXGI_FORMAT_R8G8B8A8_SINT",
"DXGI_FORMAT_R16G16_TYPELESS",
"DXGI_FORMAT_R16G16_FLOAT",
"DXGI_FORMAT_R16G16_UNORM",
"DXGI_FORMAT_R16G16_UINT",
"DXGI_FORMAT_R16G16_SNORM",
"DXGI_FORMAT_R16G16_SINT",
"DXGI_FORMAT_R32_TYPELESS",
"DXGI_FORMAT_D32_FLOAT",
"DXGI_FORMAT_R32_FLOAT",
"DXGI_FORMAT_R32_UINT",
"DXGI_FORMAT_R32_SINT",
"DXGI_FORMAT_R24G8_TYPELESS",
"DXGI_FORMAT_D24_UNORM_S8_UINT",
"DXGI_FORMAT_R24_UNORM_X8_TYPELESS",
"DXGI_FORMAT_X24_TYPELESS_G8_UINT",
"DXGI_FORMAT_R8G8_TYPELESS",
"DXGI_FORMAT_R8G8_UNORM",
"DXGI_FORMAT_R8G8_UINT",
"DXGI_FORMAT_R8G8_SNORM",
"DXGI_FORMAT_R8G8_SINT",
"DXGI_FORMAT_R16_TYPELESS",
"DXGI_FORMAT_R16_FLOAT",
"DXGI_FORMAT_D16_UNORM",
"DXGI_FORMAT_R16_UNORM",
"DXGI_FORMAT_R16_UINT",
"DXGI_FORMAT_R16_SNORM",
"DXGI_FORMAT_R16_SINT",
"DXGI_FORMAT_R8_TYPELESS",
"DXGI_FORMAT_R8_UNORM",
"DXGI_FORMAT_R8_UINT",
"DXGI_FORMAT_R8_SNORM",
"DXGI_FORMAT_R8_SINT",
"DXGI_FORMAT_A8_UNORM",
"DXGI_FORMAT_R1_UNORM",
"DXGI_FORMAT_R9G9B9E5_SHAREDEXP",
"DXGI_FORMAT_R8G8_B8G8_UNORM",
"DXGI_FORMAT_G8R8_G8B8_UNORM",
"DXGI_FORMAT_BC1_TYPELESS",
"DXGI_FORMAT_BC1_UNORM",
"DXGI_FORMAT_BC1_UNORM_SRGB",
"DXGI_FORMAT_BC2_TYPELESS",
"DXGI_FORMAT_BC2_UNORM",
"DXGI_FORMAT_BC2_UNORM_SRGB",
"DXGI_FORMAT_BC3_TYPELESS",
"DXGI_FORMAT_BC3_UNORM",
"DXGI_FORMAT_BC3_UNORM_SRGB",
"DXGI_FORMAT_BC4_TYPELESS",
"DXGI_FORMAT_BC4_UNORM",
"DXGI_FORMAT_BC4_SNORM",
"DXGI_FORMAT_BC5_TYPELESS",
"DXGI_FORMAT_BC5_UNORM",
"DXGI_FORMAT_BC5_SNORM",
"DXGI_FORMAT_B5G6R5_UNORM",
"DXGI_FORMAT_B5G5R5A1_UNORM",
"DXGI_FORMAT_B8G8R8A8_UNORM",
"DXGI_FORMAT_B8G8R8X8_UNORM",
"DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM",
"DXGI_FORMAT_B8G8R8A8_TYPELESS",
"DXGI_FORMAT_B8G8R8A8_UNORM_SRGB",
"DXGI_FORMAT_B8G8R8X8_TYPELESS",
"DXGI_FORMAT_B8G8R8X8_UNORM_SRGB",
"DXGI_FORMAT_BC6H_TYPELESS",
"DXGI_FORMAT_BC6H_UF16",
"DXGI_FORMAT_BC6H_SF16",
"DXGI_FORMAT_BC7_TYPELESS",
"DXGI_FORMAT_BC7_UNORM",
"DXGI_FORMAT_BC7_UNORM_SRGB",
"DXGI_FORMAT_AYUV",
"DXGI_FORMAT_Y410",
"DXGI_FORMAT_Y416",
"DXGI_FORMAT_NV12",
"DXGI_FORMAT_P010",
"DXGI_FORMAT_P016",
"DXGI_FORMAT_420_OPAQUE",
"DXGI_FORMAT_YUY2",
"DXGI_FORMAT_Y210",
"DXGI_FORMAT_Y216",
"DXGI_FORMAT_NV11",
"DXGI_FORMAT_AI44",
"DXGI_FORMAT_IA44",
"DXGI_FORMAT_P8",
"DXGI_FORMAT_A8P8",
"DXGI_FORMAT_B4G4R4A4_UNORM",
"DXGI_FORMAT_P208",
"DXGI_FORMAT_V208",
"DXGI_FORMAT_V408",
"DXGI_FORMAT_FORCE_UINT",
};
int index = (int)dxgiFormat;
if (index >= 0 && index < sizeof(names) / sizeof(names[0]))
return names[index];
return "(Unknown)";
}
typedef enum {
D3D10_RESOURCE_DIMENSION_UNKNOWN,
D3D10_RESOURCE_DIMENSION_BUFFER,
D3D10_RESOURCE_DIMENSION_TEXTURE1D,
D3D10_RESOURCE_DIMENSION_TEXTURE2D,
D3D10_RESOURCE_DIMENSION_TEXTURE3D
} D3D10_RESOURCE_DIMENSION;
static const char *ResourceDimensionToString(D3D10_RESOURCE_DIMENSION resourceDimension)
{
static const char *names[] = {
"D3D10_RESOURCE_DIMENSION_UNKNOWN",
"D3D10_RESOURCE_DIMENSION_BUFFER",
"D3D10_RESOURCE_DIMENSION_TEXTURE1D",
"D3D10_RESOURCE_DIMENSION_TEXTURE2D",
"D3D10_RESOURCE_DIMENSION_TEXTURE3D",
};
int index = (int)resourceDimension;
if (index >= 0 && index < sizeof(names) / sizeof(names[0]))
return names[index];
return "(Unknown)";
}
typedef enum {
D3D10_RESOURCE_MISC_GENERATE_MIPS,
D3D10_RESOURCE_MISC_SHARED,
D3D10_RESOURCE_MISC_TEXTURECUBE,
D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX,
D3D10_RESOURCE_MISC_GDI_COMPATIBLE
} D3D10_RESOURCE_MISC_FLAG;
static const char *MiscFlagToString(UINT miscFlag)
{
static const char *names[] = {
"D3D10_RESOURCE_MISC_GENERATE_MIPS",
"D3D10_RESOURCE_MISC_SHARED",
"D3D10_RESOURCE_MISC_TEXTURECUBE",
"D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX",
"D3D10_RESOURCE_MISC_GDI_COMPATIBLE",
};
int index = (int)miscFlag;
if (index >= 0 && index < sizeof(names) / sizeof(names[0]))
return names[index];
return "(Unknown)";
}
typedef struct {
DXGI_FORMAT dxgiFormat;
D3D10_RESOURCE_DIMENSION resourceDimension;
UINT miscFlag;
UINT arraySize;
UINT miscFlags2;
} DDS_HEADER_DXT10;
typedef struct {
DWORD dwMagic;
DDS_HEADER header;
DDS_HEADER_DXT10 header10;
} DDS_FILE_HEADER;
DdsFileReader::DdsFileReader(const QString &filename) :
m_filename(filename)
{
}
QOpenGLTexture *DdsFileReader::createOpenGLTexture()
{
QFile file(m_filename);
if (!file.open(QIODevice::ReadOnly)) {
qDebug() << "Open" << m_filename << "failed";
return nullptr;
}
DDS_FILE_HEADER fileHeader;
if (sizeof(fileHeader) != file.read((char *)&fileHeader, sizeof(fileHeader))) {
qDebug() << "Read DDS file hader failed";
return nullptr;
}
if (0x20534444 != qFromLittleEndian<quint32>(&fileHeader.dwMagic)) {
qDebug() << "Not a DDS file";
return nullptr;
}
if (0x30315844 != qFromLittleEndian<quint32>(&fileHeader.header.ddspf.dwFourCC)) {
qDebug() << "Unsupported DDS file, expected DX10 file";
return nullptr;
}
auto caps2 = qFromLittleEndian<quint32>(&fileHeader.header.dwCaps2);
if (!(DDSCAPS2_CUBEMAP & caps2)) {
qDebug() << "Unsupported DDS file, expected CUBEMAP file";
return nullptr;
}
//qDebug() << "Start anyalize DDS file...";
int width = qFromLittleEndian<quint32>(&fileHeader.header.dwWidth);
int height = qFromLittleEndian<quint32>(&fileHeader.header.dwHeight);
//qDebug() << "DDS size:" << width << "X" << height;
//auto pitchOrLinearSize = qFromLittleEndian<quint32>(&fileHeader.header.dwPitchOrLinearSize);
//qDebug() << "DDS pitch or linear size:" << pitchOrLinearSize;
auto arraySize = qFromLittleEndian<quint32>(&fileHeader.header10.arraySize);
//qDebug() << "DDS array size:" << arraySize;
auto mipMapCount = qFromLittleEndian<quint32>(&fileHeader.header.dwMipMapCount);
//qDebug() << "DDS mip map count:" << mipMapCount;
DXGI_FORMAT dxgiFormat = (DXGI_FORMAT)qFromLittleEndian<quint32>(&fileHeader.header10.dxgiFormat);
//qDebug() << "DDS dxgi format:" << DxgiFormatToString(dxgiFormat);
//qDebug() << "DDS resource dimension:" << ResourceDimensionToString((D3D10_RESOURCE_DIMENSION)qFromLittleEndian<quint32>(&fileHeader.header10.resourceDimension));
//qDebug() << "DDS misc flag:" << MiscFlagToString((UINT)qFromLittleEndian<quint32>(&fileHeader.header10.miscFlag));
auto faces = 0;
if (DDSCAPS2_CUBEMAP_POSITIVEX & caps2) {
//qDebug() << "DDS found +x";
++faces;
}
if (DDSCAPS2_CUBEMAP_NEGATIVEX & caps2) {
//qDebug() << "DDS found -x";
++faces;
}
if (DDSCAPS2_CUBEMAP_POSITIVEY & caps2) {
//qDebug() << "DDS found +y";
++faces;
}
if (DDSCAPS2_CUBEMAP_NEGATIVEY & caps2) {
//qDebug() << "DDS found -y";
++faces;
}
if (DDSCAPS2_CUBEMAP_POSITIVEZ & caps2) {
//qDebug() << "DDS found +z";
++faces;
}
if (DDSCAPS2_CUBEMAP_NEGATIVEZ & caps2) {
//qDebug() << "DDS found -z";
++faces;
}
if (6 != faces) {
qDebug() << "Unsupported DDS file, expected six faces";
return nullptr;
}
if (1 != arraySize) {
qDebug() << "Unsupported DDS file, expected one layer";
return nullptr;
}
if (DXGI_FORMAT_R16G16B16A16_FLOAT != dxgiFormat) {
qDebug() << "Unsupported DDS file, expected dxgi format: DXGI_FORMAT_R16G16B16A16_FLOAT";
return nullptr;
}
int components = 8;
int oneFaceSize = 0;
auto calculateOneFaceSizeAtLevel = [=](int level) {
return qMax(width >> level, 1) * qMax(height >> level, 1) * components;
};
for (auto level = 0; level < mipMapCount; ++level) {
oneFaceSize += calculateOneFaceSizeAtLevel(level);
}
int totalSize = arraySize * faces * oneFaceSize;
const QByteArray data = file.read(totalSize);
if (data.size() < totalSize) {
qDebug() << "DDS file invalid, expected total size:" << totalSize << "read size:" << data.size();
return nullptr;
}
int depth = 1;
QOpenGLTexture* texture = new QOpenGLTexture(QOpenGLTexture::TargetCubeMap);
texture->setFormat(QOpenGLTexture::RGBA16F);
texture->setSize(width, height, depth);
texture->setAutoMipMapGenerationEnabled(false);
texture->setMipBaseLevel(0);
texture->setMipMaxLevel(mipMapCount - 1);
texture->setMipLevels(mipMapCount);
if (!texture->create()) {
qDebug() << "QOpenGLTexture::create failed";
delete texture;
return nullptr;
}
texture->allocateStorage();
if (!texture->isStorageAllocated()) {
qDebug() << "QOpenGLTexture::isStorageAllocated false";
delete texture;
return nullptr;
}
uint64_t dataOffset = 0;
for (int layer = 0; layer < arraySize; ++layer) {
for (int face = 0; face < faces; ++face) {
for (int level = 0; level < mipMapCount; ++level) {
QOpenGLPixelTransferOptions uploadOptions;
uploadOptions.setAlignment(1);
texture->setData(level,
layer,
static_cast<QOpenGLTexture::CubeMapFace>(QOpenGLTexture::CubeMapPositiveX + face),
QOpenGLTexture::RGBA,
QOpenGLTexture::Float16,
data.constData() + dataOffset,
&uploadOptions);
dataOffset += calculateOneFaceSizeAtLevel(level);
}
}
}
return texture;
}

View File

@ -0,0 +1,16 @@
#ifndef DUST3D_APPLICATION_DDS_FILE_H_
#define DUST3D_APPLICATION_DDS_FILE_H_
#include <QString>
#include <QOpenGLTexture>
class DdsFileReader
{
public:
DdsFileReader(const QString &filename);
QOpenGLTexture *createOpenGLTexture();
private:
QString m_filename;
};
#endif

View File

@ -0,0 +1,15 @@
#include "debug.h"
QDebug operator<<(QDebug debug, const dust3d::Uuid &uuid)
{
QDebugStateSaver stateSaver(debug);
debug.nospace() << uuid.toString().c_str();
return debug;
}
QDebug operator<<(QDebug debug, const std::string &string)
{
QDebugStateSaver stateSaver(debug);
debug.nospace() << string.c_str();
return debug;
}

View File

@ -0,0 +1,10 @@
#ifndef DUST3D_APPLICATION_DEBUG_H_
#define DUST3D_APPLICATION_DEBUG_H_
#include <QDebug>
#include <dust3d/base/uuid.h>
QDebug operator<<(QDebug debug, const dust3d::Uuid &uuid);
QDebug operator<<(QDebug debug, const std::string &string);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,264 @@
#ifndef DUST3D_APPLICATION_DOCUMENT_H_
#define DUST3D_APPLICATION_DOCUMENT_H_
#include <QObject>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <QImage>
#include <cmath>
#include <algorithm>
#include <QPolygon>
#include <dust3d/base/uuid.h>
#include <dust3d/base/snapshot.h>
#include <dust3d/base/texture_type.h>
#include <dust3d/base/combine_mode.h>
#include "model.h"
#include "theme.h"
#include "skeleton_document.h"
#include "material_layer.h"
class MaterialPreviewsGenerator;
class TextureGenerator;
class MeshGenerator;
class MeshResultPostProcessor;
class HistoryItem
{
public:
dust3d::Snapshot snapshot;
};
class Material
{
public:
Material()
{
}
~Material()
{
delete m_previewMesh;
}
dust3d::Uuid id;
QString name;
bool dirty = true;
std::vector<MaterialLayer> layers;
void updatePreviewMesh(Model *previewMesh)
{
delete m_previewMesh;
m_previewMesh = previewMesh;
}
Model *takePreviewMesh() const
{
if (nullptr == m_previewMesh)
return nullptr;
return new Model(*m_previewMesh);
}
private:
Q_DISABLE_COPY(Material);
Model *m_previewMesh = nullptr;
};
enum class DocumentToSnapshotFor
{
Document = 0,
Nodes,
Materials
};
class Document : public SkeletonDocument
{
Q_OBJECT
signals:
void nodeCutRotationChanged(dust3d::Uuid nodeId);
void nodeCutFaceChanged(dust3d::Uuid nodeId);
void partPreviewChanged(dust3d::Uuid partId);
void resultMeshChanged();
void resultPartPreviewsChanged();
void turnaroundChanged();
void editModeChanged();
void resultTextureChanged();
void resultColorTextureChanged();
void postProcessedResultChanged();
void partSubdivStateChanged(dust3d::Uuid partId);
void partXmirrorStateChanged(dust3d::Uuid partId);
void partBaseChanged(dust3d::Uuid partId);
void partDeformThicknessChanged(dust3d::Uuid partId);
void partDeformWidthChanged(dust3d::Uuid partId);
void partDeformUnifyStateChanged(dust3d::Uuid partId);
void partRoundStateChanged(dust3d::Uuid partId);
void partColorStateChanged(dust3d::Uuid partId);
void partCutRotationChanged(dust3d::Uuid partId);
void partCutFaceChanged(dust3d::Uuid partId);
void partMaterialIdChanged(dust3d::Uuid partId);
void partChamferStateChanged(dust3d::Uuid partId);
void partTargetChanged(dust3d::Uuid partId);
void partColorSolubilityChanged(dust3d::Uuid partId);
void partMetalnessChanged(dust3d::Uuid partId);
void partRoughnessChanged(dust3d::Uuid partId);
void partHollowThicknessChanged(dust3d::Uuid partId);
void partCountershadeStateChanged(dust3d::Uuid partId);
void partSmoothStateChanged(dust3d::Uuid partId);
void componentCombineModeChanged(dust3d::Uuid componentId);
void cleanup();
void checkPart(dust3d::Uuid partId);
void partChecked(dust3d::Uuid partId);
void partUnchecked(dust3d::Uuid partId);
void enableBackgroundBlur();
void disableBackgroundBlur();
void exportReady();
void uncheckAll();
void checkNode(dust3d::Uuid nodeId);
void checkEdge(dust3d::Uuid edgeId);
void materialAdded(dust3d::Uuid materialId);
void materialRemoved(dust3d::Uuid materialId);
void materialListChanged();
void materialNameChanged(dust3d::Uuid materialId);
void materialLayersChanged(dust3d::Uuid materialId);
void materialPreviewChanged(dust3d::Uuid materialId);
void meshGenerating();
void postProcessing();
void textureGenerating();
void textureChanged();
public: // need initialize
QImage *textureImage = nullptr;
QByteArray *textureImageByteArray = nullptr;
QImage *textureNormalImage = nullptr;
QByteArray *textureNormalImageByteArray = nullptr;
QImage *textureMetalnessImage = nullptr;
QByteArray *textureMetalnessImageByteArray = nullptr;
QImage *textureRoughnessImage = nullptr;
QByteArray *textureRoughnessImageByteArray = nullptr;
QImage *textureAmbientOcclusionImage = nullptr;
QByteArray *textureAmbientOcclusionImageByteArray = nullptr;
bool weldEnabled = true;
float brushMetalness = Model::m_defaultMetalness;
float brushRoughness = Model::m_defaultRoughness;
public:
Document();
~Document();
std::map<dust3d::Uuid, Material> materialMap;
std::vector<dust3d::Uuid> materialIdList;
bool undoable() const override;
bool redoable() const override;
bool hasPastableNodesInClipboard() const override;
bool originSettled() const override;
bool isNodeEditable(dust3d::Uuid nodeId) const override;
bool isEdgeEditable(dust3d::Uuid edgeId) const override;
void copyNodes(std::set<dust3d::Uuid> nodeIdSet) const override;
void toSnapshot(dust3d::Snapshot *snapshot, const std::set<dust3d::Uuid> &limitNodeIds=std::set<dust3d::Uuid>(),
DocumentToSnapshotFor forWhat=DocumentToSnapshotFor::Document,
const std::set<dust3d::Uuid> &limitMaterialIds=std::set<dust3d::Uuid>()) const;
void fromSnapshot(const dust3d::Snapshot &snapshot);
enum class SnapshotSource
{
Unknown,
Paste,
Import
};
void addFromSnapshot(const dust3d::Snapshot &snapshot, enum SnapshotSource source=SnapshotSource::Paste);
const Material *findMaterial(dust3d::Uuid materialId) const;
Model *takeResultMesh();
Model *takePaintedMesh();
bool isMeshGenerationSucceed();
Model *takeResultTextureMesh();
Model *takeResultRigWeightMesh();
void updateTurnaround(const QImage &image);
void clearTurnaround();
void updateTextureImage(QImage *image);
void updateTextureNormalImage(QImage *image);
void updateTextureMetalnessImage(QImage *image);
void updateTextureRoughnessImage(QImage *image);
void updateTextureAmbientOcclusionImage(QImage *image);
bool hasPastableMaterialsInClipboard() const;
const dust3d::Object &currentPostProcessedObject() const;
bool isExportReady() const;
bool isPostProcessResultObsolete() const;
bool isMeshGenerating() const;
bool isPostProcessing() const;
bool isTextureGenerating() const;
void collectCutFaceList(std::vector<QString> &cutFaces) const;
public slots:
void undo() override;
void redo() override;
void paste() override;
void setNodeCutRotation(dust3d::Uuid nodeId, float cutRotation);
void setNodeCutFace(dust3d::Uuid nodeId, dust3d::CutFace cutFace);
void setNodeCutFaceLinkedId(dust3d::Uuid nodeId, dust3d::Uuid linkedId);
void clearNodeCutFaceSettings(dust3d::Uuid nodeId);
void setEditMode(SkeletonDocumentEditMode mode);
void uiReady();
void generateMesh();
void regenerateMesh();
void meshReady();
void generateTexture();
void textureReady();
void postProcess();
void postProcessedMeshResultReady();
void generateMaterialPreviews();
void materialPreviewsReady();
void setPartSubdivState(dust3d::Uuid partId, bool subdived);
void setPartXmirrorState(dust3d::Uuid partId, bool mirrored);
void setPartBase(dust3d::Uuid partId, dust3d::PartBase base);
void setPartDeformThickness(dust3d::Uuid partId, float thickness);
void setPartDeformWidth(dust3d::Uuid partId, float width);
void setPartDeformUnified(dust3d::Uuid partId, bool unified);
void setPartRoundState(dust3d::Uuid partId, bool rounded);
void setPartColorState(dust3d::Uuid partId, bool hasColor, QColor color);
void setPartCutRotation(dust3d::Uuid partId, float cutRotation);
void setPartCutFace(dust3d::Uuid partId, dust3d::CutFace cutFace);
void setPartCutFaceLinkedId(dust3d::Uuid partId, dust3d::Uuid linkedId);
void setPartMaterialId(dust3d::Uuid partId, dust3d::Uuid materialId);
void setPartChamferState(dust3d::Uuid partId, bool chamfered);
void setPartTarget(dust3d::Uuid partId, dust3d::PartTarget target);
void setPartColorSolubility(dust3d::Uuid partId, float solubility);
void setPartMetalness(dust3d::Uuid partId, float metalness);
void setPartRoughness(dust3d::Uuid partId, float roughness);
void setPartHollowThickness(dust3d::Uuid partId, float hollowThickness);
void setPartCountershaded(dust3d::Uuid partId, bool countershaded);
void setPartSmoothState(dust3d::Uuid partId, bool smooth);
void setComponentCombineMode(dust3d::Uuid componentId, dust3d::CombineMode combineMode);
void saveSnapshot();
void batchChangeBegin();
void batchChangeEnd();
void reset();
void clearHistories();
void silentReset();
void toggleSmoothNormal();
void enableWeld(bool enabled);
void addMaterial(dust3d::Uuid materialId, QString name, std::vector<MaterialLayer>);
void removeMaterial(dust3d::Uuid materialId);
void setMaterialLayers(dust3d::Uuid materialId, std::vector<MaterialLayer> layers);
void renameMaterial(dust3d::Uuid materialId, QString name);
private:
void resolveSnapshotBoundingBox(const dust3d::Snapshot &snapshot, QRectF *mainProfile, QRectF *sideProfile);
void settleOrigin();
void checkExportReadyState();
bool m_isResultMeshObsolete = false;
MeshGenerator *m_meshGenerator = nullptr;
Model *m_resultMesh = nullptr;
bool m_isMeshGenerationSucceed = true;
int m_batchChangeRefCount = 0;
dust3d::Object *m_currentObject = nullptr;
bool m_isTextureObsolete = false;
TextureGenerator *m_textureGenerator = nullptr;
bool m_isPostProcessResultObsolete = false;
MeshResultPostProcessor *m_postProcessor = nullptr;
dust3d::Object *m_postProcessedObject = new dust3d::Object;
Model *m_resultTextureMesh = nullptr;
unsigned long long m_textureImageUpdateVersion = 0;
bool m_smoothNormal = false;
MaterialPreviewsGenerator *m_materialPreviewsGenerator = nullptr;
quint64 m_meshGenerationId = 0;
quint64 m_nextMeshGenerationId = 0;
void *m_generatedCacheContext = nullptr;
private:
static unsigned long m_maxSnapshot;
std::deque<HistoryItem> m_undoItems;
std::deque<HistoryItem> m_redoItems;
};
#endif

View File

@ -0,0 +1,77 @@
#include <set>
#include <QGuiApplication>
#include <QtCore/qbuffer.h>
#include <dust3d/base/ds3_file.h>
#include <dust3d/base/snapshot_xml.h>
#include "document_saver.h"
#include "image_forever.h"
DocumentSaver::DocumentSaver(const QString *filename,
dust3d::Snapshot *snapshot,
QByteArray *turnaroundPngByteArray) :
m_filename(filename),
m_snapshot(snapshot),
m_turnaroundPngByteArray(turnaroundPngByteArray)
{
}
DocumentSaver::~DocumentSaver()
{
delete m_snapshot;
delete m_turnaroundPngByteArray;
}
void DocumentSaver::process()
{
save(m_filename,
m_snapshot,
m_turnaroundPngByteArray);
emit finished();
}
void DocumentSaver::collectUsedResourceIds(const dust3d::Snapshot *snapshot,
std::set<dust3d::Uuid> &imageIds)
{
for (const auto &material: snapshot->materials) {
for (auto &layer: material.second) {
for (auto &mapItem: layer.second) {
auto findImageIdString = mapItem.find("linkData");
if (findImageIdString == mapItem.end())
continue;
dust3d::Uuid imageId = dust3d::Uuid(findImageIdString->second);
imageIds.insert(imageId);
}
}
}
}
bool DocumentSaver::save(const QString *filename,
dust3d::Snapshot *snapshot,
const QByteArray *turnaroundPngByteArray)
{
dust3d::Ds3FileWriter ds3Writer;
{
std::string modelXml;
saveSnapshotToXmlString(*snapshot, modelXml);
if (modelXml.size() > 0) {
ds3Writer.add("model.xml", "model", modelXml.c_str(), modelXml.size());
}
}
if (nullptr != turnaroundPngByteArray && turnaroundPngByteArray->size() > 0)
ds3Writer.add("canvas.png", "asset", turnaroundPngByteArray->data(), turnaroundPngByteArray->size());
std::set<dust3d::Uuid> imageIds;
collectUsedResourceIds(snapshot, imageIds);
for (const auto &imageId: imageIds) {
const QByteArray *pngByteArray = ImageForever::getPngByteArray(imageId);
if (nullptr == pngByteArray)
continue;
if (pngByteArray->size() > 0)
ds3Writer.add("images/" + imageId.toString() + ".png", "asset", pngByteArray->data(), pngByteArray->size());
}
return ds3Writer.save(filename->toUtf8().constData());
}

View File

@ -0,0 +1,35 @@
#ifndef DUST3D_APPLICATION_DOCUMENT_SAVER_H_
#define DUST3D_APPLICATION_DOCUMENT_SAVER_H_
#include <QString>
#include <QObject>
#include <QByteArray>
#include <map>
#include <set>
#include <dust3d/base/uuid.h>
#include <dust3d/base/snapshot.h>
class DocumentSaver : public QObject
{
Q_OBJECT
public:
DocumentSaver(const QString *filename,
dust3d::Snapshot *snapshot,
QByteArray *turnaroundPngByteArray);
~DocumentSaver();
static bool save(const QString *filename,
dust3d::Snapshot *snapshot,
const QByteArray *turnaroundPngByteArray);
static void collectUsedResourceIds(const dust3d::Snapshot *snapshot,
std::set<dust3d::Uuid> &imageIds);
signals:
void finished();
public slots:
void process();
private:
const QString *m_filename = nullptr;
dust3d::Snapshot *m_snapshot = nullptr;
QByteArray *m_turnaroundPngByteArray = nullptr;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,170 @@
#ifndef DUST3D_APPLICATION_DOCUMENT_WINDOW_H_
#define DUST3D_APPLICATION_DOCUMENT_WINDOW_H_
#include <QMainWindow>
#include <QShowEvent>
#include <QPushButton>
#include <QString>
#include <QMenu>
#include <QAction>
#include <map>
#include <QStringList>
#include <QLabel>
#include <QShortcut>
#include "model_widget.h"
#include "graphics_container_widget.h"
#include "part_preview_images_generator.h"
class Document;
class SkeletonGraphicsWidget;
class PartTreeWidget;
class ToolbarButton;
class SpinnableToolbarIcon;
class DocumentWindow : public QMainWindow
{
Q_OBJECT
signals:
void initialized();
void uninialized();
void waitingExportFinished(const QString &filename, bool isSuccessful);
public:
DocumentWindow();
~DocumentWindow();
Document *document();
ModelWidget *modelWidget();
static DocumentWindow *createDocumentWindow();
static const std::map<DocumentWindow *, dust3d::Uuid> &documentWindows();
static void showAcknowlegements();
static void showContributors();
static void showSupporters();
static void showAbout();
static size_t total();
protected:
void showEvent(QShowEvent *event);
void closeEvent(QCloseEvent *event);
void mousePressEvent(QMouseEvent *event);
public slots:
void changeTurnaround();
void save();
void saveTo(const QString &saveAsFilename);
void open();
void openExample(const QString &modelName);
void openPathAs(const QString &path, const QString &asName);
void exportObjResult();
void exportGlbResult();
void exportFbxResult();
void newWindow();
void newDocument();
void saveAs();
void saveAll();
void gotoHomepage();
void viewSource();
void about();
void checkForUpdates();
void reportIssues();
void seeAcknowlegements();
void seeContributors();
void seeSupporters();
void seeReferenceGuide();
void documentChanged();
void updateXlockButtonState();
void updateYlockButtonState();
void updateZlockButtonState();
void updateRadiusLockButtonState();
void registerDialog(QWidget *widget);
void unregisterDialog(QWidget *widget);
void showCutFaceSettingPopup(const QPoint &globalPos, std::set<dust3d::Uuid> nodeIds);
void setExportWaitingList(const QStringList &filenames);
void checkExportWaitingList();
void exportObjToFilename(const QString &filename);
void exportFbxToFilename(const QString &filename);
void exportGlbToFilename(const QString &filename);
void toggleRotation();
void generatePartPreviewImages();
void partPreviewImagesReady();
void updateInprogressIndicator();
void openRecentFile();
void updateRecentFileActions();
private:
void setCurrentFilename(const QString &filename);
void updateTitle();
void initializeShortcuts();
void initializeToolShortcuts(SkeletonGraphicsWidget *graphicsWidget);
void initializeCanvasShortcuts(SkeletonGraphicsWidget *graphicsWidget);
QShortcut *createShortcut(QKeySequence key);
QString strippedName(const QString &fullFileName);
bool openFiles(const QStringList &pathList);
Document *m_document = nullptr;
bool m_firstShow = true;
bool m_documentSaved = true;
std::vector<QWidget *> m_dialogs;
bool m_isLastMeshGenerationSucceed = true;
quint64 m_currentUpdatedMeshId = 0;
QStringList m_waitingForExportToFilenames;
QString m_currentFilename;
ModelWidget *m_modelRenderWidget = nullptr;
SkeletonGraphicsWidget *m_canvasGraphicsWidget = nullptr;
GraphicsContainerWidget *m_graphicsContainerWidget = nullptr;
QMenu *m_fileMenu = nullptr;
QAction *m_newWindowAction = nullptr;
QAction *m_newDocumentAction = nullptr;
QAction *m_openAction = nullptr;
QMenu *m_openExampleMenu = nullptr;
QAction *m_saveAction = nullptr;
QAction *m_saveAsAction = nullptr;
QAction *m_saveAllAction = nullptr;
QAction *m_changeTurnaroundAction = nullptr;
std::vector<QAction *> m_recentFileActions;
QAction *m_recentFileSeparatorAction = nullptr;
QAction *m_quitAction = nullptr;
QAction *m_exportAsObjAction = nullptr;
QAction *m_exportAsGlbAction = nullptr;
QAction *m_exportAsFbxAction = nullptr;
QMenu *m_viewMenu = nullptr;
QAction *m_toggleWireframeAction = nullptr;
QAction *m_toggleRotationAction = nullptr;
QAction *m_toggleColorAction = nullptr;
bool m_modelRemoveColor = false;
QMenu *m_windowMenu = nullptr;
QAction *m_showPartsListAction = nullptr;
QAction *m_showDebugDialogAction = nullptr;
QAction *m_showMaterialsAction = nullptr;
QMenu *m_helpMenu = nullptr;
QAction *m_gotoHomepageAction = nullptr;
QAction *m_viewSourceAction = nullptr;
QAction *m_aboutAction = nullptr;
QAction *m_checkForUpdatesAction = nullptr;
QAction *m_reportIssuesAction = nullptr;
QAction *m_seeContributorsAction = nullptr;
QAction *m_seeSupportersAction = nullptr;
QAction *m_seeAcknowlegementsAction = nullptr;
QAction *m_seeReferenceGuideAction = nullptr;
ToolbarButton *m_xLockButton = nullptr;
ToolbarButton *m_yLockButton = nullptr;
ToolbarButton *m_zLockButton = nullptr;
ToolbarButton *m_radiusLockButton = nullptr;
QMetaObject::Connection m_partListDockerVisibleSwitchConnection;
PartPreviewImagesGenerator *m_partPreviewImagesGenerator = nullptr;
bool m_isPartPreviewImagesObsolete = false;
PartTreeWidget *m_partTreeWidget = nullptr;
SpinnableToolbarIcon *m_inprogressIndicator = nullptr;
std::map<QKeySequence, QShortcut *> m_shortcutMap;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,54 @@
#ifndef DUST3D_APPLICATION_FBX_FILE_H_
#define DUST3D_APPLICATION_FBX_FILE_H_
#include <map>
#include <QString>
#include <QMatrix4x4>
#include <QQuaternion>
#include <QImage>
#include <dust3d/base/object.h>
#include "fbxdocument.h"
class FbxFileWriter : public QObject
{
Q_OBJECT
public:
FbxFileWriter(dust3d::Object &object,
const QString &filename,
QImage *textureImage=nullptr,
QImage *normalImage=nullptr,
QImage *metalnessImage=nullptr,
QImage *roughnessImage=nullptr,
QImage *ambientOcclusionImage=nullptr);
bool save();
private:
void createFbxHeader();
void createCreationTime();
void createFileId();
void createCreator();
void createGlobalSettings();
void createDocuments();
void createReferences();
void createDefinitions(size_t deformerCount,
size_t textureCount=0,
size_t videoCount=0,
bool hasAnimtion=false,
size_t animationStackCount=0,
size_t animationLayerCount=0,
size_t animationCurveNodeCount=0,
size_t animationCurveCount=0);
void createTakes();
std::vector<double> matrixToVector(const QMatrix4x4 &matrix);
int64_t secondsToKtime(double seconds);
int64_t m_next64Id = 612150000;
QString m_filename;
QString m_baseName;
fbx::FBXDocument m_fbxDocument;
std::map<QString, int64_t> m_uuidTo64Map;
static std::vector<double> m_identityMatrix;
};
#endif

View File

@ -0,0 +1,80 @@
#include <QtWidgets>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "theme.h"
#include "float_number_widget.h"
FloatNumberWidget::FloatNumberWidget(QWidget *parent, bool singleLine) :
QWidget(parent)
{
m_slider = new QSlider(Qt::Horizontal, this);
m_slider->setRange(0, 100);
m_slider->setFixedWidth(240);
m_label = new QLabel(this);
m_label->setAlignment(Qt::AlignLeft);
connect(m_slider, &QAbstractSlider::valueChanged, [=](int value) {
float fvalue = value / 100.0;
updateValueLabel(fvalue);
emit valueChanged(fvalue);
});
QBoxLayout *layout = nullptr;
if (singleLine) {
layout = new QHBoxLayout(this);
layout->setMargin(2);
layout->addWidget(m_slider);
layout->addWidget(m_label);
} else {
layout = new QVBoxLayout(this);
layout->setMargin(2);
layout->addWidget(m_label);
layout->addWidget(m_slider);
}
}
void FloatNumberWidget::setSliderFixedWidth(float width)
{
m_slider->setFixedWidth(width);
}
void FloatNumberWidget::updateValueLabel(float value)
{
QString valueString = QString().sprintf("%.2f", value);
if (m_itemName.isEmpty())
m_label->setText(valueString);
else
m_label->setText(m_itemName + ": " + valueString);
}
void FloatNumberWidget::setItemName(const QString &name)
{
m_itemName = name;
updateValueLabel(value());
}
void FloatNumberWidget::setRange(float min, float max)
{
m_slider->setRange(min * 100, max * 100);
}
void FloatNumberWidget::increaseValue()
{
m_slider->triggerAction(QSlider::SliderPageStepAdd);
}
void FloatNumberWidget::descreaseValue()
{
m_slider->triggerAction(QSlider::SliderPageStepSub);
}
float FloatNumberWidget::value() const
{
return m_slider->value() / 100.0;
}
void FloatNumberWidget::setValue(float value)
{
m_slider->setValue(value * 100);
}

View File

@ -0,0 +1,36 @@
#ifndef DUST3D_APPLICATION_FLOAT_NUMBER_WIDGET_H_
#define DUST3D_APPLICATION_FLOAT_NUMBER_WIDGET_H_
#include <QToolButton>
QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QSlider)
class FloatNumberWidget : public QWidget
{
Q_OBJECT
public:
explicit FloatNumberWidget(QWidget *parent=nullptr, bool singleLine=true);
void setRange(float min, float max);
float value() const;
void setItemName(const QString &name);
void setSliderFixedWidth(float width);
public slots:
void increaseValue();
void descreaseValue();
void setValue(float value);
signals:
void valueChanged(float value);
private:
void updateValueLabel(float value);
private:
QLabel *m_label = nullptr;
QSlider *m_slider = nullptr;
QString m_itemName;
};
#endif

View File

@ -0,0 +1,201 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtWidgets>
#include "flow_layout.h"
FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
}
FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing)
: m_hSpace(hSpacing), m_vSpace(vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
}
FlowLayout::~FlowLayout()
{
QLayoutItem *item;
while ((item = takeAt(0)))
delete item;
}
void FlowLayout::addItem(QLayoutItem *item)
{
itemList.append(item);
}
int FlowLayout::horizontalSpacing() const
{
if (m_hSpace >= 0) {
return m_hSpace;
} else {
return smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
}
}
int FlowLayout::verticalSpacing() const
{
if (m_vSpace >= 0) {
return m_vSpace;
} else {
return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
}
}
int FlowLayout::count() const
{
return itemList.size();
}
QLayoutItem *FlowLayout::itemAt(int index) const
{
return itemList.value(index);
}
QLayoutItem *FlowLayout::takeAt(int index)
{
if (index >= 0 && index < itemList.size())
return itemList.takeAt(index);
else
return 0;
}
Qt::Orientations FlowLayout::expandingDirections() const
{
return 0;
}
bool FlowLayout::hasHeightForWidth() const
{
return true;
}
int FlowLayout::heightForWidth(int width) const
{
int height = doLayout(QRect(0, 0, width, 0), true);
return height;
}
void FlowLayout::setGeometry(const QRect &rect)
{
QLayout::setGeometry(rect);
doLayout(rect, false);
}
QSize FlowLayout::sizeHint() const
{
return minimumSize();
}
QSize FlowLayout::minimumSize() const
{
QSize size;
QLayoutItem *item;
foreach (item, itemList)
size = size.expandedTo(item->minimumSize());
size += QSize(2*margin(), 2*margin());
return size;
}
int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
{
int left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
int x = effectiveRect.x();
int y = effectiveRect.y();
int lineHeight = 0;
QLayoutItem *item;
foreach (item, itemList) {
QWidget *wid = item->widget();
int spaceX = horizontalSpacing();
if (spaceX == -1)
spaceX = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
int spaceY = verticalSpacing();
if (spaceY == -1)
spaceY = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
int nextX = x + item->sizeHint().width() + spaceX;
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
x = effectiveRect.x();
y = y + lineHeight + spaceY;
nextX = x + item->sizeHint().width() + spaceX;
lineHeight = 0;
}
if (!testOnly)
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
x = nextX;
lineHeight = qMax(lineHeight, item->sizeHint().height());
}
return y + lineHeight - rect.y() + bottom;
}
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
{
QObject *parent = this->parent();
if (!parent) {
return -1;
} else if (parent->isWidgetType()) {
QWidget *pw = static_cast<QWidget *>(parent);
return pw->style()->pixelMetric(pm, 0, pw);
} else {
return static_cast<QLayout *>(parent)->spacing();
}
}

View File

@ -0,0 +1,87 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef DUST3D_APPLICATION_FLOWLAYOUT_H_
#define DUST3D_APPLICATION_FLOWLAYOUT_H_
#include <QLayout>
#include <QRect>
#include <QStyle>
class FlowLayout : public QLayout
{
public:
explicit FlowLayout(QWidget *parent, int margin=-1, int hSpacing=-1, int vSpacing=-1);
explicit FlowLayout(int margin=-1, int hSpacing=-1, int vSpacing=-1);
~FlowLayout();
void addItem(QLayoutItem *item) override;
int horizontalSpacing() const;
int verticalSpacing() const;
Qt::Orientations expandingDirections() const override;
bool hasHeightForWidth() const override;
int heightForWidth(int) const override;
int count() const override;
QLayoutItem *itemAt(int index) const override;
QSize minimumSize() const override;
void setGeometry(const QRect &rect) override;
QSize sizeHint() const override;
QLayoutItem *takeAt(int index) override;
private:
int doLayout(const QRect &rect, bool testOnly) const;
int smartSpacing(QStyle::PixelMetric pm) const;
QList<QLayoutItem *> itemList;
int m_hSpace;
int m_vSpace;
};
#endif

View File

@ -0,0 +1,336 @@
#include <QFile>
#include <QQuaternion>
#include <QByteArray>
#include <QDataStream>
#include <QFileInfo>
#include <QDir>
#include <QtCore/qbuffer.h>
#include "glb_file.h"
#include "version.h"
#include "model.h"
bool GlbFileWriter::m_enableComment = false;
GlbFileWriter::GlbFileWriter(dust3d::Object &object,
const QString &filename,
QImage *textureImage,
QImage *normalImage,
QImage *ormImage) :
m_filename(filename)
{
const std::vector<std::vector<dust3d::Vector3>> *triangleVertexNormals = object.triangleVertexNormals();
if (m_outputNormal) {
m_outputNormal = nullptr != triangleVertexNormals;
}
const std::vector<std::vector<dust3d::Vector2>> *triangleVertexUvs = object.triangleVertexUvs();
if (m_outputUv) {
m_outputUv = nullptr != triangleVertexUvs;
}
QDataStream binStream(&m_binByteArray, QIODevice::WriteOnly);
binStream.setFloatingPointPrecision(QDataStream::SinglePrecision);
binStream.setByteOrder(QDataStream::LittleEndian);
auto alignBin = [this, &binStream] {
while (0 != this->m_binByteArray.size() % 4) {
binStream << (quint8)0;
}
};
QDataStream jsonStream(&m_jsonByteArray, QIODevice::WriteOnly);
jsonStream.setFloatingPointPrecision(QDataStream::SinglePrecision);
jsonStream.setByteOrder(QDataStream::LittleEndian);
auto alignJson = [this, &jsonStream] {
while (0 != this->m_jsonByteArray.size() % 4) {
jsonStream << (quint8)' ';
}
};
int bufferViewIndex = 0;
int bufferViewFromOffset;
m_json["asset"]["version"] = "2.0";
m_json["asset"]["generator"] = APP_NAME " " APP_HUMAN_VER;
m_json["scenes"][0]["nodes"] = {0};
m_json["nodes"][0]["mesh"] = 0;
std::vector<dust3d::Vector3> triangleVertexPositions;
std::vector<size_t> triangleVertexOldIndices;
for (const auto &triangleIndices: object.triangles) {
for (size_t j = 0; j < 3; ++j) {
triangleVertexOldIndices.push_back(triangleIndices[j]);
triangleVertexPositions.push_back(object.vertices[triangleIndices[j]]);
}
}
int primitiveIndex = 0;
if (!triangleVertexPositions.empty()) {
m_json["meshes"][0]["primitives"][primitiveIndex]["indices"] = bufferViewIndex;
m_json["meshes"][0]["primitives"][primitiveIndex]["material"] = primitiveIndex;
int attributeIndex = 0;
m_json["meshes"][0]["primitives"][primitiveIndex]["attributes"]["POSITION"] = bufferViewIndex + (++attributeIndex);
if (m_outputNormal)
m_json["meshes"][0]["primitives"][primitiveIndex]["attributes"]["NORMAL"] = bufferViewIndex + (++attributeIndex);
if (m_outputUv)
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;
if (object.alphaEnabled)
m_json["materials"][primitiveIndex]["alphaMode"] = "BLEND";
if (normalImage) {
m_json["materials"][primitiveIndex]["normalTexture"]["index"] = textureIndex++;
}
if (ormImage) {
m_json["materials"][primitiveIndex]["occlusionTexture"]["index"] = textureIndex;
m_json["materials"][primitiveIndex]["pbrMetallicRoughness"]["metallicRoughnessTexture"]["index"] = textureIndex;
m_json["materials"][primitiveIndex]["pbrMetallicRoughness"]["metallicFactor"] = 1.0;
m_json["materials"][primitiveIndex]["pbrMetallicRoughness"]["roughnessFactor"] = 1.0;
textureIndex++;
}
primitiveIndex++;
bufferViewFromOffset = (int)m_binByteArray.size();
for (size_t index = 0; index < triangleVertexPositions.size(); index += 3) {
binStream << (quint16)index << (quint16)(index + 1) << (quint16)(index + 2);
}
m_json["bufferViews"][bufferViewIndex]["buffer"] = 0;
m_json["bufferViews"][bufferViewIndex]["byteOffset"] = bufferViewFromOffset;
m_json["bufferViews"][bufferViewIndex]["byteLength"] = (int)triangleVertexPositions.size() * sizeof(quint16);
m_json["bufferViews"][bufferViewIndex]["target"] = 34963;
Q_ASSERT((int)triangleVertexPositions.size() * sizeof(quint16) == m_binByteArray.size() - bufferViewFromOffset);
alignBin();
if (m_enableComment)
m_json["accessors"][bufferViewIndex]["__comment"] = QString("/accessors/%1: triangle indices").arg(QString::number(bufferViewIndex)).toUtf8().constData();
m_json["accessors"][bufferViewIndex]["bufferView"] = bufferViewIndex;
m_json["accessors"][bufferViewIndex]["byteOffset"] = 0;
m_json["accessors"][bufferViewIndex]["componentType"] = 5123;
m_json["accessors"][bufferViewIndex]["count"] = triangleVertexPositions.size();
m_json["accessors"][bufferViewIndex]["type"] = "SCALAR";
bufferViewIndex++;
bufferViewFromOffset = (int)m_binByteArray.size();
m_json["bufferViews"][bufferViewIndex]["buffer"] = 0;
m_json["bufferViews"][bufferViewIndex]["byteOffset"] = bufferViewFromOffset;
float minX = 100;
float maxX = -100;
float minY = 100;
float maxY = -100;
float minZ = 100;
float maxZ = -100;
for (const auto &position: triangleVertexPositions) {
if (position.x() < minX)
minX = position.x();
if (position.x() > maxX)
maxX = position.x();
if (position.y() < minY)
minY = position.y();
if (position.y() > maxY)
maxY = position.y();
if (position.z() < minZ)
minZ = position.z();
if (position.z() > maxZ)
maxZ = position.z();
binStream << (float)position.x() << (float)position.y() << (float)position.z();
}
Q_ASSERT((int)triangleVertexPositions.size() * 3 * sizeof(float) == m_binByteArray.size() - bufferViewFromOffset);
m_json["bufferViews"][bufferViewIndex]["byteLength"] = triangleVertexPositions.size() * 3 * sizeof(float);
m_json["bufferViews"][bufferViewIndex]["target"] = 34962;
alignBin();
if (m_enableComment)
m_json["accessors"][bufferViewIndex]["__comment"] = QString("/accessors/%1: xyz").arg(QString::number(bufferViewIndex)).toUtf8().constData();
m_json["accessors"][bufferViewIndex]["bufferView"] = bufferViewIndex;
m_json["accessors"][bufferViewIndex]["byteOffset"] = 0;
m_json["accessors"][bufferViewIndex]["componentType"] = 5126;
m_json["accessors"][bufferViewIndex]["count"] = triangleVertexPositions.size();
m_json["accessors"][bufferViewIndex]["type"] = "VEC3";
m_json["accessors"][bufferViewIndex]["max"] = {maxX, maxY, maxZ};
m_json["accessors"][bufferViewIndex]["min"] = {minX, minY, minZ};
bufferViewIndex++;
if (m_outputNormal) {
bufferViewFromOffset = (int)m_binByteArray.size();
m_json["bufferViews"][bufferViewIndex]["buffer"] = 0;
m_json["bufferViews"][bufferViewIndex]["byteOffset"] = bufferViewFromOffset;
QStringList normalList;
for (const auto &normals: (*triangleVertexNormals)) {
for (const auto &it: normals) {
binStream << (float)it.x() << (float)it.y() << (float)it.z();
if (m_enableComment && m_outputNormal)
normalList.append(QString("<%1,%2,%3>").arg(QString::number(it.x())).arg(QString::number(it.y())).arg(QString::number(it.z())));
}
}
Q_ASSERT((int)triangleVertexNormals->size() * 3 * 3 * sizeof(float) == m_binByteArray.size() - bufferViewFromOffset);
m_json["bufferViews"][bufferViewIndex]["byteLength"] = triangleVertexNormals->size() * 3 * 3 * sizeof(float);
m_json["bufferViews"][bufferViewIndex]["target"] = 34962;
alignBin();
if (m_enableComment)
m_json["accessors"][bufferViewIndex]["__comment"] = QString("/accessors/%1: normal %2").arg(QString::number(bufferViewIndex)).arg(normalList.join(" ")).toUtf8().constData();
m_json["accessors"][bufferViewIndex]["bufferView"] = bufferViewIndex;
m_json["accessors"][bufferViewIndex]["byteOffset"] = 0;
m_json["accessors"][bufferViewIndex]["componentType"] = 5126;
m_json["accessors"][bufferViewIndex]["count"] = triangleVertexNormals->size() * 3;
m_json["accessors"][bufferViewIndex]["type"] = "VEC3";
bufferViewIndex++;
}
if (m_outputUv) {
bufferViewFromOffset = (int)m_binByteArray.size();
m_json["bufferViews"][bufferViewIndex]["buffer"] = 0;
m_json["bufferViews"][bufferViewIndex]["byteOffset"] = bufferViewFromOffset;
for (const auto &uvs: (*triangleVertexUvs)) {
for (const auto &it: uvs)
binStream << (float)it.x() << (float)it.y();
}
m_json["bufferViews"][bufferViewIndex]["byteLength"] = m_binByteArray.size() - bufferViewFromOffset;
alignBin();
if (m_enableComment)
m_json["accessors"][bufferViewIndex]["__comment"] = QString("/accessors/%1: uv").arg(QString::number(bufferViewIndex)).toUtf8().constData();
m_json["accessors"][bufferViewIndex]["bufferView"] = bufferViewIndex;
m_json["accessors"][bufferViewIndex]["byteOffset"] = 0;
m_json["accessors"][bufferViewIndex]["componentType"] = 5126;
m_json["accessors"][bufferViewIndex]["count"] = triangleVertexUvs->size() * 3;
m_json["accessors"][bufferViewIndex]["type"] = "VEC2";
bufferViewIndex++;
}
}
m_json["samplers"][0]["magFilter"] = 9729;
m_json["samplers"][0]["minFilter"] = 9987;
m_json["samplers"][0]["wrapS"] = 33648;
m_json["samplers"][0]["wrapT"] = 33648;
int imageIndex = 0;
int textureIndex = 0;
// Images should be put in the end of the buffer, because we are not using accessors
if (nullptr != textureImage) {
m_json["textures"][textureIndex]["sampler"] = 0;
m_json["textures"][textureIndex]["source"] = imageIndex;
bufferViewFromOffset = (int)m_binByteArray.size();
m_json["bufferViews"][bufferViewIndex]["buffer"] = 0;
m_json["bufferViews"][bufferViewIndex]["byteOffset"] = bufferViewFromOffset;
QByteArray pngByteArray;
QBuffer buffer(&pngByteArray);
textureImage->save(&buffer, "PNG");
binStream.writeRawData(pngByteArray.data(), pngByteArray.size());
alignBin();
m_json["bufferViews"][bufferViewIndex]["byteLength"] = m_binByteArray.size() - bufferViewFromOffset;
m_json["images"][imageIndex]["bufferView"] = bufferViewIndex;
m_json["images"][imageIndex]["mimeType"] = "image/png";
bufferViewIndex++;
imageIndex++;
textureIndex++;
}
if (nullptr != normalImage) {
m_json["textures"][textureIndex]["sampler"] = 0;
m_json["textures"][textureIndex]["source"] = imageIndex;
bufferViewFromOffset = (int)m_binByteArray.size();
m_json["bufferViews"][bufferViewIndex]["buffer"] = 0;
m_json["bufferViews"][bufferViewIndex]["byteOffset"] = bufferViewFromOffset;
QByteArray pngByteArray;
QBuffer buffer(&pngByteArray);
normalImage->save(&buffer, "PNG");
binStream.writeRawData(pngByteArray.data(), pngByteArray.size());
alignBin();
m_json["bufferViews"][bufferViewIndex]["byteLength"] = m_binByteArray.size() - bufferViewFromOffset;
m_json["images"][imageIndex]["bufferView"] = bufferViewIndex;
m_json["images"][imageIndex]["mimeType"] = "image/png";
bufferViewIndex++;
imageIndex++;
textureIndex++;
}
if (nullptr != ormImage) {
m_json["textures"][textureIndex]["sampler"] = 0;
m_json["textures"][textureIndex]["source"] = imageIndex;
bufferViewFromOffset = (int)m_binByteArray.size();
m_json["bufferViews"][bufferViewIndex]["buffer"] = 0;
m_json["bufferViews"][bufferViewIndex]["byteOffset"] = bufferViewFromOffset;
QByteArray pngByteArray;
QBuffer buffer(&pngByteArray);
ormImage->save(&buffer, "PNG");
binStream.writeRawData(pngByteArray.data(), pngByteArray.size());
alignBin();
m_json["bufferViews"][bufferViewIndex]["byteLength"] = m_binByteArray.size() - bufferViewFromOffset;
m_json["images"][imageIndex]["bufferView"] = bufferViewIndex;
m_json["images"][imageIndex]["mimeType"] = "image/png";
bufferViewIndex++;
imageIndex++;
textureIndex++;
}
m_json["buffers"][0]["byteLength"] = m_binByteArray.size();
auto jsonString = m_enableComment ? m_json.dump(4) : m_json.dump();
jsonStream.writeRawData(jsonString.data(), jsonString.size());
alignJson();
}
bool GlbFileWriter::save()
{
QFile file(m_filename);
if (!file.open(QIODevice::WriteOnly)) {
return false;
}
QDataStream output(&file);
output.setFloatingPointPrecision(QDataStream::SinglePrecision);
output.setByteOrder(QDataStream::LittleEndian);
uint32_t headerSize = 12;
uint32_t chunk0DescriptionSize = 8;
uint32_t chunk1DescriptionSize = 8;
uint32_t fileSize = headerSize +
chunk0DescriptionSize + m_jsonByteArray.size() +
chunk1DescriptionSize + m_binByteArray.size();
qDebug() << "Chunk 0 data size:" << m_jsonByteArray.size();
qDebug() << "Chunk 1 data size:" << m_binByteArray.size();
qDebug() << "File size:" << fileSize;
//////////// Header ////////////
// magic
output << (uint32_t)0x46546C67;
// version
output << (uint32_t)0x00000002;
// length
output << (uint32_t)fileSize;
//////////// Chunk 0 (Json) ////////////
// length
output << (uint32_t)m_jsonByteArray.size();
// type
output << (uint32_t)0x4E4F534A;
// data
output.writeRawData(m_jsonByteArray.data(), m_jsonByteArray.size());
//////////// Chunk 1 (Binary Buffer) ///
// length
output << (uint32_t)m_binByteArray.size();
// type
output << (uint32_t)0x004E4942;
// data
output.writeRawData(m_binByteArray.data(), m_binByteArray.size());
return true;
}

View File

@ -0,0 +1,37 @@
#ifndef DUST3D_APPLICATION_GLB_FILE_H_
#define DUST3D_APPLICATION_GLB_FILE_H_
#include <QObject>
#include <QString>
#include <QByteArray>
#include <QMatrix4x4>
#include <vector>
#include <QQuaternion>
#include <QImage>
#include <dust3d/base/object.h>
#include "json.hpp"
#include "document.h"
class GlbFileWriter : public QObject
{
Q_OBJECT
public:
GlbFileWriter(dust3d::Object &object,
const QString &filename,
QImage *textureImage=nullptr,
QImage *normalImage=nullptr,
QImage *ormImage=nullptr);
bool save();
private:
QString m_filename;
bool m_outputNormal = true;
bool m_outputUv = true;
QByteArray m_binByteArray;
QByteArray m_jsonByteArray;
private:
nlohmann::json m_json;
public:
static bool m_enableComment;
};
#endif

View File

@ -0,0 +1,51 @@
#include "graphics_container_widget.h"
GraphicsContainerWidget::GraphicsContainerWidget()
{
setMouseTracking(true);
}
void GraphicsContainerWidget::resizeEvent(QResizeEvent *event)
{
if (m_graphicsWidget && m_graphicsWidget->size() != event->size())
emit containerSizeChanged(event->size());
}
void GraphicsContainerWidget::mousePressEvent(QMouseEvent *event)
{
if (m_modelWidget)
m_modelWidget->inputMousePressEventFromOtherWidget(event);
}
void GraphicsContainerWidget::mouseMoveEvent(QMouseEvent *event)
{
if (m_modelWidget)
m_modelWidget->inputMouseMoveEventFromOtherWidget(event);
}
void GraphicsContainerWidget::mouseReleaseEvent(QMouseEvent *event)
{
if (m_modelWidget)
m_modelWidget->inputMouseReleaseEventFromOtherWidget(event);
}
void GraphicsContainerWidget::wheelEvent(QWheelEvent *event)
{
if (m_graphicsWidget) {
m_graphicsWidget->inputWheelEventFromOtherWidget(event);
return;
}
if (m_modelWidget)
m_modelWidget->inputWheelEventFromOtherWidget(event);
}
void GraphicsContainerWidget::setGraphicsWidget(SkeletonGraphicsWidget *graphicsWidget)
{
m_graphicsWidget = graphicsWidget;
}
void GraphicsContainerWidget::setModelWidget(ModelWidget *modelWidget)
{
m_modelWidget = modelWidget;
}

View File

@ -0,0 +1,31 @@
#ifndef DUST3D_APPLICATION_GRAPHICS_CONTAINER_WIDGET_H_
#define DUST3D_APPLICATION_GRAPHICS_CONTAINER_WIDGET_H_
#include <QWidget>
#include <QResizeEvent>
#include <QMouseEvent>
#include <QWheelEvent>
#include "model_widget.h"
#include "skeleton_graphics_widget.h"
class GraphicsContainerWidget : public QWidget
{
Q_OBJECT
signals:
void containerSizeChanged(QSize size);
public:
GraphicsContainerWidget();
void setGraphicsWidget(SkeletonGraphicsWidget *graphicsWidget);
void setModelWidget(ModelWidget *modelWidget);
protected:
void resizeEvent(QResizeEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
private:
ModelWidget *m_modelWidget = nullptr;
SkeletonGraphicsWidget *m_graphicsWidget = nullptr;
};
#endif

View File

@ -0,0 +1,10 @@
#include "horizontal_line_widget.h"
HorizontalLineWidget::HorizontalLineWidget() :
QWidget()
{
setFixedHeight(1);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setStyleSheet(QString("background-color: #565656;"));
setContentsMargins(0, 0, 0, 0);
}

View File

@ -0,0 +1,13 @@
#ifndef DUST3D_APPLICATION_HORIZONTAL_LINE_WIDGET_H_
#define DUST3D_APPLICATION_HORIZONTAL_LINE_WIDGET_H_
#include <QWidget>
class HorizontalLineWidget : public QWidget
{
Q_OBJECT
public:
HorizontalLineWidget();
};
#endif

View File

@ -0,0 +1,69 @@
#include <map>
#include <QMutex>
#include <QMutexLocker>
#include <QtCore/qbuffer.h>
#include "image_forever.h"
struct ImageForeverItem
{
QImage *image;
dust3d::Uuid id;
QByteArray *imageByteArray;
};
static std::map<dust3d::Uuid, ImageForeverItem> g_foreverMap;
static QMutex g_mapMutex;
const QImage *ImageForever::get(const dust3d::Uuid &id)
{
QMutexLocker locker(&g_mapMutex);
auto findResult = g_foreverMap.find(id);
if (findResult == g_foreverMap.end())
return nullptr;
return findResult->second.image;
}
void ImageForever::copy(const dust3d::Uuid &id, QImage &image)
{
QMutexLocker locker(&g_mapMutex);
auto findResult = g_foreverMap.find(id);
if (findResult == g_foreverMap.end())
return;
image = *findResult->second.image;
}
const QByteArray *ImageForever::getPngByteArray(const dust3d::Uuid &id)
{
QMutexLocker locker(&g_mapMutex);
auto findResult = g_foreverMap.find(id);
if (findResult == g_foreverMap.end())
return nullptr;
return findResult->second.imageByteArray;
}
dust3d::Uuid ImageForever::add(const QImage *image, dust3d::Uuid toId)
{
QMutexLocker locker(&g_mapMutex);
if (nullptr == image)
return dust3d::Uuid();
dust3d::Uuid newId = toId.isNull() ? dust3d::Uuid::createUuid() : toId;
if (g_foreverMap.find(newId) != g_foreverMap.end())
return newId;
QImage *newImage = new QImage(*image);
QByteArray *imageByteArray = new QByteArray();
QBuffer pngBuffer(imageByteArray);
pngBuffer.open(QIODevice::WriteOnly);
newImage->save(&pngBuffer, "PNG");
g_foreverMap[newId] = {newImage, newId, imageByteArray};
return newId;
}
void ImageForever::remove(const dust3d::Uuid &id)
{
QMutexLocker locker(&g_mapMutex);
auto findImage = g_foreverMap.find(id);
if (findImage == g_foreverMap.end())
return;
delete findImage->second.image;
delete findImage->second.imageByteArray;
g_foreverMap.erase(id);
}

View File

@ -0,0 +1,18 @@
#ifndef DUST3D_APPLICATION_IMAGE_FOREVER_H_
#define DUST3D_APPLICATION_IMAGE_FOREVER_H_
#include <QImage>
#include <QByteArray>
#include <dust3d/base/uuid.h>
class ImageForever
{
public:
static const QImage *get(const dust3d::Uuid &id);
static void copy(const dust3d::Uuid &id, QImage &image);
static const QByteArray *getPngByteArray(const dust3d::Uuid &id);
static dust3d::Uuid add(const QImage *image, dust3d::Uuid toId=dust3d::Uuid());
static void remove(const dust3d::Uuid &id);
};
#endif

View File

@ -0,0 +1,33 @@
#include <QPainter>
#include "image_preview_widget.h"
ImagePreviewWidget::ImagePreviewWidget(QWidget *parent) :
QWidget(parent)
{
}
void ImagePreviewWidget::updateImage(const QImage &image)
{
m_image = image;
update();
}
void ImagePreviewWidget::updateBackgroundColor(const QColor &color)
{
m_backgroundColor = color;
}
void ImagePreviewWidget::mousePressEvent(QMouseEvent *event)
{
emit clicked();
}
void ImagePreviewWidget::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
if (!m_image.isNull())
painter.drawImage(QRect(0, 0, width(), height()), m_image, QRect(0, 0, m_image.width(), m_image.height()));
else
painter.fillRect(QRect(0, 0, width(), height()), QBrush(m_backgroundColor));
}

View File

@ -0,0 +1,30 @@
#ifndef DUST3D_APPLICATION_IMAGE_PREVIEW_WIDGET_H_
#define DUST3D_APPLICATION_IMAGE_PREVIEW_WIDGET_H_
#include <QWidget>
#include <QImage>
#include <QPaintEvent>
#include <QMouseEvent>
class ImagePreviewWidget : public QWidget
{
Q_OBJECT
signals:
void clicked();
public:
ImagePreviewWidget(QWidget *parent=nullptr);
void updateImage(const QImage &image);
void updateBackgroundColor(const QColor &color);
protected:
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
private:
QImage m_image;
QColor m_backgroundColor;
void resizeImage(QImage *image, const QSize &newSize);
};
#endif

View File

@ -0,0 +1,25 @@
#include <QHBoxLayout>
#include "info_label.h"
#include "theme.h"
InfoLabel::InfoLabel(const QString &text, QWidget *parent) :
QWidget(parent)
{
m_icon = new QLabel(QChar(fa::infocircle));
Theme::initAwesomeLabel(m_icon);
m_label = new QLabel(text);
m_label->setWordWrap(true);
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(m_icon);
mainLayout->addWidget(m_label);
mainLayout->addStretch();
setLayout(mainLayout);
}
void InfoLabel::setText(const QString &text)
{
m_label->setText(text);
}

View File

@ -0,0 +1,18 @@
#ifndef DUST3D_APPLICATION_INFO_LABEL_H_
#define DUST3D_APPLICATION_INFO_LABEL_H_
#include <QLabel>
#include <QIcon>
#include <QWidget>
class InfoLabel : public QWidget
{
public:
InfoLabel(const QString &text=QString(), QWidget *parent=nullptr);
void setText(const QString &text);
private:
QLabel *m_label = nullptr;
QLabel *m_icon = nullptr;
};
#endif

View File

@ -0,0 +1,74 @@
#include <QtWidgets>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "theme.h"
#include "int_number_widget.h"
IntNumberWidget::IntNumberWidget(QWidget *parent, bool singleLine) :
QWidget(parent)
{
m_slider = new QSlider(Qt::Horizontal, this);
m_slider->setRange(0, 100);
m_slider->setFixedWidth(240);
m_label = new QLabel(this);
m_label->setAlignment(Qt::AlignLeft);
connect(m_slider, &QAbstractSlider::valueChanged, [=](int value) {
updateValueLabel(value);
emit valueChanged(value);
});
QBoxLayout *layout = nullptr;
if (singleLine) {
layout = new QHBoxLayout(this);
layout->setMargin(2);
layout->addWidget(m_slider);
layout->addWidget(m_label);
} else {
layout = new QVBoxLayout(this);
layout->setMargin(2);
layout->addWidget(m_label);
layout->addWidget(m_slider);
}
}
void IntNumberWidget::updateValueLabel(int value)
{
QString valueString = QString::number(value);
if (m_itemName.isEmpty())
m_label->setText(valueString);
else
m_label->setText(m_itemName + ": " + valueString);
}
void IntNumberWidget::setItemName(const QString &name)
{
m_itemName = name;
updateValueLabel(value());
}
void IntNumberWidget::setRange(int min, int max)
{
m_slider->setRange(min, max);
}
void IntNumberWidget::increaseValue()
{
m_slider->triggerAction(QSlider::SliderPageStepAdd);
}
void IntNumberWidget::descreaseValue()
{
m_slider->triggerAction(QSlider::SliderPageStepSub);
}
int IntNumberWidget::value() const
{
return m_slider->value();
}
void IntNumberWidget::setValue(int value)
{
m_slider->setValue(value);
}

View File

@ -0,0 +1,35 @@
#ifndef DUST3D_APPLICATION_INT_NUMBER_WIDGET_H_
#define DUST3D_APPLICATION_INT_NUMBER_WIDGET_H_
#include <QToolButton>
QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QSlider)
class IntNumberWidget : public QWidget
{
Q_OBJECT
public:
explicit IntNumberWidget(QWidget *parent = nullptr, bool singleLine=true);
void setRange(int min, int max);
int value() const;
void setItemName(const QString &name);
public slots:
void increaseValue();
void descreaseValue();
void setValue(int value);
signals:
void valueChanged(int value);
private:
void updateValueLabel(int value);
private:
QLabel *m_label = nullptr;
QSlider *m_slider = nullptr;
QString m_itemName;
};
#endif

View File

@ -0,0 +1,52 @@
#include <QMetaType>
#include <QDir>
#include "log_browser.h"
#include "log_browser_dialog.h"
bool LogBrowser::m_enableOutputToFile = true;
LogBrowser::LogBrowser(QObject *parent) :
QObject(parent)
{
qRegisterMetaType<QtMsgType>("QtMsgType");
m_browserDialog = new LogBrowserDialog;
connect(this, &LogBrowser::sendMessage, m_browserDialog, &LogBrowserDialog::outputMessage, Qt::QueuedConnection);
if (m_enableOutputToFile) {
QString filePath = "application.log";
m_outputTo = fopen(filePath.toUtf8().constData(), "w");
}
}
LogBrowser::~LogBrowser()
{
delete m_browserDialog;
if (m_outputTo)
fclose(m_outputTo);
}
void LogBrowser::showDialog()
{
m_browserDialog->show();
m_browserDialog->activateWindow();
m_browserDialog->raise();
}
void LogBrowser::hideDialog()
{
m_browserDialog->hide();
}
bool LogBrowser::isDialogVisible()
{
return m_browserDialog->isVisible();
}
void LogBrowser::outputMessage(QtMsgType type, const QString &msg, const QString &source, int line)
{
if (m_outputTo) {
fprintf(m_outputTo, "[%s:%d]: %s\n", source.toUtf8().constData(), line, msg.toUtf8().constData());
fflush(m_outputTo);
}
emit sendMessage(type, msg, source, line);
}

View File

@ -0,0 +1,31 @@
#ifndef DUST3D_APPLICATION_LOG_BROWSER_H_
#define DUST3D_APPLICATION_LOG_BROWSER_H_
#include <QObject>
#include <cstdio>
class LogBrowserDialog;
class LogBrowser : public QObject
{
Q_OBJECT
public:
explicit LogBrowser(QObject *parent=0);
~LogBrowser();
public slots:
void outputMessage(QtMsgType type, const QString &msg, const QString &source, int line);
void showDialog();
void hideDialog();
bool isDialogVisible();
signals:
void sendMessage(QtMsgType type, const QString &msg, const QString &source, int line);
private:
LogBrowserDialog *m_browserDialog = nullptr;
FILE *m_outputTo = nullptr;
static bool m_enableOutputToFile;
};
#endif

View File

@ -0,0 +1,121 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QTextBrowser>
#include <QPushButton>
#include <QFileDialog>
#include <QDir>
#include <QFile>
#include <QMessageBox>
#include <QTextStream>
#include <QCloseEvent>
#include <QKeyEvent>
#include "version.h"
#include "log_browser_dialog.h"
#include "document_window.h"
LogBrowserDialog::LogBrowserDialog(QWidget *parent) :
QDialog(parent)
{
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
QVBoxLayout *layout = new QVBoxLayout;
setLayout(layout);
m_browser = new QTextBrowser(this);
layout->addWidget(m_browser);
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->setContentsMargins(0, 0, 0, 0);
layout->addLayout(buttonLayout);
buttonLayout->addStretch(10);
m_clearButton = new QPushButton(this);
m_clearButton->setText("Clear");
buttonLayout->addWidget(m_clearButton);
connect(m_clearButton, SIGNAL(clicked()), m_browser, SLOT(clear()));
m_saveButton = new QPushButton(this);
m_saveButton->setText("Save Output");
buttonLayout->addWidget(m_saveButton);
connect(m_saveButton, SIGNAL(clicked()), this, SLOT(save()));
resize(600, 300);
setWindowTitle(applicationTitle(tr("Debug")));
hide();
}
LogBrowserDialog::~LogBrowserDialog()
{
}
void LogBrowserDialog::outputMessage(QtMsgType type, const QString &msg, const QString &source, int line)
{
switch (type) {
case QtDebugMsg:
m_browser->append(tr("— DEBUG: %1 - %2:%3").arg(msg).arg(source).arg(QString::number(line)));
break;
case QtWarningMsg:
m_browser->append(tr("— WARNING: %1 - %2:%3").arg(msg).arg(source).arg(QString::number(line)));
break;
case QtCriticalMsg:
m_browser->append(tr("— CRITICAL: %1 - %2:%3").arg(msg).arg(source).arg(QString::number(line)));
break;
case QtInfoMsg:
m_browser->append(tr("— INFO: %1 - %2:%3").arg(msg).arg(source).arg(QString::number(line)));
break;
case QtFatalMsg:
m_browser->append(tr("— FATAL: %1 - %2:%3").arg(msg).arg(source).arg(QString::number(line)));
break;
}
}
void LogBrowserDialog::save()
{
QString saveFileName = QFileDialog::getSaveFileName(this,
tr("Save Log Output"),
tr("%1/logfile.txt").arg(QDir::homePath()),
tr("Text Files (*.txt);;All Files (*)"));
if (saveFileName.isEmpty())
return;
QFile file(saveFileName);
if (!file.open(QIODevice::WriteOnly)) {
QMessageBox::warning(this,
tr("Error"),
QString(tr("<nobr>File '%1'<br/>cannot be opened for writing.<br/><br/>"
"The log output could <b>not</b> be saved!</nobr>"))
.arg(saveFileName));
return;
}
QTextStream stream(&file);
stream << m_browser->toPlainText();
file.close();
}
void LogBrowserDialog::closeEvent(QCloseEvent *e)
{
if (0 == DocumentWindow::total()) {
e->accept();
return;
}
e->ignore();
hide();
}
void LogBrowserDialog::keyPressEvent(QKeyEvent *e)
{
e->ignore();
}

View File

@ -0,0 +1,31 @@
#ifndef DUST3D_APPLICATION_LOG_BROWSER_DIALOG_H_
#define DUST3D_APPLICATION_LOG_BROWSER_DIALOG_H_
#include <QDialog>
class QTextBrowser;
class QPushButton;
class LogBrowserDialog : public QDialog
{
Q_OBJECT
public:
LogBrowserDialog(QWidget *parent = 0);
~LogBrowserDialog();
public slots:
void outputMessage(QtMsgType type, const QString &msg, const QString &source, int line);
protected slots:
void save();
protected:
virtual void keyPressEvent(QKeyEvent *e);
virtual void closeEvent(QCloseEvent *e);
QTextBrowser *m_browser;
QPushButton *m_clearButton;
QPushButton *m_saveButton;
};
#endif

View File

@ -0,0 +1,31 @@
#include <QApplication>
#include <QSurfaceFormat>
#include <QDebug>
#include <iostream>
#include <cstdio>
#include "document_window.h"
#include "theme.h"
#include "version.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
format.setVersion(3, 3);
QSurfaceFormat::setDefaultFormat(format);
Theme::initialize();
QCoreApplication::setApplicationName(APP_NAME);
QCoreApplication::setOrganizationName(APP_COMPANY);
QCoreApplication::setOrganizationDomain(APP_HOMEPAGE_URL);
freopen("dust3d.log", "w", stdout);
setvbuf(stdout, 0, _IONBF, 0);
DocumentWindow *firstWindow = DocumentWindow::createDocumentWindow();
return app.exec();
}

View File

@ -0,0 +1,34 @@
#include "material.h"
#include "image_forever.h"
void initializeMaterialTexturesFromSnapshot(const dust3d::Snapshot &snapshot,
const dust3d::Uuid &materialId,
MaterialTextures &materialTextures,
float &tileScale)
{
auto materialIdString = materialId.toString();
for (const auto &materialItem: snapshot.materials) {
if (materialIdString != dust3d::String::valueOrEmpty(materialItem.first, "id"))
continue;
for (const auto &layer: materialItem.second) {
//FIXME: Only support one layer currently
auto findTileScale = layer.first.find("tileScale");
if (findTileScale != layer.first.end())
tileScale = dust3d::String::toFloat(findTileScale->second);
for (const auto &mapItem: layer.second) {
auto textureType = dust3d::TextureTypeFromString(dust3d::String::valueOrEmpty(mapItem, "for").c_str());
if (textureType != dust3d::TextureType::None) {
int index = (int)textureType - 1;
if (index >= 0 && index < (int)dust3d::TextureType::Count - 1) {
if ("imageId" == dust3d::String::valueOrEmpty(mapItem, "linkDataType")) {
auto imageIdString = dust3d::String::valueOrEmpty(mapItem, "linkData");
materialTextures.textureImages[index] = ImageForever::get(dust3d::Uuid(imageIdString));
}
}
}
}
break;
}
break;
}
}

View File

@ -0,0 +1,19 @@
#ifndef DUST3D_APPLICATION_MATERIAL_H_
#define DUST3D_APPLICATION_MATERIAL_H_
#include <QImage>
#include <dust3d/base/uuid.h>
#include <dust3d/base/texture_type.h>
#include <dust3d/base/snapshot.h>
struct MaterialTextures
{
const QImage *textureImages[(int)dust3d::TextureType::Count - 1] = {nullptr};
};
void initializeMaterialTexturesFromSnapshot(const dust3d::Snapshot &snapshot,
const dust3d::Uuid &materialId,
MaterialTextures &materialTextures,
float &tileScale);
#endif

View File

@ -0,0 +1,336 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QFormLayout>
#include <QGridLayout>
#include <QMenu>
#include <QWidgetAction>
#include <QLineEdit>
#include <QMessageBox>
#include <QFileDialog>
#include <QLabel>
#include <QThread>
#include "theme.h"
#include "material_edit_widget.h"
#include "float_number_widget.h"
#include "version.h"
#include "image_forever.h"
#include "document.h"
#include "horizontal_line_widget.h"
ImagePreviewWidget *MaterialEditWidget::createMapButton()
{
ImagePreviewWidget *mapButton = new ImagePreviewWidget;
mapButton->setFixedSize(Theme::partPreviewImageSize * 2, Theme::partPreviewImageSize * 2);
updateMapButtonBackground(mapButton, nullptr);
return mapButton;
}
QImage *MaterialEditWidget::pickImage()
{
QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(),
tr("Image Files (*.png *.jpg *.bmp)")).trimmed();
if (fileName.isEmpty())
return nullptr;
QImage *image = new QImage();
if (!image->load(fileName))
return nullptr;
return image;
}
MaterialEditWidget::MaterialEditWidget(const Document *document, QWidget *parent) :
QDialog(parent),
m_document(document)
{
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
m_layers.resize(1);
m_previewWidget = new ModelWidget(this);
m_previewWidget->setMinimumSize(128, 128);
m_previewWidget->resize(512, 512);
m_previewWidget->move(-128, -128);
m_previewWidget->enableEnvironmentLight();
m_previewWidget->setNotGraphics(true);
QFont nameFont;
nameFont.setWeight(QFont::Light);
nameFont.setBold(false);
QGridLayout *mapLayout = new QGridLayout;
int row = 0;
int col = 0;
for (int i = 1; i < (int)dust3d::TextureType::Count; i++) {
QVBoxLayout *textureManageLayout = new QVBoxLayout;
MaterialMap item;
item.forWhat = (dust3d::TextureType)i;
m_layers[0].maps.push_back(item);
ImagePreviewWidget *imageButton = createMapButton();
connect(imageButton, &ImagePreviewWidget::clicked, [=]() {
QImage *image = pickImage();
if (nullptr == image)
return;
m_layers[0].maps[(int)i - 1].imageId = ImageForever::add(image);
updateMapButtonBackground(imageButton, image);
delete image;
emit layersAdjusted();
});
QLabel *nameLabel = new QLabel(tr(dust3d::TextureTypeToDispName(item.forWhat).c_str()));
nameLabel->setFont(nameFont);
QPushButton *eraser = new QPushButton(QChar(fa::eraser));
Theme::initAwesomeToolButton(eraser);
connect(eraser, &QPushButton::clicked, [=]() {
m_layers[0].maps[(int)i - 1].imageId = dust3d::Uuid();
updateMapButtonBackground(imageButton, nullptr);
emit layersAdjusted();
});
QHBoxLayout *textureTitleLayout = new QHBoxLayout;
textureTitleLayout->addWidget(eraser);
textureTitleLayout->addWidget(nameLabel);
textureTitleLayout->addStretch();
textureManageLayout->addWidget(imageButton);
textureManageLayout->addLayout(textureTitleLayout);
m_textureMapButtons[i - 1] = imageButton;
mapLayout->addLayout(textureManageLayout, row, col++);
if (col == 2) {
col = 0;
row++;
}
}
QVBoxLayout *rightLayout = new QVBoxLayout;
rightLayout->addStretch();
rightLayout->addLayout(mapLayout);
rightLayout->addStretch();
QHBoxLayout *paramtersLayout = new QHBoxLayout;
paramtersLayout->setContentsMargins(256, 0, 0, 0);
paramtersLayout->addStretch();
paramtersLayout->addLayout(rightLayout);
m_nameEdit = new QLineEdit;
connect(m_nameEdit, &QLineEdit::textChanged, this, [=]() {
m_unsaved = true;
updateTitle();
});
QPushButton *saveButton = new QPushButton(tr("Save"));
connect(saveButton, &QPushButton::clicked, this, &MaterialEditWidget::save);
saveButton->setDefault(true);
FloatNumberWidget *tileScaleWidget = new FloatNumberWidget;
tileScaleWidget->setItemName(tr("Tile Scale"));
tileScaleWidget->setRange(0.01, 1.0);
tileScaleWidget->setValue(m_layers[0].tileScale);
m_tileScaleSlider = tileScaleWidget;
connect(tileScaleWidget, &FloatNumberWidget::valueChanged, [=](float value) {
m_layers[0].tileScale = value;
emit layersAdjusted();
});
QPushButton *tileScaleEraser = new QPushButton(QChar(fa::eraser));
Theme::initAwesomeToolButton(tileScaleEraser);
connect(tileScaleEraser, &QPushButton::clicked, [=]() {
tileScaleWidget->setValue(1.0);
});
QHBoxLayout *tileScaleLayout = new QHBoxLayout;
tileScaleLayout->addWidget(tileScaleEraser);
tileScaleLayout->addWidget(tileScaleWidget);
tileScaleLayout->addStretch();
QHBoxLayout *baseInfoLayout = new QHBoxLayout;
baseInfoLayout->addWidget(new QLabel(tr("Name")));
baseInfoLayout->addWidget(m_nameEdit);
baseInfoLayout->addStretch();
baseInfoLayout->addWidget(saveButton);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(paramtersLayout);
mainLayout->addStretch();
mainLayout->addWidget(new HorizontalLineWidget());
mainLayout->addLayout(tileScaleLayout);
mainLayout->addLayout(baseInfoLayout);
setLayout(mainLayout);
connect(this, &MaterialEditWidget::layersAdjusted, this, &MaterialEditWidget::updatePreview);
connect(this, &MaterialEditWidget::layersAdjusted, [=]() {
m_unsaved = true;
updateTitle();
});
connect(this, &MaterialEditWidget::addMaterial, document, &Document::addMaterial);
connect(this, &MaterialEditWidget::renameMaterial, document, &Document::renameMaterial);
connect(this, &MaterialEditWidget::setMaterialLayers, document, &Document::setMaterialLayers);
updatePreview();
updateTitle();
}
void MaterialEditWidget::updateMapButtonBackground(ImagePreviewWidget *button, const QImage *image)
{
if (nullptr == image)
button->updateImage(QImage());
else
button->updateImage(*image);
}
void MaterialEditWidget::reject()
{
close();
}
void MaterialEditWidget::closeEvent(QCloseEvent *event)
{
if (m_unsaved && !m_closed) {
QMessageBox::StandardButton answer = QMessageBox::question(this,
APP_NAME,
tr("Do you really want to close while there are unsaved changes?"),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
if (answer != QMessageBox::Yes) {
event->ignore();
return;
}
}
m_closed = true;
hide();
if (nullptr != m_materialPreviewsGenerator) {
event->ignore();
return;
}
event->accept();
}
QSize MaterialEditWidget::sizeHint() const
{
return QSize(0, 200);
}
MaterialEditWidget::~MaterialEditWidget()
{
Q_ASSERT(nullptr == m_materialPreviewsGenerator);
}
void MaterialEditWidget::updatePreview()
{
if (m_closed)
return;
if (nullptr != m_materialPreviewsGenerator) {
m_isPreviewDirty = true;
return;
}
m_isPreviewDirty = false;
qDebug() << "Material preview generating..";
QThread *thread = new QThread;
m_materialPreviewsGenerator = new MaterialPreviewsGenerator();
m_materialPreviewsGenerator->addMaterial(dust3d::Uuid(), m_layers);
m_materialPreviewsGenerator->moveToThread(thread);
connect(thread, &QThread::started, m_materialPreviewsGenerator, &MaterialPreviewsGenerator::process);
connect(m_materialPreviewsGenerator, &MaterialPreviewsGenerator::finished, this, &MaterialEditWidget::previewReady);
connect(m_materialPreviewsGenerator, &MaterialPreviewsGenerator::finished, thread, &QThread::quit);
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
thread->start();
}
void MaterialEditWidget::previewReady()
{
m_previewWidget->updateMesh(m_materialPreviewsGenerator->takePreview(dust3d::Uuid()));
delete m_materialPreviewsGenerator;
m_materialPreviewsGenerator = nullptr;
qDebug() << "Material preview generation done";
if (m_closed) {
close();
return;
}
if (m_isPreviewDirty)
updatePreview();
}
void MaterialEditWidget::setEditMaterialId(dust3d::Uuid materialId)
{
if (m_materialId == materialId)
return;
m_materialId = materialId;
updateTitle();
}
void MaterialEditWidget::updateTitle()
{
if (m_materialId.isNull()) {
setWindowTitle(applicationTitle(tr("New") + (m_unsaved ? "*" : "")));
return;
}
const Material *material = m_document->findMaterial(m_materialId);
if (nullptr == material) {
qDebug() << "Find material failed:" << m_materialId;
return;
}
setWindowTitle(applicationTitle(material->name + (m_unsaved ? "*" : "")));
}
void MaterialEditWidget::setEditMaterialName(QString name)
{
m_nameEdit->setText(name);
updateTitle();
}
void MaterialEditWidget::setEditMaterialLayers(std::vector<MaterialLayer> layers)
{
for (int i = 1; i < (int)dust3d::TextureType::Count; i++) {
m_layers[0].maps[i - 1].imageId = dust3d::Uuid();
}
if (!layers.empty()) {
for (const auto &layer: layers) {
m_layers[0].tileScale = layer.tileScale;
for (const auto &mapItem: layer.maps) {
int index = (int)mapItem.forWhat - 1;
if (index >= 0 && index < (int)dust3d::TextureType::Count - 1) {
m_layers[0].maps[index].imageId = mapItem.imageId;
}
}
}
m_tileScaleSlider->setValue(m_layers[0].tileScale);
}
for (int i = 1; i < (int)dust3d::TextureType::Count; i++) {
updateMapButtonBackground(m_textureMapButtons[i - 1], ImageForever::get(m_layers[0].maps[i - 1].imageId));
}
updatePreview();
}
void MaterialEditWidget::clearUnsaveState()
{
m_unsaved = false;
updateTitle();
}
void MaterialEditWidget::save()
{
if (m_materialId.isNull()) {
m_materialId = dust3d::Uuid::createUuid();
emit addMaterial(m_materialId, m_nameEdit->text(), m_layers);
} else if (m_unsaved) {
emit renameMaterial(m_materialId, m_nameEdit->text());
emit setMaterialLayers(m_materialId, m_layers);
}
clearUnsaveState();
}

View File

@ -0,0 +1,64 @@
#ifndef DUST3D_APPLICATION_MATERIAL_EDIT_WIDGET_H_
#define DUST3D_APPLICATION_MATERIAL_EDIT_WIDGET_H_
#include <QDialog>
#include <map>
#include <QCloseEvent>
#include <QLineEdit>
#include "model_widget.h"
#include "material_previews_generator.h"
#include "image_preview_widget.h"
#include "float_number_widget.h"
#include "material_layer.h"
class Document;
enum class PopupWidgetType
{
PitchYawRoll,
Intersection
};
class MaterialEditWidget : public QDialog
{
Q_OBJECT
signals:
void addMaterial(dust3d::Uuid materialId, QString name, std::vector<MaterialLayer> layers);
void removeMaterial(dust3d::Uuid materialId);
void setMaterialLayers(dust3d::Uuid materialId, std::vector<MaterialLayer> layers);
void renameMaterial(dust3d::Uuid materialId, QString name);
void layersAdjusted();
public:
MaterialEditWidget(const Document *document, QWidget *parent=nullptr);
~MaterialEditWidget();
public slots:
void updatePreview();
void setEditMaterialId(dust3d::Uuid materialId);
void setEditMaterialName(QString name);
void setEditMaterialLayers(std::vector<MaterialLayer> layers);
void updateTitle();
void save();
void clearUnsaveState();
void previewReady();
protected:
QSize sizeHint() const override;
void closeEvent(QCloseEvent *event) override;
void reject() override;
private:
void updateMapButtonBackground(ImagePreviewWidget *button, const QImage *image);
ImagePreviewWidget *createMapButton();
QImage *pickImage();
const Document *m_document = nullptr;
MaterialPreviewsGenerator *m_materialPreviewsGenerator = nullptr;
ModelWidget *m_previewWidget = nullptr;
FloatNumberWidget *m_tileScaleSlider = nullptr;
bool m_isPreviewDirty = false;
bool m_closed = false;
dust3d::Uuid m_materialId;
bool m_unsaved = false;
QLineEdit *m_nameEdit = nullptr;
std::vector<MaterialLayer> m_layers;
ImagePreviewWidget *m_textureMapButtons[(int)dust3d::TextureType::Count - 1] = {nullptr};
};
#endif

View File

@ -0,0 +1 @@
#include "material_layer.h"

View File

@ -0,0 +1,22 @@
#ifndef DUST3D_APPLICATION_MATERIAL_LAYER_H_
#define DUST3D_APPLICATION_MATERIAL_LAYER_H_
#include <vector>
#include <dust3d/base/texture_type.h>
#include <dust3d/base/uuid.h>
class MaterialMap
{
public:
dust3d::TextureType forWhat;
dust3d::Uuid imageId;
};
class MaterialLayer
{
public:
std::vector<MaterialMap> maps;
float tileScale = 1.0;
};
#endif

View File

@ -0,0 +1,309 @@
#include <QGuiApplication>
#include <QMenu>
#include <QXmlStreamWriter>
#include <QClipboard>
#include <QApplication>
#include <dust3d/base/snapshot_xml.h>
#include "material_list_widget.h"
#include "document.h"
MaterialListWidget::MaterialListWidget(const Document *document, QWidget *parent) :
QTreeWidget(parent),
m_document(document)
{
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
setFocusPolicy(Qt::NoFocus);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setAutoScroll(false);
setHeaderHidden(true);
QPalette palette = this->palette();
palette.setColor(QPalette::Window, Qt::transparent);
palette.setColor(QPalette::Base, Qt::transparent);
setPalette(palette);
setStyleSheet("QTreeView {qproperty-indentation: 0;}");
setContentsMargins(0, 0, 0, 0);
connect(document, &Document::materialListChanged, this, &MaterialListWidget::reload);
connect(document, &Document::cleanup, this, &MaterialListWidget::removeAllContent);
connect(this, &MaterialListWidget::removeMaterial, document, &Document::removeMaterial);
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &QTreeWidget::customContextMenuRequested, this, &MaterialListWidget::showContextMenu);
reload();
}
void MaterialListWidget::enableMultipleSelection(bool enabled)
{
m_multipleSelectionEnabled = enabled;
}
void MaterialListWidget::materialRemoved(dust3d::Uuid materialId)
{
if (m_currentSelectedMaterialId == materialId)
m_currentSelectedMaterialId = dust3d::Uuid();
m_selectedMaterialIds.erase(materialId);
m_itemMap.erase(materialId);
}
void MaterialListWidget::updateMaterialSelectState(dust3d::Uuid materialId, bool selected)
{
auto findItemResult = m_itemMap.find(materialId);
if (findItemResult == m_itemMap.end()) {
qDebug() << "Find material item failed:" << materialId;
return;
}
MaterialWidget *materialWidget = (MaterialWidget *)itemWidget(findItemResult->second.first, findItemResult->second.second);
materialWidget->updateCheckedState(selected);
}
void MaterialListWidget::selectMaterial(dust3d::Uuid materialId, bool multiple)
{
if (multiple) {
if (!m_currentSelectedMaterialId.isNull()) {
m_selectedMaterialIds.insert(m_currentSelectedMaterialId);
m_currentSelectedMaterialId = dust3d::Uuid();
}
if (m_selectedMaterialIds.find(materialId) != m_selectedMaterialIds.end()) {
updateMaterialSelectState(materialId, false);
m_selectedMaterialIds.erase(materialId);
} else {
if (m_multipleSelectionEnabled || m_selectedMaterialIds.empty()) {
updateMaterialSelectState(materialId, true);
m_selectedMaterialIds.insert(materialId);
}
}
if (m_selectedMaterialIds.size() > 1) {
return;
}
if (m_selectedMaterialIds.size() == 1)
materialId = *m_selectedMaterialIds.begin();
else {
materialId = dust3d::Uuid();
emit currentSelectedMaterialChanged(materialId);
}
}
if (!m_selectedMaterialIds.empty()) {
for (const auto &id: m_selectedMaterialIds) {
updateMaterialSelectState(id, false);
}
m_selectedMaterialIds.clear();
}
if (m_currentSelectedMaterialId != materialId) {
if (!m_currentSelectedMaterialId.isNull()) {
updateMaterialSelectState(m_currentSelectedMaterialId, false);
}
m_currentSelectedMaterialId = materialId;
if (!m_currentSelectedMaterialId.isNull()) {
updateMaterialSelectState(m_currentSelectedMaterialId, true);
}
emit currentSelectedMaterialChanged(m_currentSelectedMaterialId);
}
}
void MaterialListWidget::mousePressEvent(QMouseEvent *event)
{
QModelIndex itemIndex = indexAt(event->pos());
QTreeView::mousePressEvent(event);
if (event->button() == Qt::LeftButton) {
bool multiple = QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier);
if (itemIndex.isValid()) {
QTreeWidgetItem *item = itemFromIndex(itemIndex);
auto materialId = dust3d::Uuid(item->data(itemIndex.column(), Qt::UserRole).toString().toUtf8().constData());
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) {
bool startAdd = false;
bool stopAdd = false;
std::vector<dust3d::Uuid> waitQueue;
for (const auto &childId: m_document->materialIdList) {
if (m_shiftStartMaterialId == childId || materialId == childId) {
if (startAdd) {
stopAdd = true;
} else {
startAdd = true;
}
}
if (startAdd)
waitQueue.push_back(childId);
if (stopAdd)
break;
}
if (stopAdd && !waitQueue.empty()) {
if (!m_selectedMaterialIds.empty()) {
for (const auto &id: m_selectedMaterialIds) {
updateMaterialSelectState(id, false);
}
m_selectedMaterialIds.clear();
}
if (!m_currentSelectedMaterialId.isNull()) {
m_currentSelectedMaterialId = dust3d::Uuid();
}
for (const auto &waitId: waitQueue) {
selectMaterial(waitId, true);
}
}
return;
} else {
m_shiftStartMaterialId = materialId;
}
selectMaterial(materialId, multiple);
return;
}
if (!multiple)
selectMaterial(dust3d::Uuid());
}
}
bool MaterialListWidget::isMaterialSelected(dust3d::Uuid materialId)
{
return (m_currentSelectedMaterialId == materialId ||
m_selectedMaterialIds.find(materialId) != m_selectedMaterialIds.end());
}
void MaterialListWidget::showContextMenu(const QPoint &pos)
{
if (!m_hasContextMenu)
return;
QMenu contextMenu(this);
std::set<dust3d::Uuid> unorderedMaterialIds = m_selectedMaterialIds;
if (!m_currentSelectedMaterialId.isNull())
unorderedMaterialIds.insert(m_currentSelectedMaterialId);
std::vector<dust3d::Uuid> materialIds;
for (const auto &cand: m_document->materialIdList) {
if (unorderedMaterialIds.find(cand) != unorderedMaterialIds.end())
materialIds.push_back(cand);
}
QAction modifyAction(tr("Modify"), this);
if (materialIds.size() == 1) {
connect(&modifyAction, &QAction::triggered, this, [=]() {
emit modifyMaterial(*materialIds.begin());
});
contextMenu.addAction(&modifyAction);
}
QAction copyAction(tr("Copy"), this);
if (!materialIds.empty()) {
connect(&copyAction, &QAction::triggered, this, &MaterialListWidget::copy);
contextMenu.addAction(&copyAction);
}
QAction pasteAction(tr("Paste"), this);
if (m_document->hasPastableMaterialsInClipboard()) {
connect(&pasteAction, &QAction::triggered, m_document, &Document::paste);
contextMenu.addAction(&pasteAction);
}
QAction deleteAction(tr("Delete"), this);
if (!materialIds.empty()) {
connect(&deleteAction, &QAction::triggered, [=]() {
for (const auto &materialId: materialIds)
emit removeMaterial(materialId);
});
contextMenu.addAction(&deleteAction);
}
contextMenu.exec(mapToGlobal(pos));
}
void MaterialListWidget::resizeEvent(QResizeEvent *event)
{
QTreeWidget::resizeEvent(event);
if (calculateColumnCount() != columnCount())
reload();
}
int MaterialListWidget::calculateColumnCount()
{
if (nullptr == parentWidget())
return 0;
int columns = parentWidget()->width() / Theme::materialPreviewImageSize;
if (0 == columns)
columns = 1;
return columns;
}
void MaterialListWidget::reload()
{
removeAllContent();
int columns = calculateColumnCount();
if (0 == columns)
return;
int columnWidth = parentWidget()->width() / columns;
//qDebug() << "parentWidth:" << parentWidget()->width() << "columnWidth:" << columnWidth << "columns:" << columns;
setColumnCount(columns);
for (int i = 0; i < columns; i++)
setColumnWidth(i, columnWidth);
std::vector<dust3d::Uuid> orderedMaterialIdList = m_document->materialIdList;
std::sort(orderedMaterialIdList.begin(), orderedMaterialIdList.end(), [&](const dust3d::Uuid &firstMaterialId, const dust3d::Uuid &secondMaterialId) {
const auto *firstMaterial = m_document->findMaterial(firstMaterialId);
const auto *secondMaterial = m_document->findMaterial(secondMaterialId);
if (nullptr == firstMaterial || nullptr == secondMaterial)
return false;
return QString::compare(firstMaterial->name, secondMaterial->name, Qt::CaseInsensitive) < 0;
});
decltype(orderedMaterialIdList.size()) materialIndex = 0;
while (materialIndex < orderedMaterialIdList.size()) {
QTreeWidgetItem *item = new QTreeWidgetItem(this);
item->setFlags((item->flags() | Qt::ItemIsEnabled) & ~(Qt::ItemIsSelectable) & ~(Qt::ItemIsEditable));
for (int col = 0; col < columns && materialIndex < orderedMaterialIdList.size(); col++, materialIndex++) {
const auto &materialId = orderedMaterialIdList[materialIndex];
item->setSizeHint(col, QSize(columnWidth, MaterialWidget::preferredHeight() + 2));
item->setData(col, Qt::UserRole, QString(materialId.toString().c_str()));
MaterialWidget *widget = new MaterialWidget(m_document, materialId);
connect(widget, &MaterialWidget::modifyMaterial, this, &MaterialListWidget::modifyMaterial);
setItemWidget(item, col, widget);
widget->reload();
widget->updateCheckedState(isMaterialSelected(materialId));
m_itemMap[materialId] = std::make_pair(item, col);
}
invisibleRootItem()->addChild(item);
}
}
void MaterialListWidget::setHasContextMenu(bool hasContextMenu)
{
m_hasContextMenu = hasContextMenu;
}
void MaterialListWidget::removeAllContent()
{
m_itemMap.clear();
clear();
}
void MaterialListWidget::copy()
{
if (m_selectedMaterialIds.empty() && m_currentSelectedMaterialId.isNull())
return;
std::set<dust3d::Uuid> limitMaterialIds = m_selectedMaterialIds;
if (!m_currentSelectedMaterialId.isNull())
limitMaterialIds.insert(m_currentSelectedMaterialId);
std::set<dust3d::Uuid> emptySet;
dust3d::Snapshot snapshot;
m_document->toSnapshot(&snapshot, emptySet, DocumentToSnapshotFor::Materials,
limitMaterialIds);
std::string snapshotXml;
dust3d::saveSnapshotToXmlString(snapshot, snapshotXml);
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(snapshotXml.c_str());
}

View File

@ -0,0 +1,46 @@
#ifndef DUST3D_APPLICATION_MATERIAL_LIST_WIDGET_H_
#define DUST3D_APPLICATION_MATERIAL_LIST_WIDGET_H_
#include <QTreeWidget>
#include <map>
#include <QMouseEvent>
#include "material_widget.h"
class Document;
class MaterialListWidget : public QTreeWidget
{
Q_OBJECT
signals:
void removeMaterial(dust3d::Uuid materialId);
void modifyMaterial(dust3d::Uuid materialId);
void cornerButtonClicked(dust3d::Uuid materialId);
void currentSelectedMaterialChanged(dust3d::Uuid materialId);
public:
MaterialListWidget(const Document *document, QWidget *parent=nullptr);
bool isMaterialSelected(dust3d::Uuid materialId);
void enableMultipleSelection(bool enabled);
public slots:
void reload();
void removeAllContent();
void materialRemoved(dust3d::Uuid materialId);
void showContextMenu(const QPoint &pos);
void selectMaterial(dust3d::Uuid materialId, bool multiple=false);
void copy();
void setHasContextMenu(bool hasContextMenu);
protected:
void resizeEvent(QResizeEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
private:
int calculateColumnCount();
void updateMaterialSelectState(dust3d::Uuid materialId, bool selected);
const Document *m_document = nullptr;
std::map<dust3d::Uuid, std::pair<QTreeWidgetItem *, int>> m_itemMap;
std::set<dust3d::Uuid> m_selectedMaterialIds;
dust3d::Uuid m_currentSelectedMaterialId;
dust3d::Uuid m_shiftStartMaterialId;
bool m_hasContextMenu = true;
bool m_multipleSelectionEnabled = true;
};
#endif

View File

@ -0,0 +1,64 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include "material_manage_widget.h"
#include "theme.h"
#include "material_edit_widget.h"
#include "info_label.h"
#include "document.h"
MaterialManageWidget::MaterialManageWidget(const Document *document, QWidget *parent) :
QWidget(parent),
m_document(document)
{
QPushButton *addMaterialButton = new QPushButton(Theme::awesome()->icon(fa::plus), tr("Add Material..."));
connect(addMaterialButton, &QPushButton::clicked, this, &MaterialManageWidget::showAddMaterialDialog);
QHBoxLayout *toolsLayout = new QHBoxLayout;
toolsLayout->addWidget(addMaterialButton);
m_materialListWidget = new MaterialListWidget(document);
connect(m_materialListWidget, &MaterialListWidget::modifyMaterial, this, &MaterialManageWidget::showMaterialDialog);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(toolsLayout);
mainLayout->addWidget(m_materialListWidget);
setLayout(mainLayout);
}
MaterialListWidget *MaterialManageWidget::materialListWidget()
{
return m_materialListWidget;
}
QSize MaterialManageWidget::sizeHint() const
{
return QSize(Theme::sidebarPreferredWidth, 0);
}
void MaterialManageWidget::showAddMaterialDialog()
{
showMaterialDialog(dust3d::Uuid());
}
void MaterialManageWidget::showMaterialDialog(dust3d::Uuid materialId)
{
MaterialEditWidget *materialEditWidget = new MaterialEditWidget(m_document);
materialEditWidget->setAttribute(Qt::WA_DeleteOnClose);
if (!materialId.isNull()) {
const Material *material = m_document->findMaterial(materialId);
if (nullptr != material) {
materialEditWidget->setEditMaterialId(materialId);
materialEditWidget->setEditMaterialName(material->name);
materialEditWidget->setEditMaterialLayers(material->layers);
materialEditWidget->clearUnsaveState();
}
}
materialEditWidget->show();
connect(materialEditWidget, &QDialog::destroyed, [=]() {
emit unregisterDialog((QWidget *)materialEditWidget);
});
emit registerDialog((QWidget *)materialEditWidget);
}

View File

@ -0,0 +1,28 @@
#ifndef DUST3D_APPLICATION_MATERIAL_MANAGE_WIDGET_H_
#define DUST3D_APPLICATION_MATERIAL_MANAGE_WIDGET_H_
#include <QWidget>
#include "material_list_widget.h"
class Document;
class MaterialManageWidget : public QWidget
{
Q_OBJECT
signals:
void registerDialog(QWidget *widget);
void unregisterDialog(QWidget *widget);
public:
MaterialManageWidget(const Document *document, QWidget *parent=nullptr);
MaterialListWidget *materialListWidget();
protected:
virtual QSize sizeHint() const;
public slots:
void showAddMaterialDialog();
void showMaterialDialog(dust3d::Uuid materialId);
private:
const Document *m_document = nullptr;
MaterialListWidget *m_materialListWidget = nullptr;
};
#endif

View File

@ -0,0 +1,131 @@
#include <QGuiApplication>
#include <QElapsedTimer>
#include <qDebug>
#include <QFile>
#include <dust3d/base/ds3_file.h>
#include <dust3d/base/snapshot_xml.h>
#include "material_previews_generator.h"
#include "mesh_generator.h"
#include "texture_generator.h"
#include "image_forever.h"
#include "mesh_result_post_processor.h"
MaterialPreviewsGenerator::MaterialPreviewsGenerator()
{
}
MaterialPreviewsGenerator::~MaterialPreviewsGenerator()
{
for (auto &item: m_previews) {
delete item.second;
}
}
void MaterialPreviewsGenerator::addMaterial(dust3d::Uuid materialId, const std::vector<MaterialLayer> &layers)
{
m_materials.push_back({materialId, layers});
}
const std::set<dust3d::Uuid> &MaterialPreviewsGenerator::generatedPreviewMaterialIds()
{
return m_generatedMaterialIds;
}
Model *MaterialPreviewsGenerator::takePreview(dust3d::Uuid materialId)
{
Model *resultMesh = m_previews[materialId];
m_previews[materialId] = nullptr;
return resultMesh;
}
void MaterialPreviewsGenerator::generate()
{
dust3d::Snapshot *snapshot = new dust3d::Snapshot;
QFile file(":/resources/material-demo-model.ds3");
file.open(QFile::ReadOnly);
QByteArray fileData = file.readAll();
std::vector<dust3d::Uuid> partIds;
dust3d::Ds3FileReader ds3Reader((const std::uint8_t *)fileData.data(), fileData.size());
for (int i = 0; i < ds3Reader.items().size(); ++i) {
dust3d::Ds3ReaderItem item = ds3Reader.items().at(i);
if (item.type == "model") {
std::vector<std::uint8_t> data;
ds3Reader.loadItem(item.name, &data);
std::string xmlString((char *)data.data(), data.size());
dust3d::loadSnapshotFromXmlString(snapshot, (char *)xmlString.c_str());
for (const auto &item: snapshot->parts) {
partIds.push_back(dust3d::Uuid(item.first));
}
}
}
dust3d::MeshGenerator::GeneratedCacheContext *cacheContext = new dust3d::MeshGenerator::GeneratedCacheContext();
MeshGenerator *meshGenerator = new MeshGenerator(snapshot);
meshGenerator->setGeneratedCacheContext(cacheContext);
meshGenerator->generate();
for (const auto &mirror: cacheContext->partMirrorIdMap) {
partIds.push_back(dust3d::Uuid(mirror.first));
}
dust3d::Object *object = meshGenerator->takeObject();
if (nullptr != object) {
MeshResultPostProcessor *poseProcessor = new MeshResultPostProcessor(*object);
poseProcessor->poseProcess();
delete object;
object = poseProcessor->takePostProcessedObject();
delete poseProcessor;
}
if (nullptr != object) {
for (const auto &material: m_materials) {
TextureGenerator *textureGenerator = new TextureGenerator(*object);
for (const auto &layer: material.second) {
for (const auto &mapItem: layer.maps) {
const QImage *image = ImageForever::get(mapItem.imageId);
if (nullptr == image)
continue;
for (const auto &partId: partIds) {
if (dust3d::TextureType::BaseColor == mapItem.forWhat)
textureGenerator->addPartColorMap(partId, image, layer.tileScale);
else if (dust3d::TextureType::Normal == mapItem.forWhat)
textureGenerator->addPartNormalMap(partId, image, layer.tileScale);
else if (dust3d::TextureType::Metallic == mapItem.forWhat)
textureGenerator->addPartMetalnessMap(partId, image, layer.tileScale);
else if (dust3d::TextureType::Roughness == mapItem.forWhat)
textureGenerator->addPartRoughnessMap(partId, image, layer.tileScale);
else if (dust3d::TextureType::AmbientOcclusion == mapItem.forWhat)
textureGenerator->addPartAmbientOcclusionMap(partId, image, layer.tileScale);
}
}
}
textureGenerator->generate();
Model *texturedResultMesh = textureGenerator->takeResultMesh();
if (nullptr != texturedResultMesh) {
m_previews[material.first] = new Model(*texturedResultMesh);
m_generatedMaterialIds.insert(material.first);
delete texturedResultMesh;
}
delete textureGenerator;
}
}
delete object;
delete meshGenerator;
delete cacheContext;
}
void MaterialPreviewsGenerator::process()
{
QElapsedTimer countTimeConsumed;
countTimeConsumed.start();
generate();
qDebug() << "The material previews generation took" << countTimeConsumed.elapsed() << "milliseconds";
emit finished();
}

View File

@ -0,0 +1,30 @@
#ifndef DUST3D_APPLICATION_MATERIAL_PREVIEWS_GENERATOR_H_
#define DUST3D_APPLICATION_MATERIAL_PREVIEWS_GENERATOR_H_
#include <QObject>
#include <map>
#include <vector>
#include "model.h"
#include "material_layer.h"
class MaterialPreviewsGenerator : public QObject
{
Q_OBJECT
public:
MaterialPreviewsGenerator();
~MaterialPreviewsGenerator();
void addMaterial(dust3d::Uuid materialId, const std::vector<MaterialLayer> &layers);
const std::set<dust3d::Uuid> &generatedPreviewMaterialIds();
Model *takePreview(dust3d::Uuid materialId);
void generate();
signals:
void finished();
public slots:
void process();
private:
std::vector<std::pair<dust3d::Uuid, std::vector<MaterialLayer>>> m_materials;
std::map<dust3d::Uuid, Model *> m_previews;
std::set<dust3d::Uuid> m_generatedMaterialIds;
};
#endif

View File

@ -0,0 +1,99 @@
#include <QVBoxLayout>
#include "material_widget.h"
#include "document.h"
MaterialWidget::MaterialWidget(const Document *document, dust3d::Uuid materialId) :
m_materialId(materialId),
m_document(document)
{
setObjectName("MaterialFrame");
m_previewWidget = new ModelWidget(this);
m_previewWidget->setAttribute(Qt::WA_TransparentForMouseEvents);
m_previewWidget->setFixedSize(Theme::materialPreviewImageSize, Theme::materialPreviewImageSize);
m_previewWidget->enableMove(false);
m_previewWidget->enableZoom(false);
m_previewWidget->enableEnvironmentLight();
m_nameLabel = new QLabel;
m_nameLabel->setAlignment(Qt::AlignCenter);
m_nameLabel->setStyleSheet("background: qlineargradient(x1:0.5 y1:-15.5, x2:0.5 y2:1, stop:0 " + Theme::white.name() + ", stop:1 #252525);");
QFont nameFont;
nameFont.setWeight(QFont::Light);
nameFont.setBold(false);
m_nameLabel->setFont(nameFont);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addStretch();
mainLayout->addWidget(m_nameLabel);
setLayout(mainLayout);
setFixedSize(Theme::materialPreviewImageSize, MaterialWidget::preferredHeight());
connect(document, &Document::materialNameChanged, this, &MaterialWidget::updateName);
connect(document, &Document::materialPreviewChanged, this, &MaterialWidget::updatePreview);
}
void MaterialWidget::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
m_previewWidget->move((width() - Theme::materialPreviewImageSize) / 2, 0);
}
int MaterialWidget::preferredHeight()
{
return Theme::materialPreviewImageSize;
}
void MaterialWidget::reload()
{
updatePreview(m_materialId);
updateName(m_materialId);
}
void MaterialWidget::updatePreview(dust3d::Uuid materialId)
{
if (materialId != m_materialId)
return;
const Material *material = m_document->findMaterial(m_materialId);
if (!material) {
qDebug() << "Material not found:" << m_materialId;
return;
}
Model *previewMesh = material->takePreviewMesh();
m_previewWidget->updateMesh(previewMesh);
}
void MaterialWidget::updateName(dust3d::Uuid materialId)
{
if (materialId != m_materialId)
return;
const Material *material = m_document->findMaterial(m_materialId);
if (!material) {
qDebug() << "Material not found:" << m_materialId;
return;
}
m_nameLabel->setText(material->name);
}
void MaterialWidget::updateCheckedState(bool checked)
{
if (checked)
setStyleSheet("#MaterialFrame {border: 1px solid " + Theme::red.name() + ";}");
else
setStyleSheet("#MaterialFrame {border: 1px solid transparent;}");
}
ModelWidget *MaterialWidget::previewWidget()
{
return m_previewWidget;
}
void MaterialWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
QFrame::mouseDoubleClickEvent(event);
emit modifyMaterial(m_materialId);
}

View File

@ -0,0 +1,36 @@
#ifndef DUST3D_APPLICATION_MATERIAL_WIDGET_H_
#define DUST3D_APPLICATION_MATERIAL_WIDGET_H_
#include <QFrame>
#include <QLabel>
#include <QIcon>
#include <QPushButton>
#include "model_widget.h"
class Document;
class MaterialWidget : public QFrame
{
Q_OBJECT
signals:
void modifyMaterial(dust3d::Uuid materialId);
public:
MaterialWidget(const Document *document, dust3d::Uuid materialId);
static int preferredHeight();
ModelWidget *previewWidget();
protected:
void mouseDoubleClickEvent(QMouseEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
public slots:
void reload();
void updatePreview(dust3d::Uuid materialId);
void updateName(dust3d::Uuid materialId);
void updateCheckedState(bool checked);
private:
dust3d::Uuid m_materialId;
const Document *m_document = nullptr;
ModelWidget *m_previewWidget = nullptr;
QLabel *m_nameLabel = nullptr;
};
#endif

View File

@ -0,0 +1,73 @@
#include <QElapsedTimer>
#include <QDebug>
#include "mesh_generator.h"
#include "cut_face_preview.h"
MeshGenerator::MeshGenerator(dust3d::Snapshot *snapshot) :
dust3d::MeshGenerator(snapshot)
{
}
MeshGenerator::~MeshGenerator()
{
for (auto &it: m_partPreviewImages)
delete it.second;
for (auto &it: m_partPreviewMeshes)
delete it.second;
delete m_resultMesh;
}
Model *MeshGenerator::takePartPreviewMesh(const dust3d::Uuid &partId)
{
Model *resultMesh = m_partPreviewMeshes[partId];
m_partPreviewMeshes[partId] = nullptr;
return resultMesh;
}
QImage *MeshGenerator::takePartPreviewImage(const dust3d::Uuid &partId)
{
QImage *image = m_partPreviewImages[partId];
m_partPreviewImages[partId] = nullptr;
return image;
}
void MeshGenerator::process()
{
QElapsedTimer countTimeConsumed;
countTimeConsumed.start();
generate();
if (nullptr != m_object)
m_resultMesh = new Model(*m_object);
for (const auto &partId: m_generatedPreviewImagePartIds) {
auto it = m_generatedPartPreviews.find(partId);
if (it == m_generatedPartPreviews.end())
continue;
m_partPreviewImages[partId] = buildCutFaceTemplatePreviewImage(it->second.cutTemplate);
}
for (const auto &partId: m_generatedPreviewPartIds) {
auto it = m_generatedPartPreviews.find(partId);
if (it == m_generatedPartPreviews.end())
continue;
m_partPreviewMeshes[partId] = new Model(it->second.vertices,
it->second.triangles,
it->second.vertexNormals,
it->second.color,
it->second.metalness,
it->second.roughness);
}
qDebug() << "The mesh generation took" << countTimeConsumed.elapsed() << "milliseconds";
emit finished();
}
Model *MeshGenerator::takeResultMesh()
{
Model *resultMesh = m_resultMesh;
m_resultMesh = nullptr;
return resultMesh;
}

View File

@ -0,0 +1,28 @@
#ifndef DUST3D_APPLICATION_MESH_GENERATOR_H_
#define DUST3D_APPLICATION_MESH_GENERATOR_H_
#include <QObject>
#include <QImage>
#include <dust3d/mesh/mesh_generator.h>
#include "model.h"
class MeshGenerator : public QObject, public dust3d::MeshGenerator
{
Q_OBJECT
public:
MeshGenerator(dust3d::Snapshot *snapshot);
~MeshGenerator();
Model *takeResultMesh();
Model *takePartPreviewMesh(const dust3d::Uuid &partId);
QImage *takePartPreviewImage(const dust3d::Uuid &partId);
public slots:
void process();
signals:
void finished();
private:
Model *m_resultMesh = nullptr;
std::map<dust3d::Uuid, Model *> m_partPreviewMeshes;
std::map<dust3d::Uuid, QImage *> m_partPreviewImages;
};
#endif

View File

@ -0,0 +1,49 @@
#include <QGuiApplication>
#include <dust3d/uv/unwrap_uv.h>
#include <dust3d/mesh/resolve_triangle_tangent.h>
#include "mesh_result_post_processor.h"
MeshResultPostProcessor::MeshResultPostProcessor(const dust3d::Object &object)
{
m_object = new dust3d::Object;
*m_object = object;
}
MeshResultPostProcessor::~MeshResultPostProcessor()
{
delete m_object;
}
dust3d::Object *MeshResultPostProcessor::takePostProcessedObject()
{
dust3d::Object *object = m_object;
m_object = nullptr;
return object;
}
void MeshResultPostProcessor::poseProcess()
{
if (!m_object->nodes.empty()) {
{
std::vector<std::vector<dust3d::Vector2>> triangleVertexUvs;
std::set<int> seamVertices;
std::map<dust3d::Uuid, std::vector<dust3d::Rectangle>> partUvRects;
dust3d::unwrapUv(*m_object, triangleVertexUvs, seamVertices, partUvRects);
m_object->setTriangleVertexUvs(triangleVertexUvs);
m_object->setPartUvRects(partUvRects);
}
{
std::vector<dust3d::Vector3> triangleTangents;
dust3d::resolveTriangleTangent(*m_object, triangleTangents);
m_object->setTriangleTangents(triangleTangents);
}
}
}
void MeshResultPostProcessor::process()
{
poseProcess();
emit finished();
}

Some files were not shown because too many files have changed in this diff Show More