Solved Qt3D Transform{} skew uncompatible?
-
I'm trying to implement the following transformation in Qt3D: fit a textured rectangle in an arbitrary quaternion.
I've found the calculation of the transformation 4x4 matrix on the internet and it works very well in 2D QtQuick. Then I tried to bring the same matrix to Qt3D and failed. From what I see Qt3D doesn't want to distort the objects same as QtQuick does. However simple affine transformations like translations, rotations and scale do work very well in Qt3D. Skew doesn't.
I don't believe Qt3D treats transformation matrices in a different way that all other frameworks. I must have missed something. Is it possible Qt3D clears certain 'non-important' matrix values?
Sources: https://drive.google.com/open?id=0BxC-DMpqMeoKZkkwc1ZQM3FVNHc
The test application has all controls to dynamically play with the matrices and transformations.Any ideas appreciated. Thanks!
A good guide to 4x4 transformations: https://www.w3.org/TR/css-transforms-1/#mathematical-description
-
Hi,
I'd recommend bringing this question to the interest mailing list. You'll find there Qt3D's developers/maintainers. This forum is more user oriented.
-
Finally I've found the problem root cause:
The Qt3D's Transform { ... } is compatible with affine transformations ONLY.
It means you cannot load an arbitrary matrix into Transform and expect it to work.
After receiving a matrix they decompose it to translation, rotations and scale and compose a new matrix basing on these values. Sucks. -
@sylc Interesting. How did you find out?
-
@Wieland
Looks like I will need to implement a "RawTransform { matrix: m }" QML class that would accept only a matrix and do no calculations at all.
How did I find out: Qt3D sources, file qtransform.cpp contains a matrix setter
void QTransform::setMatrix(const QMatrix4x4 &m) { Q_D(QTransform); if (m != matrix()) { d->m_matrix = m; d->m_matrixDirty = false; QVector3D s; QVector3D t; QQuaternion r; decomposeQMatrix4x4(m, t, r, s); d->m_scale = s; d->m_rotation = r; d->m_translation = t; d->m_eulerRotationAngles = d->m_rotation.toEulerAngles(); emit scale3DChanged(s); emit rotationChanged(r); emit translationChanged(t); const bool wasBlocked = blockNotifications(true); emit matrixChanged(); emit scaleChanged(d->m_scale.x()); emit rotationXChanged(d->m_eulerRotationAngles.x()); emit rotationYChanged(d->m_eulerRotationAngles.y()); emit rotationZChanged(d->m_eulerRotationAngles.z()); blockNotifications(wasBlocked); } }
-
Hey guys, just found this thread.
Is this related to what I found here ? https://bugreports.qt.io/browse/QTBUG-58987That issue is blocking my project and apprently the Qt3D folks don't seem to be interested in fixing it.
I definitely need to use nested meshes and be able to freely transform each submesh.
Cheers