diff --git a/interface/resources/serverless/Textures/2K-stone_floor_3-diffuse_l.jpg b/interface/resources/serverless/Textures/2K-stone_floor_3-diffuse_l.jpg new file mode 100644 index 0000000000..9887ef0afd Binary files /dev/null and b/interface/resources/serverless/Textures/2K-stone_floor_3-diffuse_l.jpg differ diff --git a/interface/resources/serverless/Textures/2K-wall_stone_2-diffuse_l.jpg b/interface/resources/serverless/Textures/2K-wall_stone_2-diffuse_l.jpg new file mode 100644 index 0000000000..129d3387db Binary files /dev/null and b/interface/resources/serverless/Textures/2K-wall_stone_2-diffuse_l.jpg differ diff --git a/interface/resources/serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg b/interface/resources/serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg new file mode 100644 index 0000000000..1ce9ac343c Binary files /dev/null and b/interface/resources/serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg differ diff --git a/interface/resources/serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg b/interface/resources/serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg new file mode 100644 index 0000000000..5a1c6321ff Binary files /dev/null and b/interface/resources/serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg differ diff --git a/interface/resources/serverless/Textures/floor_l.png b/interface/resources/serverless/Textures/floor_l.png new file mode 100644 index 0000000000..ec772423a6 Binary files /dev/null and b/interface/resources/serverless/Textures/floor_l.png differ diff --git a/interface/resources/serverless/Textures/ground_5-2K/2K-ground_5-diffuse.jpg b/interface/resources/serverless/Textures/ground_5-2K/2K-ground_5-diffuse.jpg new file mode 100644 index 0000000000..b38be02d64 Binary files /dev/null and b/interface/resources/serverless/Textures/ground_5-2K/2K-ground_5-diffuse.jpg differ diff --git a/interface/resources/serverless/Textures/ground_grass_gen_05.png b/interface/resources/serverless/Textures/ground_grass_gen_05.png new file mode 100644 index 0000000000..ad8c9607ef Binary files /dev/null and b/interface/resources/serverless/Textures/ground_grass_gen_05.png differ diff --git a/interface/resources/serverless/Textures/wall_l.png b/interface/resources/serverless/Textures/wall_l.png new file mode 100644 index 0000000000..673de0088e Binary files /dev/null and b/interface/resources/serverless/Textures/wall_l.png differ diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp index f6f41426d0..bdd5bd8e90 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp @@ -1103,10 +1103,6 @@ void RenderablePolyVoxEntityItem::compressVolumeDataAndSendEditPacket() { QByteArray compressedData = qCompress(uncompressedData, 9); writer << compressedData; - QByteArray decompressedData = qUncompress(compressedData); - qCDebug(entitiesrenderer) << "Uncompressed data size: " << uncompressedData.size() - << " compressed data size: " << compressedData.size() - << "Decompressed data size:" << decompressedData.size(); // make sure the compressed data can be sent over the wire-protocol if (newVoxelData.size() > 1150) { diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 294f15c07c..20a6970052 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1292,6 +1292,8 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { * type: "PolyVox", * position: position, * dimensions: { x: 2, y: 2, z: 2 }, + * voxelVolumeSize: { x: 16, y: 16, z: 16 }, + * voxelSurfaceStyle: 2, * xTextureURL: texture, * yTextureURL: texture, * zTextureURL: texture, diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index 03372f1fab..e00d72bc6b 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -751,6 +751,69 @@ var toolBar = (function () { } } } + + function handleNewPolyVoxDialogResult(result) { + if (result) { + var initialShape = result.initialShapeIndex; + var volumeSizeX = parseInt(result.volumeSizeX); + var volumeSizeY = parseInt(result.volumeSizeY); + var volumeSizeZ = parseInt(result.volumeSizeZ); + var voxelSurfaceStyle = parseInt(result.surfaceStyleIndex); + + var polyVoxID = createNewEntity({ + type: "PolyVox", + name: "terrain", + voxelVolumeSize: { + x: volumeSizeX, + y: volumeSizeY, + z: volumeSizeZ + }, + xTextureURL: result.xTextureURL, + yTextureURL: result.yTextureURL, + zTextureURL: result.zTextureURL, + voxelSurfaceStyle: 3, + collisionless: !(result.collisions), + grab: { + grabbable: result.grabbable + }, + }); + if (polyVoxID){ + // var properties = Entities.getEntityProperties(polyVoxID, ["position", "localDimensions"]); + // var position = properties.position; + // var localDimensions = properties.localDimensions; + switch (initialShape) { + // Sphere + // case 0: + // Entities.setVoxelSphere(polyVoxID, position, localDimensions/4, 255); + // break; + // Box + case 0: + Entities.setVoxelsInCuboid(polyVoxID, { + x: Math.round(volumeSizeX/4), + y: Math.round(volumeSizeY/4), + z: Math.round(volumeSizeZ/4) + }, { + x: Math.round(volumeSizeX/2.0), + y: Math.round(volumeSizeY/2.0), + z: Math.round(volumeSizeZ/2.0) + }, 255); + break; + // Plane + case 1: + Entities.setVoxelsInCuboid(polyVoxID, { + x: 0, + y: 0, + z: 0 + }, { + x: volumeSizeX, + y: Math.round(volumeSizeY/4), + z: volumeSizeZ + }, 255); + break; + } + } + } + } function handleNewMaterialDialogResult(result) { if (result) { @@ -807,6 +870,13 @@ var toolBar = (function () { case "newMaterialDialogCancel": closeExistingDialogWindow(); break; + case "newPolyVoxDialogAdd": + handleNewPolyVoxDialogResult(message.params); + closeExistingDialogWindow(); + break; + case "newPolyVoxDialogCancel": + closeExistingDialogWindow(); + break; } } @@ -913,6 +983,10 @@ var toolBar = (function () { closeExistingDialogWindow(); var qmlPath = Script.resolvePath("qml/New" + entityType + "Window.qml"); var DIALOG_WINDOW_SIZE = { x: 500, y: 300 }; + if( entityType === "PolyVox" ){ + DIALOG_WINDOW_SIZE.x = 600; + DIALOG_WINDOW_SIZE.y = 500; + } dialogWindow = Desktop.createWindow(qmlPath, { title: "New " + entityType + " Entity", additionalFlags: Desktop.ALWAYS_ON_TOP | Desktop.CLOSE_BUTTON_HIDES, diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index feb35783ac..3f80874672 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -1340,14 +1340,14 @@ const GROUPS = [ 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", diff --git a/scripts/system/create/qml/NewPolyVoxDialog.qml b/scripts/system/create/qml/NewPolyVoxDialog.qml index d22571438d..bbc9e7281a 100644 --- a/scripts/system/create/qml/NewPolyVoxDialog.qml +++ b/scripts/system/create/qml/NewPolyVoxDialog.qml @@ -53,9 +53,69 @@ Rectangle { anchors.left: parent.left anchors.right: parent.right anchors.bottom: keyboard.top + + ComboBox { + id: texturePreset + currentIndex: 0 + + property var texturePresetArray: ["Material presets", + "Grass + ground", + "Bricks", + "Stone", + "Concrete", + "Rock"] + + width: 200 + z: 100 + transformOrigin: Item.Center + model: texturePresetArray + + onCurrentIndexChanged: { + switch (currentIndex) { + // Clear texture entries + case 0: + xTextureURL.text = "" + yTextureURL.text = "" + zTextureURL.text = "" + break; + // Grass + ground + case 1: + xTextureURL.text = "qrc:///serverless/Textures/ground_5-2K/2K-ground_5-diffuse.jpg" + yTextureURL.text = "qrc:///serverless/Textures/ground_grass_gen_05.png" + zTextureURL.text = "qrc:///serverless/Textures/ground_5-2K/2K-ground_5-diffuse.jpg" + break; + // Bricks + case 2: + xTextureURL.text = "qrc:///serverless/Textures/2K-wall_stone_2-diffuse_l.jpg" + yTextureURL.text = "qrc:///serverless/Textures/2K-stone_floor_3-diffuse_l.jpg" + zTextureURL.text = "qrc:///serverless/Textures/2K-wall_stone_2-diffuse_l.jpg" + break; + // Stone + case 3: + xTextureURL.text = "qrc:///serverless/Textures/wall_l.png" + yTextureURL.text = "qrc:///serverless/Textures/floor_l.png" + zTextureURL.text = "qrc:///serverless/Textures/wall_l.png" + break; + // Concrete + case 4: + xTextureURL.text = "qrc:///serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg" + yTextureURL.text = "qrc:///serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg" + zTextureURL.text = "qrc:///serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg" + break; + // Rock + case 5: + xTextureURL.text = "qrc:///serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg" + yTextureURL.text = "qrc:///serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg" + zTextureURL.text = "qrc:///serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg" + break; + } + } + } Text { id: text1 + anchors.top: texturePreset.bottom + anchors.topMargin: 5 text: qsTr("X Texture URL") color: "#ffffff" font.pixelSize: 12 @@ -241,9 +301,10 @@ Rectangle { width: 50 anchors.left: textVolumeSizeX.right anchors.leftMargin: 3 - text: qsTr("") + text: qsTr("16") color: "white" font.pixelSize: 12 + validator: IntValidator{bottom: 8; top: 64;} onAccepted: { newPolyVoxDialog.keyboardEnabled = false; @@ -282,9 +343,10 @@ Rectangle { width: 50 anchors.left: textVolumeSizeY.right anchors.leftMargin: 3 - text: qsTr("") + text: qsTr("16") color: "white" font.pixelSize: 12 + validator: IntValidator{bottom: 8; top: 64;} onAccepted: { newPolyVoxDialog.keyboardEnabled = false; @@ -322,9 +384,10 @@ Rectangle { width: 50 anchors.left: textVolumeSizeZ.right anchors.leftMargin: 3 - text: qsTr("") + text: qsTr("16") color: "white" font.pixelSize: 12 + validator: IntValidator{bottom: 8; top: 64;} onAccepted: { newPolyVoxDialog.keyboardEnabled = false; @@ -400,6 +463,7 @@ Rectangle { ComboBox { id: surfaceStyle + currentIndex: 3 property var surfaceStyleArray: ["Marching Cubes", "Cubic", @@ -421,9 +485,9 @@ Rectangle { ComboBox { id: initialShape + currentIndex: 0 - property var initialShapeArray: ["Sphere", - "Box", + property var initialShapeArray: ["Box", "Plane"] width: 200 @@ -439,7 +503,7 @@ Rectangle { spacing: 5 anchors.horizontalCenter: column3.horizontalCenter - anchors.horizontalCenterOffset: -surfaceStyleArray20 + anchors.horizontalCenterOffset: -20 Button { id: button1 @@ -450,11 +514,16 @@ Rectangle { newPolyVoxDialog.sendToScript({ method: "newPolyVoxDialogAdd", params: { - url: xTextureURL.text, - dynamic: dynamic.checked, - collisionShapeIndex: surfaceStyle.currentIndex, + xTextureURL: xTextureURL.text, + yTextureURL: yTextureURL.text, + zTextureURL: zTextureURL.text, + volumeSizeX: volumeSizeX.text, + volumeSizeY: volumeSizeY.text, + volumeSizeZ: volumeSizeZ.text, + surfaceStyleIndex: surfaceStyle.currentIndex, + initialShapeIndex: initialShape.currentIndex, grabbable: grabbable.checked, - useOriginalPivot: useOriginalPivot.checked + collisions: collisions.checked, } }); } diff --git a/scripts/system/voxels.js b/scripts/system/voxels.js index 2f1d0eced9..f43ff32983 100644 --- a/scripts/system/voxels.js +++ b/scripts/system/voxels.js @@ -546,4 +546,4 @@ function cleanup() { Controller.mousePressEvent.connect(mousePressEvent); Controller.keyPressEvent.connect(keyPressEvent); Controller.keyReleaseEvent.connect(keyReleaseEvent); -Script.scriptEnding.connect(cleanup); \ No newline at end of file +Script.scriptEnding.connect(cleanup);