我在用 VB.NET 编写的 DirectX 中创建了一个网格框。当我旋转和缩放网格时,它是从中心开始的。
如何更改类似于下图的网格中心:
将网格矩阵平移到旋转/缩放中心,应用旋转/缩放,然后将矩阵平移回来。例如:
matWorld = Matrix.Identity
' Translate to rotation/scaling center
matWorld = matWorld * Matrix.Translate(0.1, 0.2, 0.3)
' Apply your rotation/scaling
matWorld = matWorld * Matrix.RotationZ(0.01)
' Translate from rotation/scaling center
matWorld = matWorld * Matrix.Translate(-0.1, -0.2, -0.3)
' Assign matWorld as world transformation matrix
device.Transform.World = matWorld
注意:我没有测试上述内容,因此可能存在语法问题。