[Interest] Qt3D, custom mesh and materials

Helmut Mülner helmut.muelner at gmail.com
Mon Apr 10 13:06:55 CEST 2017


Sean Harmer helped me with my little problem, thank you very much.

There were two problems:

 > I created a custom mesh by defining the following attributes: position,
normal, index, texCoord.
 > If I use a PhongMaterial, the mesh displays nicely:

  >      [...}

 > If I use a QDiffuseMapMaterial, the mesh is black and I get a lot of the
same messages in the debug output:

[...]
 > 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")));

This setSource did not work. I have to used either
   diffuseImage->setSource((QStringLiteral("qrc:/diffuse.webp"));
or
 
diffuseImage->setSource((QUrl::fromLocalFile(QStringLiteral(":/diffuse.webp"
)));

 >        material->diffuse()->addTextureImage(diffuseImage);
 >       entity->addComponent(mesh);
 >      entity->addComponent(material);


 >And if I use this:
  >     auto material = new Qt3DExtras::QNormalDiffuseMapMaterial();
  >    [...]

> ... my mesh displays in simple dark blue and I get the same debug
messages.

For QNormalDiffuseMapMaterial the mesh has to have a tangentAttribute, which
mine did not have.

Cheers
Helmut








More information about the Interest mailing list