[ui] Viewer3D: better bounding box appearance

- Add edges to the bounding box. Appearance inspired by Blender.
- Better gizmo integration over the scene.
This commit is contained in:
Julien-Haudegond 2020-07-21 16:21:55 +02:00
parent 4ab412dd90
commit f2a75861c3
2 changed files with 80 additions and 13 deletions

View file

@ -7,19 +7,86 @@ import QtQuick 2.9
Entity {
id: root
property Transform transform: Transform {}
components: [mesh, transform, material]
CuboidMesh {
id: mesh
property real edge : 2 // Important to have all the cube's vertices with a unit of 1
xExtent: edge
yExtent: edge
zExtent: edge
components: [transform]
Entity {
components: [cube, greyMaterial]
CuboidMesh {
id: cube
property real edge : 1.995 // Almost 2: important to have all the cube's vertices with a unit of 1
xExtent: edge
yExtent: edge
zExtent: edge
}
PhongAlphaMaterial {
id: greyMaterial
property color base: "#fff"
ambient: base
alpha: 0.15
// Pretty convincing combination
blendFunctionArg: BlendEquation.Add
sourceRgbArg: BlendEquationArguments.SourceAlpha
sourceAlphaArg: BlendEquationArguments.OneMinusSourceAlpha
destinationRgbArg: BlendEquationArguments.DestinationColor
destinationAlphaArg: BlendEquationArguments.OneMinusSourceAlpha
}
}
PhongAlphaMaterial {
id: material
property color base: "#dfe233"
ambient: base
alpha: 0.3
Entity {
components: [edges, orangeMaterial]
PhongMaterial {
id: orangeMaterial
property color base: "#f49b2b"
ambient: base
}
GeometryRenderer {
id: edges
primitiveType: GeometryRenderer.Lines
geometry: Geometry {
Attribute {
id: boundingBoxPosition
attributeType: Attribute.VertexAttribute
vertexBaseType: Attribute.Float
vertexSize: 3
count: 24
name: defaultPositionAttributeName
buffer: Buffer {
type: Buffer.VertexBuffer
data: new Float32Array([
1.0, 1.0, 1.0,
1.0, -1.0, 1.0,
1.0, 1.0, 1.0,
1.0, 1.0, -1.0,
1.0, 1.0, 1.0,
-1.0, 1.0, 1.0,
-1.0, -1.0, -1.0,
-1.0, 1.0, -1.0,
-1.0, -1.0, -1.0,
1.0, -1.0, -1.0,
-1.0, -1.0, -1.0,
-1.0, -1.0, 1.0,
1.0, -1.0, 1.0,
1.0, -1.0, -1.0,
1.0, 1.0, -1.0,
1.0, -1.0, -1.0,
-1.0, 1.0, 1.0,
-1.0, 1.0, -1.0,
1.0, -1.0, 1.0,
-1.0, -1.0, 1.0,
-1.0, 1.0, 1.0,
-1.0, -1.0, 1.0,
-1.0, 1.0, -1.0,
1.0, 1.0, -1.0
])
}
}
boundingVolumePositionAttribute: boundingBoxPosition
}
}
}
}

View file

@ -215,7 +215,7 @@ FocusScope {
filterMode: LayerFilter.AcceptAnyMatchingLayers
layers: [drawOnFront]
RenderStateSet {
renderStates: DepthTest { depthFunction: DepthTest.Equal }
renderStates: DepthTest { depthFunction: DepthTest.GreaterOrEqual }
}
}
}