【问题标题】:Change Directx Mesh Center更改 Directx 网格中心
【发布时间】:2023-03-12 07:24:01
【问题描述】:

我在 DirectX 中创建了一个用 VB.NET 编写的网格盒。当我旋转和缩放网格时,它是从中心开始的。

如何更改网格中心类似于下图:

Mesh Center

【问题讨论】:

    标签: directx rotation scale mesh cube


    【解决方案1】:

    将网格矩阵平移到旋转/缩放中心,应用旋转/缩放,然后将矩阵平移回来。例如:

    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
    

    注意:以上我没有测试,所以可能存在语法问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多