QMaterial Class
(Qt3DRender::QMaterial)Provides an abstract class that should be the base of all material component classes in a scene. More...
Header: | #include <QMaterial> |
qmake: | QT += 3drender |
Since: | Qt 5.5 |
Instantiated By: | Material |
Inherits: | Qt3DCore::QComponent |
Inherited By: | Qt3DExtras::QDiffuseMapMaterial, Qt3DExtras::QDiffuseSpecularMapMaterial, Qt3DExtras::QDiffuseSpecularMaterial, Qt3DExtras::QGoochMaterial, Qt3DExtras::QMetalRoughMaterial, Qt3DExtras::QMorphPhongMaterial, Qt3DExtras::QNormalDiffuseMapMaterial, Qt3DExtras::QNormalDiffuseSpecularMapMaterial, Qt3DExtras::QPerVertexColorMaterial, Qt3DExtras::QPhongAlphaMaterial, Qt3DExtras::QPhongMaterial, and Qt3DExtras::QTextureMaterial |
This class was introduced in Qt 5.5.
Properties
- effect : Qt3DRender::QEffect*
- 1 property inherited from Qt3DCore::QComponent
- 3 properties inherited from Qt3DCore::QNode
- 1 property inherited from QObject
Public Functions
void | addParameter(Qt3DRender::QParameter *parameter) |
Qt3DRender::QEffect * | effect() const |
QVector<Qt3DRender::QParameter *> | parameters() const |
void | removeParameter(Qt3DRender::QParameter *parameter) |
- 2 public functions inherited from Qt3DCore::QComponent
- 13 public functions inherited from Qt3DCore::QNode
- 30 public functions inherited from QObject
Public Slots
void | setEffect(Qt3DRender::QEffect *effect) |
- 1 public slot inherited from Qt3DCore::QComponent
- 3 public slots inherited from Qt3DCore::QNode
- 1 public slot inherited from QObject
Signals
void | effectChanged(Qt3DRender::QEffect *effect) |
- 3 signals inherited from Qt3DCore::QComponent
- 4 signals inherited from Qt3DCore::QNode
- 2 signals inherited from QObject
Related Non-Members
typedef | QNodePtr |
typedef | QNodeVector |
typedef | QObjectList |
QList<T> | qFindChildren(const QObject *obj, const QRegExp ®Exp) |
Qt3DCore::QNodeId | qIdForNode(Qt3DCore::QNode *node) |
Qt3DCore::QNodeIdVector | qIdsForNodes(const T &nodes) |
T | qobject_cast(QObject *object) |
T | qobject_cast(const QObject *object) |
Macros
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
Q_CLASSINFO(Name, Value) | |
Q_DISABLE_COPY(Class) | |
Q_DISABLE_COPY_MOVE(Class) | |
Q_DISABLE_MOVE(Class) | |
Q_EMIT | |
Q_ENUM(...) | |
Q_ENUM_NS(...) | |
Q_FLAG(...) | |
Q_FLAG_NS(...) | |
Q_GADGET | |
Q_INTERFACES(...) | |
Q_INVOKABLE | |
Q_NAMESPACE | |
Q_OBJECT | |
Q_PROPERTY(...) | |
Q_REVISION | |
Q_SET_OBJECT_NAME(Object) | |
Q_SIGNAL | |
Q_SIGNALS | |
Q_SLOT | |
Q_SLOTS |
Additional Inherited Members
- 9 static public members inherited from QObject
- 2 protected functions inherited from Qt3DCore::QNode
- 9 protected functions inherited from QObject
Detailed Description
QMaterial provides a way to specify the rendering of an entity. Any aspect can define its own subclass of QMaterial so that a Material can be used to describe a visual element; for example, the way sound should reflect off an element, the temperature of a surface, and so on.
In itself, a QMaterial doesn't do anything. It's only when it references a QEffect node that a QMaterial becomes useful.
In practice, it often happens that a single QEffect is being referenced by several QMaterial components. This allows to only create the effect, techniques, passes and shaders once while allowing to specify the material by adding QParameter instances.
A QParameter defined on a QMaterial is overridden by a QParameter (of the same name) defined in a QTechniqueFilter or a QRenderPassFilter.
QMaterial *material1 = new QMaterial(); QMaterial *material2 = new QMaterial(); // Create effect, technique, render pass and shader QEffect *effect = new QEffect(); QTechnique *gl3Technique = new QTechnique(); QRenderPass *gl3Pass = new QRenderPass(); QShaderProgram *glShader = new QShaderProgram(); // Set the shader on the render pass gl3Pass->setShaderProgram(glShader); // Add the pass to the technique gl3Technique->addRenderPass(gl3Pass); // Set the targeted GL version for the technique gl3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL); gl3Technique->graphicsApiFilter()->setMajorVersion(3); gl3Technique->graphicsApiFilter()->setMinorVersion(1); gl3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile); // Add the technique to the effect effect->addTechnique(gl3Technique); // Set the effect on the materials material1->setEffect(effect); material2->setEffect(effect); // Set different parameters on the materials const QString parameterName = QStringLiteral("color"); material1->addParameter(new QParameter(parameterName, QColor::fromRgbF(0.0f, 1.0f, 0.0f, 1.0f); material2->addParameter(new QParameter(parameterName, QColor::fromRgbF(1.0f, 1.0f, 1.0f, 1.0f);
See also QEffect, QTechnique, and QParameter.
Property Documentation
effect : Qt3DRender::QEffect*
Specifies the effect to be used with the material.
Access functions:
Qt3DRender::QEffect * | effect() const |
void | setEffect(Qt3DRender::QEffect *effect) |
Notifier signal:
void | effectChanged(Qt3DRender::QEffect *effect) |
Member Function Documentation
void QMaterial::addParameter(Qt3DRender::QParameter *parameter)
Add a parameter to the material's parameters.
QVector<Qt3DRender::QParameter *> QMaterial::parameters() const
Returns a vector of the material's current parameters
void QMaterial::removeParameter(Qt3DRender::QParameter *parameter)
Remove a parameter from the material's parameters.