Qt3d: Mesh fails to load when QMesh::setMeshName() is called.
Unsolved
General and Desktop
-
The following program to load and display at 3D mesh works fine.
#include <QGuiApplication> #include <Qt3DCore/QEntity> #include <Qt3DCore/QAspectEngine> #include <Qt3DRender/QCamera> #include <Qt3DInput/QInputAspect> #include <Qt3DRender/QRenderAspect> #include <Qt3DExtras/QPhongMaterial> #include <Qt3DExtras/QDiffuseMapMaterial> #include <Qt3DExtras/QForwardRenderer> #include <Qt3DRender/QTextureImage> #include <Qt3DRender/QMesh> #include <Qt3DCore/QTransform> #include <Qt3DExtras/qt3dwindow.h> #include <Qt3DExtras/qfirstpersoncameracontroller.h> int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); Qt3DExtras::Qt3DWindow view; // Scene Root Qt3DCore::QEntity *sceneRoot = new Qt3DCore::QEntity(); // Scene Camera Qt3DRender::QCamera *basicCamera = view.camera(); basicCamera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection); basicCamera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f)); basicCamera->setViewCenter(QVector3D(0.0f, 3.5f, 0.0f)); basicCamera->setPosition(QVector3D(0.0f, 3.5f, 25.0f)); // For camera controls Qt3DExtras::QFirstPersonCameraController *camController = new Qt3DExtras::QFirstPersonCameraController(sceneRoot); camController->setCamera(basicCamera); // Chest Qt3DCore::QEntity *chestEntity = new Qt3DCore::QEntity(sceneRoot); // Mesh Qt3DRender::QMesh *chestMesh = new Qt3DRender::QMesh(); chestMesh->setSource(QUrl::fromLocalFile("../assets/Chest.obj")); // Transform Qt3DCore::QTransform *chestTransform = new Qt3DCore::QTransform; chestTransform->setScale(0.03f); Qt3DExtras::QDiffuseMapMaterial *diffuseMapMaterial = new Qt3DExtras::QDiffuseMapMaterial(); diffuseMapMaterial->setSpecular(QColor::fromRgbF(0.2f, 0.2f, 0.2f, 1.0f)); diffuseMapMaterial->setShininess(2.0f); Qt3DRender::QTextureImage *chestDiffuseImage = new Qt3DRender::QTextureImage(); chestDiffuseImage->setSource(QUrl::fromLocalFile("../assets/diffuse.webp")); diffuseMapMaterial->diffuse()->addTextureImage(chestDiffuseImage); chestEntity->addComponent(chestMesh); chestEntity->addComponent(chestTransform); chestEntity->addComponent(diffuseMapMaterial); view.setRootEntity(sceneRoot); view.show(); return app.exec(); }
However, as soon as this is added, the mesh is no longer displayed.
chestMesh->setMeshName("myMesh");
Why does this line create problems. Is this worth writing a bug report?