| 1 |
// Copyright (C) 2017 Juan José Casafranca. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
import QtQuick 2.2 as QQ2 |
| 5 |
import Qt3D.Core 2.9 |
| 6 |
import Qt3D.Render 2.9 |
| 7 |
import Qt3D.Input 2.0 |
| 8 |
import Qt3D.Extras 2.0 |
| 9 |
|
| 10 |
Entity { |
| 11 |
id: sceneRoot |
| 12 |
|
| 13 |
Camera { |
| 14 |
id: sceneCamera |
| 15 |
projectionType: CameraLens.PerspectiveProjection |
| 16 |
upVector: Qt.vector3d(0, 1, 0) |
| 17 |
position: Qt.vector3d(0, 0, -800) |
| 18 |
viewCenter: Qt.vector3d(0, 0, 0) |
| 19 |
nearPlane: 0.1 |
| 20 |
farPlane: 1000 |
| 21 |
fieldOfView: 25 |
| 22 |
aspectRatio: 1.33 |
| 23 |
} |
| 24 |
|
| 25 |
components: [ |
| 26 |
RenderSettings { |
| 27 |
ComputeFrameGraph { |
| 28 |
} |
| 29 |
// explicitly set RenderingPolicy to AlwaysRender, as changes in the |
| 30 |
// scene won't be reflected in actual Qt scene-graph changes (due to |
| 31 |
// GPU compute calls) |
| 32 |
renderPolicy: RenderSettings.Always |
| 33 |
} |
| 34 |
] |
| 35 |
|
| 36 |
function initGraphBuffer() { |
| 37 |
var bufferData = new Uint32Array(1024); |
| 38 |
for (var i = 0; i < 1024; ++i) { |
| 39 |
bufferData[i] = 1; |
| 40 |
} |
| 41 |
return bufferData |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
Buffer { |
| 46 |
id: graphBuffer |
| 47 |
objectName: "buffer" |
| 48 |
accessType: Buffer.ReadWrite |
| 49 |
data: initGraphBuffer() |
| 50 |
} |
| 51 |
|
| 52 |
ComputeMaterial { |
| 53 |
id: computeMaterial |
| 54 |
dataBuffer: graphBuffer |
| 55 |
inputSize: 1024 |
| 56 |
} |
| 57 |
|
| 58 |
Entity { |
| 59 |
id: particleComputeEntity |
| 60 |
readonly property ComputeCommand particlesComputeJob: ComputeCommand {} |
| 61 |
components: [ |
| 62 |
particlesComputeJob, |
| 63 |
computeMaterial |
| 64 |
] |
| 65 |
} |
| 66 |
} |