![]() |
Qt 6.x
The Qt SDK
|
#include <qwavefrontmesh_p.h>
Signals | |
void | sourceChanged () |
void | lastErrorChanged () |
void | projectionPlaneVChanged () |
void | projectionPlaneWChanged () |
![]() | |
void | geometryChanged () |
![]() | |
void | destroyed (QObject *=nullptr) |
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked. | |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
This signal is emitted after the object's name has been changed. | |
Public Member Functions | |
QWavefrontMesh (QObject *parent=nullptr) | |
\qmlmodule Qt.labs.wavefrontmesh 1. | |
~QWavefrontMesh () override | |
QUrl | source () const |
\qmlproperty url WavefrontMesh::source | |
void | setSource (const QUrl &url) |
Error | lastError () const |
\qmlproperty enumeration WavefrontMesh::lastError | |
void | setLastError (Error lastError) |
bool | validateAttributes (const QList< QByteArray > &attributes, int *posIndex) override |
QSGGeometry * | updateGeometry (QSGGeometry *geometry, int attrCount, int posIndex, const QRectF &srcRect, const QRectF &rect) override |
QString | log () const override |
QVector3D | projectionPlaneV () const |
void | setProjectionPlaneV (const QVector3D &projectionPlaneV) |
\qmlproperty vector3d WavefrontMesh::projectionPlaneV | |
QVector3D | projectionPlaneW () const |
void | setProjectionPlaneW (const QVector3D &projectionPlaneW) |
\qmlproperty vector3d WavefrontMesh::projectionPlaneW | |
![]() | |
QQuickShaderEffectMesh (QObject *parent=nullptr) | |
virtual bool | validateAttributes (const QVector< QByteArray > &attributes, int *posIndex)=0 |
virtual QSGGeometry * | updateGeometry (QSGGeometry *geometry, int attrCount, int posIndex, const QRectF &srcRect, const QRectF &rect)=0 |
virtual QString | log () const |
![]() | |
Q_INVOKABLE | QObject (QObject *parent=nullptr) |
Constructs an object with parent object parent. | |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. | |
virtual bool | event (QEvent *event) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. | |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
Filters events if this object has been installed as an event filter for the watched object. | |
QString | objectName () const |
Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
Sets the object's name to name. | |
void | setObjectName (QAnyStringView name) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QBindable< QString > | bindableObjectName () |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false . | |
bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false . | |
bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false . | |
bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false . | |
bool | blockSignals (bool b) noexcept |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
QThread * | thread () const |
Returns the thread in which the object lives. | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. | |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
template<typename T > | |
T | findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
template<typename T > | |
QList< T > | findChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. | |
template<typename T > | |
QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const QObjectList & | children () const |
Returns a list of child objects. | |
void | setParent (QObject *parent) |
Makes the object a child of parent. | |
void | installEventFilter (QObject *filterObj) |
Installs an event filter filterObj on this object. | |
void | removeEventFilter (QObject *obj) |
Removes an event filter object obj from this object. | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const |
bool | disconnect (const QObject *receiver, const char *member=nullptr) const |
void | dumpObjectTree () const |
Dumps a tree of children to the debug output. | |
void | dumpObjectInfo () const |
Dumps information about signal connections, etc. | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. | |
bool | setProperty (const char *name, QVariant &&value) |
QVariant | property (const char *name) const |
Returns the value of the object's name property. | |
QList< QByteArray > | dynamicPropertyNames () const |
QBindingStorage * | bindingStorage () |
const QBindingStorage * | bindingStorage () const |
QObject * | parent () const |
Returns a pointer to the parent object. | |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false . | |
Protected Slots | |
void | readData () |
Properties | |
QUrl | source |
Error | lastError |
QVector3D | projectionPlaneV |
QVector3D | projectionPlaneW |
![]() | |
QString | objectName |
the name of this object | |
Additional Inherited Members | |
![]() | |
void | deleteLater () |
\threadsafe | |
![]() | |
static QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
\threadsafe | |
static QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
\threadsafe | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static bool | disconnect (const QMetaObject::Connection &) |
Disconnect a connection. | |
template<typename Func1 , typename Func2 > | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot) |
template<typename Func1 > | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero) |
![]() | |
QQuickShaderEffectMesh (QObjectPrivate &dd, QObject *parent=nullptr) | |
![]() | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. | |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
This event handler can be reimplemented in a subclass to receive timer events for the object. | |
virtual void | childEvent (QChildEvent *event) |
This event handler can be reimplemented in a subclass to receive child events. | |
virtual void | customEvent (QEvent *event) |
This event handler can be reimplemented in a subclass to receive custom events. | |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
![]() | |
QScopedPointer< QObjectData > | d_ptr |
![]() | |
template< class T > T | qobject_cast (const QObject *object) |
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QObjectList | |
\macro Q_CLASSINFO(Name, Value) | |
Definition at line 28 of file qwavefrontmesh_p.h.
Definition at line 39 of file qwavefrontmesh_p.h.
\qmlmodule Qt.labs.wavefrontmesh 1.
\QtMinorVersion \title Qt Labs WavefrontMesh QML Types
The WavefrontMesh provides a mesh based on a Wavefront .obj file.
To use this module, import the module with the following line:
\qml import Qt.labs.wavefrontmesh \endqml
\qmltype WavefrontMesh \inqmlmodule Qt.labs.wavefrontmesh
! \instantiates QWavefrontMesh
The WavefrontMesh provides a mesh based on a Wavefront .obj file.
WavefrontMesh reads the geometry from a Wavefront .obj file and generates a two-dimensional \l{QSGGeometry}{geometry} from this. If the .obj file contains a three-dimensional shape, it will be orthographically projected, onto a plane. If defined, this is given by \l projectionPlaneV and \l projectionPlaneW. Otherwise, the first face encountered in the data will be used to determine the projection plane.
If the file contains texture coordinates, these will also be used. Otherwise, the vertexes of the object will be normalized and used.
The mesh can be used in a ShaderEffect to define the shaded geometry. The geometry will be normalized before use, so the position and scale of the input objects have no impact on the result.
For instance, the following example takes an .obj file containing a standard torus and visualizes the automatically generated texture coordinates.
\table \row
ShaderEffect { width: 200 height: 200 mesh: WavefrontMesh { source: "torus.obj" projectionPlaneV: Qt.vector3d(0, 1, 0) projectionPlaneW: Qt.vector3d(1, 0, 0) } vertexShader: " uniform highp mat4 qt_Matrix; attribute highp vec4 qt_Vertex; attribute highp vec2 qt_MultiTexCoord0; varying highp vec2 coord; void main() { coord = qt_MultiTexCoord0; gl_Position = qt_Matrix * qt_Vertex; }" fragmentShader: " varying highp vec2 coord; uniform lowp float qt_Opacity; void main() { gl_FragColor = vec4(coord.x, coord.y, 0.0, 1.0); }"
} \endqml \endtable
Definition at line 133 of file qwavefrontmesh.cpp.
References QObject::connect(), QQuickShaderEffectMesh::geometryChanged(), projectionPlaneVChanged(), projectionPlaneWChanged(), readData(), and sourceChanged().
|
override |
Definition at line 141 of file qwavefrontmesh.cpp.
QWavefrontMesh::Error QWavefrontMesh::lastError | ( | ) | const |
\qmlproperty enumeration WavefrontMesh::lastError
This property holds the last error, if any, that occurred when parsing the source or building the mesh.
\list
Definition at line 166 of file qwavefrontmesh.cpp.
References d.
|
signal |
|
overridevirtual |
Reimplemented from QQuickShaderEffectMesh.
Definition at line 404 of file qwavefrontmesh.cpp.
References d, FileNotFoundError, InvalidPlaneDefinitionError, InvalidSourceError, MissingPositionAndTextureCoordinateAttributesError, MissingPositionAttributeError, MissingTextureCoordinateAttributeError, NoError, QStringLiteral, qtPositionAttributeName(), qtTexCoordAttributeName(), TooManyAttributesError, UnsupportedFaceShapeError, and UnsupportedIndexSizeError.
QVector3D QWavefrontMesh::projectionPlaneV | ( | ) | const |
Definition at line 623 of file qwavefrontmesh.cpp.
References d.
|
signal |
Referenced by QWavefrontMesh(), and setProjectionPlaneV().
QVector3D QWavefrontMesh::projectionPlaneW | ( | ) | const |
Definition at line 655 of file qwavefrontmesh.cpp.
References d.
|
signal |
Referenced by QWavefrontMesh(), and setProjectionPlaneW().
|
protectedslot |
Definition at line 204 of file qwavefrontmesh.cpp.
References QByteArray::at(), d, emit, file, FileNotFoundError, QQuickShaderEffectMesh::geometryChanged(), InvalidSourceError, QString::isEmpty(), ok, QFile::open(), p1, p2, Q_ASSERT, Q_UNLIKELY, qMakePair(), QIODeviceBase::ReadOnly, setLastError(), Qt::SkipEmptyParts, QStringView::split(), t2, t3, t4, UnsupportedFaceShapeError, UnsupportedIndexSizeError, and QQmlFile::urlToLocalFileOrQrc().
Referenced by QWavefrontMesh().
Definition at line 172 of file qwavefrontmesh.cpp.
References d, emit, lastError, and lastErrorChanged().
Referenced by readData(), and updateGeometry().
\qmlproperty vector3d WavefrontMesh::projectionPlaneV
Since the Wavefront .obj format describes an object in 3D space, the coordinates have to be projected into 2D before they can be displayed in Qt Quick.
This will be done in WavefrontMesh by an orthographic projection onto an appropriate plane.
The projectionPlaneV is one of two vectors in the plane in 3D space. If either this, or \l projectionPlaneW is set to (0, 0, 0) (the default), then the plane will be detected based on the first encountered face in the data set.
Definition at line 613 of file qwavefrontmesh.cpp.
References d, emit, and projectionPlaneVChanged().
\qmlproperty vector3d WavefrontMesh::projectionPlaneW
Since the Wavefront .obj format describes an object in 3D space, the coordinates have to be projected into 2D before they can be displayed in Qt Quick.
This will be done in WavefrontMesh by an orthographic projection onto an appropriate plane.
The projectionPlaneW is one of two vectors in the plane in 3D space. If either this, or \l projectionPlaneV is set to (0, 0, 0) (the default), then the plane will be detected based on the first encountered face in the data set.
Definition at line 645 of file qwavefrontmesh.cpp.
References d, emit, and projectionPlaneWChanged().
Definition at line 194 of file qwavefrontmesh.cpp.
References d, emit, source, and sourceChanged().
QUrl QWavefrontMesh::source | ( | ) | const |
\qmlproperty url WavefrontMesh::source
This property holds the URL of the source. This must be either a local file or in qrc. The source will be read as a Wavefront .obj file and the geometry will be updated.
Definition at line 188 of file qwavefrontmesh.cpp.
References d.
|
signal |
|
overridevirtual |
Implements QQuickShaderEffectMesh.
Definition at line 478 of file qwavefrontmesh.cpp.
References QSGGeometry::allocate(), QVector3D::crossProduct(), d, QSGGeometry::defaultAttributes_Point2D(), QSGGeometry::defaultAttributes_TexturedPoint2D(), QVector3D::dotProduct(), QSGGeometry::DrawTriangles, QRectF::height(), i, QSGGeometry::indexData(), InvalidPlaneDefinitionError, QVector3D::isNull(), QRectF::left(), QVector3D::normalize(), QVector3D::normalized(), Q_ASSERT, QSGGeometry::setDrawingMode(), setLastError(), QVector3D::setX(), QRectF::top(), QSGGeometry::UnsignedShortType, QSGGeometry::vertexCount(), QSGGeometry::vertexData(), QRectF::width(), QVector2D::x(), QSGGeometry::Point2D::x, QVector2D::y(), and QSGGeometry::Point2D::y.
|
override |
Definition at line 438 of file qwavefrontmesh.cpp.
References d, QListSpecialMethodsBase< T >::indexOf(), MissingPositionAndTextureCoordinateAttributesError, MissingPositionAttributeError, MissingTextureCoordinateAttributeError, NoAttributesError, qtPositionAttributeName(), qtTexCoordAttributeName(), QList< T >::size(), and TooManyAttributesError.
|
read |
Definition at line 88 of file qwavefrontmesh_p.h.
Referenced by setLastError().
|
readwrite |
Definition at line 88 of file qwavefrontmesh_p.h.
|
readwrite |
Definition at line 88 of file qwavefrontmesh_p.h.
|
readwrite |
Definition at line 88 of file qwavefrontmesh_p.h.
Referenced by setSource().