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: Show Edges for 3D Cuboids
Forum Updated to NodeBB v4.3 + New Features

Qt3D: Show Edges for 3D Cuboids

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++qt3d
4 Posts 3 Posters 2.7k 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.
  • Youssef EmadY Offline
    Youssef EmadY Offline
    Youssef Emad
    wrote on last edited by
    #1

    I am using Qt3D and C++ to draw intersecting cuboids.Every thing is fine expect for the edges as they don't appear.I checked for properties in QCuboidMesh and QPhongAlphaMaterial but I couldn't find such one.

    The output image

    The code:

    SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity)
        : m_rootEntity(rootEntity)
    {
    
        //Outer Cuboid shape data
        cuboid = new Qt3DExtras::QCuboidMesh();
        cuboid->setXExtent(4);
        cuboid->setYExtent(4);
        cuboid->setZExtent(8);
        // CuboidMesh Transform
        Qt3DCore::QTransform *cuboidTransform = new Qt3DCore::QTransform();
    
        Qt3DExtras::QPhongAlphaMaterial *cuboidMaterial = new Qt3DExtras::QPhongAlphaMaterial();
        cuboidMaterial->setDiffuse(QColor(QRgb(0xff0ff0)));
        cuboidMaterial->setAlpha(0.5);
    
        //Cuboid
        m_cuboidEntity = new Qt3DCore::QEntity(m_rootEntity);
        m_cuboidEntity->addComponent(cuboid);
        m_cuboidEntity->addComponent(cuboidMaterial);
    
        // Inner Cuboid shape data
         cuboid2 = new Qt3DExtras::QCuboidMesh();
         cuboid2->setXExtent(2);
         cuboid2->setYExtent(2);
         cuboid2->setZExtent(8);
    
    
         Qt3DExtras::QPhongMaterial *cuboidMaterial2 = new Qt3DExtras::QPhongMaterial();
         cuboidMaterial2->setDiffuse(QColor(QRgb(0xffffff)));
    
         //Cuboid
    
         m_cuboidEntity2 = new Qt3DCore::QEntity(m_rootEntity);
    
         m_cuboidEntity2->addComponent(cuboid2);
         m_cuboidEntity2->addComponent(cuboidMaterial2);
    
         Qt3DCore::QTransform* cuboidTransform3 = new Qt3DCore::QTransform();
         cuboidTransform3->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(0.1f, -0.1f, 0.0f), 45.0f));
    
         m_rootEntity->addComponent(cuboidTransform3);
    }
    
    ? 1 Reply Last reply
    1
    • Youssef EmadY Youssef Emad

      I am using Qt3D and C++ to draw intersecting cuboids.Every thing is fine expect for the edges as they don't appear.I checked for properties in QCuboidMesh and QPhongAlphaMaterial but I couldn't find such one.

      The output image

      The code:

      SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity)
          : m_rootEntity(rootEntity)
      {
      
          //Outer Cuboid shape data
          cuboid = new Qt3DExtras::QCuboidMesh();
          cuboid->setXExtent(4);
          cuboid->setYExtent(4);
          cuboid->setZExtent(8);
          // CuboidMesh Transform
          Qt3DCore::QTransform *cuboidTransform = new Qt3DCore::QTransform();
      
          Qt3DExtras::QPhongAlphaMaterial *cuboidMaterial = new Qt3DExtras::QPhongAlphaMaterial();
          cuboidMaterial->setDiffuse(QColor(QRgb(0xff0ff0)));
          cuboidMaterial->setAlpha(0.5);
      
          //Cuboid
          m_cuboidEntity = new Qt3DCore::QEntity(m_rootEntity);
          m_cuboidEntity->addComponent(cuboid);
          m_cuboidEntity->addComponent(cuboidMaterial);
      
          // Inner Cuboid shape data
           cuboid2 = new Qt3DExtras::QCuboidMesh();
           cuboid2->setXExtent(2);
           cuboid2->setYExtent(2);
           cuboid2->setZExtent(8);
      
      
           Qt3DExtras::QPhongMaterial *cuboidMaterial2 = new Qt3DExtras::QPhongMaterial();
           cuboidMaterial2->setDiffuse(QColor(QRgb(0xffffff)));
      
           //Cuboid
      
           m_cuboidEntity2 = new Qt3DCore::QEntity(m_rootEntity);
      
           m_cuboidEntity2->addComponent(cuboid2);
           m_cuboidEntity2->addComponent(cuboidMaterial2);
      
           Qt3DCore::QTransform* cuboidTransform3 = new Qt3DCore::QTransform();
           cuboidTransform3->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(0.1f, -0.1f, 0.0f), 45.0f));
      
           m_rootEntity->addComponent(cuboidTransform3);
      }
      
      ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi, and welcome to the Qt forum!

      @Youssef-Emad said:

      Every thing is fine expect for the edges as they don't appear.

      That's because only facets (triangles) are rendered, and not edges. and when the facets along an edge have the same color (because of your lighting model etc.) then you can't tell where they meet. If you want to render the edges you'll need to use different shaders.

      1 Reply Last reply
      0
      • JohnLeeJ Offline
        JohnLeeJ Offline
        JohnLee
        wrote on last edited by
        #3

        I meet the same problem, I show my custom mesh(construct with QGeometry and QGeometryRenderer,with QPhongMaterial),there is no light and shade effect,i think i can solve the problem with GLSL(shader),I found a shader example in qt document: Qt3D:Defferred Renderer C++ Example,I can not run the example,Even I can not find the main.cpp in the example,Is there any one show me a example about how to custom my material use shader.Thank you very much.

        ? 1 Reply Last reply
        0
        • JohnLeeJ JohnLee

          I meet the same problem, I show my custom mesh(construct with QGeometry and QGeometryRenderer,with QPhongMaterial),there is no light and shade effect,i think i can solve the problem with GLSL(shader),I found a shader example in qt document: Qt3D:Defferred Renderer C++ Example,I can not run the example,Even I can not find the main.cpp in the example,Is there any one show me a example about how to custom my material use shader.Thank you very much.

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @JohnLee All examples can be found here (in the examples directory).

          1 Reply Last reply
          1

          • Login

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