在vb里面实现加载三维模型图 我现在需要在vb里面加个三维的模型,但是我没有弄过,请哪位大虾指教. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Private CenterX As IntegerPrivate CenterY As IntegerPrivate Const Size = 40Private CurX As IntegerPrivate CurY As IntegerPrivate CurZ As IntegerPrivate MoveTo As IntegerPrivate Const MOVE_LEFT = 0Private Const MOVE_RIGHT = 1Private Const MOVE_UP = 2Private Const MOVE_DOWN = 3Private Const MOVE_FORWARD = 4Private Const MOVE_BACKWARD = 5Public Sub EraseBlock()X = CurX: y = CurY: Z = CurZxs = (CenterX + X * Size) - Z * (Size / 2)Ys = (CenterY - y * Size) + Z * (Size / 2)Line (xs, Ys)-(xs + Size, Ys - Size), BackColor, BFLine (xs - Size / 2, Ys + Size / 2)-(xs + Size / 2, Ys - Size / 2), BackColor, BFFor i = 0 To Size / 2Line (xs - i, Ys + i)-(xs - i, Ys + i - Size - 1), BackColorLine (xs - i + Size, Ys + i)-(xs - i + Size, Ys + i - Size), BackColorNextEnd SubPublic Sub DrawBlock()Line (CenterX, CenterY)-(CenterX + Size * 6, CenterY - Size * 6), vbBlue, BLine (CenterX, CenterY)-(CenterX - Size * 6 / 2, CenterY + Size * 6 / 2), vbBlueLine (CenterX, CenterY - Size * 6)-(CenterX - Size * 6 / 2, CenterY + Size * 6 / 2 - Size * 6), vbBlueLine (CenterX + 1, CenterY - 1)-(CenterX + Size * 6 - 1, CenterY - Size * 6 + 1), RGB(0, 60, 0), BFFor i = 1 To Size * 6 / 2 - 1Line (CenterX - i + 1, CenterY + i)-(CenterX - i + Size * 6, CenterY + i), RGB(0, 60 + i * 2, 0)NextFor i = 0 To Size * 6 / 2 - 1Line (CenterX - i - 1, CenterY + i)-(CenterX - i - 1, CenterY + i - Size * 6 + 1), RGB(0, 60 + i * 2, 0)NextLabel1.Caption = "X : " & CurX & vbCrLf & "Y : " & CurY & vbCrLf & "Z : " & CurZ & vbCrLfX = CurX: y = CurY: Z = CurZcol = 10 + Z * 20xs = (CenterX + X * Size) - Z * (Size / 2)Ys = CenterY + Z * (Size / 2)For i = 0 To Size / 2Line (xs - i, Ys + i)-(xs - i + Size, Ys + i), vbBlackNextYs = (CenterY - y * Size) + Z * (Size / 2)Line (xs - Size / 2 + 1, Ys + Size / 2 - 1)-(xs + Size / 2 - 1, Ys - Size / 2 + 1), RGB(col + 120, 0, 0), BFLine (xs + 1, Ys - 1)-(xs + Size - 1, Ys - Size + 1), RGB(col, 0, 0), BFFor i = 0 To Size / 2Line (xs - i, Ys + i)-(xs - i + Size, Ys + i), RGB(col + i * 8, 0, 0)Line (xs - i, Ys + i)-(xs - i, Ys + i - Size), RGB(col + i * 8, 0, 0)Line (xs - i + Size, Ys + i)-(xs - i + Size, Ys + i - Size), RGB(col + i * 8, 0, 0)NextLine (CenterX - Size * 6 / 2, CenterY + Size * 6 / 2)-(CenterX + Size * 6 / 2, CenterY - Size * 6 / 2), vbBlue, BLine (CenterX + Size * 6, CenterY)-(CenterX + Size * 6 - Size * 6 / 2, CenterY + Size * 6 / 2), vbBlueLine (CenterX + Size * 6, CenterY - Size * 6)-(CenterX + Size * 6 - Size * 6 / 2, CenterY + Size * 6 / 2 - Size * 6), vbBlueEnd SubPrivate Sub cmdDemo_Click()Select Case cmdDemo.CaptionCase "DEMO ON"Timer1.Enabled = TruecmdDemo.Caption = "DEMO OFF"Case ElseTimer1.Enabled = FalsecmdDemo.Caption = "DEMO ON"End SelectEnd SubPrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)Select Case KeyCodeCase vbKeyLeftIf CurX > 0 ThenEraseBlockCurX = CurX - 1DrawBlockEnd IfCase vbKeyRightIf CurX < 5 ThenEraseBlockCurX = CurX + 1DrawBlockEnd IfCase vbKeyUpIf Shift = 0 ThenIf CurY < 5 ThenEraseBlockCurY = CurY + 1DrawBlockEnd IfElseIf Shift = 1 ThenIf CurZ > 0 ThenEraseBlockCurZ = CurZ - 1DrawBlockEnd IfEnd IfCase vbKeyDownIf Shift = 0 ThenIf CurY > 0 ThenEraseBlockCurY = CurY - 1DrawBlockEnd IfElseIf Shift = 1 ThenIf CurZ < 5 ThenEraseBlockCurZ = CurZ + 1DrawBlockEnd IfEnd IfEnd SelectEnd SubPrivate Sub Form_Load()Move 0, 0, Screen.Width, Screen.HeightShowLabel1.Move Picture1.ScaleWidth - Label2.Width, 0Label2.Move Picture1.ScaleWidth - Label2.Width, Label1.Height * 4Picture1.Move ScaleWidth - Picture1.Width, 0CenterX = ScaleWidth / 4CenterY = ScaleHeight / 1.5DrawBlockEnd SubPrivate Sub Timer1_Timer()Randomized = Int(Rnd * 11)If d > 5 And MoveTo < 4 Then MoveTo = RandomMoveEraseBlockSelect Case MoveToCase MOVE_DOWNIf CurY > 0 Then CurY = CurY - 1 Else: MoveTo = RandomMoveCase MOVE_UPIf CurY < 5 Then CurY = CurY + 1 Else: MoveTo = RandomMoveCase MOVE_RIGHTIf CurX < 5 Then CurX = CurX + 1 Else: MoveTo = RandomMoveCase MOVE_LEFTIf CurX > 0 Then CurX = CurX - 1 Else: MoveTo = RandomMoveCase MOVE_BACKWARDIf CurZ > 0 Then CurZ = CurZ - 1 Else MoveTo = RandomMoveCase MOVE_FORWARDIf CurZ < 5 Then CurZ = CurZ + 1 Else: MoveTo = RandomMoveEnd SelectDrawBlockEnd SubPrivate Function RandomMove() As IntegerRandomizeDim d As Integerd = Int(Rnd * 6)RandomMove = dEnd Function'参考一下. txt文件数据读取 菜鸟提问,使用VB直接插入排序法将数组A中的10个整数进行排序 无法生成EXE文件,郁闷! 用ADO连接能修改ACCESS2000的数据库密码吗? 注册表问题? 如何使CommonDialog.ShowSave中的"文件名"设定为指定的名称!? vb中使用c代码的问题? 转换数据库的问题! 如何判断EXCEL中单元格中输入的是公式呀? 如何为计算一个时间段内星期3的日期 timer事件的累加 菜鸟提问 关于VB+SQL查询语句返回结果问题
Private CenterY As Integer
Private Const Size = 40
Private CurX As Integer
Private CurY As Integer
Private CurZ As Integer
Private MoveTo As Integer
Private Const MOVE_LEFT = 0
Private Const MOVE_RIGHT = 1
Private Const MOVE_UP = 2
Private Const MOVE_DOWN = 3
Private Const MOVE_FORWARD = 4
Private Const MOVE_BACKWARD = 5
Public Sub EraseBlock()
X = CurX: y = CurY: Z = CurZ
xs = (CenterX + X * Size) - Z * (Size / 2)
Ys = (CenterY - y * Size) + Z * (Size / 2)
Line (xs, Ys)-(xs + Size, Ys - Size), BackColor, BF
Line (xs - Size / 2, Ys + Size / 2)-(xs + Size / 2, Ys - Size / 2), BackColor, BF
For i = 0 To Size / 2
Line (xs - i, Ys + i)-(xs - i, Ys + i - Size - 1), BackColor
Line (xs - i + Size, Ys + i)-(xs - i + Size, Ys + i - Size), BackColor
Next
End Sub
Public Sub DrawBlock()
Line (CenterX, CenterY)-(CenterX + Size * 6, CenterY - Size * 6), vbBlue, B
Line (CenterX, CenterY)-(CenterX - Size * 6 / 2, CenterY + Size * 6 / 2), vbBlue
Line (CenterX, CenterY - Size * 6)-(CenterX - Size * 6 / 2, CenterY + Size * 6 / 2 - Size * 6), vbBlue
Line (CenterX + 1, CenterY - 1)-(CenterX + Size * 6 - 1, CenterY - Size * 6 + 1), RGB(0, 60, 0), BF
For i = 1 To Size * 6 / 2 - 1
Line (CenterX - i + 1, CenterY + i)-(CenterX - i + Size * 6, CenterY + i), RGB(0, 60 + i * 2, 0)
NextFor i = 0 To Size * 6 / 2 - 1
Line (CenterX - i - 1, CenterY + i)-(CenterX - i - 1, CenterY + i - Size * 6 + 1), RGB(0, 60 + i * 2, 0)
Next
Label1.Caption = "X : " & CurX & vbCrLf & "Y : " & CurY & vbCrLf & "Z : " & CurZ & vbCrLf
X = CurX: y = CurY: Z = CurZ
col = 10 + Z * 20
xs = (CenterX + X * Size) - Z * (Size / 2)
Ys = CenterY + Z * (Size / 2)
For i = 0 To Size / 2
Line (xs - i, Ys + i)-(xs - i + Size, Ys + i), vbBlack
Next
Ys = (CenterY - y * Size) + Z * (Size / 2)
Line (xs - Size / 2 + 1, Ys + Size / 2 - 1)-(xs + Size / 2 - 1, Ys - Size / 2 + 1), RGB(col + 120, 0, 0), BF
Line (xs + 1, Ys - 1)-(xs + Size - 1, Ys - Size + 1), RGB(col, 0, 0), BF
For i = 0 To Size / 2
Line (xs - i, Ys + i)-(xs - i + Size, Ys + i), RGB(col + i * 8, 0, 0)
Line (xs - i, Ys + i)-(xs - i, Ys + i - Size), RGB(col + i * 8, 0, 0)
Line (xs - i + Size, Ys + i)-(xs - i + Size, Ys + i - Size), RGB(col + i * 8, 0, 0)
Next
Line (CenterX - Size * 6 / 2, CenterY + Size * 6 / 2)-(CenterX + Size * 6 / 2, CenterY - Size * 6 / 2), vbBlue, B
Line (CenterX + Size * 6, CenterY)-(CenterX + Size * 6 - Size * 6 / 2, CenterY + Size * 6 / 2), vbBlue
Line (CenterX + Size * 6, CenterY - Size * 6)-(CenterX + Size * 6 - Size * 6 / 2, CenterY + Size * 6 / 2 - Size * 6), vbBlue
End Sub
Private Sub cmdDemo_Click()
Select Case cmdDemo.Caption
Case "DEMO ON"
Timer1.Enabled = True
cmdDemo.Caption = "DEMO OFF"
Case Else
Timer1.Enabled = False
cmdDemo.Caption = "DEMO ON"
End Select
End SubPrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft
If CurX > 0 Then
EraseBlock
CurX = CurX - 1
DrawBlock
End If
Case vbKeyRight
If CurX < 5 Then
EraseBlock
CurX = CurX + 1
DrawBlock
End If
Case vbKeyUp
If Shift = 0 Then
If CurY < 5 Then
EraseBlock
CurY = CurY + 1
DrawBlock
End If
ElseIf Shift = 1 Then
If CurZ > 0 Then
EraseBlock
CurZ = CurZ - 1
DrawBlock
End If
End If
Case vbKeyDown
If Shift = 0 Then
If CurY > 0 Then
EraseBlock
CurY = CurY - 1
DrawBlock
End If
ElseIf Shift = 1 Then
If CurZ < 5 Then
EraseBlock
CurZ = CurZ + 1
DrawBlock
End If
End If
End Select
End Sub
Private Sub Form_Load()
Move 0, 0, Screen.Width, Screen.Height
Show
Label1.Move Picture1.ScaleWidth - Label2.Width, 0
Label2.Move Picture1.ScaleWidth - Label2.Width, Label1.Height * 4
Picture1.Move ScaleWidth - Picture1.Width, 0
CenterX = ScaleWidth / 4
CenterY = ScaleHeight / 1.5
DrawBlock
End Sub
Private Sub Timer1_Timer()
Randomize
d = Int(Rnd * 11)
If d > 5 And MoveTo < 4 Then MoveTo = RandomMove
EraseBlock
Select Case MoveTo
Case MOVE_DOWN
If CurY > 0 Then CurY = CurY - 1 Else: MoveTo = RandomMove
Case MOVE_UP
If CurY < 5 Then CurY = CurY + 1 Else: MoveTo = RandomMove
Case MOVE_RIGHT
If CurX < 5 Then CurX = CurX + 1 Else: MoveTo = RandomMove
Case MOVE_LEFT
If CurX > 0 Then CurX = CurX - 1 Else: MoveTo = RandomMove
Case MOVE_BACKWARD
If CurZ > 0 Then CurZ = CurZ - 1 Else MoveTo = RandomMove
Case MOVE_FORWARD
If CurZ < 5 Then CurZ = CurZ + 1 Else: MoveTo = RandomMove
End Select
DrawBlock
End Sub
Private Function RandomMove() As Integer
Randomize
Dim d As Integer
d = Int(Rnd * 6)
RandomMove = d
End Function
'参考一下.