| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 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.0 as QQ2 |
| 7 |
|
| 8 |
Entity { |
| 9 |
id: sceneRoot |
| 10 |
|
| 11 |
Camera { |
| 12 |
id: camera |
| 13 |
projectionType: CameraLens.PerspectiveProjection |
| 14 |
fieldOfView: 45 |
| 15 |
aspectRatio: 1280 / 768 //_window.width / _window.height |
| 16 |
nearPlane: 0.01 |
| 17 |
farPlane: 1000.0 |
| 18 |
position: Qt.vector3d(0.0, 0.0, -100.0) |
| 19 |
upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) |
| 20 |
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) |
| 21 |
} |
| 22 |
|
| 23 |
Configuration { |
| 24 |
controlledCamera: camera |
| 25 |
} |
| 26 |
|
| 27 |
Light { |
| 28 |
id: light |
| 29 |
} |
| 30 |
|
| 31 |
components: [ |
| 32 |
Qt3DBenchFrameGraph { |
| 33 |
id: frameGraph |
| 34 |
viewCamera: camera |
| 35 |
lightCamera: light.lightCamera |
| 36 |
} |
| 37 |
] |
| 38 |
|
| 39 |
ShadowEffect { |
| 40 |
id: shadowEffect |
| 41 |
|
| 42 |
shadowTexture: frameGraph.shadowTexture |
| 43 |
light: light |
| 44 |
} |
| 45 |
|
| 46 |
NodeInstantiator { |
| 47 |
id: spheres |
| 48 |
property int count: 100 |
| 49 |
property real spacing: 2 |
| 50 |
property int cols: 10 |
| 51 |
property int rows: 10 |
| 52 |
property int levelCount: cols * rows |
| 53 |
property int levels: 1 |
| 54 |
|
| 55 |
model: count |
| 56 |
delegate: SphereElement { |
| 57 |
id: sphereEntity |
| 58 |
|
| 59 |
xPos: spheres.spacing * (index % spheres.cols - 0.5 * (spheres.cols - 1)) |
| 60 |
yPos: spheres.spacing * (Math.floor(index / spheres.levelCount) - 0.5 * spheres.levels) |
| 61 |
zPos: spheres.spacing * (Math.floor((index % spheres.levelCount) / spheres.cols) - 0.5 * spheres.rows) |
| 62 |
material: ShadowMaterial { |
| 63 |
effect: shadowEffect |
| 64 |
diffuseColor: Qt.rgba(0.9, 0.5, 0.3, 1.0) |
| 65 |
shininess: 75 |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
// Ground plane |
| 71 |
// Just for showing that shadows are really working |
| 72 |
GroundPlane { |
| 73 |
material: ShadowMaterial { |
| 74 |
effect: shadowEffect |
| 75 |
diffuseColor: Qt.rgba(0.2, 0.5, 0.3, 1.0) |
| 76 |
specularColor: Qt.rgba(1.0, 0, 0, 1.0) |
| 77 |
} |
| 78 |
} |
| 79 |
} |