Qt:显示3D长方体的边缘

时间:2016-06-16 11:45:50

标签: c++ qt qt3d

我正在使用Qt3D绘制相交的长方体。由于边缘没有出现,所以对于边缘都很好。我检查了QCuboidMeshQPhongAlphaMaterial中的属性但是我不能找不到这样的。

enter image description here

代码:

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);
}

0 个答案:

没有答案