Debian Codegraph @

tests/manual/shared_texture_image/main.qml

raw
1 // Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
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.0
6 import Qt3D.Render 2.0
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, 0.0, -40.0 )
21 upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
22 viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
23 }
24
25 OrbitCameraController {
26 camera: camera
27 }
28
29 components: [
30 RenderSettings {
31 activeFrameGraph: ForwardRenderer {
32 clearColor: Qt.rgba(0, 0.5, 1, 1)
33 camera: camera
34 }
35 },
36 // Event Source will be set by the Qt3DQuickWindow
37 InputSettings { }
38 ]
39
40 // 2 Textures can reference the same texture image
41 // (Though it's up to the user to make sure that the images are compatible with the textures)
42 // If the 2 Textures contain the exact same number of images and filtering options
43 // Qt3D will only generate 1 actual GL texture, if they differ, 2 will be generated
44 TextureImage {
45 id: mainImage
46 source: "qrc:/image.png"
47 }
48
49 readonly property GeometryRenderer mesh: CuboidMesh { }
50
51 Entity {
52 id: leftCube
53
54 readonly property Transform transform: Transform {
55 translation: Qt.vector3d(-10, 0, 0)
56 scale: 10
57 }
58
59 readonly property DiffuseMapMaterial material: DiffuseMapMaterial {
60 diffuse: Texture2D {
61 generateMipMaps: false
62 minificationFilter: Texture.Nearest
63 magnificationFilter: Texture.Nearest
64 wrapMode {
65 x: WrapMode.ClampToEdge
66 y: WrapMode.ClampToEdge
67 }
68 textureImages: [mainImage]
69 }
70 }
71 components: [ mesh, material, transform ]
72 }
73
74 Entity {
75 id: rightCube
76
77 readonly property Transform transform: Transform {
78 translation: Qt.vector3d(10, 0, 0)
79 scale: 10
80 }
81
82 readonly property DiffuseMapMaterial material: DiffuseMapMaterial {
83 diffuse: Texture2D {
84 generateMipMaps: true
85 minificationFilter: Texture.LinearMipMapLinear
86 magnificationFilter: Texture.Linear
87 maximumAnisotropy: 16.0
88 wrapMode {
89 x: WrapMode.ClampToEdge
90 y: WrapMode.ClampToEdge
91 }
92 textureImages: [mainImage]
93 }
94 }
95 components: [ mesh, material, transform ]
96 }
97 }