Лабораторная работа: Greating 3D-Graphics on visual basic

Polygon PicBox. hdc, tmp (0), shape. NumPoints + 1

'draw rest of objects transparently

PicBox. FillStyle = 1

End If

End Function

Private Function VisiblePlane (shape As Verticies, CameraX As Integer, CameraY As Integer, CameraZ As Integer)

'this function takes the normal of the plane and returns True if visible FALSE if

'not visible

'Camera is the spot the object is being viewed from

'Find the dot product

D = (shape. Normal. X * CameraX) + (shape. Normal. Y * CameraY) + (shape. Normal. Z * CameraZ)

'return true if object is visible

VisiblePlane = D >= 0

End Function

Private Function FindNormals ()

'This function finds the normal of each plane

For i = 0 To NumObjectSides

'Find the normal vector

With Sides (i)

' * * * * * * * *

Nx = (. Points (1). Y - Points (0). Y) * (. Points (. NumPoints). Z - Points (0). Z) - (. Points (1). Z - Points (0). Z) * (. Points (. NumPoints). Y - Points (0). Y)

Ny = (. Points (1). Z - Points (0). Z) * (. Points (. NumPoints). X - Points (0). X) - (. Points (1). X - Points (0). X) * (. Points (. NumPoints). Z - Points (0). Z)

Nz = (. Points (1). X - Points (0). X) * (. Points (. NumPoints). Y - Points (0). Y) - (. Points (1). Y - Points (0). Y) * (. Points (. NumPoints). X - Points (0). X)

'Normalize the normal vector (make length of 1)

Length = Sqr (Nx ^ 2 + Ny ^ 2 + Nz ^ 2)

. Normal. X = Nx / Length

. Normal. Y = Ny / Length

. Normal. Z = Nz / Length

End With

К-во Просмотров: 290
Бесплатно скачать Лабораторная работа: Greating 3D-Graphics on visual basic