summaryrefslogtreecommitdiffstats
path: root/util/qt3d/modeltweak/qml/ConfigPane.qml
blob: e1f61a018374a70a55bd009c81c1c536fde5e33d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
import QtQuick 1.0
import Qt3D 1.0
import ModelTweak 1.0

Row {
    x: 16
    y: parent.height/2 + 16
    width: parent.width/2 - 16 - 16
    height: parent.height/2 - 16 - 16
    spacing: 16

    Column {
        width: parent.width/2
        height: parent.height
        spacing: 4

        // POSITION
        Text {
            text: "Position";
            color: "#FFFFFF"
            width: parent.width
            horizontalAlignment: Text.AlignHCenter
        }
        BlenderValueSlider {
            focus: true
            id: posX
            label: "X:"
            value: transformTranslate.translate.x.toFixed(3)
            function update (f)  {
                transformTranslate.translate = Qt.vector3d(f, transformTranslate.translate.y, transformTranslate.translate.z);
            }
            Keys.onTabPressed:   { updateMe(); focus = false; posY.focus = true; }
        }
        BlenderValueSlider {
            id: posY
            label: "Y:"
            value: transformTranslate.translate.y.toFixed(3)
            function update (f)  {
                transformTranslate.translate = Qt.vector3d(transformTranslate.translate.x, f, transformTranslate.translate.z);
            }
            Keys.onTabPressed:   { updateMe(); focus = false; posZ.focus = true; }
        }
        BlenderValueSlider {
            id: posZ
            label: "Z:"
            value: transformTranslate.translate.z.toFixed(3)
            function update (f)  {
                transformTranslate.translate = Qt.vector3d(transformTranslate.translate.x, transformTranslate.translate.y, f);
            }
            Keys.onTabPressed:   { updateMe(); focus = false; rotX.focus = true; }
        }

        // ROTATE
        Text {
            text: "Rotation";
            color: "#FFFFFF"
            anchors.horizontalCenter: parent.horizontalCenter
        }
        BlenderValueSlider {
            id: rotX
            label: "X:"
            delta: 1
            min: 0;   limitMin: true
            max: 360; limitMax: true
            value: transformRotateX.angle.toFixed(3)
            function update (f)  { transformRotateX.angle = f }
            Keys.onTabPressed:   { updateMe(); focus = false; rotY.focus = true; }
        }
        BlenderValueSlider {
            id: rotY
            label: "Y:"
            delta: 1
            min: 0;   limitMin: true
            max: 360; limitMax: true
            value: transformRotateY.angle.toFixed(3)
            function update (f)  { transformRotateY.angle = f }
            Keys.onTabPressed:   { updateMe(); focus = false; rotZ.focus = true; }
        }
        BlenderValueSlider {
            id: rotZ
            label: "Z:"
            delta: 1
            min: 0;   limitMin: true
            max: 360; limitMax: true
            value: transformRotateZ.angle.toFixed(3)
            function update (f)  { transformRotateZ.angle = f }
            Keys.onTabPressed:   { updateMe(); focus = false; scaleX.focus = true; }
        }

        // SCALE
        Text {
            text: "Scale";
            color: "#FFFFFF"
            anchors.horizontalCenter: parent.horizontalCenter
        }
        BlenderValueSlider {
            id: scaleX
            label: "X:"
            min: 0; limitMin: true
            value: transformScale.scale.x.toFixed(3)
            function update (f)  { transformScale.scale = Qt.vector3d(f, transformScale.scale.y, transformScale.scale.z); }
            Keys.onTabPressed:   { updateMe(); focus = false; scaleY.focus = true; }
        }
        BlenderValueSlider {
            id: scaleY
            label: "Y:"
            min: 0; limitMin: true
            value: transformScale.scale.y.toFixed(3)
            function update (f)  { transformScale.scale = Qt.vector3d(transformScale.scale.x, f, transformScale.scale.z); }
            Keys.onTabPressed:   { updateMe(); focus = false; scaleZ.focus = true; }
        }
        BlenderValueSlider {
            id: scaleZ
            label: "Z:"
            min: 0; limitMin: true
            value: transformScale.scale.z.toFixed(3)
            function update (f)  { transformScale.scale = Qt.vector3d(transformScale.scale.x, transformScale.scale.y, f); }
            Keys.onTabPressed:   { updateMe(); focus = false; posX.focus = true; }
        }

    }
    Column {
        width: parent.width/2 - 16
        height: parent.height
        spacing: 8

        Row {
            width: parent.width
            height: childrenRect.height
            spacing: 8

            BlenderToggle {
                width: parent.width / 2 - 4
                buttonText: "Save!"
                function onClicked() {
                    var saveData =
                            "import QtQuick 1.0\n" +
                            "import Qt3D 1.0\n" +
                            "\n" +
                            "Item3D {\n" +
                            "    Translation3D {\n" +
                            "        id: transformTranslate\n" +
                            "        translate: Qt.vector3d(" +
                                transformTranslate.translate.x + ", " +
                                transformTranslate.translate.y + ", " +
                                transformTranslate.translate.z + ")\n" +
                            "    }\n" +
                            "\n" +
                            "    Rotation3D {\n" +
                            "        id: transformRotateX\n" +
                            "        angle: " + transformRotateX.angle + "\n" +
                            "        axis: Qt.vector3d(1, 0, 0)\n" +
                            "    }\n" +
                            "\n" +
                            "    Rotation3D {\n" +
                            "        id: transformRotateY\n" +
                            "        angle: " + transformRotateY.angle + "\n" +
                            "        axis: Qt.vector3d(0, 1, 0)\n" +
                            "    }\n" +
                            "\n" +
                            "    Rotation3D {\n" +
                            "        id: transformRotateZ\n" +
                            "        angle: " + transformRotateZ.angle + "\n" +
                            "        axis: Qt.vector3d(0, 0, 1)\n" +
                            "    }\n" +
                            "\n" +
                            "    Scale3D {\n" +
                            "        id: transformScale\n" +
                            "        scale: Qt.vector3d(" +
                                transformScale.scale.x + ", " +
                                transformScale.scale.y + ", " +
                                transformScale.scale.z + ")\n" +
                            "    }\n" +
                            "\n" +
                            "    Mesh {\n" +
                            "        id: source_mesh\n" +
                            "        source: \"%1\"\n" +
                            "    }\n" +
                            "\n" +
                            "    mesh: source_mesh\n" +
                            "    effect: Effect {}\n" +
                            "    transform: [\n" +
                            "        transformScale\n" +
                            "        transformRotateX,\n" +
                            "        transformRotateY,\n" +
                            "        transformRotateZ,\n" +
                            "        transformTranslate,\n" +
                            "    ]\n" +
                            "}\n";

                    quickSave.filename = source_mesh.source
                    quickSave.data = saveData
                    var result = quickSave.save
                    console.log("If there was an error it will be after here:" + result)
                }
            }

            BlenderToggle {
                width: parent.width / 2 - 4
                buttonText: "Load!"
                function onClicked() { console.log(quickLoad.openModelFile); }
            }

        }

        Row {
            width: parent.width
            height: childrenRect.height
            spacing: 8

            BlenderToggle {
                width: parent.width / 2 - 4
                buttonText: "Help!"
                function onClicked() { helpOverlay.visible = true }
            }

            BlenderToggle {
                width: parent.width / 2 - 4
                buttonText: "To let."
                function onClicked() { console.log("Dunno what this does yet...") }
            }
        }
    }
}