Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-105236

QLineWidth and QCullFace no effect in Qt 6

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 6.3.1
    • Qt3D
    • None

    Description

      void Entity::createEntity()
      {
      QList<Triangle> triangles;
      QMap<QPair<int, int>, Vertex> vertexMap = setVertexDataBuffer(triangles);
      setIndexDataBuffer(triangles, vertexMap);
      if (!m_vertexDataBuffer)
      return;

      int vCount = m_vertexDataBuffer->data().count() / sizeof(Vertex);

      auto positionAttribute = new Attribute();
      positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
      positionAttribute->setBuffer(m_vertexDataBuffer);
      positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float);
      positionAttribute->setVertexSize(3);
      positionAttribute->setByteOffset(Vertex::positionOffset());
      positionAttribute->setByteStride(sizeof(Vertex));
      if (m_type == C::CrossHair)
      positionAttribute->setCount(6);
      else
      positionAttribute->setCount(vCount);
      positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());

      Qt3DRender::QAttribute* normalAttribute = nullptr;
      if (!triangles.isEmpty())

      { normalAttribute = new Qt3DRender::QAttribute(); normalAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); normalAttribute->setBuffer(m_vertexDataBuffer); normalAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); normalAttribute->setVertexSize(3); normalAttribute->setByteOffset(Vertex::normalOffset()); normalAttribute->setByteStride(sizeof(Vertex)); normalAttribute->setCount(vCount); normalAttribute->setName(Qt3DRender::QAttribute::defaultNormalAttributeName()); }

      auto colorAttribute = new Qt3DRender::QAttribute();
      colorAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
      colorAttribute->setBuffer(m_vertexDataBuffer);
      colorAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float);
      colorAttribute->setVertexSize(4);
      colorAttribute->setByteOffset(Vertex::colorOffset());
      colorAttribute->setByteStride(sizeof(Vertex));
      if (m_type == C::CrossHair)
      colorAttribute->setCount(6);
      else
      colorAttribute->setCount(vCount);
      colorAttribute->setName(Qt3DRender::QAttribute::defaultColorAttributeName());

      Qt3DRender::QAttribute* indexAttribute = nullptr;
      if (m_indexDataBuffer)

      { int iCount = m_indexDataBuffer->data().count() / sizeof(uint); indexAttribute = new Qt3DRender::QAttribute(); indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); indexAttribute->setBuffer(m_indexDataBuffer); indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt); indexAttribute->setVertexSize(1); indexAttribute->setByteOffset(0); indexAttribute->setByteStride(sizeof(uint)); indexAttribute->setCount(iCount); indexAttribute->setName(Qt3DRender::QAttribute::defaultJointIndicesAttributeName()); }

      auto customGeometry = new Qt3DRender::QGeometry();
      customGeometry->addAttribute(positionAttribute);
      customGeometry->addAttribute(colorAttribute);
      if (normalAttribute)
      customGeometry->addAttribute(normalAttribute);
      if (indexAttribute)
      customGeometry->addAttribute(indexAttribute);
      //createBoundingVolumePositionAttribute(customGeometry);

      auto customMeshRenderer = new Qt3DRender::QGeometryRenderer;
      if (type() == C::HorizonT0)

      { customMeshRenderer->setPrimitiveType(Qt3DRender::QGeometryRenderer::LineStrip); customMeshRenderer->setPrimitiveRestartEnabled(true); }

      else if (type() == C::CrossHair)
      customMeshRenderer->setPrimitiveType(Qt3DRender::QGeometryRenderer::Lines);
      else if (type() == C::InLine || type() == C::CrossLine ||
      type() == C::Traverse || type() == C::TimeSlice)

      { customMeshRenderer->setPrimitiveType(Qt3DRender::QGeometryRenderer::TriangleStrip); customMeshRenderer->setPrimitiveRestartEnabled(true); }

      else
      customMeshRenderer->setPrimitiveType(Qt3DRender::QGeometryRenderer::Triangles);
      customMeshRenderer->setGeometry(customGeometry);

      auto material = new Qt3DExtras::QPerVertexColorMaterial();
      if (type() != C::HorizonT0 && type() != C::CrossHair)

      { m_parameter = new Qt3DRender::QParameter(); m_parameter->setName("line.width"); m_parameter->setValue(0.0f); material->effect()->techniques()[0]->renderPasses()[0]->addParameter(m_parameter); material->effect()->techniques()[0]->renderPasses()[0]->addParameter( new Qt3DRender::QParameter("line.color", QColor(100, 100, 100))); auto sp1 = new Qt3DRender::QShaderProgram(); sp1->setVertexShaderCode(Qt3DRender::QShaderProgram::loadSource(QUrl("qrc:/shaders/pervertexcolormaterial.vert"))); sp1->setGeometryShaderCode(Qt3DRender::QShaderProgram::loadSource(QUrl("qrc:/shaders/pervertexcolormaterial.geom"))); sp1->setFragmentShaderCode(Qt3DRender::QShaderProgram::loadSource(QUrl("qrc:/shaders/pervertexcolormaterial.frag"))); material->effect()->techniques()[0]->renderPasses()[0]->setShaderProgram(sp1); }

      if (type() == C::HorizonSlice || type() == C::InLine || type() == C::CrossLine ||
      type() == C::Traverse || type() == C::TimeSlice)

      { auto offset = new Qt3DRender::QPolygonOffset(); offset->setScaleFactor(1.0f); offset->setDepthSteps(1.0f); material->effect()->techniques()[0]->renderPasses()[0]->addRenderState(offset); }

      if (type() == C::Passage && (id() == C::Roof || id() == C::Floor))

      { auto offset = new Qt3DRender::QPolygonOffset(); offset->setScaleFactor(1.5f); offset->setDepthSteps(1.0f); material->effect()->techniques()[0]->renderPasses()[0]->addRenderState(offset); }

      auto cullFront = new Qt3DRender::QCullFace();
      cullFront->setMode(Qt3DRender::QCullFace::NoCulling);
      material->effect()>techniques()[0]>renderPasses()[0]->addRenderState(cullFront);

      auto lineWidth = new Qt3DRender::QLineWidth();
      lineWidth->smooth();
      lineWidth->setValue(2.0f);
      material->effect()>techniques()[0]>renderPasses()[0]->addRenderState(lineWidth);

      addComponent(customMeshRenderer);
      addComponent(material);

      if (type() == C::CrossHair)
      setEnabled(false);
      else
      addComponent(m_modifier->m_transform);

      if (type() == C::Passage && (id() == C::Roof || id() == C::Floor))

      { if (m_modifier->pickEnabled()) addComponent(m_modifier->m_picker); createWireframe(vertexMap); }

      }

       

      auto cullFront = new Qt3DRender::QCullFace();auto cullFront = new Qt3DRender::QCullFace(); cullFront->setMode(Qt3DRender::QCullFace::NoCulling); material->effect()>techniques()[0]>renderPasses()[0]->addRenderState(cullFront);
      auto lineWidth = new Qt3DRender::QLineWidth(); lineWidth->smooth(); lineWidth->setValue(2.0f); material->effect()>techniques()[0]>renderPasses()[0]->addRenderState(lineWidth);

      在Qt6下cullFront 和lineWidth没有效果

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            seanharmer Sean Harmer
            cssgfjs 金生 付
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes