可以借助DirectX來編程。免費(fèi)3D引擎可不好找,一般來說速度比不上硬件加速后的DX,尤其令人頭疼的是一般都沒有針對VB的文檔,LZ有這方面理想的話,自己寫一個(gè)吧……
為五原等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及五原網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站建設(shè)、成都網(wǎng)站制作、五原網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!
我不得不承認(rèn)在VB上寫DirectX的教程相當(dāng)難找!如果LZ想深入研究三維圖形問題,C++一定要學(xué),就算不能用C++編程,起碼要能把C++程序翻譯成VB程序。
我自己學(xué)會DX編程花了兩三個(gè)月(很淺)。編這樣一個(gè)程序難度是有點(diǎn)大的。
工具:DirectX9和其針對VB的庫(項(xiàng)目-添加引用。.NET庫里DX庫一般都有),VB不知道現(xiàn)在支不支持DX10以上的版本,不過9絕對夠用了。
思路:一切3D圖形都是由三角形拼成的。矩形挖掉一個(gè)圓孔可不是一個(gè)方便畫的圖形,我估計(jì)至少得有24個(gè)三角形。你需要記錄這些點(diǎn)的坐標(biāo),或者干脆把它們寫在文件里,到時(shí)讀出來。
這是我的一個(gè)老DX程序的不完全的代碼(顯示一個(gè)黑乎乎的平面),不一定能編譯,可以參考一下。
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 ’有兩個(gè)三角形
AttrTable(0).VertexStart = 0
AttrTable(0).VertexCount = 4 ‘四個(gè)點(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é)束程序時(shí)放掉資源
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
你想知道的是什么呀,表示不懂。我裝了DX后,要導(dǎo)入dll文件,我是到C:\Windows\Microsoft.NET\DirectX for Managed Code\1.0.2902.0里找的,我需要用的都在里面,而VC++ VB.NET之類的在哪兒你就不需要關(guān)心了吧,用VS就行了呢
您好,建議您使用mouse_event或者?Cursor.Position來實(shí)現(xiàn)。例如:
1. 您需要將鼠標(biāo)移動dx, dy的位置。
Public?Sub?MouseMoveBy(ByVal?dx?As?Integer,?ByVal?dy?As?Integer)
Cursor.Position?=?New?Point(Cursor.Position.X?+?dx,?Cursor.Position.Y?+?dy)
End?Sub
或者
Public?Sub?MouseMoveBy(ByVal?dx?As?Integer,?ByVal?dy?As?Integer)
mouse_event(0,?dx,?dy,?0,?0)
End?Sub
2. 您需要將鼠標(biāo)移動到x, y的位置
Public?Sub?MouseMoveTo(ByVal?x?As?Integer,?ByVal?y?As?Integer)
Cursor.Position?=?New?Point(x,?y)
End?Sub
請您試一下。
DX即DirectX(Direct eXtension,簡稱DX)是由微軟公司創(chuàng)建的多媒體編程接口。由C++編程語言實(shí)現(xiàn),遵循COM。被廣泛使用于Microsoft Windows、Microsoft XBOX、Microsoft XBOX 360和Microsoft XBOX ONE電子游戲開發(fā),并且只能支持這些平臺。最新版本為DirectX 12,創(chuàng)建在最新的Windows10。
.NET插件是微軟用來實(shí)現(xiàn)XML/Web Services/SOA(面向服務(wù)的體系結(jié)構(gòu)service-oriented architecture)和敏捷性的技術(shù)。技術(shù)人員一般將微軟看成一個(gè)平臺廠商。微軟搭建技術(shù)平臺,而技術(shù)人員在這個(gè)技術(shù)平臺之上創(chuàng)建應(yīng)用系統(tǒng)。從這個(gè)角度,.NET也可以如下來定義:.NET是微軟的新一代技術(shù)平臺,為敏捷商務(wù)構(gòu)建互聯(lián)互通的應(yīng)用系統(tǒng),這些系統(tǒng)是基于標(biāo)準(zhǔn)的,聯(lián)通的,適應(yīng)變化的,穩(wěn)定的和高性能的。
網(wǎng)站欄目:包含dx綁定vb.net的詞條
本文網(wǎng)址:http://aaarwkj.com/article48/dsiidhp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、域名注冊、虛擬主機(jī)、動態(tài)網(wǎng)站、網(wǎng)站設(shè)計(jì)公司、關(guān)鍵詞優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)