6#include <QtCore/qfile.h>
7#include <QtCore/qtextstream.h>
8#include <QtCore/private/qobject_p.h>
10#include <QtGui/qvector2d.h>
11#include <QtGui/qvector3d.h>
13#include <QtQml/qqmlfile.h>
14#include <QtQml/qqmlcontext.h>
16#include <QtQuick/qsggeometry.h>
31 return mesh->d_func();
36 return mesh->d_func();
208 d->textureCoordinates.clear();
226 if (tokens.size() < 2)
231 if (command ==
"vt") {
233 float u = tokens.at(1).toFloat(&
ok);
239 float v = tokens.size() > 2 ? tokens.at(2).toFloat(&
ok) : 0.0;
246 }
else if (command ==
"v") {
248 if (tokens.size() < 4 || tokens.size() > 5) {
255 float x = tokens.at(1).toFloat(&
ok);
261 float y = tokens.at(2).toFloat(&
ok);
267 float z = tokens.at(3).toFloat(&
ok);
274 }
else if (command ==
"f") {
281 if (tokens.size() >= 4 && tokens.size() <= 5) {
287 p1 = faceTokens.at(0).toInt(&
ok) - 1;
293 if (faceTokens.size() > 1) {
294 t1 = faceTokens.at(1).toInt(&
ok) - 1;
307 p2 = faceTokens.at(0).toInt(&
ok) - 1;
313 if (faceTokens.size() > 1) {
314 t2 = faceTokens.at(1).toInt(&
ok) - 1;
327 p3 = faceTokens.at(0).toInt(&
ok) - 1;
333 if (faceTokens.size() > 1) {
334 t3 = faceTokens.at(1).toInt(&
ok) - 1;
343 || p2 < 0 || p2 > UINT16_MAX
344 || p3 < 0 || p3 > UINT16_MAX
345 || t1 < 0 || t1 > UINT16_MAX
346 || t2 < 0 || t2 > UINT16_MAX
347 || t3 < 0 || t3 > UINT16_MAX)) {
360 if (tokens.size() == 5) {
365 int p4 = faceTokens.at(0).toInt(&
ok) - 1;
372 if (faceTokens.size() > 1) {
373 t4 = faceTokens.at(1).toInt(&
ok) - 1;
380 if (
Q_UNLIKELY(p4 < 0 || p4 > UINT16_MAX || t4 < 0 || t4 > UINT16_MAX)) {
407 switch (
d->lastError) {
425 return QStringLiteral(
"Error: Missing '%1' and '%2' attributes").arg(
432 "V and W must be non-null and cannot be parallel");
441 const int attrCount = attributes.
size();
450 if (positionIndex < 0) {
456 if (positionIndex < 0 || texCoordIndex < 0) {
457 if (positionIndex < 0 && texCoordIndex < 0)
459 else if (positionIndex < 0)
461 else if (texCoordIndex < 0)
472 *posIndex = positionIndex;
479 const QRectF &sourceRect,
const QRectF &destinationRect)
483 if (geometry ==
nullptr) {
484 Q_ASSERT(attributeCount == 1 || attributeCount == 2);
494 geometry->
allocate(
d->indexes.size(),
d->indexes.size());
498 if (
d->indexes.size() < 3) {
509 planeV = (
d->vertexes.at(
d->indexes.at(1).first) -
p);
510 planeW = (
p -
d->vertexes.at(
d->indexes.at(2).first)).
normalized();
517 if (planeNormal.
isNull()) {
534 *(indexData +
i) =
i;
545 positionData->
x =
w.x();
546 positionData->
y =
w.y();
548 if (
i == 0 || minX >
w.x())
550 if (
i == 0 ||
maxX <
w.x())
552 if (
i == 0 ||
minY >
w.y())
554 if (
i == 0 ||
maxY <
w.y())
557 if (attributeCount > 1 && !
d->textureCoordinates.isEmpty()) {
558 Q_ASSERT(positionIndex == 0 || positionIndex == 1);
560 QVector2D uv =
d->textureCoordinates.at(
d->indexes.at(
i).second);
561 QSGGeometry::Point2D *textureCoordinateData = vertexData + (
i * attributeCount + (1 - positionIndex));
562 textureCoordinateData->
x = uv.
x();
563 textureCoordinateData->
y = uv.
y();
574 float x = ((vertexData + positionIndex)->
x - center.x()) *
scale.x();
575 float y = ((vertexData + positionIndex)->
y - center.y()) *
scale.y();
577 for (
int attributeIndex = 0; attributeIndex < attributeCount; ++attributeIndex) {
578 if (attributeIndex == positionIndex) {
579 vertexData->
x = float(destinationRect.
left()) +
x * float(destinationRect.
width()) + float(destinationRect.
width()) / 2.0f;
580 vertexData->
y = float(destinationRect.
top()) +
y * float(destinationRect.
height()) + float(destinationRect.
height()) / 2.0f;
583 float tx =
d->textureCoordinates.isEmpty() ?
x : vertexData->
x;
584 float ty =
d->textureCoordinates.isEmpty() ?
y : vertexData->
y;
586 vertexData->
x = float(sourceRect.
left()) + tx * float(sourceRect.
width());
587 vertexData->
y = float(sourceRect.
top()) +
ty * float(sourceRect.
height());
664#include "moc_qwavefrontmesh_p.cpp"
char at(qsizetype i) const
Returns the byte at index position i in the byte array.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
qsizetype size() const noexcept
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static QString urlToLocalFileOrQrc(const QString &)
If url is a local file returns a path suitable for passing to QFile.
\inmodule QtCore\reentrant
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr qreal left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
The QSGGeometry class provides low-level storage for graphics primitives in the \l{Qt Quick Scene Gra...
static const AttributeSet & defaultAttributes_Point2D()
Convenience function which returns attributes to be used for 2D solid color drawing.
void setDrawingMode(unsigned int mode)
Sets the mode to be used for drawing this geometry.
static const AttributeSet & defaultAttributes_TexturedPoint2D()
Convenience function which returns attributes to be used for textured 2D drawing.
void * indexData()
Returns a pointer to the raw index data of this geometry object.
void allocate(int vertexCount, int indexCount=0)
Resizes the vertex and index data of this geometry object to fit vertexCount vertices and indexCount ...
void * vertexData()
Returns a pointer to the raw vertex data of this geometry object.
int vertexCount() const
Returns the number of vertices in this geometry object.
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the view into substring views wherever sep occurs, and returns the list of those string views.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
The QVector2D class represents a vector or vertex in 2D space.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr float x() const noexcept
Returns the x coordinate of this point.
The QVector3D class represents a vector or vertex in 3D space.
constexpr void setX(float x) noexcept
Sets the x coordinate of this point to the given finite x coordinate.
constexpr bool isNull() const noexcept
Returns true if the x, y, and z coordinates are set to 0.0, otherwise returns false.
QVector3D normalized() const noexcept
Returns the normalized unit vector form of this vector.
static constexpr float dotProduct(QVector3D v1, QVector3D v2) noexcept
Returns the dot product of v1 and v2.
static constexpr QVector3D crossProduct(QVector3D v1, QVector3D v2) noexcept
Returns the cross-product of vectors v1 and v2, which is normal to the plane spanned by v1 and v2.
void normalize() noexcept
Normalizes the current vector in place.
QVector< QPair< ushort, ushort > > indexes
QWavefrontMesh::Error lastError
static QWavefrontMeshPrivate * get(QWavefrontMesh *mesh)
QVector< QVector2D > textureCoordinates
static const QWavefrontMeshPrivate * get(const QWavefrontMesh *mesh)
QVector< QVector3D > vertexes
void projectionPlaneVChanged()
QVector3D projectionPlaneV
QVector3D projectionPlaneW
void setLastError(Error lastError)
QWavefrontMesh(QObject *parent=nullptr)
\qmlmodule Qt.labs.wavefrontmesh 1.
QString log() const override
void projectionPlaneWChanged()
~QWavefrontMesh() override
void setProjectionPlaneW(const QVector3D &projectionPlaneW)
\qmlproperty vector3d WavefrontMesh::projectionPlaneW
void setProjectionPlaneV(const QVector3D &projectionPlaneV)
\qmlproperty vector3d WavefrontMesh::projectionPlaneV
bool validateAttributes(const QList< QByteArray > &attributes, int *posIndex) override
@ MissingPositionAndTextureCoordinateAttributesError
@ MissingTextureCoordinateAttributeError
@ UnsupportedIndexSizeError
@ UnsupportedFaceShapeError
@ MissingPositionAttributeError
@ InvalidPlaneDefinitionError
QSGGeometry * updateGeometry(QSGGeometry *geometry, int attrCount, int posIndex, const QRectF &srcRect, const QRectF &rect) override
void setSource(const QUrl &url)
Combined button and popup list for selecting options.
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLfloat GLfloat GLfloat GLfloat GLfloat maxY
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
GLfloat GLfloat GLfloat GLfloat maxX
GLsizei GLsizei GLchar * source
GLenum GLenum GLenum GLenum GLenum scale
constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
const char * qtTexCoordAttributeName()
const char * qtPositionAttributeName()
QLatin1StringView QLatin1String
#define QStringLiteral(str)
\inmodule QtCore \reentrant
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
The QSGGeometry::Point2D struct is a convenience struct for accessing 2D Points.
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent