Unsolved DiffuseMapMaterial Texture
-
Hi all,
I'm trying to add a texture to my mesh but for some reason it wont work. Based on https://doc.qt.io/qt-5/qt3d-materials-renderableentity-qml.html
RenderableEntity{ id: bow source: "qrc:/assets/models/Bow.obj" position: Qt.vector3d(0, 0, 0) scale: 1 material: DiffuseMapMaterial { id: material diffuse: TextureImage { source: "qrc:/assets/models/texture.png" } specular: Qt.rgba( 0.2, 0.2, 0.2, 1.0 ) shininess: 1.0 } }
qrc:/main.qml:50:22: Cannot assign object to property
This makes no sense because according to the documentation:
https://doc.qt.io/qt-5/qml-qt3d-extras-diffusemapmaterial.html#diffuse-prop
it takes a Texture imageRenderableEntity{ id: bow source: "qrc:/assets/models/Bow.obj" position: Qt.vector3d(0, 0, 0) scale: 1 material: DiffuseMapMaterial { id: material diffuse: "qrc:/assets/models/texture.png" specular: Qt.rgba( 0.2, 0.2, 0.2, 1.0 ) shininess: 1.0 } }
qrc:/main.qml:50:22: Invalid property assignment: unsupported type "Qt3DRender::QAbstractTexture*"
-
Hi! Something is broken with TextureImage. I've experienced that, too. As a workaround the following worked for me:
TextureLoader { id: rectTexture source: rectEntity.textureSource } NormalDiffuseSpecularMapMaterial { id: rectMaterial ambient: // ... diffuse: rectTexture specular: rectTexture normal: rectTexture // ... } // ... components: [ rectMesh, rectMaterial, rectTransform ]
-
Thanks for the quick reply! What kind of an object is:
source: rectEntity.textureSource
Im not able to find the documentation of TextureLoader :(
TextureImage { id: ti; source: "qrc:/assets/models/texture.png" } TextureLoader { id: rectTexture ??? } RenderableEntity{ id: bow source: "qrc:/assets/models/Bow.obj" position: Qt.vector3d(0, 0, 0) scale: 1 material: DiffuseMapMaterial { id: material diffuse: rectTexture specular: Qt.rgba( 0.2, 0.2, 0.2, 1.0 ) shininess: 1.0 } }
-
TextureLoader { id: rectTexture source: "qrc:/assets/models/texture.png" }
-
-
Btw, what's your graphics card? Nvidia?
-
@Wieland NVidia 780 with the latest drivers
-
okay. things should work then.