Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Public Type m3Point
- x As Double
- y As Double
- Z As Double
- 'w = 1
- End Type
- Public Function m3PointInit(ByVal x As Double, ByVal y As Double, ByVal Z As Double) As m3Point
- Dim p As m3Point
- p.x = x
- p.y = y
- p.Z = Z
- m3PointInit = p
- End Function
- Public Sub m3PointApply(ByRef p As m3Point, ByRef m As m3Matrix)
- Dim x As Double
- Dim y As Double
- Dim Z As Double
- x = p.x
- y = p.y
- Z = p.Z
- p.x = x * m.m11 + y * m.m21 + Z * m.m31 + m.m41
- p.y = x * m.m12 + y * m.m22 + Z * m.m32 + m.m42
- p.Z = x * m.m13 + y * m.m23 + Z * m.m33 + m.m43
- End Sub
- Public Function m3PointToString(ByRef p As m3Point) As String
- m3PointToString = Format(p.x, "0.00") & vbTab & Format(p.y, "0.00") & vbTab & Format(p.Z, "0.00") & vbTab & "1"
- End Function
- Public Sub m3PointDraw(ByRef canvas As Object, ByRef p As m3Point)
- Dim d As Double
- Dim y As Double
- Dim x As Double
- Dim f As Double
- d = Camera3D.getDistance()
- f = d / (d - p.Z)
- x = p.x * f
- y = p.y * f
- canvas.Circle (x, y), 3
- End Sub
- Public Sub m3PointDrawLine(ByRef canvas As Object, ByRef p1 As m3Point, ByRef p2 As m3Point)
- Dim x1 As Double
- Dim y1 As Double
- Dim x2 As Double
- Dim y2 As Double
- Dim d As Double
- Dim f As Double
- d = Camera3D.getDistance
- f = d / (d - p1.Z)
- x1 = f * p1.x
- y1 = f * p1.y
- f = d / (d - p2.Z)
- x2 = f * p2.x
- y2 = f * p2.y
- canvas.Line (x1, y1)-(x2, y2)
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement