Nominate our 2022 Qt Champions!

How to add texture to 3D obj in Entity element in qml in Qt 5.5?

  • The following code snippet shows how I have tried to add texture to the .obj file.
    This is the error message:
    Texture data is null, texture data failed to load

    Entity {
    property Material materialSpeedometer: PMaterial{}
    components: [
    Mesh {
    source: "assets/obj/speedmeter3.obj"

             PMaterial {
                effect: shadowMapEffectDB
               ambientLight: "blue"
                specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0)
                diffuseMap: "C:/Qt/Qt5.5.0/Examples/Qt-5.5/qt3d/exampleresources/assets/obj/Speedometer_01.JPG"
                normalMap: "C:/Qt/Qt5.5.0/Examples/Qt-5.5/qt3d/exampleresources/assets/obj/Speedometer_01.JPG"
               shininess: shininessSpecularMap


    PS: PMaterial is a separate qml defining different Material Parameters.

    Please describe the correct way to load texture .

Log in to reply