Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. DiffuseMapMaterial Texture
Forum Updated to NodeBB v4.3 + New Features

DiffuseMapMaterial Texture

Scheduled Pinned Locked Moved Unsolved Game Development
8 Posts 2 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QKelteseth
    wrote on last edited by
    #1

    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 image

        RenderableEntity{
            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*"

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      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 ]
      
      1 Reply Last reply
      1
      • Q Offline
        Q Offline
        QKelteseth
        wrote on last edited by QKelteseth
        #3

        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
                }
            }
        
        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4
          TextureLoader {
              id: rectTexture
              source: "qrc:/assets/models/texture.png" 
          }
          
          Q 1 Reply Last reply
          1
          • ? A Former User
            TextureLoader {
                id: rectTexture
                source: "qrc:/assets/models/texture.png" 
            }
            
            Q Offline
            Q Offline
            QKelteseth
            wrote on last edited by
            #5

            @Wieland said in DiffuseMapMaterial Texture:

            source:

            Thanks! It works now :D

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              Btw, what's your graphics card? Nvidia?

              Q 1 Reply Last reply
              0
              • ? A Former User

                Btw, what's your graphics card? Nvidia?

                Q Offline
                Q Offline
                QKelteseth
                wrote on last edited by
                #7

                @Wieland NVidia 780 with the latest drivers

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  okay. things should work then.

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved