more work on gtk & code cleanup
This commit is contained in:
@@ -120,7 +120,7 @@ Namespace CameraN
|
||||
|
||||
Private Sub OrientateCam(ang As Single, ang2 As Single)
|
||||
Dim CamLX As Single = CSng(Math.Sin(ang)) * CSng(Math.Sin(-ang2))
|
||||
Dim CamLY As Single = CSng(Math.Cos(ang2))
|
||||
Dim CamLY As Single = Math.Cos(ang2)
|
||||
Dim CamLZ As Single = CSng(-Math.Cos(ang)) * CSng(Math.Sin(-ang2))
|
||||
|
||||
myLookat.X = pos.X + (-CamLX) * 100.0F
|
||||
@@ -131,11 +131,11 @@ Namespace CameraN
|
||||
Private Sub OffsetCam(xAmt As Integer, yAmt As Integer, zAmt As Integer)
|
||||
Dim pitch_Renamed As Double = CamAngleY - (Math.PI / 2)
|
||||
Dim CamLX As Single = CSng(Math.Sin(CamAngleX)) * CSng(Math.Cos(-pitch_Renamed))
|
||||
Dim CamLY As Single = CSng(Math.Sin(pitch_Renamed))
|
||||
Dim CamLY As Single = Math.Sin(pitch_Renamed)
|
||||
Dim CamLZ As Single = CSng(-Math.Cos(CamAngleX)) * CSng(Math.Cos(-pitch_Renamed))
|
||||
pos.X = pos.X + xAmt * (CamLX) * CamSpeedMultiplier
|
||||
pos.Y = pos.Y + yAmt * (CamLY) * CamSpeedMultiplier
|
||||
pos.Z = pos.Z + zAmt * (CamLZ) * CamSpeedMultiplier
|
||||
pos.X += xAmt * (CamLX) * CamSpeedMultiplier
|
||||
pos.Y += yAmt * (CamLY) * CamSpeedMultiplier
|
||||
pos.Z += zAmt * (CamLZ) * CamSpeedMultiplier
|
||||
End Sub
|
||||
|
||||
Public Sub Move(y As Single, ByRef camMtx As Matrix4)
|
||||
@@ -154,7 +154,7 @@ Namespace CameraN
|
||||
Dim x_diff As Single = myLookat.X - pos.X
|
||||
Dim y_diff As Single = myLookat.Y - pos.Y
|
||||
Dim z_diff As Single = myLookat.Z - pos.Z
|
||||
Dim dist As Single = CSng(Math.Sqrt(x_diff * x_diff + y_diff * y_diff + z_diff * z_diff))
|
||||
Dim dist As Single = Math.Sqrt(x_diff * x_diff + y_diff * y_diff + z_diff * z_diff)
|
||||
If z_diff = 0 Then
|
||||
z_diff = 0.001F
|
||||
End If
|
||||
@@ -210,32 +210,32 @@ Namespace CameraN
|
||||
currentLookDirection = dir
|
||||
Select Case currentLookDirection
|
||||
Case LookDirection.Top
|
||||
pos = lookPositions(CInt(LookDirection.Top))
|
||||
pos = lookPositions(LookDirection.Top)
|
||||
myLookat = New Vector3(pos.X, -25000, pos.Z - 1)
|
||||
UpdateMatrix(cameraMatrix)
|
||||
SetRotationFromLookAt()
|
||||
Case LookDirection.Bottom
|
||||
pos = lookPositions(CInt(LookDirection.Bottom))
|
||||
pos = lookPositions(LookDirection.Bottom)
|
||||
myLookat = New Vector3(pos.X, 25000, pos.Z + 1)
|
||||
UpdateMatrix(cameraMatrix)
|
||||
SetRotationFromLookAt()
|
||||
Case LookDirection.Left
|
||||
pos = lookPositions(CInt(LookDirection.Left))
|
||||
pos = lookPositions(LookDirection.Left)
|
||||
myLookat = New Vector3(25000, pos.Y, pos.Z)
|
||||
UpdateMatrix(cameraMatrix)
|
||||
SetRotationFromLookAt()
|
||||
Case LookDirection.Right
|
||||
pos = lookPositions(CInt(LookDirection.Right))
|
||||
pos = lookPositions(LookDirection.Right)
|
||||
myLookat = New Vector3(-25000, pos.Y, pos.Z)
|
||||
UpdateMatrix(cameraMatrix)
|
||||
SetRotationFromLookAt()
|
||||
Case LookDirection.Front
|
||||
pos = lookPositions(CInt(LookDirection.Front))
|
||||
pos = lookPositions(LookDirection.Front)
|
||||
myLookat = New Vector3(pos.X, pos.Y, -25000)
|
||||
UpdateMatrix(cameraMatrix)
|
||||
SetRotationFromLookAt()
|
||||
Case LookDirection.Back
|
||||
pos = lookPositions(CInt(LookDirection.Back))
|
||||
pos = lookPositions(LookDirection.Back)
|
||||
myLookat = New Vector3(pos.X, pos.Y, 25000)
|
||||
UpdateMatrix(cameraMatrix)
|
||||
SetRotationFromLookAt()
|
||||
@@ -313,9 +313,9 @@ Namespace CameraN
|
||||
|
||||
Dim pitch_Renamed As Double = CamAngleY - (Math.PI / 2)
|
||||
Dim yaw_Renamed As Double = CamAngleX - (Math.PI / 2)
|
||||
Dim CamLX As Single = CSng(Math.Sin(yaw_Renamed))
|
||||
Dim CamLY As Single = CSng(Math.Cos(pitch_Renamed))
|
||||
Dim CamLZ As Single = CSng(-Math.Cos(yaw_Renamed))
|
||||
Dim CamLX As Single = Math.Sin(yaw_Renamed)
|
||||
Dim CamLY As Single = Math.Cos(pitch_Renamed)
|
||||
Dim CamLZ As Single = -Math.Cos(yaw_Renamed)
|
||||
|
||||
Dim m As Single = 8.0F
|
||||
|
||||
@@ -324,36 +324,36 @@ Namespace CameraN
|
||||
pos.X = orgPos.X - ((MousePosX * CamSpeedMultiplier) * (CamLX) * m) - ((MousePosY * CamSpeedMultiplier) * (CamLZ) * m)
|
||||
pos.Z = orgPos.Z - ((MousePosX * CamSpeedMultiplier) * (CamLZ) * m) - ((MousePosY * CamSpeedMultiplier) * (CamLX) * m)
|
||||
cameraMatrix = Matrix4.LookAt(pos.X, pos.Y, pos.Z, pos.X, pos.Y - 1000, pos.Z - 1, 0, 1, 0)
|
||||
lookPositions(CInt(currentLookDirection)) = pos
|
||||
lookPositions(currentLookDirection) = pos
|
||||
Case LookDirection.Bottom
|
||||
pos.X = orgPos.X - ((MousePosX * CamSpeedMultiplier) * (CamLX) * m) + ((MousePosY * CamSpeedMultiplier) * (CamLZ) * m)
|
||||
pos.Z = orgPos.Z - ((MousePosX * CamSpeedMultiplier) * (CamLZ) * m) + ((MousePosY * CamSpeedMultiplier) * (CamLX) * m)
|
||||
cameraMatrix = Matrix4.LookAt(pos.X, pos.Y, pos.Z, pos.X, pos.Y + 1000, pos.Z + 1, 0, 1, 0)
|
||||
lookPositions(CInt(currentLookDirection)) = pos
|
||||
lookPositions(currentLookDirection) = pos
|
||||
Case LookDirection.Left
|
||||
pos.X = orgPos.X - ((MousePosX * CamSpeedMultiplier) * (CamLX) * m)
|
||||
pos.Y = orgPos.Y - ((MousePosY * CamSpeedMultiplier) * (-1.0F) * m)
|
||||
pos.Z = orgPos.Z - ((MousePosX * CamSpeedMultiplier) * (CamLZ) * m)
|
||||
cameraMatrix = Matrix4.LookAt(pos.X, pos.Y, pos.Z, pos.X + 12500, pos.Y, pos.Z, 0, 1, 0)
|
||||
lookPositions(CInt(currentLookDirection)) = pos
|
||||
lookPositions(currentLookDirection) = pos
|
||||
Case LookDirection.Right
|
||||
pos.X = orgPos.X - ((MousePosX * CamSpeedMultiplier) * (CamLX) * m)
|
||||
pos.Y = orgPos.Y - ((MousePosY * CamSpeedMultiplier) * (-1.0F) * m)
|
||||
pos.Z = orgPos.Z - ((MousePosX * CamSpeedMultiplier) * (CamLZ) * m)
|
||||
cameraMatrix = Matrix4.LookAt(pos.X, pos.Y, pos.Z, pos.X - 12500, pos.Y, pos.Z, 0, 1, 0)
|
||||
lookPositions(CInt(currentLookDirection)) = pos
|
||||
lookPositions(currentLookDirection) = pos
|
||||
Case LookDirection.Front
|
||||
pos.X = orgPos.X - ((MousePosX * CamSpeedMultiplier) * (CamLX) * m)
|
||||
pos.Y = orgPos.Y - ((MousePosY * CamSpeedMultiplier) * (-1.0F) * m)
|
||||
pos.Z = orgPos.Z - ((MousePosX * CamSpeedMultiplier) * (CamLZ) * m)
|
||||
cameraMatrix = Matrix4.LookAt(pos.X, pos.Y, pos.Z, pos.X, pos.Y, pos.Z - 12500, 0, 1, 0)
|
||||
lookPositions(CInt(currentLookDirection)) = pos
|
||||
lookPositions(currentLookDirection) = pos
|
||||
Case LookDirection.Back
|
||||
pos.X = orgPos.X - ((MousePosX * CamSpeedMultiplier) * (CamLX) * m)
|
||||
pos.Y = orgPos.Y - ((MousePosY * CamSpeedMultiplier) * (-1.0F) * m)
|
||||
pos.Z = orgPos.Z - ((MousePosX * CamSpeedMultiplier) * (CamLZ) * m)
|
||||
cameraMatrix = Matrix4.LookAt(pos.X, pos.Y, pos.Z, pos.X, pos.Y, pos.Z + 12500, 0, 1, 0)
|
||||
lookPositions(CInt(currentLookDirection)) = pos
|
||||
lookPositions(currentLookDirection) = pos
|
||||
End Select
|
||||
|
||||
RaisePerspectiveChanged()
|
||||
@@ -372,7 +372,7 @@ Namespace CameraN
|
||||
End If
|
||||
Dim MousePosX As Integer = mouseX - lastMouseX
|
||||
Dim MousePosY As Integer = mouseY - lastMouseY
|
||||
CamAngleX = CamAngleX + (0.01F * MousePosX)
|
||||
CamAngleX += (0.01F * MousePosX)
|
||||
' This next part isn't neccessary, but it keeps the Yaw rotation value within [0, 2*pi] which makes debugging simpler.
|
||||
If CamAngleX > TAU Then
|
||||
CamAngleX -= TAU
|
||||
@@ -419,9 +419,9 @@ Namespace CameraN
|
||||
'Console.WriteLine(MousePosX+","+ MousePosY);
|
||||
Dim pitch_Renamed As Double = CamAngleY - (Math.PI / 2)
|
||||
Dim yaw_Renamed As Double = CamAngleX - (Math.PI / 2)
|
||||
Dim CamLX As Single = CSng(Math.Sin(yaw_Renamed))
|
||||
Dim CamLX As Single = Math.Sin(yaw_Renamed)
|
||||
' float CamLY = (float)Math.Cos(pitch);
|
||||
Dim CamLZ As Single = CSng(-Math.Cos(yaw_Renamed))
|
||||
Dim CamLZ As Single = -Math.Cos(yaw_Renamed)
|
||||
pos.X += ((horz_amount * CamSpeedMultiplier) * (CamLX))
|
||||
pos.Y += ((vert_amount * CamSpeedMultiplier) * (-1.0F))
|
||||
pos.Z += ((horz_amount * CamSpeedMultiplier) * (CamLZ))
|
||||
|
||||
@@ -136,12 +136,13 @@ Namespace PreviewN
|
||||
DoubleBuffered = True
|
||||
|
||||
'glControl1
|
||||
Me.glControl1 = New GLControl
|
||||
Me.glControl1.BackColor = Color.Black
|
||||
Me.glControl1.Location = New Point(0, 0)
|
||||
Me.glControl1.MinimumSize = New Size(600, 120)
|
||||
Me.glControl1.Name = "glControl1"
|
||||
Me.glControl1.Anchor = AnchorStyles.Left Or AnchorStyles.Top Or AnchorStyles.Right Or AnchorStyles.Bottom
|
||||
Me.glControl1 = New GLControl With {
|
||||
.BackColor = Color.Black,
|
||||
.Location = New Point(0, 0),
|
||||
.MinimumSize = New Size(600, 120),
|
||||
.Name = "glControl1",
|
||||
.Anchor = AnchorStyles.Left Or AnchorStyles.Top Or AnchorStyles.Right Or AnchorStyles.Bottom
|
||||
}
|
||||
Me.glControl1.Location = New Point(0, 0)
|
||||
Me.glControl1.Size = Me.ClientSize
|
||||
Me.glControl1.TabIndex = 0
|
||||
@@ -268,7 +269,7 @@ Namespace PreviewN
|
||||
|
||||
Private Sub glControl1_Wheel(sender As Object, e As MouseEventArgs)
|
||||
MyCamera.ResetMouseStuff()
|
||||
MyCamera.UpdateCameraMatrixWithScrollWheel(CInt(Math.Truncate(e.Delta * (If(IsShiftPressed, 3.5F, 1.5F)))), camMtx)
|
||||
MyCamera.UpdateCameraMatrixWithScrollWheel(Math.Truncate(e.Delta * (If(IsShiftPressed, 3.5F, 1.5F))), camMtx)
|
||||
savedCamPos = MyCamera.Position
|
||||
glControl1.Invalidate()
|
||||
End Sub
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
Imports System.Drawing.Imaging
|
||||
Imports System.Drawing
|
||||
Imports System.Drawing.Imaging
|
||||
|
||||
Imports OpenTK.Graphics.OpenGL
|
||||
|
||||
Imports Bitmap = System.Drawing.Bitmap
|
||||
Imports System.Drawing
|
||||
|
||||
Namespace RenderingN
|
||||
|
||||
|
||||
Reference in New Issue
Block a user