[Interest] Qt3D, custom mesh and materials
Helmut Mülner
helmut.muelner at gmail.com
Wed Apr 5 18:34:36 CEST 2017
Another question for the Qt3D experts:
I created a custom mesh by defining the following attributes: position,
normal, index, texCoord.
If I use a PhongMaterial, the mesh displays nicely:
auto material = new Qt3DExtras::QPhongMaterial();
material->setAmbient(QColor(85, 85, 128));
material->setDiffuse(QColor(128, 128, 192));
material->setSpecular(QColor(170, 170, 255));
entity->addComponent(mesh);
entity->addComponent(material);
If I use a QDiffuseMapMaterial, the mesh is black and I get a lot of the
same messages in the debug output:
[Qt3DRender::GLTexture] No QTextureImageData generated from functor
Code:
auto material = new Qt3DExtras::QDiffuseMapMaterial();
material->setShininess(70.0f);
material->setAmbient(QColor(85, 85, 128));
material->setSpecular(QColor(170, 170, 255));
Qt3DRender::QTextureImage *diffuseImage = new
Qt3DRender::QTextureImage();
diffuseImage->setSource(QUrl(QStringLiteral(":/diffuse.webp")));
material->diffuse()->addTextureImage(diffuseImage);
entity->addComponent(mesh);
entity->addComponent(material);
And if I use this:
auto material = new Qt3DExtras::QNormalDiffuseMapMaterial();
material->setShininess(70.0f);
material->setAmbient(QColor(85, 85, 128));
material->setSpecular(QColor(170, 170, 255));
Qt3DRender::QTextureImage *diffuseImage = new
Qt3DRender::QTextureImage();
diffuseImage->setSource(QUrl(QStringLiteral(":/diffuse.webp")));
material->diffuse()->addTextureImage(diffuseImage);
Qt3DRender::QTextureImage *normalImage = new
Qt3DRender::QTextureImage();
normalImage->setSource(QUrl((QStringLiteral(":/normal.webp"))));
material->normal()->addTextureImage(normalImage);
entity->addComponent(mesh);
entity->addComponent(material);
... my mesh displays in simple dark blue and I get the same debug messages.
(I burrowed the texture images from the materials-cpp sample.)
What did I miss?
Best regards
More information about the Interest
mailing list