summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2016-11-10 10:57:23 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2016-11-10 11:30:48 +0000
commit9caf7130d15852052f5d0de07d3bbc99792d486c (patch)
treefead2999bd1370712341ecf9ebc5711edd71b4c8
parentf4a993b98e25037fe9e834feaeb98613ca901986 (diff)
Add option to GLTF export selected entity instead of whole scene
Change-Id: I1526c1cc17722eb1f4745b0ffd69fecdc6c9c9dd Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--editorlib/qml/ExportDialog.qml33
-rw-r--r--editorlib/src/editorscene.cpp7
-rw-r--r--editorlib/src/editorscene.h2
3 files changed, 35 insertions, 7 deletions
diff --git a/editorlib/qml/ExportDialog.qml b/editorlib/qml/ExportDialog.qml
index d38a802..ef8483d 100644
--- a/editorlib/qml/ExportDialog.qml
+++ b/editorlib/qml/ExportDialog.qml
@@ -40,11 +40,13 @@ Window {
color: editorContent.paneBackgroundColor
minimumHeight: exportLayout.Layout.minimumHeight + buttonRow.Layout.minimumHeight
minimumWidth: buttonRow.Layout.minimumWidth
+ property bool previousExportSceneRoot
property bool previousExportBinaryJson
property bool previousExportCompactJson
property string previousExportSceneName
property url previousExportFolder
+ property bool exportSceneRoot
property bool exportBinaryJson: true
property bool exportCompactJson: false
property string exportSceneName: ""
@@ -57,10 +59,13 @@ Window {
onVisibleChanged: {
if (visible == true) {
accepted = false;
+ previousExportSceneRoot = exportSceneRoot;
previousExportBinaryJson = exportBinaryJson;
previousExportCompactJson = exportCompactJson;
previousExportSceneName = exportSceneName;
previousExportFolder = exportFolder;
+ selectedEntityButton.checked = true;
+ sceneRootButton.checked = exportSceneRoot;
humanReadableJsonButton.checked = true;
binaryJsonButton.checked = exportBinaryJson;
compactJsonButton.checked = exportCompactJson;
@@ -68,6 +73,7 @@ Window {
currentFolder = exportFolder;
} else {
if (accepted) {
+ exportSceneRoot = sceneRootButton.checked;
exportBinaryJson = binaryJsonButton.checked;
exportCompactJson = compactJsonButton.checked;
exportSceneName = sceneNameField.text;
@@ -76,6 +82,7 @@ Window {
notification.text = qsTr("Scene exported successfully.");
notification.open();
} else {
+ exportSceneRoot = previousExportSceneRoot;
exportBinaryJson = previousExportBinaryJson;
exportCompactJson = previousExportCompactJson;
exportSceneName = previousExportSceneName;
@@ -109,6 +116,26 @@ Window {
ColumnLayout {
id: gltfOptionsLayout
StyledLabel {
+ text: qsTr("Exported entity") + editorScene.emptyString
+ font.weight: Font.Bold
+ }
+ RowLayout {
+ StyledRadioButton {
+ id: sceneRootButton
+ }
+ StyledLabel {
+ anchors.verticalCenter: parent.verticalCenter
+ text: qsTr("Scene Root") + editorScene.emptyString
+ }
+ StyledRadioButton {
+ id: selectedEntityButton
+ }
+ StyledLabel {
+ anchors.verticalCenter: parent.verticalCenter
+ text: qsTr("Selected Entity: %1").arg(selectedEntityName) + editorScene.emptyString
+ }
+ }
+ StyledLabel {
text: qsTr("JSON format") + editorScene.emptyString
font.weight: Font.Bold
}
@@ -122,7 +149,6 @@ Window {
}
StyledRadioButton {
id: compactJsonButton
- checked: exportCompactJson
}
StyledLabel {
anchors.verticalCenter: parent.verticalCenter
@@ -130,7 +156,6 @@ Window {
}
StyledRadioButton {
id: binaryJsonButton
- checked: exportBinaryJson
}
StyledLabel {
anchors.verticalCenter: parent.verticalCenter
@@ -209,8 +234,8 @@ Window {
onButtonClicked: {
var options = {binaryJson: binaryJsonButton.checked,
compactJson: compactJsonButton.checked};
- if (editorScene.exportGltfScene(currentFolder, sceneNameField.text, options)
- === true) {
+ if (editorScene.exportGltfScene(currentFolder, sceneNameField.text,
+ selectedEntityButton.checked, options) === true) {
dialog.accepted = true;
dialog.close();
}
diff --git a/editorlib/src/editorscene.cpp b/editorlib/src/editorscene.cpp
index 1d5a4ce..069f4b4 100644
--- a/editorlib/src/editorscene.cpp
+++ b/editorlib/src/editorscene.cpp
@@ -2180,7 +2180,7 @@ void EditorScene::changeCameraPosition(EditorScene::CameraPosition preset)
}
bool EditorScene::exportGltfScene(const QUrl &folder, const QString &exportName,
- const QJSValue &options)
+ bool exportSelected, const QJSValue &options)
{
#ifdef GLTF_EXPORTER_AVAILABLE
if (canExportGltf()) {
@@ -2193,7 +2193,10 @@ bool EditorScene::exportGltfScene(const QUrl &folder, const QString &exportName,
if (options.hasProperty(compactKey))
optionsHash.insert(compactKey, options.property(compactKey).toBool());
if (exportDir.length() > 0 && exportName.length() > 0) {
- if (!m_gltfExporter->exportScene(m_sceneEntity, exportDir, exportName, optionsHash))
+ Qt3DCore::QEntity *exportEntity = m_selectedEntity;
+ if (!exportSelected || !exportEntity)
+ exportEntity = m_sceneEntity;
+ if (!m_gltfExporter->exportScene(exportEntity, exportDir, exportName, optionsHash))
setError(m_gltfExportFailString);
else
return true;
diff --git a/editorlib/src/editorscene.h b/editorlib/src/editorscene.h
index 3fe5ede..19322c0 100644
--- a/editorlib/src/editorscene.h
+++ b/editorlib/src/editorscene.h
@@ -269,7 +269,7 @@ public:
Q_INVOKABLE void updateWorldPositionLabelToDragHandle(DragMode dragMode, int handleIndex = 0);
Q_INVOKABLE void changeCameraPosition(CameraPosition preset);
Q_INVOKABLE bool exportGltfScene(const QUrl &folder, const QString &exportName,
- const QJSValue &options);
+ bool exportSelected, const QJSValue &options);
void removeEntityFromMultiSelection(const QString &name);
void addEntityToMultiSelection(const QString &name);