Voxel creation and presets from Create App
After Width: | Height: | Size: 4.5 MiB |
After Width: | Height: | Size: 4.9 MiB |
After Width: | Height: | Size: 4.6 MiB |
After Width: | Height: | Size: 3.5 MiB |
BIN
interface/resources/serverless/Textures/floor_l.png
Normal file
After Width: | Height: | Size: 3.2 MiB |
After Width: | Height: | Size: 4 MiB |
BIN
interface/resources/serverless/Textures/ground_grass_gen_05.png
Normal file
After Width: | Height: | Size: 2.6 MiB |
BIN
interface/resources/serverless/Textures/wall_l.png
Normal file
After Width: | Height: | Size: 3.5 MiB |
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -546,4 +546,4 @@ function cleanup() {
|
|||
Controller.mousePressEvent.connect(mousePressEvent);
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
|
|