Qt 5.15.2 Q3D对象拾取在自定义项上不起作用
然而,我再次尝试在Q3D中做一些定制的事情,并面临以下问题。 我按照示例中的说明制作了一个自定义几何体,并且(实际上)从源代码修改了QTorusMesh类 不知何故,我成功地画出了我想要的东西,但对象拾取功能无法在我的网格上正常工作。 我注意到,如果我以相反的顺序绘制几何体(srface的切片将朝着相反的方向绘制,最后给出相反的图形),拾取开始工作,但不是在整个曲面上,而是在中心区域的某个位置。 我试着:Qt 5.15.2 Q3D对象拾取在自定义项上不起作用,qt,geometry,picking,Qt,Geometry,Picking,然而,我再次尝试在Q3D中做一些定制的事情,并面临以下问题。 我按照示例中的说明制作了一个自定义几何体,并且(实际上)从源代码修改了QTorusMesh类 不知何故,我成功地画出了我想要的东西,但对象拾取功能无法在我的网格上正常工作。 我注意到,如果我以相反的顺序绘制几何体(srface的切片将朝着相反的方向绘制,最后给出相反的图形),拾取开始工作,但不是在整个曲面上,而是在中心区域的某个位置。 我试着: 更改顶点标记的位置(打开/关闭面的可见性,不影响拾取) 改变法线方向(看起来根本不相关
- 更改顶点标记的位置(打开/关闭面的可见性,不影响拾取)
- 改变法线方向(看起来根本不相关)
- 更改切线(相同结果)
- 哭和笑(结果相同)
好的。。。现在我的逻辑结束了。。。。 我关掉了所有的东西,除了一个 这样采摘才有效
Qt3DCore::QTransform *transform = new Qt3DCore::QTransform();
transform->setScale(4.0f);// this line
transform->setTranslation(QVector3D(15.0f, -10.0f, 0.0f));
Qt3DExtras::QPhongMaterial *material = new Qt3DExtras::QPhongMaterial();
material->setDiffuse(QColor(QRgb(0x665423)));
m_twoCylinderFilletEntity = new Qt3DCore::QEntity(m_rootEntity);
m_twoCylinderFilletEntity->setObjectName("m_twoCylinderFilletEntity");
{
m_objectPicker = new Qt3DRender::QObjectPicker(m_twoCylinderFilletEntity);
m_objectPickers.push_back(m_objectPicker);
connect(m_objectPicker,&Qt3DRender::QObjectPicker::clicked,
this,&SceneModifier::clickedHandler);
}
m_twoCylinderFilletEntity->addComponent(m_twoCylinderFilletMesh);
m_twoCylinderFilletEntity->addComponent(material);
m_twoCylinderFilletEntity->addComponent(transform);
m_twoCylinderFilletEntity->addComponent(m_objectPicker);
这样就不会了
Qt3DCore::QTransform *transform = new Qt3DCore::QTransform();
transform->setScale(1.0f);// this line
transform->setTranslation(QVector3D(15.0f, -10.0f, 0.0f));
Qt3DExtras::QPhongMaterial *material = new Qt3DExtras::QPhongMaterial();
material->setDiffuse(QColor(QRgb(0x665423)));
m_twoCylinderFilletEntity = new Qt3DCore::QEntity(m_rootEntity);
m_twoCylinderFilletEntity->setObjectName("m_twoCylinderFilletEntity");
{
m_objectPicker = new Qt3DRender::QObjectPicker(m_twoCylinderFilletEntity);
m_objectPickers.push_back(m_objectPicker);
connect(m_objectPicker,&Qt3DRender::QObjectPicker::clicked,
this,&SceneModifier::clickedHandler);
}
m_twoCylinderFilletEntity->addComponent(m_twoCylinderFilletMesh);
m_twoCylinderFilletEntity->addComponent(material);
m_twoCylinderFilletEntity->addComponent(transform);
m_twoCylinderFilletEntity->addComponent(m_objectPicker);
我特别复制了整个代码,以表明除了QT转换中的规模之外,没有其他变化。我只是不明白缩放如何可能影响交点计算。。。。
请有人给我解释一下,因为我真的不知道开发人员想要实现什么
我还认真考虑将qtq3d作为我的项目选择,因为这种意外行为很难调试和维护。Q3D看起来非常不成熟,容易出现bug,并且在不同版本之间不断变化。
fron-end/back-end架构在这种情况下没有提供任何特殊的优势,但是混淆了源代码,并将调试过程拖入了试错阶段
可能对于一些简单的项目没有一些进展(但实际上没有那么先进),几何处理Q3D是可以的。如果是这样的话,我希望看到complite文档(不仅仅是QML,它永远不会是接口开发的唯一手段,在这个意义上,Python或Lua作为脚本和配置机制将是更好的选择)