Debian Codegraph @

tests/manual/bigscene-instanced-qml/main.qml

raw
1 // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 import Qt3D.Core 2.0
5 import Qt3D.Render 2.0
6 import QtQuick 2.2 as QQ2
7 import Qt3D.Input 2.0
8 import Qt3D.Extras 2.0
9
10 Entity {
11 id: sceneRoot
12
13 Camera {
14 id: camera
15 projectionType: CameraLens.PerspectiveProjection
16 fieldOfView: 45
17 aspectRatio: 16/9
18 nearPlane : 0.1
19 farPlane : 1000.0
20 position: Qt.vector3d(0.0, -300.0, 50.0)
21 upVector: Qt.vector3d(0.0, 1.0, 0.0)
22 viewCenter: Qt.vector3d(0.0, 0.0, 0.0)
23 }
24
25 FirstPersonCameraController { camera: camera }
26
27 components: [
28 RenderSettings {
29 activeFrameGraph: ForwardRenderer {
30 clearColor: Qt.rgba(0, 0.5, 1, 1)
31 camera: camera
32 }
33 // we need to explicitly set the RenderPolicy to AlwaysRender here,
34 // because a vertex shader will use time-based rendering, so the
35 // scene will change every frame without the scene-graph changing.
36 // RenderOnDemand would therefore not render every frame, as it won't
37 // detect scene-graph changes
38 renderPolicy: RenderSettings.Always
39 },
40 // Event Source will be set by the Qt3DQuickWindow
41 InputSettings { }
42 ]
43
44 property real timeValue: 5
45
46 Material {
47 id: instancedPhongMaterial
48 effect: Effect {
49 techniques: Technique {
50 graphicsApiFilter {
51 api: GraphicsApiFilter.OpenGL
52 profile: GraphicsApiFilter.CoreProfile
53 minorVersion: 2
54 majorVersion: 3
55 }
56 filterKeys: [ FilterKey { name: "renderingStyle"; value: "forward" } ]
57 renderPasses: RenderPass {
58 shaderProgram: ShaderProgram {
59 vertexShaderCode: loadSource("qrc:/instanced.vert")
60 fragmentShaderCode: loadSource("qrc:/instanced.frag")
61 }
62 }
63 }
64 }
65 parameters: Parameter { name: "instanceCount"; value: cylinderMeshRenderer.view.instanceCount }
66 }
67
68 CylinderMesh {
69 id: cylinderMeshRenderer
70 view.instanceCount: 2000
71 rings: 50
72 slices: 30
73 radius: 2.5
74 length: 5.0
75 }
76
77 Entity {
78 id: torusEntity
79 components: [ cylinderMeshRenderer, instancedPhongMaterial ]
80 }
81 }