1 /* 2 Copyright © 2020, Inochi2D Project 3 Distributed under the 2-Clause BSD License, see LICENSE file. 4 5 Authors: Luna Nielsen 6 */ 7 module creator.viewport.model; 8 import creator.viewport.model.deform; 9 import creator.widgets.tooltip; 10 import creator.core.input; 11 import creator.core; 12 import creator; 13 import inochi2d; 14 import bindbc.imgui; 15 import i18n; 16 17 void incViewportModelOverlay() { 18 igPushFont(incIconFont()); 19 if (igButton("", ImVec2(0, 0))) { 20 incShowVertices = !incShowVertices; 21 } 22 igPopFont(); 23 incTooltip(_("Show/hide Vertices")); 24 25 igPushFont(incIconFont()); 26 igSameLine(0, 0); 27 if (igButton("", ImVec2(0, 0))) { 28 incShowBounds = !incShowBounds; 29 } 30 igPopFont(); 31 incTooltip(_("Show/hide Bounds")); 32 33 igPushFont(incIconFont()); 34 igSameLine(0, 0); 35 if (igButton("", ImVec2(0, 0))) { 36 incShowOrientation = !incShowOrientation; 37 } 38 igPopFont(); 39 incTooltip(_("Show/hide Orientation Gizmo")); 40 } 41 42 void incViewportModelNodeSelectionChanged() { 43 incViewportModelDeformNodeSelectionChanged(); 44 } 45 46 void incViewportModelUpdate(ImGuiIO* io, Camera camera) { 47 if (Parameter param = incArmedParameter()) { 48 incViewportModelDeformUpdate(io, camera, param); 49 } 50 } 51 52 void incViewportModelDraw(Camera camera) { 53 Parameter param = incArmedParameter(); 54 if (param) { 55 incActivePuppet().root.beginUpdate(); 56 incArmedParameter().update(); 57 incActivePuppet().root.update(); 58 incActivePuppet.draw(); 59 } else { 60 incActivePuppet.update(); 61 incActivePuppet.draw(); 62 } 63 64 if (param) { 65 incViewportModelDeformDraw(camera, param); 66 } else { 67 if (incSelectedNodes.length > 0) { 68 foreach(selectedNode; incSelectedNodes) { 69 if (selectedNode is null) continue; 70 if (incShowOrientation) selectedNode.drawOrientation(); 71 if (incShowBounds) selectedNode.drawBounds(); 72 73 74 if (Drawable selectedDraw = cast(Drawable)selectedNode) { 75 76 if (incShowVertices || incEditMode != EditMode.ModelEdit) { 77 selectedDraw.drawMeshLines(); 78 selectedDraw.drawMeshPoints(); 79 } 80 } 81 82 } 83 } 84 } 85 } 86 87 void incViewportModelToolSettings() { 88 incViewportModelDeformToolSettings(); 89 } 90 91 void incViewportModelPresent() { 92 93 } 94 95 void incViewportModelWithdraw() { 96 97 } 98 99 void incViewportModelToolbar() { 100 101 }