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. I can't load Texture with QVariant in QMetalRoughMaterial ? What happened With Qt3D 5.13.1 ?
Forum Updated to NodeBB v4.3 + New Features

I can't load Texture with QVariant in QMetalRoughMaterial ? What happened With Qt3D 5.13.1 ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 215 Views
  • 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.
  • G Offline
    G Offline
    GeminiMan
    wrote on last edited by
    #1

    hello,
    I tried to use QMetalRoughMaterial for my cube to see how it's work. i saw the example in QML and i tried to translate it in C++ code That's it :

    Qt3DExtras::QMorphPhongMaterial *mat {new Qt3DExtras::QMorphPhongMaterial(this)};
    mat->baseColor().setValue(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_col.jpg")));
    mat->metalness().setValue(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_met.jpg")));
    mat->roughness().setValue(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_rgh.jpg")));
    mat->normal().setValue(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_nrm.jpg")));
    mat->ambientOcclusion().setValue(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_disp.jpg")));
    

    Not Working, so I say to go the documentation to see how the methods work, the properties are Qvariant type. I looked how to do, QVariant :: FromValue() it does not work either.

    My question is how to get textures through qvariant or QAbsractTexture ?

    Oh yes, the QTextureLoader does not work anymore? is it deleted in this version?

    i tried this too nothing works

    Qt3DExtras::QMetalRoughMaterial *mat {new Qt3DExtras::QMetalRoughMaterial(this)};
    Qt3DRender::QTextureImage *baseColorTextureImage {new Qt3DRender::QTextureImage()};
    Qt3DRender::QTextureImage *metalnessTextureImage {new Qt3DRender::QTextureImage()};
    Qt3DRender::QTextureImage *roughnessTextureImage {new Qt3DRender::QTextureImage()};
    Qt3DRender::QTextureImage *normalTextureImage {new Qt3DRender::QTextureImage()};
    Qt3DRender::QTextureImage *ambientOcclusionTextureImage {new Qt3DRender::QTextureImage()};
    
    MTexture *baseColorTexture = new MTexture(); //MTexture is inherit QAbstractTexture
    MTexture *metalnessTexture = new MTexture();
    MTexture *roughnessTexture = new MTexture();
    MTexture *normalTexture = new MTexture();
    MTexture *ambientOcclusionTexture = new MTexture();
    
    baseColorTextureImage->setSource(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_col.jpg")));
    metalnessTextureImage->setSource(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_met.jpg")));
    roughnessTextureImage->setSource(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_rgh.jpg")));
    normalTextureImage->setSource(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_nrm.jpg")));
    ambientOcclusionTextureImage->setSource(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_disp.jpg")));
    
    baseColorTexture->addTextureImage(baseColorTextureImage);
    metalnessTexture->addTextureImage(metalnessTextureImage);
    roughnessTexture->addTextureImage(roughnessTextureImage);
    normalTexture->addTextureImage(normalTextureImage);
    ambientOcclusionTexture->addTextureImage(ambientOcclusionTextureImage);
    
    mat->baseColor().setValue(QVariant::fromValue(baseColorTexture));
    mat->metalness().setValue(QVariant::fromValue(metalnessTexture));
    mat->roughness().setValue(QVariant::fromValue(roughnessTexture));
    mat->normal().setValue(QVariant::fromValue(normalTexture));
    mat->ambientOcclusion().setValue(QVariant::fromValue(ambientOcclusionTexture));
    
    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