Qt Transformationsmatrix
Ich muss QML-Elemente über QMatrix4x4 bearbeiten, um einige perspektivische Transformationen anzuwenden. Grundsätzlich habe ich die Klasse Transform definiert, um ein Objekt QMatrix4x4 als Argument für das Transformationsfeld des QML-Elements @ zu verwende
class Transform : public QQuickTransform{
Q_OBJECT
Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY matrixChanged)
public:
explicit Transform(QQuickItem *parent = 0);
QMatrix4x4 matrix() const;
void setMatrix(QMatrix4x4 matrix);
virtual void applyTo(QMatrix4x4 *matrix) const;
signals:
void matrixChanged();
private:
QMatrix4x4 m_matrix;
};
wohe
void Transform::applyTo(QMatrix4x4 *matrix) const {
*matrix *= m_matrix;
matrix->optimize();
}
Es scheint jedoch, dass QML die Perspektivenmatrix nicht auf klassische Weise "definiert". Ich habe mich bei meinen Tests hauptsächlich auf die Rotationen konzentriert http: //en.wikipedia.org/wiki/Rotation_matri). Angenommen, ich habe ein QML-Element in x: 200, y: 200 und wende die Transformation @ a
transform: [Transform{matrix:mytra},Rotation { axis { x: 1; y: 0; z: 0 } angle: 90 } ]
wo mytra ist die Identitätsmatrix. Die Methode applyTo () erhält die (Rotations-) Matrix
1 -0.195312 0 200
0 -0.195312 0 200
0 0 1 0
0 -0.000976562 0 1
aber das "klassische" sollte man sein
1 0 0 200
0 0 -1 200
0 1 0 0
0 0 0 1
Ich verstehe nicht, woher diese Matrix kommt und wie ich meine Matrix an qt anpasse. Danke für die Hilfe