190930
This commit is contained in:
@@ -23,7 +23,6 @@ Namespace PreviewN
|
||||
Private camMtx As Matrix4 = Matrix4.Identity
|
||||
Private savedCamPos As New Vector3
|
||||
Private _isMouseDown As Boolean = False
|
||||
'Private myPressedKeys As New List(Of Keys)
|
||||
Private isDeactivated As Boolean = False
|
||||
Private ReadOnly myModels As New Dictionary(Of Object3D, Renderer)
|
||||
|
||||
@@ -32,12 +31,6 @@ Namespace PreviewN
|
||||
Public Property Scaling As Single = 500.0F
|
||||
Public Property ClearColor As Color = Color.CornflowerBlue
|
||||
|
||||
'Public ReadOnly Property PressedKeys As IReadOnlyList(Of Keys)
|
||||
' Get
|
||||
' Return myPressedKeys
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
Public ReadOnly Property Camera As Camera
|
||||
Get
|
||||
Return MyCamera
|
||||
@@ -56,9 +49,14 @@ Namespace PreviewN
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property GLControl As Control
|
||||
Get
|
||||
Return glControl1
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private ReadOnly Property IsStrgPressed As Boolean
|
||||
Get
|
||||
'Return myPressedKeys.Contains(Keys.ControlKey)
|
||||
Dim state As KeyboardState = Keyboard.GetState()
|
||||
Return state(Key.ControlLeft) OrElse state(Key.ControlRight)
|
||||
End Get
|
||||
@@ -66,7 +64,6 @@ Namespace PreviewN
|
||||
|
||||
Private ReadOnly Property IsShiftPressed As Boolean
|
||||
Get
|
||||
'Return myPressedKeys.Contains(Keys.ShiftKey)
|
||||
Dim state As KeyboardState = Keyboard.GetState()
|
||||
Return state(Key.ShiftLeft) OrElse state(Key.ShiftRight)
|
||||
End Get
|
||||
@@ -142,7 +139,6 @@ Namespace PreviewN
|
||||
|
||||
Public Sub UpdateView()
|
||||
glControl1.Invalidate()
|
||||
'glControl1.Update()
|
||||
End Sub
|
||||
|
||||
Public Function AddModel(obj As Object3D) As Renderer
|
||||
@@ -226,38 +222,8 @@ Namespace PreviewN
|
||||
Next
|
||||
|
||||
glControl1.SwapBuffers()
|
||||
|
||||
'If Not IsMouseDown AndAlso obj3d IsNot Nothing Then
|
||||
' e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
|
||||
' e.Graphics.DrawString(GetModelInfoAsString, New Font(FontFamily.GenericSerif, 10), New SolidBrush(Panel1.ForeColor), New Drawing.Point(10, 10))
|
||||
'End If
|
||||
End Sub
|
||||
|
||||
Private Function GetModelInfoAsString() As String
|
||||
Dim matsCount As Long = 0
|
||||
Dim facesCount As Long = 0
|
||||
Dim vertsCount As Long = 0
|
||||
Dim vcCount As Long = 0
|
||||
Dim uvCount As Long = 0
|
||||
|
||||
For Each obj3d As Object3D In myModels.Keys
|
||||
matsCount += obj3d.Materials.Count
|
||||
For Each m As Mesh In obj3d.Meshes
|
||||
vertsCount += m.Vertices.Count
|
||||
facesCount += m.Faces.Count
|
||||
vcCount += m.VertexColors.Count
|
||||
uvCount += m.UVs.Count
|
||||
Next
|
||||
Next
|
||||
|
||||
Return String.Format("Materials:{0}{1}
|
||||
Faces:{0}{0}{2}
|
||||
Vertices:{0}{3}
|
||||
Vertex Colors{0}{4}
|
||||
UVs:{0}{0}{5}",
|
||||
vbTab, matsCount, facesCount, vertsCount, vcCount, uvCount)
|
||||
End Function
|
||||
|
||||
Private Sub glControl1_Resize(sender As Object, e As EventArgs) Handles glControl1.Resize
|
||||
glControl1.Context.Update(glControl1.WindowInfo)
|
||||
GL.Viewport(0, 0, glControl1.Width, glControl1.Height)
|
||||
@@ -293,44 +259,10 @@ UVs:{0}{0}{5}",
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Public Sub HandlesOnKeyDown(sender As Object, e As KeyEventArgs) Handles glControl1.KeyDown
|
||||
' If Not myPressedKeys.Contains(e.KeyCode) Then myPressedKeys.Add(e.KeyCode)
|
||||
'End Sub
|
||||
|
||||
'Public Sub HandlesOnKeyUp(sender As Object, e As KeyEventArgs) Handles MyBase.KeyUp
|
||||
' If myPressedKeys.Contains(e.KeyCode) Then myPressedKeys.Remove(e.KeyCode)
|
||||
'End Sub
|
||||
|
||||
Public Sub MoveCameraViaWASDQE()
|
||||
Dim moveSpeed As Integer = Convert.ToInt32(Math.Round((If(IsShiftPressed, 60, 30)) * (MyCamera.CamSpeedMultiplier), 0))
|
||||
Dim allowCamMove As Boolean = Not (IsMouseDown AndAlso IsShiftPressed)
|
||||
|
||||
'For Each k As Keys In myPressedKeys
|
||||
' If allowCamMove Then
|
||||
' Select Case k
|
||||
' Case Keys.W
|
||||
' 'camera.Move(moveSpeed, moveSpeed, camMtx)
|
||||
' MyCamera.UpdateCameraMatrixWithScrollWheel(moveSpeed, camMtx)
|
||||
' savedCamPos = MyCamera.Position
|
||||
' Case Keys.S
|
||||
' 'camera.Move(-moveSpeed, -moveSpeed, camMtx)
|
||||
' MyCamera.UpdateCameraMatrixWithScrollWheel(-moveSpeed, camMtx)
|
||||
' savedCamPos = MyCamera.Position
|
||||
' Case Keys.A
|
||||
' 'camera.Move(-moveSpeed, 0, camMtx)
|
||||
' MyCamera.UpdateCameraOffsetDirectly(-moveSpeed, 0, camMtx)
|
||||
' Case Keys.D
|
||||
' 'camera.Move(moveSpeed, 0, camMtx)
|
||||
' MyCamera.UpdateCameraOffsetDirectly(moveSpeed, 0, camMtx)
|
||||
' Case Keys.E
|
||||
' 'camera.Move(0, -moveSpeed, camMtx)
|
||||
' MyCamera.UpdateCameraOffsetDirectly(0, -moveSpeed, camMtx)
|
||||
' Case Keys.Q
|
||||
' 'camera.Move(0, moveSpeed, camMtx)
|
||||
' MyCamera.UpdateCameraOffsetDirectly(0, moveSpeed, camMtx)
|
||||
' End Select
|
||||
' End If
|
||||
'Next
|
||||
If allowCamMove Then
|
||||
Dim state As KeyboardState = Keyboard.GetState
|
||||
|
||||
|
||||
Reference in New Issue
Block a user