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 if (incArmedParameter()) { 19 igSameLine(0, 0); 20 incViewportModelDeformOverlay(); 21 } else { 22 igPushFont(incIconFont()); 23 if (igButton("", ImVec2(0, 0))) { 24 incShowVertices = !incShowVertices; 25 } 26 igPopFont(); 27 incTooltip(_("Show/hide Vertices")); 28 29 igPushFont(incIconFont()); 30 igSameLine(0, 0); 31 if (igButton("", ImVec2(0, 0))) { 32 incShowBounds = !incShowBounds; 33 } 34 igPopFont(); 35 incTooltip(_("Show/hide Bounds")); 36 37 igPushFont(incIconFont()); 38 igSameLine(0, 0); 39 if (igButton("", ImVec2(0, 0))) { 40 incShowOrientation = !incShowOrientation; 41 } 42 igPopFont(); 43 incTooltip(_("Show/hide Orientation Gizmo")); 44 } 45 } 46 47 void incViewportModelNodeSelectionChanged() { 48 incViewportModelDeformNodeSelectionChanged(); 49 } 50 51 void incViewportModelUpdate(ImGuiIO* io, Camera camera) { 52 if (Parameter param = incArmedParameter()) { 53 incViewportModelDeformUpdate(io, camera, param); 54 } 55 } 56 57 void incViewportModelDraw(Camera camera) { 58 Parameter param = incArmedParameter(); 59 if (param) { 60 incActivePuppet().root.beginUpdate(); 61 incArmedParameter().update(); 62 incActivePuppet().root.update(); 63 incActivePuppet.draw(); 64 } else { 65 incActivePuppet.update(); 66 incActivePuppet.draw(); 67 } 68 69 if (param) { 70 incViewportModelDeformDraw(camera, param); 71 } else { 72 if (incSelectedNodes.length > 0) { 73 foreach(selectedNode; incSelectedNodes) { 74 if (selectedNode is null) continue; 75 if (incShowOrientation) selectedNode.drawOrientation(); 76 if (incShowBounds) selectedNode.drawBounds(); 77 78 79 if (Drawable selectedDraw = cast(Drawable)selectedNode) { 80 81 if (incShowVertices || incEditMode != EditMode.ModelEdit) { 82 selectedDraw.drawMeshLines(); 83 selectedDraw.drawMeshPoints(); 84 } 85 } 86 87 if (Driver selectedDriver = cast(Driver)selectedNode) { 88 selectedDriver.drawDebug(); 89 } 90 } 91 } 92 } 93 } 94 95 void incViewportModelToolSettings() { 96 incViewportModelDeformToolSettings(); 97 } 98 99 void incViewportModelPresent() { 100 101 } 102 103 void incViewportModelWithdraw() { 104 105 } 106 107 void incViewportModelToolbar() { 108 109 }