2012-05-05 62 views
1

我在用VB.NET編寫的DirectX中創建了一個網格框。當我旋轉和縮放網格時,它是從中心開始的。更改Directx網格中心

如何更改類似下面的圖像的網中心:

Mesh Center

回答

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 

注:我沒有測試以上,所以有可能是語法問題。