Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT3D: How to apply a 2D Texture on a Mesh?
Forum Updated to NodeBB v4.3 + New Features

QT3D: How to apply a 2D Texture on a Mesh?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 386 Views 2 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.
  • A Offline
    A Offline
    Alain38 0
    wrote on last edited by
    #1

    Hi,
    In a first version of my application, I applied a 2D texture on a QCuboidMesh using the simple code:

            Qt3DExtras::QCuboidMesh * background2DView = new Qt3DExtras::QCuboidMesh;
            ...
            Qt3DExtras::QTextureMaterial *backgroundMaterial = new Qt3DExtras::QTextureMaterial;
            Qt3DRender::QTexture2D *      backgroundTexture  = new Qt3DRender::QTexture2D(backgroundMaterial);
            Qt3DRender::QTextureImage *   backgroundImage    = new Qt3DRender::QTextureImage(backgroundMaterial);
            backgroundImage->setSource(QUrl("qrc:/Resources/Img/Contrast/test.png"));
            backgroundTexture->addTextureImage(backgroundImage);
            backgroundMaterial->setTexture(backgroundTexture);
            backgroundEntity->addComponent(background2DView);
            backgroundEntity->addComponent(backgroundMaterial);
    
    

    And this code works well. No I have to change to use a custom mesh. But, texture is not correctly applied to it. It seems that texture coordinates used for the display are always (0,0). I tried to find an sample to help me. But, I find nothing (unfortunately a lot of web sites are blocked by our internal security rules). So, if someone can help me by giving me the right piece of code for my problem.

    Thanks a lot in advance.

    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