-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathForm1.frm
238 lines (188 loc) · 5.58 KB
/
Form1.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
VERSION 5.00
Begin VB.Form Form1
Caption = "3D Fishes by reexre (You can resize the Form)"
ClientHeight = 9225
ClientLeft = 120
ClientTop = 420
ClientWidth = 9645
BeginProperty Font
Name = "Tahoma"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 9225
ScaleWidth = 9645
StartUpPosition = 1 'CenterOwner
Begin VB.HScrollBar HScroll1
Height = 255
Left = 240
Max = 500
Min = 100
TabIndex = 4
Top = 3000
Value = 100
Visible = 0 'False
Width = 1815
End
Begin VB.CheckBox chkFollow
Caption = "Follow RND fish"
ForeColor = &H00000000&
Height = 375
Left = 240
TabIndex = 3
Top = 2040
Visible = 0 'False
Width = 1815
End
Begin VB.CommandButton Command1
Caption = "ResetCamera"
Height = 495
Left = 120
TabIndex = 2
Top = 1320
Width = 2055
End
Begin VB.CommandButton cmdR
Caption = "Re-Start"
Height = 495
Left = 120
TabIndex = 1
Top = 720
Width = 2055
End
Begin VB.CheckBox chk3D
Caption = "3D View"
ForeColor = &H00000000&
Height = 375
Left = 240
TabIndex = 0
Top = 240
Width = 1215
End
Begin VB.Label lZOOM
Caption = "ZOOM"
BeginProperty Font
Name = "Tahoma"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 5
Top = 2760
Visible = 0 'False
Width = 1815
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private WithEvents tmrClock As cTimer
Attribute tmrClock.VB_VarHelpID = -1
Private Pitch As Double
Private Yaw As Double
Private Const Deg2Rad As Double = 3.14159265358979 / 180#
Private Sub chk3D_Click()
Do3D = chk3D.Value = vbChecked
If Not (Do3D) Then Fish3Dto2D
chkFollow.Visible = Do3D
HScroll1.Visible = Do3D
lZOOM.Visible = Do3D
End Sub
Private Sub chkFollow_Click()
If chkFollow.Value = vbChecked Then
CamTarget = Int(Rnd * NF) + 1
Else
CamTarget = 0
Camera.cTo = Vec3(0, 0, 0)
UpdateCamera
End If
End Sub
Private Sub cmdR_Click()
InitFishes NF
End Sub
Private Sub Command1_Click()
InitCamera Vec3(0, 0, 1000), Vec3(0, 0, 0)
Pitch = 0
Yaw = 0 '90
HScroll1.Value = 100
End Sub
Private Sub Form_DblClick()
If Me.WindowState <> vbMaximized Then
Me.WindowState = vbMaximized
Else
Me.WindowState = vbNormal
End If
End Sub
Private Sub Form_Load()
Randomize Timer
InitFishes 250
Scree.Center = Vec3(0, 0, 0)
Scree.Size = Vec3(SideHalf, SideHalf, SideHalf)
InitCamera Vec3(0, 0, 1000), Vec3(0, 0, 0)
Command1_Click
Set tmrClock = New_c.Timer(40, True)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim D As Double
Dim A As Single
Static x0, y0, dx, dy: dx = X - x0: dy = Y - y0
Select Case Button
Case 0
x0 = X: y0 = Y
Case 1
If chk3D.Value Then 'don't modify pitch and yaw when we're not in 3D mode
Pitch = Pitch - 0.25 * dy
Yaw = (Yaw - 0.25 * dx) ' Mod 360
x0 = X: y0 = Y
If Pitch > 90 Then Pitch = 90
If Pitch < -90 Then Pitch = -90
CameraSetRotation Yaw, Pitch
End If
Case 2 'zoom
D = Sqr(vec3LEN2(vec3SUB(Camera.cFrom, Camera.cTo)))
D = D - dy * 0.25
If D < SideHalf * 1.7 Then D = SideHalf * 1.7
With Camera
.cFrom = vec3SUM(vec3MUL(Vec3Normalize(vec3SUB(.cFrom, .cTo)), D), .cTo)
End With
UpdateCamera
End Select
End Sub
Private Sub Form_Resize()
ScaleMode = vbPixels
Set BBuf = Cairo.CreateSurface(ScaleWidth, ScaleHeight)
' RedrawOn BBuf.CreateContext
' Set Picture = BBuf.Picture 'finally set the updated content of the BackBuf-Surface as the new Form-Picture
End Sub
Private Sub HScroll1_Change()
Camera.Zoom = HScroll1.Value * 0.01
UpdateCamera
lZOOM = "ZOOM: " & HScroll1.Value * 0.01
End Sub
Private Sub HScroll1_Scroll()
HScroll1_Change
End Sub
Private Sub tmrClock_Timer()
' If CamTarget Then
' Camera.cTo = GetFishPos(CamTarget)
' UpdateCamera
' End If
RedrawOn BBuf.CreateContext
Set Picture = BBuf.Picture 'finally set the updated content of the BackBuf-Surface as the new Form-Picture
End Sub
Private Sub Form_Terminate()
New_c.CleanupRichClientDll
End Sub