VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Environ"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Private m() As New Mass
Private Cnt As Long
Dim xo, yo, tt, ss, zm As Double
Public Sub SetVar(ByVal m1 As Long, ByVal Vr As Double)
    m(m1).Vr = Vr
End Sub
Public Function GetVar(ByVal m1 As Long)
    GetVar = m(m1).Vr
End Function
Public Function GetZoom() As Double
    GetZoom = zm
End Function
Public Sub SetOrigin(ByVal nxo As Double, ByVal nyo As Double)
    xo = nxo
    yo = nyo
End Sub
Public Sub SetRotation(ByVal ntt As Double, ByVal nss As Double)
    tt = ntt
    ss = nss
End Sub
Public Sub IncZoom(ByVal inn As Boolean)
    If inn Then
        If zm < 2 Then zm = zm + 0.25
    Else
        If zm > 0.25 Then zm = zm - 0.25
    End If
End Sub
Public Sub SetZoom(ByVal n As Double)
    zm = n
End Sub
Public Sub IncRotation(ByVal ntt As Double, ByVal nss As Double)
    tt = tt + ntt
    ss = ss + nss
    
    If tt > 360 Then
        tt = Abs(360 - tt)
    End If
    If ss > 360 Then
        ss = Abs(360 - ss)
    End If
    If tt < 0 Then
        tt = 360 - Abs(tt)
    End If
    If ss < 0 Then
        ss = 360 - Abs(ss)
    End If

End Sub
Public Sub GetRotation(ByRef ntt, ByRef nss)
    ntt = tt
    nss = ss
End Sub
Public Sub DimMass(ByVal n As Long)
    Cnt = n
    ReDim m(1 To Cnt)
End Sub
Public Function Count() As Long
    Count = Cnt
End Function
Public Sub Forces()
    For a = 1 To Cnt
        m(a).Forces
    Next a
End Sub
Public Sub Draw(ByRef pic As Object)
    n = 200
    n2 = n * 0.6
    pic.Cls
    pic.Circle (xo * zm, yo * zm), n2 * zm, vbWhite
    pic.Line ((xo - n) * zm, yo * zm)-((xo + n) * zm, yo * zm), vbWhite
    pic.Line (xo * zm, (yo - n) * zm)-(xo * zm, (yo + n) * zm), vbWhite
    For a = 1 To Cnt
        m(a).RenderDraw xo, yo, tt, ss
    Next a
    For a = 1 To Cnt
        m(a).Draw pic, zm
    Next a
    
    'print stats
    pic.ForeColor = vbWhite
    pic.PSet (1, 1), vbBlack
    pic.Print " NYIT Seminar Project - 3D Material Simulator"
    pic.Print " © 2006 Rostislav Persion"
    pic.Print " Nodes: " & Str(Int(Cnt))
    pic.Print " V-Rot: " & Str(Int(ss))
    pic.Print " H-Rot: " & Str(Int(tt))
    pic.Print " Zoom: " & Str(Int(zm * 100)) & "%"
End Sub
Public Sub SetCaption(ByVal m1 As Long, ByVal Cap As String)
    m(m1).Caption = Trim(Cap)
End Sub
Public Function GetCaption(ByVal m1 As Long) As String
    GetCaption = m(m1).Caption
End Function
Public Sub Move()
    For a = 1 To Cnt
        m(a).Move
    Next a
End Sub
Public Sub Connect(ByVal m1 As Long, ByVal m2 As Long, ByVal kk1 As Double, ByVal kk2 As Double, ByVal sf As Double, ByVal bf As Double)
    m(m1).ConnectTo m(m2), kk1, kk2, sf, bf
End Sub
Public Sub SetX(ByVal m1 As Long, ByVal XX As Double)
    m(m1).X = XX
End Sub
Public Sub SetY(ByVal m1 As Long, ByVal YY As Double)
    m(m1).Y = YY
End Sub
Public Sub SetZ(ByVal m1 As Long, ByVal zz As Double)
    m(m1).Z = zz
End Sub
Public Sub SetF(ByVal m1 As Long, ByVal v As Boolean)
    m(m1).Fixed = v
End Sub
Public Sub SetM(ByVal m1 As Long, ByVal MM As Double)
    m(m1).m = MM
End Sub
Public Sub SetGc(ByVal nn As Double)
    For a = 1 To Cnt
        m(a).Gc = nn
    Next a
End Sub
Public Sub SetFc(ByVal nn As Double)
    For a = 1 To Cnt
        m(a).Fc = nn
    Next a
End Sub
Public Sub SetDt(ByVal nn As Double)
    For a = 1 To Cnt
        m(a).dt = nn
    Next a
End Sub
Public Sub SetXYZ(ByVal m1 As Long, ByVal XX As Double, ByVal YY As Double, ByVal zz As Double)
    m(m1).X = XX
    m(m1).Y = YY
    m(m1).Z = zz
End Sub
Public Sub IncX(ByVal m1 As Long, ByVal nn As Double)
    m(m1).X = m(m1).X + nn
End Sub
Public Sub IncY(ByVal m1 As Long, ByVal nn As Double)
    m(m1).Y = m(m1).Y + nn
End Sub
Public Sub IncZ(ByVal m1 As Long, ByVal nn As Double)
    m(m1).Z = m(m1).Z + nn
End Sub
Public Function GetX(ByVal m1 As Long) As Double
    GetX = m(m1).X
End Function
Public Function GetY(ByVal m1 As Long) As Double
    GetY = m(m1).Y
End Function
Public Function GetZ(ByVal m1 As Long) As Double
    GetZ = m(m1).Z
End Function
Public Function GetAx(ByVal m1 As Long) As Double
    GetAx = m(m1).Ax
End Function
Public Function GetAy(ByVal m1 As Long) As Double
    GetAy = m(m1).Ay
End Function
Public Function GetAz(ByVal m1 As Long) As Double
    GetAz = m(m1).Az
End Function
Public Function GetVx(ByVal m1 As Long) As Double
    GetVx = m(m1).Vx
End Function
Public Function GetVy(ByVal m1 As Long) As Double
    GetVy = m(m1).Vy
End Function
Public Function GetVz(ByVal m1 As Long) As Double
    GetVz = m(m1).Vz
End Function
Public Function GetM(ByVal m1 As Long) As Double
    GetM = m(m1).m
End Function
Public Function GetCount() As Long
    GetCount = Cnt
End Function
Public Sub SetVX(ByVal m1 As Long, ByVal XX As Double)
    m(m1).Vx = XX
End Sub
Public Sub SetVY(ByVal m1 As Long, ByVal YY As Double)
    m(m1).Vy = YY
End Sub
Public Sub SetVZ(ByVal m1 As Long, ByVal zz As Double)
    m(m1).Vz = zz
End Sub
