Лабораторная работа: Создание 3D-графики средствами языка программирования Visual Basic
y0 = obj.vertex (obj.polygon(poly).v_pointer(0)).sy
x1 = obj.vertex (obj.polygon(poly).v_pointer(1)).sx
y1 = obj.vertex (obj.polygon(poly).v_pointer(1)).sy
x2 = obj.vertex (obj.polygon(poly).v_pointer(2)).sx
y2 = obj.vertex (obj.polygon(poly).v_pointer(2)).sy
frm. Line (x0, y0) – (x1, y1), obj.polygon(poly).colr
frm. Line – (x2, y2), obj.polygon(poly).colr
frm. Line – (x0, y0), obj.polygon(poly).colr
End Sub
Public Sub ProjectObject (obj As Object3D, frm As Object)
Dim pnt As Long, dz As Single
For pnt = 0 To UBound (obj.vertex())
dz = obj.vertex(pnt).z: If dz <= 0 Then dz = 0.001
obj.vertex(pnt).sx = (frm. ScaleWidth / 2) + ((obj.vertex(pnt).x * 300) / dz)
obj.vertex(pnt).sy = (frm. ScaleHeight / 2) + ((obj.vertex(pnt).y * 300) / dz)
Next
End Sub
Public Sub RotateObject (yaw As Single, pit As Single, rol As Single, obj As Object3D)
Dim pnt As Long
Dim x0 As Single, y0 As Single, z0 As Single
Dim x1 As Single, y1 As Single, z1 As Single
Dim x2 As Single, y2 As Single, z2 As Single
'
For pnt = 0 To UBound (obj.vertex())
x0 = Cos(yaw) * obj.vertex(pnt).x + Sin(yaw) * obj.vertex(pnt).z
y0 = obj.vertex(pnt).y
z0 = Sin(yaw) * obj.vertex(pnt).x – Cos(yaw) * obj.vertex(pnt).z
x1 = x0
y1 = Cos(pit) * y0 + Sin(pit) * z0