diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index 60a364d9cf..03372f1fab 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -4,6 +4,7 @@ // Persist toolbar by HRS 6/11/15. // Copyright 2014 High Fidelity, Inc. // Copyright 2020 Vircadia contributors. +// Copyright 2022 Overte e.V. // // This script allows you to edit entities with a new UI/UX for mouse and trackpad based editing // @@ -971,6 +972,8 @@ var toolBar = (function () { addButton("newMaterialButton", createNewEntityDialogButtonCallback("Material")); + addButton("newPolyVoxButton", createNewEntityDialogButtonCallback("PolyVox")); + var deactivateCreateIfDesktopWindowsHidden = function() { if (!shouldUseEditTabletApp() && !entityListTool.isVisible() && !createToolsWindow.isVisible()) { that.setActive(false); diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index 85c7b378da..feb35783ac 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -1326,6 +1326,48 @@ const GROUPS = [ } ] }, + { + id: "polyvox", + label: "POLYVOX", + properties: [ + { + label: "Volume Size", + type: "vec3", + vec3Type: "xyz", + step: 1.0, + decimals: 0, + subLabels: [ "x", "y", "z" ], + unit: "", + propertyID: "voxelVolumeSize", + }, + { + label: "Surface Style", + type: "dropdown", + options: { 0: "Marching cubes", 1: "Cubic", + 2: "Edged cubic", 3: "Edged marching cubes" }, + propertyID: "voxelSurfaceStyle", + propertyName: "voxelSurfaceStyle", + }, + { + label: "X Texture URL", + type: "string", + propertyID: "xTextureURL", + propertyName: "xTextureURL", + }, + { + label: "Y Texture URL", + type: "string", + propertyID: "yTextureURL", + propertyName: "yTextureURL", + }, + { + label: "Z Texture URL", + type: "string", + propertyID: "zTextureURL", + propertyName: "zTextureURL", + }, + ] + }, { id: "spatial", label: "SPATIAL", @@ -1705,7 +1747,7 @@ const GROUPS_PER_TYPE = { ParticleEffect: [ 'base', 'particles', 'particles_emit', 'particles_size', 'particles_color', 'particles_behavior', 'particles_constraints', 'spatial', 'behavior', 'scripts', 'physics' ], PolyLine: [ 'base', 'spatial', 'behavior', 'scripts', 'collision', 'physics' ], - PolyVox: [ 'base', 'spatial', 'behavior', 'scripts', 'collision', 'physics' ], + PolyVox: [ 'base', 'polyvox', 'spatial', 'behavior', 'scripts', 'collision', 'physics' ], Grid: [ 'base', 'grid', 'spatial', 'behavior', 'scripts', 'physics' ], Multiple: [ 'base', 'spatial', 'behavior', 'scripts', 'collision', 'physics' ], }; diff --git a/scripts/system/create/qml/EditTabView.qml b/scripts/system/create/qml/EditTabView.qml index 617cdd9e5a..b122370192 100644 --- a/scripts/system/create/qml/EditTabView.qml +++ b/scripts/system/create/qml/EditTabView.qml @@ -178,6 +178,18 @@ TabBar { editTabView.currentIndex = 2 } } + + NewEntityButton { + icon: "icons/voxels.svg" + text: "VOXELS" + onClicked: { + editRoot.sendToScript({ + method: "newEntityButtonClicked", + params: { buttonName: "newPolyVoxButton" } + }); + editTabView.currentIndex = 2 + } + } } HifiControls.Button { diff --git a/scripts/system/create/qml/EditToolsTabView.qml b/scripts/system/create/qml/EditToolsTabView.qml index 39074946bd..bd4d47ddea 100644 --- a/scripts/system/create/qml/EditToolsTabView.qml +++ b/scripts/system/create/qml/EditToolsTabView.qml @@ -184,6 +184,18 @@ TabBar { editTabView.currentIndex = tabIndex.properties } } + + NewEntityButton { + icon: "icons/voxels.svg" + text: "VOXELS" + onClicked: { + editRoot.sendToScript({ + method: "newEntityButtonClicked", + params: { buttonName: "newPolyVoxButton" } + }); + editTabView.currentIndex = tabIndex.properties + } + } } HifiControls.Button { diff --git a/scripts/system/create/qml/NewPolyVoxDialog.qml b/scripts/system/create/qml/NewPolyVoxDialog.qml new file mode 100644 index 0000000000..d22571438d --- /dev/null +++ b/scripts/system/create/qml/NewPolyVoxDialog.qml @@ -0,0 +1,487 @@ +// +// NewPolyVoxDialog.qml +// based on NewModelDialog.qml +// qml/hifi +// +// Copyright 2017 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors +// Copyright 2022 Overte e.V. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtQuick.Dialogs 1.2 as OriginalDialogs + +import stylesUit 1.0 +import controlsUit 1.0 +import hifi.dialogs 1.0 + +Rectangle { + id: newPolyVoxDialog + // width: parent.width + // height: parent.height + HifiConstants { id: hifi } + color: hifi.colors.baseGray; + signal sendToScript(var message); + property bool keyboardEnabled: false + property bool keyboardRaised: false + property bool punctuationMode: false + property bool keyboardRasied: false + + function errorMessageBox(message) { + try { + return desktop.messageBox({ + icon: hifi.icons.warning, + defaultButton: OriginalDialogs.StandardButton.Ok, + title: "Error", + text: message + }); + } catch(e) { + Window.alert(message); + } + } + + Item { + id: column1 + anchors.rightMargin: 10 + anchors.leftMargin: 10 + anchors.bottomMargin: 10 + anchors.topMargin: 0 + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: keyboard.top + + Text { + id: text1 + text: qsTr("X Texture URL") + color: "#ffffff" + font.pixelSize: 12 + } + + TextInput { + id: xTextureURL + height: 20 + text: qsTr("") + color: "white" + anchors.top: text1.bottom + anchors.topMargin: 5 + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.right: parent.right + anchors.rightMargin: 0 + font.pixelSize: 12 + + onAccepted: { + newPolyVoxDialog.keyboardEnabled = false; + } + + onTextChanged : { + if (xTextureURL.text.length === 0){ + button1.enabled = false; + } else { + button1.enabled = true; + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + newPolyVoxDialog.keyboardEnabled = HMD.active + parent.focus = true; + parent.forceActiveFocus(); + xTextureURL.cursorPosition = xTextureURL.positionAt(mouseX, mouseY, TextInput.CursorBetweenCharaters); + } + } + } + + Rectangle { + id: textInputBox1 + color: "white" + anchors.fill: xTextureURL + opacity: 0.1 + } + + Text { + id: text2 + text: qsTr("Y Texture URL") + color: "#ffffff" + font.pixelSize: 12 + anchors.top: textInputBox1.bottom + anchors.topMargin: 5 + } + + TextInput { + id: yTextureURL + height: 20 + text: qsTr("") + color: "white" + anchors.top: text2.bottom + anchors.topMargin: 5 + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.right: parent.right + anchors.rightMargin: 0 + font.pixelSize: 12 + + onAccepted: { + newPolyVoxDialog.keyboardEnabled = false; + } + + onTextChanged : { + if (yTextureURL.text.length === 0){ + button1.enabled = false; + } else { + button1.enabled = true; + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + newPolyVoxDialog.keyboardEnabled = HMD.active + parent.focus = true; + parent.forceActiveFocus(); + yTextureURL.cursorPosition = yTextureURL.positionAt(mouseX, mouseY, TextInput.CursorBetweenCharaters); + } + } + } + + Rectangle { + id: textInputBox2 + color: "white" + anchors.fill: yTextureURL + opacity: 0.1 + } + + Text { + id: text3 + text: qsTr("Z Texture URL") + color: "#ffffff" + font.pixelSize: 12 + anchors.top: textInputBox2.bottom + anchors.topMargin: 5 + } + + TextInput { + id: zTextureURL + height: 20 + text: qsTr("") + color: "white" + anchors.top: text3.bottom + anchors.topMargin: 5 + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.right: parent.right + anchors.rightMargin: 0 + font.pixelSize: 12 + + onAccepted: { + newPolyVoxDialog.keyboardEnabled = false; + } + + onTextChanged : { + if (zTextureURL.text.length === 0){ + button1.enabled = false; + } else { + button1.enabled = true; + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + newPolyVoxDialog.keyboardEnabled = HMD.active + parent.focus = true; + parent.forceActiveFocus(); + zTextureURL.cursorPosition = zTextureURL.positionAt(mouseX, mouseY, TextInput.CursorBetweenCharaters); + } + } + } + + Rectangle { + id: textInputBox3 + color: "white" + anchors.fill: zTextureURL + opacity: 0.1 + } + + Text { + id: textVolumeSize + text: qsTr("Volume Size (number of voxels along the edge)") + color: "#ffffff" + font.pixelSize: 12 + anchors.top: zTextureURL.bottom + anchors.topMargin: 5 + } + + Row { + id: rowVolumeSize + height: 50 + spacing: 30 + anchors.top: textVolumeSize.bottom + anchors.topMargin: 5 + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.right: parent.right + anchors.rightMargin: 0 + + Text { + id: textVolumeSizeX + text: qsTr("X") + color: "#ffffff" + font.pixelSize: 12 + } + + TextInput { + id: volumeSizeX + height: 20 + width: 50 + anchors.left: textVolumeSizeX.right + anchors.leftMargin: 3 + text: qsTr("") + color: "white" + font.pixelSize: 12 + + onAccepted: { + newPolyVoxDialog.keyboardEnabled = false; + } + + MouseArea { + anchors.fill: parent + onClicked: { + newPolyVoxDialog.keyboardEnabled = HMD.active + parent.focus = true; + parent.forceActiveFocus(); + volumeSizeX.cursorPosition = volumeSizeX.positionAt(mouseX, mouseY, TextInput.CursorBetweenCharaters); + } + } + } + + Rectangle { + id: textInputBoxVolumeSizeX + color: "white" + anchors.fill: volumeSizeX + opacity: 0.1 + } + + Text { + id: textVolumeSizeY + text: qsTr("Y") + color: "#ffffff" + font.pixelSize: 12 + anchors.left: volumeSizeX.right + anchors.leftMargin: 5 + } + + TextInput { + id: volumeSizeY + height: 20 + width: 50 + anchors.left: textVolumeSizeY.right + anchors.leftMargin: 3 + text: qsTr("") + color: "white" + font.pixelSize: 12 + + onAccepted: { + newPolyVoxDialog.keyboardEnabled = false; + } + + MouseArea { + anchors.fill: parent + onClicked: { + newPolyVoxDialog.keyboardEnabled = HMD.active + parent.focus = true; + parent.forceActiveFocus(); + volumeSizeY.cursorPosition = volumeSizeY.positionAt(mouseX, mouseY, TextInput.CursorBetweenCharaters); + } + } + } + + Rectangle { + id: textInputBoxVolumeSizeY + color: "white" + anchors.fill: volumeSizeY + opacity: 0.1 + } + Text { + id: textVolumeSizeZ + text: qsTr("X") + color: "#ffffff" + font.pixelSize: 12 + anchors.left: volumeSizeY.right + anchors.leftMargin: 5 + } + + TextInput { + id: volumeSizeZ + height: 20 + width: 50 + anchors.left: textVolumeSizeZ.right + anchors.leftMargin: 3 + text: qsTr("") + color: "white" + font.pixelSize: 12 + + onAccepted: { + newPolyVoxDialog.keyboardEnabled = false; + } + + MouseArea { + anchors.fill: parent + onClicked: { + newPolyVoxDialog.keyboardEnabled = HMD.active + parent.focus = true; + parent.forceActiveFocus(); + volumeSizeZ.cursorPosition = volumeSizeZ.positionAt(mouseX, mouseY, TextInput.CursorBetweenCharaters); + } + } + } + + Rectangle { + id: textInputBoxVolumeSizeZ + color: "white" + anchors.fill: volumeSizeZ + opacity: 0.1 + } + } + + Row { + id: row1 + height: 400 + spacing: 30 + anchors.top: rowVolumeSize.bottom + anchors.topMargin: 5 + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.right: parent.right + anchors.rightMargin: 0 + + Column { + id: column2 + width: 200 + height: 600 + spacing: 10 + + + CheckBox { + id: grabbable + text: qsTr("Grabbable") + } + + CheckBox { + id: collisions + text: qsTr("Collisions") + } + + Row { + id: row2 + width: 200 + height: 400 + spacing: 20 + + } + } + + Column { + id: column3 + height: 400 + spacing: 10 + + Text { + id: text4 + text: qsTr("Voxel type") + color: "#ffffff" + font.pixelSize: 12 + } + + ComboBox { + id: surfaceStyle + + property var surfaceStyleArray: ["Marching Cubes", + "Cubic", + "Edged Cubic", + "Edged Marching Cubes"] + + width: 200 + z: 100 + transformOrigin: Item.Center + model: surfaceStyleArray + } + + Text { + id: textInitialShape + text: qsTr("Initial shape") + color: "#ffffff" + font.pixelSize: 12 + } + + ComboBox { + id: initialShape + + property var initialShapeArray: ["Sphere", + "Box", + "Plane"] + + width: 200 + z: 100 + transformOrigin: Item.Center + model: initialShapeArray + } + + Row { + id: row3 + width: 200 + height: 400 + spacing: 5 + + anchors.horizontalCenter: column3.horizontalCenter + anchors.horizontalCenterOffset: -surfaceStyleArray20 + + Button { + id: button1 + text: qsTr("Create") + z: -1 + enabled: false + onClicked: { + newPolyVoxDialog.sendToScript({ + method: "newPolyVoxDialogAdd", + params: { + url: xTextureURL.text, + dynamic: dynamic.checked, + collisionShapeIndex: surfaceStyle.currentIndex, + grabbable: grabbable.checked, + useOriginalPivot: useOriginalPivot.checked + } + }); + } + } + + Button { + id: button2 + z: -1 + text: qsTr("Cancel") + onClicked: { + newPolyVoxDialog.sendToScript({method: "newPolyVoxDialogCancel"}) + } + } + } + } + } + } + + Keyboard { + id: keyboard + raised: parent.keyboardEnabled && parent.keyboardRaised + numeric: parent.punctuationMode + anchors { + bottom: parent.bottom + bottomMargin: 40 + left: parent.left + right: parent.right + } + } +} diff --git a/scripts/system/create/qml/NewPolyVoxWindow.qml b/scripts/system/create/qml/NewPolyVoxWindow.qml new file mode 100644 index 0000000000..bd05922714 --- /dev/null +++ b/scripts/system/create/qml/NewPolyVoxWindow.qml @@ -0,0 +1,20 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.2 + +StackView { + id: stackView + anchors.fill: parent + anchors.leftMargin: 10 + anchors.rightMargin: 10 + anchors.topMargin: 40 + + signal sendToScript(var message); + + NewPolyVoxDialog { + id: dialog + anchors.fill: parent + Component.onCompleted:{ + dialog.sendToScript.connect(stackView.sendToScript); + } + } +} diff --git a/scripts/system/create/qml/icons/voxels.svg b/scripts/system/create/qml/icons/voxels.svg new file mode 100644 index 0000000000..a7520bd4f2 --- /dev/null +++ b/scripts/system/create/qml/icons/voxels.svg @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> + +<svg + version="1.1" + id="Layer_1" + x="0px" + y="0px" + viewBox="0 0 50 50" + style="enable-background:new 0 0 50 50;" + xml:space="preserve" + sodipodi:docname="voxels.svg" + inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)" + 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"><defs + id="defs27" /><sodipodi:namedview + id="namedview25" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + showgrid="false" + inkscape:zoom="17.42" + inkscape:cx="25.028703" + inkscape:cy="20.407577" + inkscape:window-width="1918" + inkscape:window-height="1042" + inkscape:window-x="1920" + inkscape:window-y="18" + inkscape:window-maximized="1" + inkscape:current-layer="Layer_1" /> +<style + type="text/css" + id="style2"> + .st0{opacity:0.9;} + .st1{fill:#1E1E1E;} + .st2{fill:#EAEAEA;} +</style> + +<path + class="st2" + d="M 42.986179,11.33074 34.367376,6.3639716 c -0.438244,-0.2921628 -1.02257,-0.2921628 -1.460814,0 L 25.164247,10.892495 17.129769,6.2178902 c -0.438244,-0.2921628 -1.02257,-0.2921628 -1.460814,0 L 7.196233,11.184658 C 6.7579887,11.476821 6.4658259,11.915065 6.4658259,12.35331 v 9.933535 c 0,0.438244 0.2921628,1.02257 0.7304071,1.168651 l 7.888397,4.528524 v 9.057048 c 0,0.438244 0.292162,1.02257 0.730407,1.168651 l 8.618803,4.966768 c 0.292163,0.146081 0.438244,0.146081 0.730407,0.146081 0.292163,0 0.438244,0 0.730407,-0.146081 l 8.618803,-4.966768 c 0.438245,-0.292163 0.730407,-0.730407 0.730407,-1.168651 v -8.910966 l 7.888397,-4.528524 c 0.438244,-0.292163 0.730407,-0.730407 0.730407,-1.168652 V 12.499391 C 43.716586,12.061147 43.424423,11.622902 42.986179,11.33074 Z m -2.04514,8.910965 -5.989337,-3.505954 V 9.8699255 l 5.989337,3.5059535 z m -7.011907,5.551094 -7.304071,-4.236361 v -8.180559 l 5.989338,-3.5059535 v 6.8658255 l -2.921628,1.752977 c -0.584326,0.292163 -0.730407,1.02257 -0.438244,1.606896 0.292162,0.438244 0.584325,0.584326 1.022569,0.584326 0.146082,0 0.438245,0 0.584326,-0.146082 l 2.921628,-1.752977 5.989338,3.505954 z m -7.596234,5.697175 v -6.719745 l 5.989338,3.505954 v 6.719745 z M 23.703433,20.095624 17.714095,16.58967 V 9.7238441 l 5.989338,3.5059539 z M 9.2413727,13.229798 15.230711,9.7238441 V 16.58967 l -3.213791,1.899058 c -0.584326,0.292163 -0.730407,1.02257 -0.438244,1.606896 0.292163,0.438244 0.584325,0.584326 1.02257,0.584326 0.146081,0 0.438244,0 0.584325,-0.146082 l 3.213791,-1.899058 5.989338,3.505954 -5.989338,3.505954 -7.1579893,-4.09028 z m 15.9228743,27.317224 -7.157989,-4.09028 v -8.180559 l 5.989338,-3.505954 v 6.865826 l -2.921629,1.606896 c -0.584325,0.292163 -0.730407,1.02257 -0.438244,1.606895 0.292163,0.438245 0.584326,0.584326 1.02257,0.584326 0.146082,0 0.438244,0 0.584326,-0.146081 l 2.921628,-1.606896 5.989338,3.505954 z" + id="path10" + style="stroke-width:1.46081;fill:#000000" /> + +</svg>