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. QSphereMesh Texture with PNG
Qt 6.11 is out! See what's new in the release blog

QSphereMesh Texture with PNG

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 938 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.
  • joaopagottoJ Offline
    joaopagottoJ Offline
    joaopagotto
    wrote on last edited by
    #1

    Hello friends good afternoon I'm getting started migrating from my OpenGL projects to QT3D however, I'm having trouble understanding, and how to make solids texture like QSphereMesh presented in the qt example called basicshapes-cpp. Can anybody help me ?

       // Sphere shape data
       Qt3DExtras::QSphereMesh *sphereMesh = new Qt3DExtras::QSphereMesh();
       sphereMesh->setRings(32);
       sphereMesh->setSlices(32);
       sphereMesh->setRadius(4);
    
       // Sphere mesh transform
       Qt3DCore::QTransform *sphereTransform = new Qt3DCore::QTransform();
       sphereTransform->setScale(1.0f);
       sphereTransform->setTranslation(QVector3D(0.0f, 0.0f, 0.0f));
       sphereTransform->setRotation(QQuaternion(1.0f, 0.0f, 0.0f, 0.0f));
    
       Qt3DExtras::QPhongMaterial *sphereMaterial = new Qt3DExtras::QPhongMaterial();
       sphereMaterial->setDiffuse(QColor(QRgb(0xA69929)));
    
       // Sphere
       m_sphereEntity = new Qt3DCore::QEntity(m_rootEntity);
       m_sphereEntity->addComponent(sphereMesh);
       m_sphereEntity->addComponent(sphereMaterial);
       m_sphereEntity->addComponent(sphereTransform);
    
    1 Reply Last reply
    0
    • joaopagottoJ Offline
      joaopagottoJ Offline
      joaopagotto
      wrote on last edited by
      #2

      Solved =D

         // Sphere shape data
         Qt3DExtras::QSphereMesh *sphereMesh = new Qt3DExtras::QSphereMesh();
         sphereMesh->setRings(32);
         sphereMesh->setSlices(32);
         sphereMesh->setRadius(4);
      
         // Sphere mesh transform
         Qt3DCore::QTransform *sphereTransform = new Qt3DCore::QTransform();
         sphereTransform->setScale(1.0f);
         sphereTransform->setTranslation(QVector3D(0.0f, 0.0f, 0.0f));
         sphereTransform->setRotation(QQuaternion(1.0f, 0.0f, 0.0f, 0.0f));
      
         Qt3DRender::QTextureImage *diffuseTextureImage = new Qt3DRender::QTextureImage();
         diffuseTextureImage->setMirrored(false);
         diffuseTextureImage->setSource(QUrl(QStringLiteral("qrc:/resources/image.png")));
      
         Qt3DExtras::QDiffuseSpecularMapMaterial *diffuseSpecularMaterial = new Qt3DExtras::QDiffuseSpecularMapMaterial();
         diffuseSpecularMaterial->diffuse()->addTextureImage(diffuseTextureImage);
      
         // Sphere
         m_sphereEntity = new Qt3DCore::QEntity(m_rootEntity);
         m_sphereEntity->addComponent(sphereMesh);
         m_sphereEntity->addComponent(diffuseSpecularMaterial);
         m_sphereEntity->addComponent(sphereTransform);
      
      1 Reply Last reply
      2

      • Login

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