Using QGLTwoSidedMaterial vs QGLMaterial
-
So using QGLMaterial is pretty straight forward. This works fine for me:
@
QGeometryData plot1;
QGLSceneNode *node1 = builder.newNode();QVector3D a1( 0, 0, 0 ); plot1.appendVertex(a1); ... QVector3D h1( 3, 1.5, 0 ); plot1.appendVertex(h1); builder.addQuadStrip(plot1); QGLMaterial *mat1 = new QGLMaterial; mat1->setColor(Qt::green); node1->setMaterial(mat1); node1->setEffect(QGL::LitMaterial);@
However I have not seen any tutorials or examples of using two sided material so I tried this:
@ QGLMaterial *mat1 = new QGLMaterial;
mat1->setColor(Qt::green);QGLTwoSidedMaterial *ts = new QGLTwoSidedMaterial; ts->setFront(mat1); ts->setBack(mat1); node1->setMaterial(ts); node1->setEffect(QGL::LitMaterial);@
but I get an error
@error: no matching function for call to 'QGLSceneNode::setMaterial(QGLTwoSidedMaterial*&)'@
How exactly do you utilize the two sided material? I dont see it used in the Qt3D examples or the API page.
You guys rock!
Long Live Qt!
-
Had the same problem. Solved it by binding the material to the painter in the node's draw(QGLPainter *painter) routine. Try this -
ts->bind(painter);
.... (other code) ...
ts->release(painter, 0);QGLTwoSidedMaterial is derived from QGLAbstractMaterial, not from QGLMaterial, so setMaterial(ts) won't work.
Hope this helps.