| 1 |
// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
| 2 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 3 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 4 |
|
| 5 |
import Qt3D.Core 2.0 |
| 6 |
import Qt3D.Render 2.0 |
| 7 |
import QtQuick 2.1 |
| 8 |
|
| 9 |
Material { |
| 10 |
id: root |
| 11 |
property color ambientLight: Qt.rgba(0.1, 0.1, 0.1, 1.0) |
| 12 |
property color diffuseColor: Qt.rgba(0.7, 0.7, 0.7, 1.0) |
| 13 |
property color specularColor: Qt.rgba(0.5, 0.5, 0.5, 1.0) |
| 14 |
property real shininess: 150.0 |
| 15 |
property string diffuseMap |
| 16 |
property string specularMap |
| 17 |
property string normalMap |
| 18 |
property real textureScale: 1.0 |
| 19 |
property real opacity: 1.0 |
| 20 |
|
| 21 |
parameters: [ |
| 22 |
Parameter { |
| 23 |
name: "ambient" |
| 24 |
value: Qt.vector3d(root.ambientLight.r, root.ambientLight.g, root.ambientLight.b) |
| 25 |
}, |
| 26 |
Parameter { |
| 27 |
name: "diffuse" |
| 28 |
value: Qt.vector3d(root.diffuseColor.r, root.diffuseColor.g, root.diffuseColor.b) |
| 29 |
}, |
| 30 |
Parameter { |
| 31 |
name: "specular" |
| 32 |
value: Qt.vector3d(root.specularColor.r, root.specularColor.g, root.specularColor.b) |
| 33 |
}, |
| 34 |
Parameter { |
| 35 |
name: "shininess" |
| 36 |
value: root.shininess |
| 37 |
}, |
| 38 |
Parameter { |
| 39 |
name: "diffuseTexture" |
| 40 |
value: Texture2D { |
| 41 |
id: diffuseTexture |
| 42 |
minificationFilter: Texture.LinearMipMapLinear |
| 43 |
magnificationFilter: Texture.Linear |
| 44 |
wrapMode { |
| 45 |
x: WrapMode.Repeat |
| 46 |
y: WrapMode.Repeat |
| 47 |
} |
| 48 |
generateMipMaps: true |
| 49 |
maximumAnisotropy: 16.0 |
| 50 |
TextureImage { |
| 51 |
id: diffuseTextureImage |
| 52 |
source: diffuseMap |
| 53 |
} |
| 54 |
} |
| 55 |
}, |
| 56 |
Parameter { |
| 57 |
name: "specularTexture" |
| 58 |
value: Texture2D { |
| 59 |
id: specularTexture |
| 60 |
minificationFilter: Texture.LinearMipMapLinear |
| 61 |
magnificationFilter: Texture.Linear |
| 62 |
wrapMode { |
| 63 |
x: WrapMode.Repeat |
| 64 |
y: WrapMode.Repeat |
| 65 |
} |
| 66 |
generateMipMaps: true |
| 67 |
maximumAnisotropy: 16.0 |
| 68 |
TextureImage { |
| 69 |
id: specularTextureImage |
| 70 |
// Get rid of runtime warnings. It's safe, as the texture just isn't used |
| 71 |
source: specularMap !== "" ? specularMap |
| 72 |
: "qrc:/images/solarsystemscope/uranusmap.jpg" |
| 73 |
} |
| 74 |
} |
| 75 |
}, |
| 76 |
Parameter { |
| 77 |
name: "normalTexture" |
| 78 |
value: Texture2D { |
| 79 |
id: normalTexture |
| 80 |
minificationFilter: Texture.Linear |
| 81 |
magnificationFilter: Texture.Linear |
| 82 |
wrapMode { |
| 83 |
x: WrapMode.Repeat |
| 84 |
y: WrapMode.Repeat |
| 85 |
} |
| 86 |
maximumAnisotropy: 16.0 |
| 87 |
TextureImage { |
| 88 |
id: normalTextureImage |
| 89 |
// Get rid of runtime warnings. It's safe, as the texture just isn't used |
| 90 |
source: normalMap !== "" ? normalMap |
| 91 |
: "qrc:/images/solarsystemscope/uranusmap.jpg" |
| 92 |
} |
| 93 |
} |
| 94 |
}, |
| 95 |
Parameter { |
| 96 |
name: "texCoordScale" |
| 97 |
value: textureScale |
| 98 |
}, |
| 99 |
Parameter { |
| 100 |
name: "opacity" |
| 101 |
value: opacity |
| 102 |
} |
| 103 |
] |
| 104 |
} |