VB.NET中屏幕坐标如何转换为世界坐标

123工艺品 2017-04-19 07:32:42
directx 9,左手坐系,VB2010,部分代码如下。
请问如何转换

Private Sub SetupCamera()
'设置投影转换矩阵
Dim fieldOfView As Single = Math.PI / 4
Dim aspectRatio As Single = Me.Width / Me.Height
Dim nearPlane As Single = 2.0F
Dim farPlane As Single = 500.0F
device.Transform.Projection = Matrix.PerspectiveFovLH(fieldOfView, aspectRatio, nearPlane, farPlane)


'设置视图转换矩阵
Select Case CameraDirect
Case 0
Dim cameraPosition As New Vector3(20, 20, -20.0F)
Dim cameraTarget As New Vector3(0, 0, 0)
Dim upDirection As New Vector3(0, 1, 0)
device.Transform.View = Matrix.LookAtLH(cameraPosition, cameraTarget, upDirection)
Case 1
Dim cameraPosition As New Vector3(-20, -20, 20.0F)
Dim cameraTarget As New Vector3(0, 0, 0)
Dim upDirection As New Vector3(0, -1, 0)
device.Transform.View = Matrix.LookAtLH(cameraPosition, cameraTarget, upDirection)
End Select
device.RenderState.Lighting = False '设置打开光照
device.RenderState.CullMode = IIf(enableCullMode, Cull.CounterClockwise, Cull.None) '设置剔除背影
device.RenderState.FillMode = IIf(enableSolidMode, FillMode.Solid, FillMode.WireFrame) '设置填充模式
device.RenderState.Ambient = Color.White
device.Lights(0).Range = 150.0F
End Sub
...全文
301 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

456

社区成员

发帖
与我相关
我的任务
社区描述
其它游戏引擎
社区管理员
  • 其它游戏引擎社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧