这里的代码示例:
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)
将产生此输出:
现在我想从这个绿色矩形的中心应用 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)