Qt3D - [c++] QExtrudedTextMesh gets overlayed by lower QCuboidMesh
Solved
Game Development
-
HI!
I have a QCuboidMesh with a certain z-extend.
Also, i transform it for test reason to a factor of 0.001.
Additionally, i place a QExtrudedTestMesh vertically significant above the cuboid.Unfortunately, the TextMesh gets randomly replaced by the pixel-contents of the cuboid, although its z-position is lower than the text's.
I have tried layers, layerfilters and raycasters, but the text gets cropped by the cuboid screen values, obviously clipping after the text.
- Is there an advice of how to render the entities according to their world coordinates?
- Is there the usage of QLayers, to stack objects visually above each others? or ...
- Can i trigger the order in which the entities are drawn? So to draw the "lower" entities first?
best regards
Code:
EntityClassA : QEntity(root) { auto* tile = Qt3DExtras::QCuboidMesh(root); tile->setXExtend(1); tile->setYExtend(1); tile->setZExtend(0.01); Qt3DCore::QTransform scale = new Qt3DCore::QTransform; scale->setScale3D(QVector(1, 1, 0.001); addComponent(scale); addComponet(tile); } EntityClassB : QEntity(root) { auto* text = new Qt3DExtras::QExtrudedTextMesh(root); text->setText("A1"); Qt3DCore::QTransform scaleText = new Qt3DCore::QTransform; scaleText->setTranslation(x,y, properZValue); addComponent(scaleText); addComponent(text); }
-
Finally the scene gets properly rendered by explicietely setting the QSortPolicy on the frameGraph:
Qt3DRender::QFrameGraphNode *framegraph = view.activeFrameGraph(); Qt3DRender::QSortPolicy *sortPolicy = new Qt3DRender::QSortPolicy(scene); framegraph->setParent(sortPolicy); QVector<Qt3DRender::QSortPolicy::SortType> sortTypes = QVector<Qt3DRender::QSortPolicy::SortType>() << Qt3DRender::QSortPolicy::BackToFront; sortPolicy->setSortTypes(sortTypes); view.setActiveFrameGraph(framegraph);