add OpenTK3 to keep OpenTK.Input alive & change checking for pressed keys back
This commit is contained in:
@@ -94,4 +94,9 @@
|
||||
<ItemGroup>
|
||||
<Compile Remove="ModelPreview.Designer.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="OpenTK3">
|
||||
<HintPath>..\Shared Libs\OpenTK3.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -10,6 +10,7 @@ Imports Color = System.Drawing.Color
|
||||
Imports System.Windows.Forms.Integration
|
||||
Imports OpenTK.Mathematics
|
||||
Imports System.Windows.Input
|
||||
Imports Key = OpenTK3.Input.Key
|
||||
|
||||
Namespace PreviewN
|
||||
|
||||
@@ -31,6 +32,12 @@ Namespace PreviewN
|
||||
Public Property Scaling As Single = 500.0F
|
||||
Public Property ClearColor As Color = Color.CornflowerBlue
|
||||
|
||||
Public ReadOnly Property Keyboard As OpenTK3.Input.KeyboardState
|
||||
Get
|
||||
Return OpenTK3.Input.Keyboard.GetState
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Property EnableCameraControlling As Boolean
|
||||
Get
|
||||
Return _EnableCameraControlling
|
||||
@@ -82,13 +89,15 @@ Namespace PreviewN
|
||||
|
||||
Private ReadOnly Property IsStrgPressed As Boolean
|
||||
Get
|
||||
Return Keyboard.IsKeyDown(Key.LeftCtrl) OrElse Keyboard.IsKeyDown(Key.RightCtrl)
|
||||
Dim state = Keyboard
|
||||
Return state.IsKeyDown(Key.ControlLeft) OrElse state.IsKeyDown(Key.ControlRight)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private ReadOnly Property IsShiftPressed As Boolean
|
||||
Get
|
||||
Return Keyboard.IsKeyDown(Key.LeftShift) OrElse Keyboard.IsKeyDown(Key.RightShift)
|
||||
Dim state = Keyboard
|
||||
Return state.IsKeyDown(Key.ShiftLeft) OrElse state.IsKeyDown(Key.ShiftRight)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
@@ -284,31 +293,32 @@ Namespace PreviewN
|
||||
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)
|
||||
Dim state = Keyboard
|
||||
|
||||
If allowCamMove Then
|
||||
If Keyboard.IsKeyDown(Key.W) Then
|
||||
If state.IsKeyDown(Key.W) Then
|
||||
'camera.Move(moveSpeed, moveSpeed, camMtx)
|
||||
MyCamera.UpdateCameraMatrixWithScrollWheel(moveSpeed, camMtx)
|
||||
savedCamPos = MyCamera.Position
|
||||
End If
|
||||
If Keyboard.IsKeyDown(Key.S) Then
|
||||
If state.IsKeyDown(Key.S) Then
|
||||
'camera.Move(-moveSpeed, -moveSpeed, camMtx)
|
||||
MyCamera.UpdateCameraMatrixWithScrollWheel(-moveSpeed, camMtx)
|
||||
savedCamPos = MyCamera.Position
|
||||
End If
|
||||
If Keyboard.IsKeyDown(Key.A) Then
|
||||
If state.IsKeyDown(Key.A) Then
|
||||
'camera.Move(-moveSpeed, 0, camMtx)
|
||||
MyCamera.UpdateCameraOffsetDirectly(-moveSpeed, 0, camMtx)
|
||||
End If
|
||||
If Keyboard.IsKeyDown(Key.D) Then
|
||||
If state.IsKeyDown(Key.D) Then
|
||||
'camera.Move(moveSpeed, 0, camMtx)
|
||||
MyCamera.UpdateCameraOffsetDirectly(moveSpeed, 0, camMtx)
|
||||
End If
|
||||
If Keyboard.IsKeyDown(Key.E) Then
|
||||
If state.IsKeyDown(Key.E) Then
|
||||
'camera.Move(0, -moveSpeed, camMtx)
|
||||
MyCamera.UpdateCameraOffsetDirectly(0, -moveSpeed, camMtx)
|
||||
End If
|
||||
If Keyboard.IsKeyDown(Key.Q) Then
|
||||
If state.IsKeyDown(Key.Q) Then
|
||||
'camera.Move(0, moveSpeed, camMtx)
|
||||
MyCamera.UpdateCameraOffsetDirectly(0, moveSpeed, camMtx)
|
||||
End If
|
||||
|
||||
BIN
Shared Libs/OpenTK3.dll
Normal file
BIN
Shared Libs/OpenTK3.dll
Normal file
Binary file not shown.
Reference in New Issue
Block a user