QML: using Matrix4x4 transform

别等时光非礼了梦想. 提交于 2019-12-24 04:01:12

问题


How do you rotate, using Matrix4x4 transform, a QML item around another axis than z, with the center of the item as origin of the transformation?

To rotate around the y axis with (0,0) as origin, I tried naively:

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)
    }
}

As a result, I get a cut width item whereas I am looking for a perspective effect.

Can anyone explain how the transformation matrix of QML items works?


回答1:


Here's comment from 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.

Link to source code: https://github.com/ubports/unity8/blob/xenial/qml/Launcher/LauncherDelegate.qml#L287



来源:https://stackoverflow.com/questions/28628465/qml-using-matrix4x4-transform

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!