ModelPreview: fix WASD (use Pilz.Win32.Keyboard)
This commit is contained in:
@@ -95,13 +95,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Pilz.Simple3DFileParser\Pilz.Simple3DFileParser.vbproj" />
|
<ProjectReference Include="..\Pilz.Simple3DFileParser\Pilz.Simple3DFileParser.vbproj" />
|
||||||
|
<ProjectReference Include="..\Pilz.Win32\Pilz.Win32.vbproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="ModelPreview.Designer.vb" />
|
<Compile Remove="ModelPreview.Designer.vb" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="OpenTK3">
|
|
||||||
<HintPath>..\Shared Libs\OpenTK3.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -9,9 +9,7 @@ Imports Point = System.Drawing.Point
|
|||||||
Imports Color = System.Drawing.Color
|
Imports Color = System.Drawing.Color
|
||||||
Imports OpenTK.Mathematics
|
Imports OpenTK.Mathematics
|
||||||
Imports OpenTK.WinForms
|
Imports OpenTK.WinForms
|
||||||
Imports OpenTK.Input
|
Imports Pilz.Win32.Mapped
|
||||||
Imports OpenTK.Windowing.GraphicsLibraryFramework
|
|
||||||
Imports Key = OpenTK3.Input.Key
|
|
||||||
|
|
||||||
Namespace PreviewN
|
Namespace PreviewN
|
||||||
|
|
||||||
@@ -32,12 +30,6 @@ Namespace PreviewN
|
|||||||
Public Property Scaling As Single = 500.0F
|
Public Property Scaling As Single = 500.0F
|
||||||
Public Property ClearColor As Color = Color.CornflowerBlue
|
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
|
Public Property EnableCameraControlling As Boolean
|
||||||
Get
|
Get
|
||||||
Return _EnableCameraControlling
|
Return _EnableCameraControlling
|
||||||
@@ -89,15 +81,13 @@ Namespace PreviewN
|
|||||||
|
|
||||||
Private ReadOnly Property IsStrgPressed As Boolean
|
Private ReadOnly Property IsStrgPressed As Boolean
|
||||||
Get
|
Get
|
||||||
Dim state = Keyboard
|
Return Keyboard.IsKeyDown(Keys.Control)
|
||||||
Return state(Key.ControlLeft) OrElse state(Key.ControlRight)
|
|
||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
Private ReadOnly Property IsShiftPressed As Boolean
|
Private ReadOnly Property IsShiftPressed As Boolean
|
||||||
Get
|
Get
|
||||||
Dim state = Keyboard
|
Return Keyboard.IsKeyDown(Keys.Shift)
|
||||||
Return state(Key.ShiftLeft) OrElse state(Key.ShiftRight)
|
|
||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
@@ -293,32 +283,24 @@ Namespace PreviewN
|
|||||||
Dim allowCamMove As Boolean = Not (IsMouseDown AndAlso IsShiftPressed)
|
Dim allowCamMove As Boolean = Not (IsMouseDown AndAlso IsShiftPressed)
|
||||||
|
|
||||||
If allowCamMove Then
|
If allowCamMove Then
|
||||||
Dim state = Keyboard
|
If Keyboard.IsKeyDown(Keys.W) Then
|
||||||
|
|
||||||
If state(Key.W) Then
|
|
||||||
'camera.Move(moveSpeed, moveSpeed, camMtx)
|
|
||||||
MyCamera.UpdateCameraMatrixWithScrollWheel(moveSpeed, camMtx)
|
MyCamera.UpdateCameraMatrixWithScrollWheel(moveSpeed, camMtx)
|
||||||
savedCamPos = MyCamera.Position
|
savedCamPos = MyCamera.Position
|
||||||
End If
|
End If
|
||||||
If state(Key.S) Then
|
If Keyboard.IsKeyDown(Keys.S) Then
|
||||||
'camera.Move(-moveSpeed, -moveSpeed, camMtx)
|
|
||||||
MyCamera.UpdateCameraMatrixWithScrollWheel(-moveSpeed, camMtx)
|
MyCamera.UpdateCameraMatrixWithScrollWheel(-moveSpeed, camMtx)
|
||||||
savedCamPos = MyCamera.Position
|
savedCamPos = MyCamera.Position
|
||||||
End If
|
End If
|
||||||
If state(Key.A) Then
|
If Keyboard.IsKeyDown(Keys.A) Then
|
||||||
'camera.Move(-moveSpeed, 0, camMtx)
|
|
||||||
MyCamera.UpdateCameraOffsetDirectly(-moveSpeed, 0, camMtx)
|
MyCamera.UpdateCameraOffsetDirectly(-moveSpeed, 0, camMtx)
|
||||||
End If
|
End If
|
||||||
If state(Key.D) Then
|
If Keyboard.IsKeyDown(Keys.D) Then
|
||||||
'camera.Move(moveSpeed, 0, camMtx)
|
|
||||||
MyCamera.UpdateCameraOffsetDirectly(moveSpeed, 0, camMtx)
|
MyCamera.UpdateCameraOffsetDirectly(moveSpeed, 0, camMtx)
|
||||||
End If
|
End If
|
||||||
If state(Key.E) Then
|
If Keyboard.IsKeyDown(Keys.E) Then
|
||||||
'camera.Move(0, -moveSpeed, camMtx)
|
|
||||||
MyCamera.UpdateCameraOffsetDirectly(0, -moveSpeed, camMtx)
|
MyCamera.UpdateCameraOffsetDirectly(0, -moveSpeed, camMtx)
|
||||||
End If
|
End If
|
||||||
If state(Key.Q) Then
|
If Keyboard.IsKeyDown(Keys.Q) Then
|
||||||
'camera.Move(0, moveSpeed, camMtx)
|
|
||||||
MyCamera.UpdateCameraOffsetDirectly(0, moveSpeed, camMtx)
|
MyCamera.UpdateCameraOffsetDirectly(0, moveSpeed, camMtx)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|||||||
Reference in New Issue
Block a user