[英]Qt3D QAbstractTextureImage pixelated
我在我的項目中使用 Qt3D,我需要動態更改平面的紋理。 為此,我使用了我的 QAbstractTextureImage 實現。 我願意:
auto planeMaterial = new Qt3DExtras::QTextureMaterial();
Qt3DRender::QTexture2D *planeTexture = new Qt3DRender::QTexture2D();
auto *planeTextureImage = new PaintedTextureImage();
planeTextureImage->update();
planeTexture->addTextureImage(planeTextureImage);
planeMaterial->setTexture(planeTexture);
Qt3DCore::QTransform *planeTransform = new Qt3DCore::QTransform();
planeTransform->setRotationX(90);
planeTransform->setTranslation(QVector3D(0.0f, 0.0f, 15.0f));
auto planeEntity = new Qt3DCore::QEntity(this->rootEntity);
planeEntity->addComponent(mPlane);
planeEntity->addComponent(planeMaterial);
planeEntity->addComponent(planeTransform);
planeEntity->setEnabled(true);
在我的場景修改器中。 因此,它使用紋理將平面添加到場景中。 mPlane 有寬度和高度:4.0 和 3.0。 紋理圖像的分辨率為 640x480,因此也是 4:3。
void PaintedTextureImage::paint(QPainter *painter)
{
...
current = QImage((uchar*)color.data, color.cols, color.rows, color.step, QImage::Format_RGB888);
painter->drawImage(0, 0, current);
}
所以圖像質量變得非常糟糕,我不明白為什么。
解決方案:
planeTextureImage->setWidth(640);
planeTextureImage->setHeight(480);
默認為 256x256。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.