Matriz de transformación Qt
Necesito manipular elementos QML a través de QMatrix4x4, para aplicar algunas transformaciones de perspectiva. Básicamente, definí la clase Transformar para usar un objeto QMatrix4x4 como argumento para el campo de transformación del Elemento QML
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;
};
dónde
void Transform::applyTo(QMatrix4x4 *matrix) const {
*matrix *= m_matrix;
matrix->optimize();
}
Sin embargo, parece que QML no "define" la matriz de perspectiva de la manera clásica. He centrado mis pruebas principalmente en las rotaciones (http://en.wikipedia.org/wiki/Rotation_matrix) Digamos que tengo un elemento QML en x: 200, y: 200 y aplico la transformación
transform: [Transform{matrix:mytra},Rotation { axis { x: 1; y: 0; z: 0 } angle: 90 } ]
donde mytra es la matriz de identidad. El método applyTo () recibe la matriz (rotación)
1 -0.195312 0 200
0 -0.195312 0 200
0 0 1 0
0 -0.000976562 0 1
pero el "clásico" debería ser
1 0 0 200
0 0 -1 200
0 1 0 0
0 0 0 1
No entiendo de dónde viene esta matriz y cómo adaptar mi matriz a qt. Gracias por la ayuda.