Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-19190

Unable to texture with an image a subnode read from a 3D model using QGLMaterial

    XMLWordPrintable

Details

    Description

      I am reading a 3D model using QGLAbstractScene::loadScene(), I access a subnode and try to texture it with a QGLMaterial. It seems the texturing is not applied to the subnode.

      Here is an outline of the code I have:

       
      // Read in the 3D model, 
      QGLAbstractScene *m_modelScene = QGLAbstractScene::loadScene(fileName);
      
      // This will print: ("smartphone.3DS", "<3DSRoot>", "phone", "button", "screen", "phone::m_phone", "button::m_button", "screen::m_screen") 
      qDebug() << m_modelScene->objectNames(); 
      
      // Access the main node and the subnode that we want to texture.
      QGLSceneNode *m_meshObject = m_modelScene->mainNode();
      QSceneNode *displayNode = qobject_cast<QGLSceneNode *>(m_modelScene->object(QLatin1String("screen")));
      
      // Create the texture we want to apply to the subnode "screen". Use existing image for texturing. 
      QGLMaterial *materialTexture = new QGLMaterial(this);
      QUrl url;
      url.setPath(QLatin1String(":/smartp0.png"));
      url.setScheme(QLatin1String("file"));
      materialTexture->setTextureUrl(url);
      
      // Set the texturing material and draw the model.
      displayNode->setMaterial(materialTexture);
      m_meshObject->draw(painter);
      

      The subnode is, however, not textured with the new image but instead the model is shown as defined as modelled in 3D Studio.

      A test application that can be compiled to test this issue can be found here:
      https://gitorious.org/kypeli-s-qt3d-playground/qt3d-texture-subnode/commits/image_texture

      Files can be browsed here:
      https://gitorious.org/kypeli-s-qt3d-playground/qt3d-texture-subnode/trees/image_texture

      And finally, the code is a remote branch called "image_texture" of this project:
      https://gitorious.org/kypeli-s-qt3d-playground/qt3d-texture-subnode

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            debhal Julian de Bhal (closed Nokia identity) (Inactive)
            kypeli Johan Paul
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes