如何使用Matrix4x4 transform围绕z之外的另一个轴旋转QML项目,并将项目的中心作为转换的原点?
要以(0,0)作为原点围绕y轴旋转,我天真地尝试:
Image {
source: "..."
width: 100
height: 100
transform: Matrix4x4 {
property real a: Math.PI / 4
matrix: Qt.matrix4x4(
Math.cos(a), 0, -Math.sin(a), 0,
0, 1, 0, 0,
Math.sin(a), 0, Math.cos(a), 0,
0, 0, 0, 1)
}
}
结果,我得到一个剪切宽度的项目,而我正在寻找透视效果。
任何人都可以解释QML项目的转换矩阵是如何工作的吗?
答案 0 :(得分:2)
以下是Unity 8的评论:
// Rotating 3 times at top/bottom because that increases the perspective.
// This is a hack, but as QML does not support real 3D coordinates
// getting a higher perspective can only be done by a hack. This is the most
// readable/understandable one I could come up with.
源代码链接:https://github.com/ubports/unity8/blob/xenial/qml/Launcher/LauncherDelegate.qml#L287