三維圖形導(dǎo)入vb.net 三維模型導(dǎo)入turbogrid

怎么利用VB.NET實(shí)現(xiàn)三維繪圖

數(shù)學(xué)上不是有斜二測畫法,算好坐標(biāo)即可畫出

創(chuàng)新互聯(lián)公司于2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站建設(shè)、成都網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元阿拉山口做網(wǎng)站,已為上家服務(wù),為阿拉山口各地企業(yè)和個人服務(wù),聯(lián)系電話:028-86922220

或者用AnyCAD的.Net圖形控件

也可以調(diào)用matlab 實(shí)現(xiàn)

VB.net可以開發(fā)小型3D圖形顯示軟件嗎?

可以借助DirectX來編程。免費(fèi)3D引擎可不好找,一般來說速度比不上硬件加速后的DX,尤其令人頭疼的是一般都沒有針對VB的文檔,LZ有這方面理想的話,自己寫一個吧……

我不得不承認(rèn)在VB上寫DirectX的教程相當(dāng)難找!如果LZ想深入研究三維圖形問題,C++一定要學(xué),就算不能用C++編程,起碼要能把C++程序翻譯成VB程序。

我自己學(xué)會DX編程花了兩三個月(很淺)。編這樣一個程序難度是有點(diǎn)大的。

工具:DirectX9和其針對VB的庫(項(xiàng)目-添加引用。.NET庫里DX庫一般都有),VB不知道現(xiàn)在支不支持DX10以上的版本,不過9絕對夠用了。

思路:一切3D圖形都是由三角形拼成的。矩形挖掉一個圓孔可不是一個方便畫的圖形,我估計(jì)至少得有24個三角形。你需要記錄這些點(diǎn)的坐標(biāo),或者干脆把它們寫在文件里,到時讀出來。

這是我的一個老DX程序的不完全的代碼(顯示一個黑乎乎的平面),不一定能編譯,可以參考一下。

Imports Microsoft.DirectX '一定要~

Public Class FormMain

'Direct3D Startup

Dim d3dpp As New Direct3D.PresentParameters 'DX基本參數(shù),例如全屏還是窗口等

Public MyDevice As Direct3D.Device ‘DX基本設(shè)備,畫圖就靠它。

'Matrices

Dim matWorld, matView, matProj As Matrix '世界位置矩陣,攝像機(jī)位置矩陣和透視矩陣,數(shù)學(xué)要學(xué)好啊。

'mesh

Public MyPlane as Direct3D.Mesh ’我們的物體

Public VBPlane(3) As Direct3D.CustomVertex.PositionNormalTextured '存放頂點(diǎn)位置的數(shù)組

#Region "DX Core"

Public Sub InitDeviceObjects()

With d3dpp ‘以下請照抄。

.Windowed = True ‘不全屏。

.SwapEffect = Direct3D.SwapEffect.Discard ’雙緩沖交換效果。請百度“雙緩沖”

.BackBufferFormat = Direct3D.Format.Unknown

.EnableAutoDepthStencil = True ’讓DX自動管理深度緩沖

.AutoDepthStencilFormat = Direct3D.DepthFormat.D16

End With

MyDevice = New Direct3D.Device(0, Direct3D.DeviceType.Hardware, Me.Handle, Direct3D.CreateFlags.HardwareVertexProcessing, d3dpp) '創(chuàng)建DX設(shè)備啦!以下兩句請照抄。

MyDevice.SetRenderState(Direct3D.RenderStates.ZEnable, True) ‘Z緩沖

MyDevice.SetRenderState(Direct3D.RenderStates.NormalizeNormals, True)'法線歸一化,請看相關(guān)數(shù)學(xué)書籍。

End Sub

Public Sub RestoreDeviceObjects()

Dim PlaneIB() As Short = {0, 1, 3, 0, 2, 3} ’頂點(diǎn)索引信息。

Dim AttrTable(1) As Direct3D.AttributeRange ‘頂點(diǎn)分組屬性表

AttrTable(0).AttributeId = 0

AttrTable(0).FaceStart = 0

AttrTable(0).FaceCount = 2 ’有兩個三角形

AttrTable(0).VertexStart = 0

AttrTable(0).VertexCount = 4 ‘四個點(diǎn)

‘頂點(diǎn)坐標(biāo)信息。

VBPlane(0) = New Direct3D.CustomVertex.PositionNormalTextured(-500, -500, 0, 0, 0, 1, 0, 0)

VBPlane(1) = New Direct3D.CustomVertex.PositionNormalTextured(500, -500, 0, 0, 0, 1, 1, 0)

VBPlane(2) = New Direct3D.CustomVertex.PositionNormalTextured(-500, 500, 0, 0, 0, 1, 0, 1)

VBPlane(3) = New Direct3D.CustomVertex.PositionNormalTextured(500, 500, 0, 0, 0, 1, 1, 1)

MyPlane = New Direct3D.Mesh(2, 4, Direct3D.MeshFlags.Managed, Direct3D.VertexFormats.Position + Direct3D.VertexFormats.Normal + Direct3D.VertexFormats.Texture1, MyDevice) ’創(chuàng)建物體

MyPlane.SetVertexBufferData(VBPlane, Direct3D.LockFlags.None) ‘輸入頂點(diǎn)坐標(biāo)數(shù)據(jù)

MyPlane.SetIndexBufferData(PlaneIB, Direct3D.LockFlags.None) ‘輸入索引數(shù)據(jù)

MyPlane.SetAttributeTable(AttrTable) ‘輸入頂點(diǎn)分組屬性表

End Sub

Public Sub Render() ‘調(diào)用它畫圖

Dim vlook As New Vector3(1, 0, 0)

Dim vPos As New Vector3(0,0,0)

Dim vUp As New Vector3(0, 0, 1)

MatView = Matrix.LookAtLH(vPos, vlook, vUp) ‘計(jì)算攝像機(jī)位置矩陣

Device.SetTransform(Direct3D.TransformType.View, MatView) ‘設(shè)置當(dāng)前攝像機(jī)位置矩陣為MatView。

Dim fAspect As Single = Me.Width / Me.Height ’窗口長寬比

matProj = Matrix.PerspectiveFovLH(Math.PI / 4, fAspect, 1.0F, 10001) ‘計(jì)算透視矩陣MatProj。

MyDevice.SetTransform(Direct3D.TransformType.Projection, matProj) ‘設(shè)置當(dāng)前透視矩陣為MatProj。

MyDevice.Clear(Direct3D.ClearFlags.Target + Direct3D.ClearFlags.ZBuffer, Color.Blue, 1.0F, 0) ’先刷藍(lán)屏

MyDevice.BeginScene() ‘開始畫

MatWorld = Matrix.Identity ’物體位于原點(diǎn),不旋轉(zhuǎn)

Device.SetTransform(Direct3D.TransformType.World, MatWorld) ’設(shè)置物體位置

Me.Mesh.DrawSubset(0) ‘畫物體

MyDevice.EndScene() ’結(jié)束

MyDevice.Present() ‘顯示在屏幕上

End Sub

Public Sub DeleteDeviceObjects() ’結(jié)束程序時放掉資源

MyPlane.Dispose()

MyDevice.Dispose()

End Sub

#End Region

Private Sub FormMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

DeleteDeviceObjects()

Windows.Forms.Cursor.Show()

End Sub

Private Sub FormMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

InitDeviceObjects()

RestoreDeviceObjects()

Windows.Forms.Cursor.Hide()

Render()

End Sub

End Class

如何用VB畫三維圖形?

三維圖形不知道,但我知道用什么可以畫二維的。需要一個控件:visual graph。導(dǎo)入VG后就可以使用了,提供了豐富的元件圖庫,方便至極。

分享標(biāo)題:三維圖形導(dǎo)入vb.net 三維模型導(dǎo)入turbogrid
網(wǎng)頁URL:http://muchs.cn/article22/ddcdsjc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、微信公眾號用戶體驗(yàn)、軟件開發(fā)微信小程序、小程序開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)