找回密码
 立即注册
收起左侧

qt3d里给root Entity加上RenderSettings之后就无法正常渲染

0
回复
83
查看
[复制链接]
累计签到:1 天
连续签到:1 天
来源: 2019-10-16 18:53:23 显示全部楼层 |阅读模式
1Qter豆
我在root Entity里加入了一个正方体,代码如下:

m_cubeEntity = new Qt3DCore::QEntity;
...
Qt3DExtras::QCuboidMesh cubeMesh = new Qt3DExtras::QCuboidMesh;
Qt3DRender::QMaterial
cubeMaterial = new Qt3DRender::QMaterial;
Qt3DCore::QTransform cubeTransform = new Qt3DCore::QTransform;
Qt3DRender::QObjectPicker
objectPicker = new Qt3DRender::QObjectPicker;
...
m_cubeEntity.addComponent(cubeMesh);
m_cubeEntity.addComponent(cubeMaterial);
m_cubeEntity.addComponent(cubeTransform);
m_cubeEntity.adComponent(objectPicker);

m_cubeEntity.setParent(m_rootEntity);



到这里运行正常,3d场景里有一个正方体。

默认的拾取方式应该是PickingSettings.BoundingVolumePicking。但是准确度很低,我想改用PickingSettings.TrianglePicking。所以我尝试在root entity里加入RenderSettings,添加的代码如下:

m_renderSettings = new Qt3DRender::QRenderSettings();
m_renderSettings->pickingSettings()->setPickMethod(Qt3DRender::QPickingSettings::TrianglePicking);
m_renderSettings->pickingSettings()->setPickResultMode(Qt3DRender::QPickingSettings::AllPicks);
m_renderer = new Qt3DExtras::QForwardRenderer();
m_renderer->setClearColor(Qt::lightGray);
m_renderSettings->setActiveFrameGraph(m_renderer);
m_rootEntity->addComponent(m_renderSettings);



然后那个正方体就无法正常渲染了。
感觉应该是RenderSettings设置的有问题,有兄dei知道怎么修改吗(有鼠标拾取的需求,需要绘制自)?之前在用qml写也是这个问题

阿里云
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册