QML:使用Matrix4x4转换 [英] QML: using Matrix4x4 transform

查看:619
本文介绍了QML:使用Matrix4x4转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Matrix4x4变换,您如何旋转 QML项围绕z以外的另一个轴,以项的中心为变换的原点?

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?

要以(0,0)为原点绕y轴旋转,我天真地尝试了:

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.

谁能解释QML项目的转换矩阵如何工作?

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

推荐答案

这里是Unity 8的评论:

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.

链接到源代码: https://github.com/ubports/unity8/blob/xenial/qml/Launcher/LauncherDelegate.qml#L287

这篇关于QML:使用Matrix4x4转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆