- Contents in this wiki are for entertainment purposes only
VB6 Dex3D.frm: Difference between revisions
Jump to navigation
Jump to search
XenoEngineer (talk | contribs) No edit summary |
XenoEngineer (talk | contribs) No edit summary |
||
| Line 3: | Line 3: | ||
'''After refactoring the code found below, the following code creates rather a function for direct-calling of scene-rendering, which is called from various points in the project code, where previously a flag was set to invoked a forever-loop (now replaced) to redraw the screen once while looping forever.''' This direct-call approach is now working by Windows events, like mouse-movements, to invoke a screen refresh. | '''After refactoring the code found below, the following code creates rather a function for direct-calling of scene-rendering, which is called from various points in the project code, where previously a flag was set to invoked a forever-loop (now replaced) to redraw the screen once while looping forever.''' This direct-call approach is now working by Windows events, like mouse-movements, to invoke a screen refresh. | ||
The new refactored method, RefreshScene(), is found in | The new refactored method, RefreshScene(), is found in original code as a Form_Activate() event, [[VB6_Dex3D.frm|Dex3D.frm]] now renamed to [[VB6_QuasiVisual3D.frm]]. | ||
===VB6 RefreshScene() method reworked from startup-form Dex3D.frm=== | ===VB6 RefreshScene() method reworked from startup-form Dex3D.frm=== | ||
Revision as of 14:15, 1 January 2024
After refactoring the code found below, the following code creates rather a function for direct-calling of scene-rendering, which is called from various points in the project code, where previously a flag was set to invoked a forever-loop (now replaced) to redraw the screen once while looping forever. This direct-call approach is now working by Windows events, like mouse-movements, to invoke a screen refresh.
The new refactored method, RefreshScene(), is found in original code as a Form_Activate() event, Dex3D.frm now renamed to VB6_QuasiVisual3D.frm.
VB6 RefreshScene() method reworked from startup-form Dex3D.frm
Private Sub RefreshScene()
If LockCamera = True Then
VLight(MyLight).Origin = _
VectorAdd( _
VectorNull, _
VectorScale( _
OrientationToVector(OrientationInput(0, OrbitLatitude, -OrbitLongitude)), _
-OrbitRadius _
) _
)
If CameraModel <> 0 Then
VMesh(CameraModel).Origin = VLight(MyLight).Origin
VMesh(CameraModel).Angles.Pitch = OrbitLatitude
VMesh(CameraModel).Angles.Yaw = -OrbitLongitude
VMesh(CameraModel).UpdateTransformation = True
End If
Else
Call OrbitCamera(MyCamera, VectorNull, OrbitRadius, OrbitLongitude, OrbitLatitude)
VLight(MyLight).Origin = VCamera(MyCamera).Origin
End If
'' Render the new bitmap
paintCanvas Picture1
End Sub
Sub paintCanvas(C As PictureBox)
C.Cls
RenderImage C, MyCamera
LastFaceOver = 0 '' The active mesh face(triangle) under the mouse pointer.
'' Print UI properties to the canvas ''
C.ForeColor = vbWhite
C.Print "Longitude: " & Int(RadianToDegree(OrbitLongitude))
C.Print "Latitude: " & Int(RadianToDegree(OrbitLatitude))
C.Print "Radius: " & Int(OrbitRadius)
C.Print
C.Print "Name: " & VMesh(MyMesh).Tag
C.Print "Vertices: " & VMesh(MyMesh).Vertices.Length
C.Print "Faces: " & VMesh(MyMesh).Faces.Length
End Sub
Following is a nearly original Dex3D method, which created a forever-loop for flagged-repaints in the VB6 Form_Activate() event.
Private Sub Form_Activate()
Debug.Print "Beginning Form_Activate()"
'Dim FrameRate As Single ''obsoleted by event-driven drawing
If BeginRenderLoop = True Then
'' Run render loop once ''
BeginRenderLoop = False
Do Until (RenderLoopCanceled) '' Added RenderLoopCanceled by XenoEngineer
If RefreshScene = True Then
RefreshScene = False
LastFaceOver = 0
If LockCamera = True Then
VLight(MyLight).Origin = _
VectorAdd( _
VectorNull, _
VectorScale( _
OrientationToVector(OrientationInput(0, OrbitLatitude, -OrbitLongitude)), _
-OrbitRadius _
) _
)
If CameraModel <> 0 Then
VMesh(CameraModel).Origin = VLight(MyLight).Origin
VMesh(CameraModel).Angles.Pitch = OrbitLatitude
VMesh(CameraModel).Angles.Yaw = -OrbitLongitude
VMesh(CameraModel).UpdateTransformation = True
End If
Else
Call OrbitCamera(MyCamera, VectorNull, OrbitRadius, OrbitLongitude, OrbitLatitude)
VLight(MyLight).Origin = VCamera(MyCamera).Origin
End If
Picture1.Cls
Call RenderImage(Picture1, MyCamera)
Picture1.ForeColor = vbWhite
Picture1.Print "Longitude: " & Int(RadianToDegree(OrbitLongitude))
Picture1.Print "Latitude: " & Int(RadianToDegree(OrbitLatitude))
Picture1.Print "Radius: " & Int(OrbitRadius)
Picture1.Print
Picture1.Print "Name: " & VMesh(MyMesh).Tag
Picture1.Print "Vertices: " & VMesh(MyMesh).Vertices.Length
Picture1.Print "Faces: " & VMesh(MyMesh).Faces.Length
End If
DoEvents
Loop
End If
Debug.Print "Ending Form_Activate()"
End Sub