summaryrefslogtreecommitdiffstats
path: root/examples/wireframe
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2014-12-15 15:54:44 +0000
committerSean Harmer <sean.harmer@kdab.com>2014-12-19 10:19:48 +0100
commitb93d45a312e1fc40a7dede177e46412f4f0e84cd (patch)
treee73c7a61a550ea77d9f9fa63c1297ea955d98768 /examples/wireframe
parent8c8fe2cb0d1b0d26090b7c7689b2f28ffce6a642 (diff)
Clean up the wireframe example a little
Change-Id: I1ceb32b820541f3a615d76439635bb794f6b0672 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'examples/wireframe')
-rw-r--r--examples/wireframe/BasicCamera.qml3
-rw-r--r--examples/wireframe/ForwardRenderer.qml6
-rw-r--r--examples/wireframe/TrefoilKnot.qml21
-rw-r--r--examples/wireframe/WireframeEffect.qml28
-rw-r--r--examples/wireframe/WireframeMaterial.qml5
-rw-r--r--examples/wireframe/main.qml16
6 files changed, 28 insertions, 51 deletions
diff --git a/examples/wireframe/BasicCamera.qml b/examples/wireframe/BasicCamera.qml
index 9c9f9583b..6f8c9c89a 100644
--- a/examples/wireframe/BasicCamera.qml
+++ b/examples/wireframe/BasicCamera.qml
@@ -41,15 +41,12 @@
import Qt3D 2.0
import Qt3D.Render 2.0
-import QtQuick 2.1 as QQ2
Camera {
id: mainCamera
- objectName: "mainCamera"
projectionType: CameraLens.PerspectiveProjection
fieldOfView: 22.5
aspectRatio: _window.width / _window.height
- onAspectRatioChanged: console.log( "aspectRatio = " + aspectRatio )
nearPlane: 0.01
farPlane: 1000.0
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
diff --git a/examples/wireframe/ForwardRenderer.qml b/examples/wireframe/ForwardRenderer.qml
index 7732f8827..80d8e5fdb 100644
--- a/examples/wireframe/ForwardRenderer.qml
+++ b/examples/wireframe/ForwardRenderer.qml
@@ -44,7 +44,6 @@ import Qt3D.Render 2.0
TechniqueFilter {
id: root
- objectName : "techniqueFilter"
// Expose camera to allow user to choose which camera to use for rendering
property alias camera: cameraSelector.camera
@@ -55,15 +54,14 @@ TechniqueFilter {
// Use the whole viewport
Viewport {
id: viewport
- objectName : "viewport"
rect: Qt.rect(0.0, 0.0, 1.0, 1.0)
+ clearColor: Qt.rgba( 1.0, 1.0, 1.0, 1.0 )
// Use the specified camera
CameraSelector {
id : cameraSelector
- objectName : "cameraSelector"
ClearBuffer {
- buffers : ClearBuffer.ColorDepthBuffer
+ buffers: ClearBuffer.ColorDepthBuffer
}
}
}
diff --git a/examples/wireframe/TrefoilKnot.qml b/examples/wireframe/TrefoilKnot.qml
index c3b6acb70..84a0aa373 100644
--- a/examples/wireframe/TrefoilKnot.qml
+++ b/examples/wireframe/TrefoilKnot.qml
@@ -41,27 +41,26 @@
import Qt3D 2.0
import Qt3D.Render 2.0
-import QtQuick 2.1 as QQ2
Entity {
id: root
- property real x: 0.0
- property real y: 0.0
- property real z: 0.0
- property real scale: 1.0
- property real theta: 0.0
- property real phi: 0.0
+ property alias x: translation.dx
+ property alias y: translation.dy
+ property alias z: translation.dz
+ property alias scale: scaleTransform.scale
+ property alias theta: thetaRotation.angle
+ property alias phi: phiRotation.angle
property Material material
components: [ transform, mesh, root.material ]
Transform {
id: transform
- Translate { dx: root.x; dy: root.y; dz: root.z }
- Scale { scale: root.scale }
- Rotate{ angle: root.theta; axis: Qt.vector3d(1.0, 0.0, 0.0) }
- Rotate{ angle: root.phi; axis: Qt.vector3d(0.0, 1.0, 0.0) }
+ Translate { id: translation }
+ Scale { id: scaleTransform }
+ Rotate{ id: thetaRotation; axis: Qt.vector3d( 1.0, 0.0, 0.0 ) }
+ Rotate{ id: phiRotation; axis: Qt.vector3d( 0.0, 1.0, 0.0 ) }
}
Mesh {
diff --git a/examples/wireframe/WireframeEffect.qml b/examples/wireframe/WireframeEffect.qml
index a5401439b..e5469630c 100644
--- a/examples/wireframe/WireframeEffect.qml
+++ b/examples/wireframe/WireframeEffect.qml
@@ -41,19 +41,10 @@
import Qt3D 2.0
import Qt3D.Render 2.0
-import QtQuick 2.1
Effect {
id: root
- // These parameters act as default values for the effect. They take
- // priority over any parameters specified in the RenderPasses below
- // (none provided in this example). In turn these parameters can be
- // overwritten by specifying them in a Material that references this
- // effect.
- // The priority order is:
- //
- // Material -> Effect -> Technique -> RenderPass -> GLSL default values
parameters: [
Parameter { name: "ambient"; value: Qt.vector3d( 0.1, 0.1, 0.1 ) },
Parameter { name: "diffuse"; value: Qt.vector3d( 0.7, 0.7, 0.7 ) },
@@ -70,33 +61,26 @@ Effect {
minorVersion: 1
}
- annotations: [ Annotation { name : "renderingStyle"; value : "forward" } ]
+ annotations: [ Annotation { name: "renderingStyle"; value: "forward" } ]
parameters: [
- Parameter { name: "light.position"; value: Qt.vector4d(0.0, 0.0, 0.0, 1.0) },
- Parameter { name: "light.intensity"; value: Qt.vector3d(1.0, 1.0, 1.0) },
- // TODO: 1.0 gets mapped as an integer for line.width. Fix this by using type from glsl
- // Works once we specify lineWidth property in WireframeMaterial as that is typed to a real
- Parameter { name: "line.width"; value: 1.01 },
- Parameter { name: "line.color"; value: Qt.vector4d(1.0, 1.0, 1.0, 1.0) }
+ Parameter { name: "light.position"; value: Qt.vector4d( 0.0, 0.0, 0.0, 1.0 ) },
+ Parameter { name: "light.intensity"; value: Qt.vector3d( 1.0, 1.0, 1.0 ) },
+ Parameter { name: "line.width"; value: 1.0 },
+ Parameter { name: "line.color"; value: Qt.vector4d( 1.0, 1.0, 1.0, 1.0 ) }
]
renderPasses: [
RenderPass {
- // The bindings property allows us to map from names of parameters (uniforms or vertex attributes)
- // within a shader to more friendly names in QML. By default the parameter names are exposed from
- // the shader so we only need to add add mappings where the names differ. E.g. here we map from the
- // ka uniform name in the shader to a property called ambient
bindings: [
- // Uniforms (those provided by the user)
ParameterMapping { parameterName: "ambient"; shaderVariableName: "ka"; bindingType: ParameterMapping.Uniform },
ParameterMapping { parameterName: "diffuse"; shaderVariableName: "kd"; bindingType: ParameterMapping.Uniform },
ParameterMapping { parameterName: "specular"; shaderVariableName: "ks"; bindingType: ParameterMapping.Uniform }
]
shaderProgram: ShaderProgram {
- vertexShaderCode: loadSource("qrc:/shaders/robustwireframe.vert")
+ vertexShaderCode: loadSource("qrc:/shaders/robustwireframe.vert")
geometryShaderCode: loadSource("qrc:/shaders/robustwireframe.geom")
fragmentShaderCode: loadSource("qrc:/shaders/robustwireframe.frag")
}
diff --git a/examples/wireframe/WireframeMaterial.qml b/examples/wireframe/WireframeMaterial.qml
index 80f65bd6b..ae5e9176e 100644
--- a/examples/wireframe/WireframeMaterial.qml
+++ b/examples/wireframe/WireframeMaterial.qml
@@ -41,7 +41,6 @@
import Qt3D 2.0
import Qt3D.Render 2.0
-import QtQuick 2.1 as QQ2
Material {
id: root
@@ -50,8 +49,8 @@ Material {
property color diffuse: Qt.rgba( 0.7, 0.7, 0.7, 1.0 )
property color specular: Qt.rgba( 0.95, 0.95, 0.95, 1.0 )
property real shininess: 150.0
- property real lineWidth: 1.0
- property color lineColor: Qt.rgba( 1.0, 1.0, 1.0, 1.0 )
+ property real lineWidth: 0.8
+ property color lineColor: Qt.rgba( 0.0, 0.0, 0.0, 1.0 )
parameters: [
Parameter { name: "ambient"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) },
diff --git a/examples/wireframe/main.qml b/examples/wireframe/main.qml
index ccb34d8b3..266689b04 100644
--- a/examples/wireframe/main.qml
+++ b/examples/wireframe/main.qml
@@ -45,10 +45,8 @@ import QtQuick 2.1 as QQ2
Entity {
id: root
- objectName: "root"
- // Use the renderer configuration specified in ForwardRenderer.qml
- // and render from the mainCamera
+ // Render from the mainCamera
components: [
FrameGraph {
activeFrameGraph: ForwardRenderer {
@@ -60,7 +58,7 @@ Entity {
BasicCamera {
id: mainCamera
- position: Qt.vector3d( 0.0, 0.0, 25.0 )
+ position: Qt.vector3d( 0.0, 0.0, 15.0 )
}
Configuration {
@@ -81,17 +79,19 @@ Entity {
target: wireframeMaterial;
property: "lineWidth";
duration: 1000;
- from: 1.0
- to: 3.0
+ from: 0.8
+ to: 1.8
}
QQ2.NumberAnimation {
target: wireframeMaterial;
property: "lineWidth";
duration: 1000;
- from: 3.0
- to: 1.0
+ from: 1.8
+ to: 0.8
}
+
+ QQ2.PauseAnimation { duration: 1500 }
}
}