日々のDraft

回答原案集

3Dと行列

2006-11-21 20:36:24 | プログラム
http://www012.upp.so-net.ne.jp/flab/3d/

やったー頂点が表示されなかった理由判明!

presentParameters.Windowed = True
presentParameters.EnableAutoDepthStencil = True
presentParameters.AutoDepthStencilFormat = Microsoft.DirectX.Direct3D.DepthFormat.D16

presentParameters.SwapEffect = Microsoft.DirectX.Direct3D.SwapEffect.Discard
presentParameters.PresentationInterval = Microsoft.DirectX.Direct3D.PresentInterval.Immediate
presentParameters.BackBufferWidth = 0
presentParameters.BackBufferHeight = 0

しているので

Do


Try

Direct3DDevice.Clear(Microsoft.DirectX.Direct3D.ClearFlags.Target Or Microsoft.DirectX.Direct3D.ClearFlags.ZBuffer, System.Drawing.Color.DarkBlue, 1.0F, 0)
Direct3DDevice.Transform.View = Microsoft.DirectX.Matrix.LookAtLH(New Microsoft.DirectX.Vector3(0.0F, 0.0F, -5.0F), New Microsoft.DirectX.Vector3(0.0F, 0.0F, 0.0F), New Microsoft.DirectX.Vector3(0.0F, 1.0F, 0.0F))
Direct3DDevice.Transform.Projection = Microsoft.DirectX.Matrix.PerspectiveFovLH(System.Math.PI / 4.0, Single.Parse(MyForm.ClientSize.Width.ToString) / Single.Parse(MyForm.ClientSize.Height.ToString), 3.0F, 15.0F)
Direct3DDevice.RenderState.Lighting = True

DrawGround()

'System.Diagnostics.Debugger.Break()
Direct3DDevice.BeginScene()

Catch ex As System.Exception

(中略)


End Try

Loop

一回一回ZBufferをクリアして、カメラとライトの設定をするようにしてあげたら上手く行った。


最新の画像もっと見る

post a comment