小编mch*_*son的帖子

如何在 3D 中为 QML 旋转变换设置动画并正确插入

这里的代码示例:

import QtQuick 2.0
Item {
    width: 200; height: 200
    Rectangle {
        width: 100; height: 100
        anchors.centerIn: parent
        color: "#00FF00"
        Rectangle {
            color: "#FF0000"
            width: 10; height: 10
            anchors.top: parent.top
            anchors.right: parent.right
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

将产生此输出:

第1步

现在我想从这个绿色矩形的中心应用 3D 旋转。首先,我想在 X 上旋转 -45 度(向下弯曲),然后在 Y 上旋转 -60 度(向左转)。

我使用以下 C++ 代码在侧面使用 GLM 截取来帮助我计算轴和角度:

// generate rotation matrix from euler in X-Y-Z order
// please note that GLM uses radians, not degrees
glm::mat4 rotationMatrix = glm::eulerAngleXY(glm::radians(-45.0f), glm::radians(-60.0f));

// convert the rotation matrix …
Run Code Online (Sandbox Code Playgroud)

c++ 3d qt qml glm-math

4
推荐指数
1
解决办法
4148
查看次数

标签 统计

3d ×1

c++ ×1

glm-math ×1

qml ×1

qt ×1