Older Version Newer Version

JanetTerra JanetTerra Jul 24, 2006


Source Code for LBWF10_template

Tom Nally - steelweaver52 steelweaver52





If you prefer, you may download the zipped file .

Return to the companion article for these functions, Chapter 5:Using Wire (Focusing on the FF.LBWF.RequestObjectNameFromXY$() Function).



Source Code for LBWF10_template

'** Created by Liberty BASIC Workshop - 7/22/2005 10:36:03 PM
'** Testing Object Selection

 
 
dim zoomlist$(20)
dim zoomlist(20)
 
for i = 1 to 20
    zoomlist(i)  = 0.5 + (i-1)*0.1
    zoomlist$(i) = using("#.#",zoomlist(i))
next i
 
zoomlistIndex = 8
 
CameraDistance = 360
 
Explain$ = "Click on any of the pyramids in order " + _
           "watch an object transformation.  Each pyramid " + _
           "produces a different transformation." + chr$(13) + chr$(13) + _
           "You must click within 3 pixels of an object's " + _
           "line in order to trigger the effect." + chr$(13) + chr$(13) + _
           "Click on the controls below to change the " + _
           "current view."
 
 
 
gosub [Initialize.Liberty.BASIC.WireFrame.Library]
 
[WindowSetup]
    NOMAINWIN
    WindowWidth = 780 : WindowHeight = 570
    UpperLeftX = INT((DisplayWidth-WindowWidth)/2)
    UpperLeftY = INT((DisplayHeight-WindowHeight)/2)
 
[ControlSetup]
'The graphicbox...
graphicbox  #main.wfscene, 255, 20, 500, 500
 
'The statictext explanation...
statictext  #main.statExpl, Explain$, 20, 20, 230, 180
 
'The random camera location button...
button      #main.btnRandCam, "Random Camera Location", [Select.Random.Camera.Location.And.Redraw], UL, 15, 220, 170, 30
 
'The zoom combo box control...
statictext  #main.stat04a, "Zoom : ", 20, 270, 50, 20
COMBOBOX    #main.cbozoom, zoomlist$(), [Read.Zoom.ComboBox.And.Redraw.Scene], 80, 265, 100, 180
 
'The redraw scene button...
button      #main.btnRedraw, "Redraw Scene", [btnRedraw.click], UL, 15, 305, 170, 30
 
'The selected object controls...
statictext  #main.stat07, "Object Selected : ", 15, 380, 105, 20
textbox     #main.txtObjSelected, 125, 375, 70, 25
 
'The quit button...
button      #main.btnQuit, "Quit", [Quit.click], UL, 15, 480, 170, 30
 
Open "Testing Object Selection" for Window as #main
    #main "trapclose [Quit.click]"
    #main.wfscene "down; fill White; flush"
    #main.wfscene "setfocus; when leftButtonUp [MouseLeftButtonUp]"
    #main "font arial 10"
 
    'Initialize the zoom combo box...
    print #main.cbozoom, "selectindex "; zoomlistIndex
 
 
 
 
    'Initialize a camera location...
    CamX = 250 : CamY = 200 : CamZ = 160
 
    AAA = FF.LBWF.CameraLocation(CamX, CamY, CamZ)
 
    'Initialize the zoom factor...
    ZoomFac = 1.2
 
    AAA = FF.LBWF.ZoomFactor(ZoomFac)
 
    'Initialize the Viewing Center...
    VCtrX = 0 : VCtrY = 0 : VCtrZ = 0
    AAA = FF.LBWF.ViewingCenter(VCtrX, VCtrY, VCtrZ)
 
    'Initialize the screen center...
    ScreenCenterX = 250 : ScreenCenterY = 250
    AAA = FF.LBWF.ScreenCenter(ScreenCenterX, ScreenCenterY)
 
    'Set the axes to "visible"...
    AAA = FF.LBWF.ShowAxes()
 
    'Create a grid object...
    GridName$ = "grid1"
    NumUnitsXdirection = 10
    NumUnitsZdirection = 10
    UnitSize = 30
    GridColor$ = "lightgray"
    AAA = FF.LBWF.CreateGridObject(GridName$, NumUnitsXdirection, NumUnitsZdirection, UnitSize, GridColor$)
 
    xdim = 35
    zdim = 35
    pyrheight = 40
    pyrColor$ = "black"
 
    'Create six pyramids...
    for i = 1 to 6
        pyrName$ = "pyr" + str$(i)
        AAA = FF.LBWF.CreatePyramid(pyrName$, xdim, zdim, pyrheight, pyrColor$)
        transX = 140 - (i-1)*55
        AAA = FF.LBWF.TranslateObject("pyr" + str$(i), transX, 0, 0)
    next i
 
    'Clear the screen and draw all objects...
    AAA = FF.LBWF.ClearGraphicScreen()
    AAA = FF.LBWF.DrawAllObjects()
 
 
 
 
 
[loop]
    Wait
 
[Read.Zoom.ComboBox.And.Redraw.Scene]
 
    print #main.cbozoom, "selectionindex? zoomlistIndex"
 
    ZoomFac = zoomlist(zoomlistIndex)
    AAA = FF.LBWF.ZoomFactor(ZoomFac)
 
    'Clear the screen and draw all objects...
    AAA = FF.LBWF.ClearGraphicScreen()
    AAA = FF.LBWF.DrawAllObjects()
 
 
    Wait
 
[Select.Random.Camera.Location.And.Redraw]
 
    CameraTiltAngleRads   = 0.1 + rnd(1)*1.3
                     CamY = CameraDistance * sin(CameraTiltAngleRads)
    HorizontalProjection  = CameraDistance * cos(CameraTiltAngleRads)
    CameraSwivelAngleRads = rnd(1)*(2*3.14159)
                     CamX = HorizontalProjection * cos(CameraSwivelAngleRads)
                     CamZ = HorizontalProjection * sin(CameraSwivelAngleRads)
 
    AAA = FF.LBWF.CameraLocation(CamX, CamY, CamZ)
 
    'Clear the screen and draw all objects...
    AAA = FF.LBWF.ClearGraphicScreen()
    AAA = FF.LBWF.DrawAllObjects()
 
    Wait
 
 
[Quit.click]
    close #main : END
    wait
 
[btnRedraw.click]
 
    'Clear the screen and draw all objects...
    AAA = FF.LBWF.ClearGraphicScreen()
    AAA = FF.LBWF.DrawAllObjects()
    wait
 
[MouseLeftButtonUp]
 
    ScreenX = MouseX
    ScreenY = MouseY
    pixelLimit = 3
    ObjectName$ = FF.LBWF.RequestObjectNameFromXY$(ScreenX, ScreenY, pixelLimit)
    print #main.txtObjSelected, ObjectName$
 
    if (ObjectName$ <> "null00") then
        gosub [Disable.Controls.During.Transformation]
 
        if (ObjectName$ = "pyr1") then
            gosub [Spin.Pyramid.1]
        end if
        if (ObjectName$ = "pyr2") then
            gosub [Translate.Pyramid.2]
        end if
        if (ObjectName$ = "pyr3") then
            gosub [Rotate.Pyramid.3]
        end if
        if (ObjectName$ = "pyr4") then
            gosub [Change.Line.Thickness.Of.Pyramid.4]
        end if
        if (ObjectName$ = "pyr5") then
            gosub [Cycle.Pyramid.5.Through.Several.Colors]
        end if
        if (ObjectName$ = "pyr6") then
            gosub [Rotate.And.Elevate.Pyramid.6]
        end if
 
        gosub [Enable.Controls.During.Transformation]
 
    end if
 
    Wait
 
''''''''''''''''''''''''''''''''''''''''''

 
 
 
 
''''''''''''''''''''''''''''''''''''''''''
[Spin.Pyramid.1]
    'Set the drawing rule to XOR...
    print #main.wfscene, "rule xor"
 
    AAA = FF.LBWF.DrawObject("pyr1") 'undraw the object
    
    for i = 1 to 36
        AAA = FF.LBWF.RotateObjectAboutY("pyr1", 5) 'rotate the object 5 degrees
        AAA = FF.LBWF.DrawObject("pyr1") 'Redraw the object
        AAA = FF.LBWF.PauseUsingTimer(100) 'pause a moment
        AAA = FF.LBWF.DrawObject("pyr1") 'undraw the object
    next i
 
    print #main.wfscene, "rule over"
    AAA = FF.LBWF.DrawObject("pyr1") 'Redraw the object

Return
 
''''''''''''''''''''''''''''''''''''''''''
[Translate.Pyramid.2]
 
    'Set the drawing rule to XOR...
    print #main.wfscene, "rule xor"
 
    AAA = FF.LBWF.DrawObject("pyr2") 'undraw the object
    
    for i = 1 to 20
        AAA = FF.LBWF.TranslateObject("pyr2", 0, 0, -2)
        AAA = FF.LBWF.DrawObject("pyr2") 'Redraw the object
        AAA = FF.LBWF.PauseUsingTimer(100) 'pause a moment
        AAA = FF.LBWF.DrawObject("pyr2") 'undraw the object
    next i
 
    for i = 1 to 20
        AAA = FF.LBWF.TranslateObject("pyr2", 0, 0, 2)
        AAA = FF.LBWF.DrawObject("pyr2") 'Redraw the object
        AAA = FF.LBWF.PauseUsingTimer(100) 'pause a moment
        AAA = FF.LBWF.DrawObject("pyr2") 'undraw the object
    next i
 
    print #main.wfscene, "rule over"
    AAA = FF.LBWF.DrawObject("pyr2") 'Redraw the object

 
Return
 
 
''''''''''''''''''''''''''''''''''''''''''
[Rotate.Pyramid.3]
    'Set the drawing rule to XOR...
    print #main.wfscene, "rule xor"
 
    AAA = FF.LBWF.DrawObject("pyr3") 'undraw the object
    
    for i = 1 to 72
        AAA = FF.LBWF.RotateObjectAboutX("pyr3", 5) 'rotate the object 5 degrees
        AAA = FF.LBWF.DrawObject("pyr3") 'Redraw the object
        AAA = FF.LBWF.PauseUsingTimer(100) 'pause a moment
        AAA = FF.LBWF.DrawObject("pyr3") 'undraw the object
    next i
 
    print #main.wfscene, "rule over"
    AAA = FF.LBWF.DrawObject("pyr3") 'Redraw the object

Return
 
''''''''''''''''''''''''''''''''''''''''''

[Change.Line.Thickness.Of.Pyramid.4]
 
    print #main.wfscene, "rule XOR"
    AAA = FF.LBWF.DrawObject("pyr4") 'undraw it
    AAA = FF.LBWF.ObjectSetLineThickness("pyr4", 2)
    AAA = FF.LBWF.DrawObject("pyr4") 'redraw it
    AAA = FF.LBWF.PauseUsingTimer(333)
 
    AAA = FF.LBWF.DrawObject("pyr4") 'undraw it
    AAA = FF.LBWF.ObjectSetLineThickness("pyr4", 3)
    AAA = FF.LBWF.DrawObject("pyr4") 'redraw it
    AAA = FF.LBWF.PauseUsingTimer(333)
 
    AAA = FF.LBWF.DrawObject("pyr4") 'undraw it
    AAA = FF.LBWF.ObjectSetLineThickness("pyr4", 4)
    AAA = FF.LBWF.DrawObject("pyr4") 'redraw it
    AAA = FF.LBWF.PauseUsingTimer(333)
 
    AAA = FF.LBWF.DrawObject("pyr4") 'undraw it
    AAA = FF.LBWF.ObjectSetLineThickness("pyr4", 5)
    AAA = FF.LBWF.DrawObject("pyr4") 'redraw it
    AAA = FF.LBWF.PauseUsingTimer(333)
 
    AAA = FF.LBWF.DrawObject("pyr4") 'undraw it
    AAA = FF.LBWF.ObjectSetLineThickness("pyr4", 6)
    AAA = FF.LBWF.DrawObject("pyr4") 'redraw it
    AAA = FF.LBWF.PauseUsingTimer(333)
 
    AAA = FF.LBWF.DrawObject("pyr4") 'undraw it
    AAA = FF.LBWF.ObjectSetLineThickness("pyr4", 7)
    AAA = FF.LBWF.DrawObject("pyr4") 'redraw it
    AAA = FF.LBWF.PauseUsingTimer(333)
 
 
    AAA = FF.LBWF.DrawObject("pyr4") 'undraw it
    AAA = FF.LBWF.ObjectSetLineThickness("pyr4", 6)
    AAA = FF.LBWF.DrawObject("pyr4") 'redraw it
    AAA = FF.LBWF.PauseUsingTimer(333)
 
 
    AAA = FF.LBWF.DrawObject("pyr4")
    AAA = FF.LBWF.ObjectSetLineThickness("pyr4", 5)
    AAA = FF.LBWF.DrawObject("pyr4")
    AAA = FF.LBWF.PauseUsingTimer(333)
 
 
    AAA = FF.LBWF.DrawObject("pyr4")
    AAA = FF.LBWF.ObjectSetLineThickness("pyr4", 4)
    AAA = FF.LBWF.DrawObject("pyr4")
    AAA = FF.LBWF.PauseUsingTimer(333)
 
 
    AAA = FF.LBWF.DrawObject("pyr4")
    AAA = FF.LBWF.ObjectSetLineThickness("pyr4", 3)
    AAA = FF.LBWF.DrawObject("pyr4")
    AAA = FF.LBWF.PauseUsingTimer(333)
 
 
    AAA = FF.LBWF.DrawObject("pyr4")
    AAA = FF.LBWF.ObjectSetLineThickness("pyr4", 2)
    AAA = FF.LBWF.DrawObject("pyr4")
    AAA = FF.LBWF.PauseUsingTimer(333)
 
 
    AAA = FF.LBWF.DrawObject("pyr4")
    AAA = FF.LBWF.ObjectSetLineThickness("pyr4", 1)
    AAA = FF.LBWF.DrawObject("pyr4")
    AAA = FF.LBWF.PauseUsingTimer(333)
 
 
    print #main.wfscene, "rule OVER"
    AAA = FF.LBWF.ClearGraphicScreen()
    AAA = FF.LBWF.DrawAllObjects()
 
 
 
Return
 
''''''''''''''''''''''''''''''''''''''''''''''''''

[Cycle.Pyramid.5.Through.Several.Colors]
 
 
    for i = 1 to 85
 
        NewColor$ = str$(3*i) + " " + str$(0) + " " + str$(255-3*i)
        AAA = FF.LBWF.ObjectSetColor("pyr5", NewColor$)
        AAA = FF.LBWF.DrawObject("pyr5")
        AAA = FF.LBWF.PauseUsingTimer(30)
 
    next i
 
    for i = 1 to 84
 
        NewColor$ = str$(255 - 3*i) + " " + str$(0) + " " + str$(0)
        AAA = FF.LBWF.ObjectSetColor("pyr5", NewColor$)
        AAA = FF.LBWF.DrawObject("pyr5")
        AAA = FF.LBWF.PauseUsingTimer(30)
 
    next i
 
 
    AAA = FF.LBWF.ObjectSetColor("pyr5", "black")
    AAA = FF.LBWF.DrawObject("pyr5")
 
 
Return
''''''''''''''''''''''''''''''''''''''''''''''''''

[Rotate.And.Elevate.Pyramid.6]
 
    print #main.wfscene, "rule XOR"
    AAA = FF.LBWF.DrawObject("pyr6")
 
    for i = 1 to 36
        AAA = FF.LBWF.RotateObjectAboutY("pyr6", 5) 'rotate the object 5 degrees
        AAA = FF.LBWF.TranslateObject("pyr6", 0, 1.5, 0)
        AAA = FF.LBWF.DrawObject("pyr6") 'Redraw the object
        AAA = FF.LBWF.PauseUsingTimer(100) 'pause a moment
        AAA = FF.LBWF.DrawObject("pyr6") 'undraw the object
    next i
 
    for i = 1 to 36
        AAA = FF.LBWF.RotateObjectAboutY("pyr6", 5) 'rotate the object 5 degrees
        AAA = FF.LBWF.TranslateObject("pyr6", 0, -1.5, 0)
        AAA = FF.LBWF.DrawObject("pyr6") 'Redraw the object
        AAA = FF.LBWF.PauseUsingTimer(100) 'pause a moment
        AAA = FF.LBWF.DrawObject("pyr6") 'undraw the object
    next i
 
 
 
 
 
    print #main.wfscene, "rule OVER"
    AAA = FF.LBWF.DrawObject("pyr6")
 
Return
 
''''''''''''''''''''''''''''''''''''''''''''''''''
[Disable.Controls.During.Transformation]
 
    print #main.btnRandCam, "!disable"
    print #main.cbozoom, "disable"
    print #main.btnRedraw, "!disable"
    print #main.txtObjSelected, "!disable"
    print #main.btnQuit, "!disable"
 
    Return
 
''''''''''''''''''''''''''''''''''''''''''''''''''
[Enable.Controls.During.Transformation]
 
    print #main.btnRandCam, "!enable"
    print #main.cbozoom, "enable"
    print #main.btnRedraw, "!enable"
    print #main.txtObjSelected, "!enable"
    print #main.btnQuit, "!enable"
 
    Return
 
''''''''''''''''''''''''''''''''''''''''''''''''''

'---Insert library below this line----

 
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'        Begin Liberty BASIC WireFrame Library             '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'''''''''''''''''''''''''''''''''''''''''''''''''''
'List of Liberty BASIC Wire Frame Library Functions
'''''''''''''''''''''''''''''''''''''''''''''''''''
'
'function count = 53
'
'Function FF.LBWF.Camera()
'Function FF.LBWF.CameraLocation()
'Function FF.LBWF.ViewingCenter()
'Function FF.LBWF.ZoomFactor()
'Function FF.LBWF.ScreenCenter()
'Function FF.LBWF.PointCameraAtObject()
'Function FF.LBWF.BackGroundColor()
'Function FF.LBWF.ShowAxes()
'Function FF.LBWF.HideAxes()
'Function FF.LBWF.SetAxesProperties()
'
'Function FF.LBWF.CreateBox()
'Function FF.LBWF.CreateCylinder()
'Function FF.LBWF.CreatePyramid()
'Function FF.LBWF.CreateCone()
'Function FF.LBWF.CreatePolygon()
'Function FF.LBWF.CreateGridObject()
'Function FF.LBWF.CreateDome()
'Function FF.LBWF.CreateLine()
'Function FF.LBWF.CreateCyl2()
'Function FF.LBWF.CreateComplexObject()
'
'Function FF.LBWF.TranslateObject()
'Function FF.LBWF.HideObject()
'Function FF.LBWF.ShowObject()
'Function FF.LBWF.ObjectSetColor()
'Function FF.LBWF.ObjectSetLineThickness()
'Function FF.LBWF.MoveObjectAbsolute()
'Function FF.LBWF.RotateObjectAboutY()
'Function FF.LBWF.RotateObjectAboutX()
'Function FF.LBWF.RotateObjectAboutZ()
'
'Function FF.LBWF.HideObjectsOfType()
'Function FF.LBWF.ShowObjectsOfType()
'Function FF.LBWF.TranslateObjectsOfType()
'Function FF.LBWF.DrawObjectsOfType()
'Function FF.LBWF.ObjectAssignCustomType()
'
'
'Function FF.LBWF.HideAllObjects()
'Function FF.LBWF.ShowAllObjects()
'
'Function FF.LBWF.ClearGraphicScreen()
'Function FF.LBWF.DrawObject()
'Function FF.LBWF.DrawAllObjects()
'
'Function FF.LBWF.LBWFVersion$()
'Function FF.LBWF.About()
'Function FF.LBWF.PauseMilliseconds()
'Function FF.LBWF.PauseUsingTimer()
'Function FF.LBWF.ZeroAllData()
'
'Function FF.LBWF.RequestLibraryResources$()
'Function FF.LBWF.RequestRemainingResources$()
'Function FF.LBWF.RequestObjectGeometricCenter$()
'Function FF.LBWF.RequestObjectColor$()
'Function FF.LBWF.RequestObjectLineThickness()
'Function FF.LBWF.RequestObjectType$()
'Function FF.LBWF.RequestObjectExtents$()
'Function FF.LBWF.RequestObjectVisibleState()
'Function FF.LBWF.RequestObjectNameFromXY$()
'
'
'Function FF.LBWF.ATAN2()
'Function FF.LBWF.FindPerpendicularDistance$()
'

 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
[Initialize.Liberty.BASIC.WireFrame.Library]
 
dim LBWF.CamX(1)
dim LBWF.CamY(1)
dim LBWF.CamZ(1)
dim LBWF.VCtrX(1)
dim LBWF.VCtrY(1)
dim LBWF.VCtrZ(1)
dim LBWF.ZoomFac(1)
dim LBWF.BackGroundColor$(1)
dim LBWF.VersionNumber$(1)
dim LBWF.NodeResources(1)
dim LBWF.LineResources(1)
dim LBWF.ObjectResources(1)
 
LBWF.CamX(1) = 200
LBWF.CamY(1) = 200
LBWF.CamZ(1) = 200
LBWF.VCtrX(1) = 0
LBWF.VCtrY(1) = 0
LBWF.VCtrZ(1) = 0
LBWF.ZoomFac(1) = 1
LBWF.BackGroundColor$(1) = "white"
LBWF.VersionNumber$(1) = "0.6a"
 
LBWF.NodeResources(1) = 4000
LBWF.LineResources(1) = 4000
LBWF.ObjectResources(1) = 500
 
 
dim LBWF.ScrCenterX(1)
dim LBWF.ScrCenterY(1)
 
LBWF.ScrCenterX(1) = 180
LBWF.ScrCenterY(1) = 180
 
dim LBWF.NodeCount(1)
dim LBWF.LineCount(1)
dim LBWF.ObjectCount(1)
 
LBWF.NodeCount(1) = 0
LBWF.LineCount(1) = 0
LBWF.ObjectCount(1) = 0
 
 
dim LBWF.NodeWX(LBWF.NodeResources(1))
dim LBWF.NodeWY(LBWF.NodeResources(1))
dim LBWF.NodeWZ(LBWF.NodeResources(1))
 
dim LBWF.NodeSX(LBWF.NodeResources(1))
dim LBWF.NodeSY(LBWF.NodeResources(1))
 
dim LBWF.LineInode(LBWF.LineResources(1))
dim LBWF.LineJnode(LBWF.LineResources(1))
 
dim LBWF.ObjectName$(LBWF.ObjectResources(1))
dim LBWF.ObjectColor$(LBWF.ObjectResources(1))
dim LBWF.ObjectFirstNode(LBWF.ObjectResources(1))
dim LBWF.ObjectLastNode(LBWF.ObjectResources(1))
 
dim LBWF.ObjectFirstLine(LBWF.ObjectResources(1))
dim LBWF.ObjectLastLine(LBWF.ObjectResources(1))
 
dim LBWF.ObjectVisible(LBWF.ObjectResources(1))
dim LBWF.ObjectLineThickness(LBWF.ObjectResources(1))
 
dim LBWF.ObjectType$(LBWF.ObjectResources(1))
 
dim LBWF.ObjectCenterX(LBWF.ObjectResources(1))
dim LBWF.ObjectCenterY(LBWF.ObjectResources(1))
dim LBWF.ObjectCenterZ(LBWF.ObjectResources(1))
 
 
    'Information about the axes...
    Dim LBWF.AxesVisible(1)
    LBWF.AxesVisible(1) = 0   'Default state: axes are NOT visible

    Dim LBWF.AxesLength(1)
    LBWF.AxesLength(1) = 50   'The startup length of the axes are 30 units
    
    Dim LBWF.AxesLineThickness(1)
    LBWF.AxesLineThickness(1) = 2   'The startup thickness of the axes objects is 2 pixels

    Dim LBWF.XaxisColor$(1)
    Dim LBWF.YaxisColor$(1)
    Dim LBWF.ZaxisColor$(1)
 
    LBWF.XaxisColor$(1) = "blue"
    LBWF.YaxisColor$(1) = "red"
    LBWF.ZaxisColor$(1) = "darkgreen"
 
 
    Dim LBWF.AxesWorldX(4)
    Dim LBWF.AxesWorldY(4)
    Dim LBWF.AxesWorldZ(4)
 
    Dim LBWF.AxesScreenX(4)
    Dim LBWF.AxesScreenY(4) 
 
    LBWF.AxesWorldX(1) = 0  'These are the world coordinates of
    LBWF.AxesWorldY(1) = 0  'the origin point.
    LBWF.AxesWorldZ(1) = 0  '

    LBWF.AxesWorldX(2) = LBWF.AxesLength(1)  'These are the coordinates of the end
    LBWF.AxesWorldY(2) = 0                   'end point of the X-axis
    LBWF.AxesWorldZ(2) = 0                   '

    LBWF.AxesWorldX(3) = 0                   'These are the coordinates of the
    LBWF.AxesWorldY(3) = LBWF.AxesLength(1)  'endpoint of the Y-axis
    LBWF.AxesWorldZ(3) = 0
 
    LBWF.AxesWorldX(4) = 0                   'These are the coordinates of the
    LBWF.AxesWorldY(4) = 0                   'endpoint of the Z-axis
    LBWF.AxesWorldZ(4) = LBWF.AxesLength(1)  '

'Dimension the arrays for complex objects...

    Dim LBWF.ComplexTextLines$(1000)
 
    dim LBWF.ComplexNodeID(300)
    dim LBWF.ComplexNodeX(300)
    dim LBWF.ComplexNodeY(300)
    dim LBWF.ComplexNodeZ(300)
 
    dim LBWF.ComplexLineID(300)
    dim LBWF.ComplexLineInode(300)
    dim LBWF.ComplexLineJnode(300)
 
 
    Return
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.RequestObjectNameFromXY$(ScreenX, ScreenY, pixelLimit)
 
    'This function identifies the first non-hidden object that
    'contains a line that is located within pixelLimit of the 
    'screen coordinates ScreenX and ScreenY...

 
    FF.LBWF.RequestObjectNameFromXY$ = "null00"
 
    OC = LBWF.ObjectCount(1)
 
    for i = 1 to OC
 
        'Only evaluate the lines in this object if the visible state
        'of the object has been set to "visible"
        
        If (LBWF.ObjectVisible(i) = 1) then
 
            ObjectToCheck = i
            FirstLineOfObjectToCheck = LBWF.ObjectFirstLine(ObjectToCheck)
            LastLineOfObjectToCheck  = LBWF.ObjectLastLine(ObjectToCheck)
 
            For j = FirstLineOfObjectToCheck to LastLineOfObjectToCheck
 
                TheLine = j
                InodeOfTheLine = LBWF.LineInode(TheLine)
                JnodeOfTheLine = LBWF.LineJnode(TheLine)
                xa = LBWF.NodeSX(InodeOfTheLine)
                ya = LBWF.NodeSY(InodeOfTheLine)
                xb = LBWF.NodeSX(JnodeOfTheLine)
                yb = LBWF.NodeSY(JnodeOfTheLine)
                xc = ScreenX
                yc = ScreenY
 
                Distance$ = FF.LBWF.FindPerpendicularDistance$(xa, ya, xb, yb, xc, yc)
                DistanceComponent    = val(word$(Distance$, 1))
                EvaluationComponent$ = word$(Distance$, 2)
 
                If ((DistanceComponent <= pixelLimit) and (EvaluationComponent$ = "yes")) then 
                    FF.LBWF.RequestObjectNameFromXY$ = LBWF.ObjectName$(i)
                    j = LastLineOfObjectToCheck
                    i = OC
                end if
 
            next j
 
 
        end if
 
    next i
 
 
End Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'LBWF.NodeSX()
'LBWF.NodeSY()

 
'LBWF.LineInode()
'LBWF.LineJnode()

'LBWF.ObjectCount(1) = 0
'LBWF.ObjectVisible(i)
'LBWF.ObjectFirstLine()
'LBWF.ObjectLastLine()

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.CreateComplexObject(ObjectName$, FileName$, ObjectColor$)
 
    'Read the complex object text file into an array...

    LineCount = 0
 
    open FileName$ for input as #cplx
 
    While (eof(#cplx) <> -1)
        LineCount = LineCount + 1
        Line input #cplx, TheLine$
        LBWF.ComplexTextLines$(LineCount) = TheLine$
    Wend
 
    close #cplx
 
 
    'Parse all of the text data lines into node data and
    'line data of the complex object...

    ComplexNodeCount = 0
    ComplexLineCount = 0
 
    For i = 1 to LineCount
 
    if (lower$(word$(LBWF.ComplexTextLines$(i), 1)) = "node") then
        ComplexNodeCount = ComplexNodeCount + 1
        LBWF.ComplexNodeID(ComplexNodeCount) = val(word$(LBWF.ComplexTextLines$(i), 2))
        LBWF.ComplexNodeX(LBWF.ComplexNodeID(ComplexNodeCount)) = val(word$(LBWF.ComplexTextLines$(i), 3))
        LBWF.ComplexNodeY(LBWF.ComplexNodeID(ComplexNodeCount)) = val(word$(LBWF.ComplexTextLines$(i), 4))
        LBWF.ComplexNodeZ(LBWF.ComplexNodeID(ComplexNodeCount)) = val(word$(LBWF.ComplexTextLines$(i), 5))
    end if
 
    if (lower$(word$(LBWF.ComplexTextLines$(i), 1)) = "line") then
        ComplexLineCount = ComplexLineCount + 1
        LBWF.ComplexLineID(ComplexLineCount) = val(word$(LBWF.ComplexTextLines$(i), 2))
        LBWF.ComplexLineInode(LBWF.ComplexLineID(ComplexLineCount)) = val(word$(LBWF.ComplexTextLines$(i), 3))
        LBWF.ComplexLineJnode(LBWF.ComplexLineID(ComplexLineCount)) = val(word$(LBWF.ComplexTextLines$(i), 4))
    end if
 
    next i
 
    'Integrate the data for the complex object into the database for
    'all of the wireframe objects, starting with the nodes...
    
    NC = LBWF.NodeCount(1)
 
    for i = 1 to ComplexNodeCount
        LBWF.NodeWX(NC + i) = LBWF.ComplexNodeX(i)
        LBWF.NodeWY(NC + i) = LBWF.ComplexNodeY(i)
        LBWF.NodeWZ(NC + i) = LBWF.ComplexNodeZ(i)
    next i
 
    'Define the new lines for this complex object...
    
    LC = LBWF.LineCount(1)
 
    for i = 1 to ComplexLineCount
        LBWF.LineInode(LC + i) = NC + LBWF.ComplexLineInode(i)
        LBWF.LineJnode(LC + i) = NC + LBWF.ComplexLineJnode(i)
    next i
 
    'Define other properties for this complex object...
    OC = LBWF.ObjectCount(1)
 
    LBWF.ObjectName$(OC + 1)     = ObjectName$
    LBWF.ObjectColor$(OC + 1)    = ObjectColor$
    LBWF.ObjectFirstNode(OC + 1) = (NC + 1)
    LBWF.ObjectLastNode(OC + 1)  = (NC + ComplexNodeCount)
    LBWF.ObjectFirstLine(OC + 1) = (LC + 1)
    LBWF.ObjectLastLine(OC + 1)  = (LC + ComplexLineCount)
    LBWF.ObjectVisible(OC + 1)   = 1
    LBWF.ObjectLineThickness(OC + 1) = 1
    LBWF.ObjectType$(OC + 1)     = "complex"
 
    'Determine the geometric center of the complex object.
    'First, for all nodal coordinates, determine the min and
    'max values for the x-, y- and z-directions...
    
    minX = LBWF.ComplexNodeX(1) : maxX = LBWF.ComplexNodeX(1)
    minY = LBWF.ComplexNodeY(1) : maxY = LBWF.ComplexNodeY(1)
    minZ = LBWF.ComplexNodeZ(1) : maxZ = LBWF.ComplexNodeZ(1)
 
    for i = 2 to ComplexNodeCount
 
        if (LBWF.ComplexNodeX(i) < minX) then
            minX = LBWF.ComplexNodeX(i)
        end if
 
        if (LBWF.ComplexNodeX(i) > maxX) then
            maxX = LBWF.ComplexNodeX(i)
        end if
 
        if (LBWF.ComplexNodeY(i) < minY) then
            minY = LBWF.ComplexNodeY(i)
        end if
 
        if (LBWF.ComplexNodeY(i) > maxY) then
            maxY = LBWF.ComplexNodeY(i)
        end if
 
        if (LBWF.ComplexNodeZ(i) < minZ) then
            minZ = LBWF.ComplexNodeZ(i)
        end if
 
        if (LBWF.ComplexNodeZ(i) > maxZ) then
            maxZ = LBWF.ComplexNodeZ(i)
        end if
 
    next i
 
    'The center of the object is equal to the value that 
    'is midway between the min value and the max value...
    LBWF.ObjectCenterX(OC + 1) = (minX + maxX)/2
    LBWF.ObjectCenterY(OC + 1) = (minY + maxY)/2
    LBWF.ObjectCenterZ(OC + 1) = (minZ + maxZ)/2
 
    'Update the node count, the line count, and the object count...

    LBWF.NodeCount(1)   = LBWF.NodeCount(1) + ComplexNodeCount
    LBWF.LineCount(1)   = LBWF.LineCount(1) + ComplexLineCount
    LBWF.ObjectCount(1) = LBWF.ObjectCount(1) + 1
 
 
 
 
 
 
End Function
 
' LBWF.LineInode(LBWF.LineResources(1))
' LBWF.LineJnode(LBWF.LineResources(1))

 
 
' LBWF.NodeWX(i)
' LBWF.NodeWY(i)
' LBWF.NodeWZ(i)

 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function FF.LBWF.ZeroAllData()
 
LBWF.CamX(1) = 200
LBWF.CamY(1) = 200
LBWF.CamZ(1) = 200
LBWF.VCtrX(1) = 0
LBWF.VCtrY(1) = 0
LBWF.VCtrZ(1) = 0
LBWF.ZoomFac(1) = 1
LBWF.BackGroundColor$(1) = "white"
LBWF.VersionNumber$(1) = "0.6a"
 
LBWF.NodeResources(1) = 4000
LBWF.LineResources(1) = 4000
LBWF.ObjectResources(1) = 500
 
LBWF.ScrCenterX(1) = 180
LBWF.ScrCenterY(1) = 180
 
LBWF.NodeCount(1) = 0
LBWF.LineCount(1) = 0
LBWF.ObjectCount(1) = 0
 
LBWF.AxesVisible(1) = 0   'Default state: axes are NOT visible

LBWF.AxesLength(1) = 50   'The startup length of the axes are 30 units
    
LBWF.AxesLineThickness(1) = 2   'The startup thickness of the axes objects is 2 pixels

LBWF.XaxisColor$(1) = "blue"
LBWF.YaxisColor$(1) = "red"
LBWF.ZaxisColor$(1) = "darkgreen"
 
LBWF.AxesWorldX(1) = 0  'These are the world coordinates of
LBWF.AxesWorldY(1) = 0  'the origin point.
LBWF.AxesWorldZ(1) = 0  '

LBWF.AxesWorldX(2) = LBWF.AxesLength(1)  'These are the coordinates of the end
LBWF.AxesWorldY(2) = 0                   'end point of the X-axis
LBWF.AxesWorldZ(2) = 0                   '

LBWF.AxesWorldX(3) = 0                   'These are the coordinates of the
LBWF.AxesWorldY(3) = LBWF.AxesLength(1)  'endpoint of the Y-axis
LBWF.AxesWorldZ(3) = 0
 
LBWF.AxesWorldX(4) = 0                   'These are the coordinates of the
LBWF.AxesWorldY(4) = 0                   'endpoint of the Z-axis
LBWF.AxesWorldZ(4) = LBWF.AxesLength(1)  '

 
 
 
 
End Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.ObjectAssignCustomType(ObjectName$, CustomType$)
 
    ObjectToType = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectToType = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    LBWF.ObjectType$(ObjectToType) = CustomType$
 
 
End Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''    
Function FF.LBWF.HideObjectsOfType(ObjectType$)
 
    'In version 0.6 of the library, this function presumes
    'that the programmer has passed a legitimate type
    'as an argument in the function.
    
    'Examine the types of all current objects.
    'If an object's type matches the type identified
    'in the argument of the function, then set the visibility
    'of that object to "hidden"
    
    OC = LBWF.ObjectCount(1)
 
    for i = 1 to OC
        if (LBWF.ObjectType$(i) = ObjectType$) then
            LBWF.ObjectVisible(i) = 0
        end if 
    next i
 
End Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.ShowObjectsOfType(ObjectType$)
 
    OC = LBWF.ObjectCount(1)
 
    for i = 1 to OC
        if (LBWF.ObjectType$(i) = ObjectType$) then
            LBWF.ObjectVisible(i) = 1
        end if 
    next i
 
End function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.TranslateObjectsOfType(ObjectType$, transX, transY, transZ)
 
    OC = LBWF.ObjectCount(1)
 
    for i = 1 to OC
        if (LBWF.ObjectType$(i) = ObjectType$) then
 
            FirstNode = LBWF.ObjectFirstNode(i)
            LastNode  = LBWF.ObjectLastNode(i)
 
            for j = FirstNode to LastNode
                LBWF.NodeWX(j) = LBWF.NodeWX(j) + transX
                LBWF.NodeWY(j) = LBWF.NodeWY(j) + transY
                LBWF.NodeWZ(j) = LBWF.NodeWZ(j) + transZ
            next j
 
            LBWF.ObjectCenterX(i) = LBWF.ObjectCenterX(i) + transX
            LBWF.ObjectCenterY(i) = LBWF.ObjectCenterY(i) + transY
            LBWF.ObjectCenterZ(i) = LBWF.ObjectCenterZ(i) + transZ
 
        end if 
    next i
 
End Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'dim LBWF.ObjectCenterX(i)
'dim LBWF.ObjectCenterY(i)
'dim LBWF.ObjectCenterZ(i)

'dim LBWF.NodeWX(i)
'dim LBWF.NodeWY(i)
'dim LBWF.NodeWZ(i)

 
'dim LBWF.ObjectFirstNode(i)
'dim LBWF.ObjectLastNode(i)
'dim LBWF.ObjectVisible(LBWF.ObjectResources(1))
'dim LBWF.ObjectLineThickness(LBWF.ObjectResources(1))
'dim LBWF.ObjectType$(LBWF.ObjectResources(1))    
    
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function FF.LBWF.CreateLine(LineName$, x1, y1, z1, x2, y2, z2, LineColor$)
 
    NC = LBWF.NodeCount(1)
    LC = LBWF.LineCount(1)
 
    'Identify the two new nodes...
    LBWF.NodeWX(NC + 1) = x1
    LBWF.NodeWY(NC + 1) = y1
    LBWF.NodeWZ(NC + 1) = z1
 
    LBWF.NodeWX(NC + 2) = x2
    LBWF.NodeWY(NC + 2) = y2
    LBWF.NodeWZ(NC + 2) = z2
 
    'Identify the one new line...
    LBWF.LineInode(LC + 1) = (NC + 1)
    LBWF.LineJnode(LC + 1) = (NC + 2)
 
    'Define other object properties
    OC = LBWF.ObjectCount(1)
 
    LBWF.ObjectName$(OC + 1)         = LineName$
    LBWF.ObjectColor$(OC + 1)        = LineColor$
    LBWF.ObjectFirstNode(OC + 1)     = (NC + 1)
    LBWF.ObjectLastNode(OC + 1)      = (NC + 2)
    LBWF.ObjectFirstLine(OC + 1)     = (LC + 1)
    LBWF.ObjectLastLine(OC + 1)      = (LC + 1)
    LBWF.ObjectVisible(OC + 1)       = 1
    LBWF.ObjectLineThickness(OC + 1) = 1
    LBWF.ObjectType$(OC + 1)         = "line"
    LBWF.ObjectCenterX(OC + 1)       = (x1 + x2)/2
    LBWF.ObjectCenterY(OC + 1)       = (y1 + y2)/2
    LBWF.ObjectCenterZ(OC + 1)       = (z1 + z2)/2
 
    'Update the node count, the line count, and the object count...

    LBWF.NodeCount(1)   = LBWF.NodeCount(1) + 2
    LBWF.LineCount(1)   = LBWF.LineCount(1) + 1
    LBWF.ObjectCount(1) = LBWF.ObjectCount(1) + 1
 
End Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function FF.LBWF.CreateDome(DomeName$, radius, numSides, DomeColor$)
 
    'Define the new nodes for this dome...
    NC = LBWF.NodeCount(1)
    pi = 3.14159
    wedgeAngle = (2*pi)/numSides
 
    NNDN = 3*numSides + 1    'Number of new dome nodes
    NNDL = 6*numSides        'Number of new dome lines

    'Find the coordinates of all the nodes on the base
    'layer of the dome...
    for i = 1 to numSides
        LBWF.NodeWX(NC + i) = radius*cos((i-1)*wedgeAngle)
        LBWF.NodeWY(NC + i) = 0
        LBWF.NodeWZ(NC + i) = radius*sin((i-1)*wedgeAngle)
    next i
 
    'Find the coordinates of all the nodes on the SECOND
    'layer of the dome.
    NC1 = NC + numSides
    for i = 1 to numSides
        LBWF.NodeWX(NC1 + i) = 0.866*radius*cos((i-1)*wedgeAngle)
        LBWF.NodeWY(NC1 + i) = 0.5*radius
        LBWF.NodeWZ(NC1 + i) = 0.866*radius*sin((i-1)*wedgeAngle)
    next i
 
    'Find the coordinates of all the nodes on the THIRD
    'layer of the dome.
    NC2 = NC1 + numSides
    for i = 1 to numSides
        LBWF.NodeWX(NC2 + i) = 0.500*radius*cos((i-1)*wedgeAngle)
        LBWF.NodeWY(NC2 + i) = 0.866*radius
        LBWF.NodeWZ(NC2 + i) = 0.500*radius*sin((i-1)*wedgeAngle)
    next i
 
    'Identify the coordinate of the top-most node of the dome...
    LBWF.NodeWX(NC + 3*numSides + 1) = 0
    LBWF.NodeWY(NC + 3*numSides + 1) = radius
    LBWF.NodeWZ(NC + 3*numSides + 1) = 0
 
    'Define the new lines for this dome...
    LC = LBWF.LineCount(1)
 
    'These are the lines for the base layer of the dome...
    for i = 1 to (numSides - 1)
        LBWF.LineInode(LC + i) = (NC + i)
        LBWF.LineJnode(LC + i) = (NC + i + 1)
    next i
 
    LBWF.LineInode(LC + numSides) = (NC + numSides)
    LBWF.LineJnode(LC + numSides) = (NC + 1)
 
    'These are the lines which connect the SECOND
    'layer of nodes...
    
    LC1 = LC + numSides
    NC1 = NC + numSides
 
    for i = 1 to (numSides - 1)
        LBWF.LineInode(LC1 + i) = (NC1 + i)
        LBWF.LineJnode(LC1 + i) = (NC1 + i + 1)
    next i
 
    LBWF.LineInode(LC1 + numSides) = (NC1 + numSides)
    LBWF.LineJnode(LC1 + numSides) = (NC1 + 1)
 
    'These are the lines which connect the THIRD
    'layer of nodes...
    
    LC2 = LC1 + numSides
    NC2 = NC1 + numSides
 
    for i = 1 to (numSides - 1)
        LBWF.LineInode(LC2 + i) = (NC2 + i)
        LBWF.LineJnode(LC2 + i) = (NC2 + i + 1)
    next i
 
    LBWF.LineInode(LC2 + numSides) = (NC2 + numSides)
    LBWF.LineJnode(LC2 + numSides) = (NC2 + 1)
 
    'These are the lines which connect the BASE layer
    'of nodes to the SECOND layer of nodes...
    
    LC3 = LC2 + numSides
 
    for i = 1 to numSides
        LBWF.LineInode(LC3 + i) = (NC + i)
        LBWF.LineJnode(LC3 + i) = (NC1 + i)
    next i
 
    'These are the lines which connect the SECOND layer
    'of nodes to the THIRD layer of nodes...
    
    LC4 = LC3 + numSides
 
    for i = 1 to numSides
        LBWF.LineInode(LC4 + i) = (NC1 + i)
        LBWF.LineJnode(LC4 + i) = (NC2 + i)
    next i
 
    'These are the lines which connect the THIRD layer
    'of nodes to the TOP-MOST node...
    
    LC5 = LC4 + numSides
 
    for i = 1 to numSides
        LBWF.LineInode(LC5 + i) = (NC2 + i)
        LBWF.LineJnode(LC5 + i) = (NC + NNDN)   'NNDN is the last node of the dome...
    next i
 
    'Define other object properties
    OC = LBWF.ObjectCount(1)
 
    LBWF.ObjectName$(OC + 1)         = DomeName$
    LBWF.ObjectColor$(OC + 1)        = DomeColor$
    LBWF.ObjectFirstNode(OC + 1)     = (NC + 1)
    LBWF.ObjectLastNode(OC + 1)      = (NC + NNDN)
    LBWF.ObjectFirstLine(OC + 1)     = (LC + 1)
    LBWF.ObjectLastLine(OC + 1)      = (LC + NNDL)
    LBWF.ObjectVisible(OC + 1)       = 1
    LBWF.ObjectLineThickness(OC + 1) = 1
    LBWF.ObjectType$(OC + 1)         = "dome"
    LBWF.ObjectCenterX(OC + 1)       = 0
    LBWF.ObjectCenterY(OC + 1)       = radius/2
    LBWF.ObjectCenterZ(OC + 1)       = 0
 
    'Update the node count, the line count, and the object count...

    LBWF.NodeCount(1)   = LBWF.NodeCount(1) + NNDN
    LBWF.LineCount(1)   = LBWF.LineCount(1) + NNDL
    LBWF.ObjectCount(1) = LBWF.ObjectCount(1) + 1
 
end function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.PauseUsingTimer(DelayMS)
 
    Timer DelayMS, [End.Of.Delay]
    Wait
    [End.Of.Delay]
    Timer 0
 
End Function
 
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.PauseMilliseconds(DelayMS)
 
    StartingTimeMS = time$("ms")
 
    ElapsedTimeMS = 0
 
    While (ElapsedTimeMS <= DelayMS)
        'Keep checking the elapsed time until the 
        'elapsed time is greater than the delay time
        'as contained in the variable DelayMS
        CurrentTimeMS = time$("ms")
        ElapsedTimeMS = CurrentTimeMS - StartingTimeMS
    Wend
 
End Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.About()
 
    Notice "Liberty BASIC Wireframe Library          " + chr$(13) + _
           "                                         " + chr$(13) + _
           "Library Version " + LBWF.VersionNumber$(1) + chr$(13) + _
           "                                         " + chr$(13) + _
           "by Tomas J. Nally                        "
 
end Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.LBWFVersion$()
 
    FF.LBWF.LBWFVersion$ = LBWF.VersionNumber$(1)
 
end Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.ObjectSetColor(ObjectName$, NewColor$)
 
    'Determine the object whose color will
    'change by comparing the name of the object
    'against a list of all object names...
    
    ObjectToChangeColor = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectToChangeColor = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    'Now that the object has been identified,
    'change its color property...
    
    LBWF.ObjectColor$(ObjectToChangeColor) = NewColor$
 
end Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.ObjectSetLineThickness(ObjectName$, LineThickness)
 
    'Determine the object whose line thickness will
    'change by comparing the name of the object
    'against a list of all object names...
    
    ObjectToChange = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectToChange = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    'Now that the object has been identified,
    'change its line thickness property...
    
    LBWF.ObjectLineThickness(ObjectToChange) = LineThickness
 
end Function
 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.SetAxesProperties(AxesLength, AxesThickness)
 
    LBWF.AxesLength(1) = AxesLength
    LBWF.AxesWorldX(2) = LBWF.AxesLength(1)
    LBWF.AxesWorldY(3) = LBWF.AxesLength(1)
    LBWF.AxesWorldZ(4) = LBWF.AxesLength(1)
 
    LBWF.AxesLineThickness(1) = AxesThickness
 
 
end Function
 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.ShowAxes()
 
    LBWF.AxesVisible(1) = 1
 
End function
 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.HideAxes()
 
    LBWF.AxesVisible(1) = 0
 
End function
 
 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.ShowObject(ObjectName$)
 
    'Determine the object to be hidden by comparing the name
    'argument against a list of object names...
    
    ObjectToShow = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectToShow = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    'Set the visible property of that object to 1...
    LBWF.ObjectVisible(ObjectToShow) = 1
 
end Function
 
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.HideObject(ObjectName$)
 
    'Determine the object to be hidden by comparing the name
    'argument against a list of object names...
    
    ObjectToHide = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectToHide = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    'Set the visible property of that object to zero...
    LBWF.ObjectVisible(ObjectToHide) = 0
 
end Function
 
 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.PointCameraAtObject(ObjectName$)
 
    'Find the geometric center of the object identified
    'as the argument above...
    
    ObjectCenter$ = FF.LBWF.RequestObjectGeometricCenter$(ObjectName$)
 
    ObjectCenterX = val(word$(ObjectCenter$, 1))
    ObjectCenterY = val(word$(ObjectCenter$, 2))
    ObjectCenterZ = val(word$(ObjectCenter$, 3))
 
    'Now, point the camera to the x, y and z coordinates
    'identified above...
    
    AAA = FF.LBWF.ViewingCenter(ObjectCenterX, ObjectCenterY, ObjectCenterZ)
 
End Function
 
 
 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function FF.LBWF.CreateGridObject(GridName$, NumUnitsXdirection, NumUnitsZdirection, UnitSize, GridColor$)
 
    NumGridNodes = 2*(NumUnitsXdirection + 1) + 2*(NumUnitsZdirection + 1)
    NumGridLines = (NumUnitsXdirection + 1) + (NumUnitsZdirection + 1)
 
    TotalGridLengthX = NumUnitsXdirection * UnitSize
    TotalGridWidthZ  = NumUnitsZdirection * UnitSize
 
    UpperLeftCornerX = (0 - TotalGridLengthX/2)
    UpperLeftCornerZ = (0 - TotalGridWidthZ/2)
 
    LowerRightCornerX = TotalGridLengthX/2
    LowerRightCornerZ = TotalGridWidthZ/2
 
    NC = LBWF.NodeCount(1)
    LC = LBWF.LineCount(1)
 
    'Define all of the nodes which connect the lines parallel to 
    'the z-axis...
    
    for i = 1 to (NumUnitsXdirection + 1)
        LBWF.NodeWX(NC + i) = UpperLeftCornerX + (i-1)*UnitSize
        LBWF.NodeWY(NC + i) = 0
        LBWF.NodeWZ(NC + i) = UpperLeftCornerZ
    next i
 
    Na = NC + NumUnitsXdirection + 1
 
    for i = 1 to (NumUnitsXdirection + 1)
        LBWF.NodeWX(Na + i) = UpperLeftCornerX + (i-1)*UnitSize
        LBWF.NodeWY(Na + i) = 0
        LBWF.NodeWZ(Na + i) = LowerRightCornerZ
    next i
 
    'Define all of the nodes which connect the lines parallel to
    'the x-axis...
    
    Nb = NC + 2*(NumUnitsXdirection + 1)
 
    for i = 1 to (NumUnitsZdirection + 1)
        LBWF.NodeWX(Nb + i) = UpperLeftCornerX
        LBWF.NodeWY(Nb + i) = 0
        LBWF.NodeWZ(Nb + i) = UpperLeftCornerZ + (i-1)*UnitSize
    next i
 
    Nd = NC + 2*(NumUnitsXdirection + 1) + (NumUnitsZdirection + 1)
 
    for i = 1 to (NumUnitsZdirection + 1)
        LBWF.NodeWX(Nd + i) = LowerRightCornerX
        LBWF.NodeWY(Nd + i) = 0
        LBWF.NodeWZ(Nd + i) = UpperLeftCornerZ + (i-1)*UnitSize
    next i
 
    'Define the i-nodes and j-nodes for the (NumUnitsXdirection + 1) lines
    'that run parallel to the z-axis...
    
    for i = 1 to (NumUnitsXdirection + 1)
        LBWF.LineInode(LC + i) = (NC + i)
        LBWF.LineJnode(LC + i) = (NC + (NumUnitsXdirection + 1) + i)
    next i
 
    'Define the i-nodes and j-nodes for the (NumUnitsZdirection + 1) lines
    'that run parallel to the x-axis...

    LCa = LC + (NumUnitsXdirection + 1)
 
    for i = 1 to (NumUnitsZdirection + 1)
        LBWF.LineInode(LCa + i) = (NC + 2*(NumUnitsXdirection + 1) + i)
        LBWF.LineJnode(LCa + i) = LBWF.LineInode(LCa + i) + (NumUnitsZdirection + 1)
    next i
 
    'Define other object properties
    OC = LBWF.ObjectCount(1)
 
    LBWF.ObjectName$(OC + 1)         = GridName$
    LBWF.ObjectColor$(OC + 1)        = GridColor$
    LBWF.ObjectFirstNode(OC + 1)     = (NC + 1)
    LBWF.ObjectLastNode(OC + 1)      = (NC + NumGridNodes)
    LBWF.ObjectFirstLine(OC + 1)     = (LC + 1)
    LBWF.ObjectLastLine(OC + 1)      = (LC + NumGridLines)
    LBWF.ObjectVisible(OC + 1)       = 1
    LBWF.ObjectLineThickness(OC + 1) = 1
    LBWF.ObjectType$(OC + 1)         = "grid"
    LBWF.ObjectCenterX(OC + 1)       = 0
    LBWF.ObjectCenterY(OC + 1)       = 0
    LBWF.ObjectCenterZ(OC + 1)       = 0
 
 
    'Update the node count, the line count, and the object count...

    LBWF.NodeCount(1)   = LBWF.NodeCount(1) + NumGridNodes
    LBWF.LineCount(1)   = LBWF.LineCount(1) + NumGridLines
    LBWF.ObjectCount(1) = LBWF.ObjectCount(1) + 1
 
 
 
end Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.CreateCone(ConeName$, radius, numSides, coneheight, ConeColor$)
 
    'Define the new nodes for this cone...
    NC = LBWF.NodeCount(1)
    pi = 3.14159
    wedgeAngle = (2*pi)/numSides
 
    for i = 1 to numSides
        LBWF.NodeWX(NC + i) = radius*cos((i-1)*wedgeAngle)
        LBWF.NodeWY(NC + i) = 0
        LBWF.NodeWZ(NC + i) = radius*sin((i-1)*wedgeAngle)
    next i
 
    LBWF.NodeWX(NC + numSides + 1) = 0
    LBWF.NodeWY(NC + numSides + 1) = coneheight
    LBWF.NodeWZ(NC + numSides + 1) = 0
 
 
    'Define the new lines for this cone...
    LC = LBWF.LineCount(1)
 
    'These are the new lines for the bottom face of the cone...
    for i = 1 to (numSides - 1)
        LBWF.LineInode(LC + i) = (NC + i)
        LBWF.LineJnode(LC + i) = (NC + i + 1)
    next i
 
    LBWF.LineInode(LC + numSides) = (NC + numSides)
    LBWF.LineJnode(LC + numSides) = (NC + 1)
 
    'These are the lines for the sides of the cone which
    'go from the base up to the peak of the cone...
    
    for i = 1 to numSides
        LBWF.LineInode(LC + numSides + i) = (NC + i)
        LBWF.LineJnode(LC + numSides + i) = (NC + numSides + 1)
    next i
 
    'Define other object properties
    OC = LBWF.ObjectCount(1)
 
    LBWF.ObjectName$(OC + 1)         = ConeName$
    LBWF.ObjectColor$(OC + 1)        = ConeColor$
    LBWF.ObjectFirstNode(OC + 1)     = (NC + 1)
    LBWF.ObjectLastNode(OC + 1)      = (NC + numSides + 1)
    LBWF.ObjectFirstLine(OC + 1)     = (LC + 1)
    LBWF.ObjectLastLine(OC + 1)      = (LC + 2*numSides)
    LBWF.ObjectVisible(OC + 1)       = 1
    LBWF.ObjectLineThickness(OC + 1) = 1
    LBWF.ObjectType$(OC + 1)         = "cone"
    LBWF.ObjectCenterX(OC + 1)       = 0
    LBWF.ObjectCenterY(OC + 1)       = coneheight/2
    LBWF.ObjectCenterZ(OC + 1)       = 0
 
    'Update the node count, the line count, and the object count...

    LBWF.NodeCount(1)   = LBWF.NodeCount(1) + numSides + 1
    LBWF.LineCount(1)   = LBWF.LineCount(1) + 2*numSides
    LBWF.ObjectCount(1) = LBWF.ObjectCount(1) + 1
 
 
End Function
 
''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.CreatePyramid(pyrName$, xdim, zdim, pyrheight, pyrColor$)
 
    'Define the 5 new nodes for this pyramid...
    NC = LBWF.NodeCount(1)
 
    LBWF.NodeWX(NC + 1) = xdim/2      : LBWF.NodeWY(NC + 1) = 0 : LBWF.NodeWZ(NC + 1) = (-1)*zdim/2
    LBWF.NodeWX(NC + 2) = xdim/2      : LBWF.NodeWY(NC + 2) = 0 : LBWF.NodeWZ(NC + 2) = zdim/2
    LBWF.NodeWX(NC + 3) = (-1)*xdim/2 : LBWF.NodeWY(NC + 3) = 0 : LBWF.NodeWZ(NC + 3) = zdim/2
    LBWF.NodeWX(NC + 4) = (-1)*xdim/2 : LBWF.NodeWY(NC + 4) = 0 : LBWF.NodeWZ(NC + 4) = (-1)*zdim/2
 
    LBWF.NodeWX(NC + 5) = 0 
    LBWF.NodeWY(NC + 5) = pyrheight 
    LBWF.NodeWZ(NC + 5) = 0
 
    'Define the 8 new lines for this pyramid...
    LC = LBWF.LineCount(1)
 
    LBWF.LineInode(LC + 1) = (NC + 1) : LBWF.LineJnode(LC + 1) = (NC + 2)
    LBWF.LineInode(LC + 2) = (NC + 2) : LBWF.LineJnode(LC + 2) = (NC + 3)
    LBWF.LineInode(LC + 3) = (NC + 3) : LBWF.LineJnode(LC + 3) = (NC + 4)
    LBWF.LineInode(LC + 4) = (NC + 4) : LBWF.LineJnode(LC + 4) = (NC + 1)
 
    LBWF.LineInode(LC + 5) = (NC + 1) : LBWF.LineJnode(LC + 5) = (NC + 5)
    LBWF.LineInode(LC + 6) = (NC + 2) : LBWF.LineJnode(LC + 6) = (NC + 5)
    LBWF.LineInode(LC + 7) = (NC + 3) : LBWF.LineJnode(LC + 7) = (NC + 5)
    LBWF.LineInode(LC + 8) = (NC + 4) : LBWF.LineJnode(LC + 8) = (NC + 5)
 
    'Define other object properties
    OC = LBWF.ObjectCount(1)
 
    LBWF.ObjectName$(OC + 1)     = pyrName$
    LBWF.ObjectColor$(OC + 1)    = pyrColor$
    LBWF.ObjectFirstNode(OC + 1) = (NC + 1)
    LBWF.ObjectLastNode(OC + 1)  = (NC + 5)
    LBWF.ObjectFirstLine(OC + 1) = (LC + 1)
    LBWF.ObjectLastLine(OC + 1)  = (LC + 8)
    LBWF.ObjectVisible(OC + 1)   = 1
    LBWF.ObjectLineThickness(OC + 1) = 1
    LBWF.ObjectType$(OC + 1)     = "pyramid"
    LBWF.ObjectCenterX(OC + 1)       = 0
    LBWF.ObjectCenterY(OC + 1)       = pyrheight/2
    LBWF.ObjectCenterZ(OC + 1)       = 0
 
    'Update the node count, the line count, and the object count...

    LBWF.NodeCount(1)   = LBWF.NodeCount(1) + 5
    LBWF.LineCount(1)   = LBWF.LineCount(1) + 8
    LBWF.ObjectCount(1) = LBWF.ObjectCount(1) + 1
 
end Function
 
''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.TranslateObject(ObjectName$, transX, transY, transZ)
 
    'Determine the object to be translated by comparing the name
    'argument against a list of object names...
    
    ObjectToTranslate = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectToTranslate = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    FirstNodeToMove = LBWF.ObjectFirstNode(ObjectToTranslate)
    LastNodeToMove  = LBWF.ObjectLastNode(ObjectToTranslate)
 
    for i = FirstNodeToMove to LastNodeToMove
        LBWF.NodeWX(i) = LBWF.NodeWX(i) + transX
        LBWF.NodeWY(i) = LBWF.NodeWY(i) + transY
        LBWF.NodeWZ(i) = LBWF.NodeWZ(i) + transZ
    next i
 
    'As of Library Version 0.6, the array variables
    'which hold the values of the geometric center
    'of the object must be adjusted also

    LBWF.ObjectCenterX(ObjectToTranslate) = LBWF.ObjectCenterX(ObjectToTranslate) + transX
    LBWF.ObjectCenterY(ObjectToTranslate) = LBWF.ObjectCenterY(ObjectToTranslate) + transY
    LBWF.ObjectCenterZ(ObjectToTranslate) = LBWF.ObjectCenterZ(ObjectToTranslate) + transZ
 
 
end Function
 
 
 
''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.CreatePolygon(PolyName$, radius, numSides, PolyColor$)
 
    'Define the new nodes for this polygon...
    NC = LBWF.NodeCount(1)
    pi = 3.14159
    wedgeAngle = (2*pi)/numSides
 
    for i = 1 to numSides
        LBWF.NodeWX(NC + i) = radius*cos((i-1)*wedgeAngle)
        LBWF.NodeWY(NC + i) = 0
        LBWF.NodeWZ(NC + i) = radius*sin((i-1)*wedgeAngle)
    next i
 
    'Define the lines for this polygon...
    LC = LBWF.LineCount(1)
 
    for i = 1 to (numSides - 1)
        LBWF.LineInode(LC + i) = (NC + i)
        LBWF.LineJnode(LC + i) = (NC + i + 1)
    next i
 
    LBWF.LineInode(LC + numSides) = (NC + numSides)
    LBWF.LineJnode(LC + numSides) = (NC + 1)
 
    'Define other object properties
    OC = LBWF.ObjectCount(1)
 
    LBWF.ObjectName$(OC + 1)     = PolyName$
    LBWF.ObjectColor$(OC + 1)    = PolyColor$
    LBWF.ObjectFirstNode(OC + 1) = (NC + 1)
    LBWF.ObjectLastNode(OC + 1)  = (NC + numSides)
    LBWF.ObjectFirstLine(OC + 1) = (LC + 1)
    LBWF.ObjectLastLine(OC + 1)  = (LC + numSides)
    LBWF.ObjectVisible(OC + 1)   = 1
    LBWF.ObjectLineThickness(OC + 1) = 1
    LBWF.ObjectType$(OC + 1)     = "polygon"
    LBWF.ObjectCenterX(OC + 1)       = 0
    LBWF.ObjectCenterY(OC + 1)       = 0
    LBWF.ObjectCenterZ(OC + 1)       = 0
 
    'Update the node count, the line count, and the object count...

    LBWF.NodeCount(1)   = LBWF.NodeCount(1) + numSides
    LBWF.LineCount(1)   = LBWF.LineCount(1) + numSides
    LBWF.ObjectCount(1) = LBWF.ObjectCount(1) + 1
 
 
end Function
 
'''''''''''''''''''''''''''''''''''''''''
Function FF.LBWF.CreateCyl2(Cyl2Name$, radiusBottum, radiusTop, numSides, cyl2height, Cyl2Color$)
 
    'Define the new nodes for this cyl2...
    NC = LBWF.NodeCount(1)
    pi = 3.14159
    wedgeAngle = (2*pi)/numSides
 
    for i = 1 to numSides
        LBWF.NodeWX(NC + i) = radiusBottum*cos((i-1)*wedgeAngle)
        LBWF.NodeWY(NC + i) = 0
        LBWF.NodeWZ(NC + i) = radiusBottum*sin((i-1)*wedgeAngle)
    next i
 
    for i = 1 to numSides
        LBWF.NodeWX(NC + numSides + i) = radiusTop*cos((i-1)*wedgeAngle)
        LBWF.NodeWY(NC + numSides + i) = cyl2height
        LBWF.NodeWZ(NC + numSides + i) = radiusTop*sin((i-1)*wedgeAngle)
    next i
 
    'Define the new lines for this cyl2...
    
    LC = LBWF.LineCount(1)
 
    'These are the new lines for the bottom face of the cyl2...
    for i = 1 to (numSides - 1)
        LBWF.LineInode(LC + i) = (NC + i)
        LBWF.LineJnode(LC + i) = (NC + i + 1)
    next i
 
    LBWF.LineInode(LC + numSides) = (NC + numSides)
    LBWF.LineJnode(LC + numSides) = (NC + 1)
 
    'These are the new lines for the top face of the cyl2...
    for i = 1 to (numSides - 1)
        LBWF.LineInode(LC + numSides + i) = (NC + numSides + i)
        LBWF.LineJnode(LC + numSides + i) = (NC + numSides + i + 1)
    next i
 
    LBWF.LineInode(LC + 2*numSides) = (NC + 2*numSides)
    LBWF.LineJnode(LC + 2*numSides) = (NC + numSides + 1)
 
    'These are the side lines of the cyl2...
    
    for i = 1 to numSides
        LBWF.LineInode(LC + 2*numSides + i) = (NC + i)
        LBWF.LineJnode(LC + 2*numSides + i) = (NC + numSides + i)
    next i
 
    'Define other object properties
    OC = LBWF.ObjectCount(1)
 
    LBWF.ObjectName$(OC + 1)     = Cyl2Name$
    LBWF.ObjectColor$(OC + 1)    = Cyl2Color$
    LBWF.ObjectFirstNode(OC + 1) = (NC + 1)
    LBWF.ObjectLastNode(OC + 1)  = (NC + 2*numSides)
    LBWF.ObjectFirstLine(OC + 1) = (LC + 1)
    LBWF.ObjectLastLine(OC + 1)  = (LC + 3*numSides)
    LBWF.ObjectVisible(OC + 1)   = 1
    LBWF.ObjectLineThickness(OC + 1) = 1
    LBWF.ObjectType$(OC + 1)     = "cyl2"
    LBWF.ObjectCenterX(OC + 1)       = 0
    LBWF.ObjectCenterY(OC + 1)       = cyl2height/2
    LBWF.ObjectCenterZ(OC + 1)       = 0
 
    'Update the node count, the line count, and the object count...

    LBWF.NodeCount(1)   = LBWF.NodeCount(1) + 2*numSides
    LBWF.LineCount(1)   = LBWF.LineCount(1) + 3*numSides
    LBWF.ObjectCount(1) = LBWF.ObjectCount(1) + 1
 
End Function
 
'''''''''''''''''''''''''''''''''''''''''

 
Function FF.LBWF.CreateCylinder(ObjectName$, radius, numSides, cylheight, ObjectColor$)
 
    'Define the new nodes for this cylinder...
    NC = LBWF.NodeCount(1)
    pi = 3.14159
    wedgeAngle = (2*pi)/numSides
 
    for i = 1 to numSides
        LBWF.NodeWX(NC + i) = radius*cos((i-1)*wedgeAngle)
        LBWF.NodeWY(NC + i) = 0
        LBWF.NodeWZ(NC + i) = radius*sin((i-1)*wedgeAngle)
    next i
 
    for i = 1 to numSides
        LBWF.NodeWX(NC + numSides + i) = radius*cos((i-1)*wedgeAngle)
        LBWF.NodeWY(NC + numSides + i) = cylheight
        LBWF.NodeWZ(NC + numSides + i) = radius*sin((i-1)*wedgeAngle)
    next i
 
    'Define the new lines for this cylinder...
    
    LC = LBWF.LineCount(1)
 
    'These are the new lines for the bottom face of the cylinder...
    for i = 1 to (numSides - 1)
        LBWF.LineInode(LC + i) = (NC + i)
        LBWF.LineJnode(LC + i) = (NC + i + 1)
    next i
 
    LBWF.LineInode(LC + numSides) = (NC + numSides)
    LBWF.LineJnode(LC + numSides) = (NC + 1)
 
    'These are the new lines for the top face of the cylinder...
    for i = 1 to (numSides - 1)
        LBWF.LineInode(LC + numSides + i) = (NC + numSides + i)
        LBWF.LineJnode(LC + numSides + i) = (NC + numSides + i + 1)
    next i
 
    LBWF.LineInode(LC + 2*numSides) = (NC + 2*numSides)
    LBWF.LineJnode(LC + 2*numSides) = (NC + numSides + 1)
 
    'These are the side lines of the cylinder...
    
    for i = 1 to numSides
        LBWF.LineInode(LC + 2*numSides + i) = (NC + i)
        LBWF.LineJnode(LC + 2*numSides + i) = (NC + numSides + i)
    next i
 
    'Define other object properties
    OC = LBWF.ObjectCount(1)
 
    LBWF.ObjectName$(OC + 1)     = ObjectName$
    LBWF.ObjectColor$(OC + 1)    = ObjectColor$
    LBWF.ObjectFirstNode(OC + 1) = (NC + 1)
    LBWF.ObjectLastNode(OC + 1)  = (NC + 2*numSides)
    LBWF.ObjectFirstLine(OC + 1) = (LC + 1)
    LBWF.ObjectLastLine(OC + 1)  = (LC + 3*numSides)
    LBWF.ObjectVisible(OC + 1)   = 1
    LBWF.ObjectLineThickness(OC + 1) = 1
    LBWF.ObjectType$(OC + 1)     = "cylinder"
    LBWF.ObjectCenterX(OC + 1)       = 0
    LBWF.ObjectCenterY(OC + 1)       = cylheight/2
    LBWF.ObjectCenterZ(OC + 1)       = 0
 
    'Update the node count, the line count, and the object count...

    LBWF.NodeCount(1)   = LBWF.NodeCount(1) + 2*numSides
    LBWF.LineCount(1)   = LBWF.LineCount(1) + 3*numSides
    LBWF.ObjectCount(1) = LBWF.ObjectCount(1) + 1
 
 
end Function
 
''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.CreateBox(ObjectName$, xdim, zdim, boxheight, ObjectColor$)
 
    'Define the 8 new nodes for this box...
    NC = LBWF.NodeCount(1)
    BH = boxheight
 
    LBWF.NodeWX(NC + 1) = xdim/2      : LBWF.NodeWY(NC + 1) = 0 : LBWF.NodeWZ(NC + 1) = (-1)*zdim/2
    LBWF.NodeWX(NC + 2) = xdim/2      : LBWF.NodeWY(NC + 2) = 0 : LBWF.NodeWZ(NC + 2) = zdim/2
    LBWF.NodeWX(NC + 3) = (-1)*xdim/2 : LBWF.NodeWY(NC + 3) = 0 : LBWF.NodeWZ(NC + 3) = zdim/2
    LBWF.NodeWX(NC + 4) = (-1)*xdim/2 : LBWF.NodeWY(NC + 4) = 0 : LBWF.NodeWZ(NC + 4) = (-1)*zdim/2
 
    LBWF.NodeWX(NC + 5) = xdim/2      : LBWF.NodeWY(NC + 5) = BH : LBWF.NodeWZ(NC + 5) = (-1)*zdim/2
    LBWF.NodeWX(NC + 6) = xdim/2      : LBWF.NodeWY(NC + 6) = BH : LBWF.NodeWZ(NC + 6) = zdim/2
    LBWF.NodeWX(NC + 7) = (-1)*xdim/2 : LBWF.NodeWY(NC + 7) = BH : LBWF.NodeWZ(NC + 7) = zdim/2
    LBWF.NodeWX(NC + 8) = (-1)*xdim/2 : LBWF.NodeWY(NC + 8) = BH : LBWF.NodeWZ(NC + 8) = (-1)*zdim/2
 
 
    'Define 12 new lines for this box...
    LC = LBWF.LineCount(1)
 
    LBWF.LineInode(LC + 1) = (NC + 1) : LBWF.LineJnode(LC + 1) = (NC + 2)
    LBWF.LineInode(LC + 2) = (NC + 2) : LBWF.LineJnode(LC + 2) = (NC + 3)
    LBWF.LineInode(LC + 3) = (NC + 3) : LBWF.LineJnode(LC + 3) = (NC + 4)
    LBWF.LineInode(LC + 4) = (NC + 4) : LBWF.LineJnode(LC + 4) = (NC + 1)
 
    LBWF.LineInode(LC + 5) = (NC + 1) : LBWF.LineJnode(LC + 5) = (NC + 5)
    LBWF.LineInode(LC + 6) = (NC + 2) : LBWF.LineJnode(LC + 6) = (NC + 6)
    LBWF.LineInode(LC + 7) = (NC + 3) : LBWF.LineJnode(LC + 7) = (NC + 7)
    LBWF.LineInode(LC + 8) = (NC + 4) : LBWF.LineJnode(LC + 8) = (NC + 8)
 
    LBWF.LineInode(LC + 9)  = (NC + 5) : LBWF.LineJnode(LC + 9)  = (NC + 6)
    LBWF.LineInode(LC + 10) = (NC + 6) : LBWF.LineJnode(LC + 10) = (NC + 7)
    LBWF.LineInode(LC + 11) = (NC + 7) : LBWF.LineJnode(LC + 11) = (NC + 8)
    LBWF.LineInode(LC + 12) = (NC + 8) : LBWF.LineJnode(LC + 12) = (NC + 5)
 
    'Define other object properties
    OC = LBWF.ObjectCount(1)
 
    LBWF.ObjectName$(OC + 1)     = ObjectName$
    LBWF.ObjectColor$(OC + 1)    = ObjectColor$
    LBWF.ObjectFirstNode(OC + 1) = (NC + 1)
    LBWF.ObjectLastNode(OC + 1)  = (NC + 8)
    LBWF.ObjectFirstLine(OC + 1) = (LC + 1)
    LBWF.ObjectLastLine(OC + 1)  = (LC + 12)
    LBWF.ObjectVisible(OC + 1)   = 1
    LBWF.ObjectLineThickness(OC + 1) = 1
    LBWF.ObjectType$(OC + 1)     = "box"
    LBWF.ObjectCenterX(OC + 1)       = 0
    LBWF.ObjectCenterY(OC + 1)       = boxheight/2
    LBWF.ObjectCenterZ(OC + 1)       = 0
 
    'Update the node count, the line count, and the object count...

    LBWF.NodeCount(1)   = LBWF.NodeCount(1) + 8
    LBWF.LineCount(1)   = LBWF.LineCount(1) + 12
    LBWF.ObjectCount(1) = LBWF.ObjectCount(1) + 1
 
 
    FF.LBWF.CreateBox = 0
 
end function
 
'''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.CameraLocation(CamX, CamY, CamZ)
 
    LBWF.CamX(1) = CamX
    LBWF.CamY(1) = CamY
    LBWF.CamZ(1) = CamZ
 
End Function
 
'''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.ViewingCenter(VCtrX, VCtrY, VCtrZ)
 
    LBWF.VCtrX(1) = VCtrX
    LBWF.VCtrY(1) = VCtrY
    LBWF.VCtrZ(1) = VCtrZ
 
End Function
'''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.ZoomFactor(ZoomFac)
 
    LBWF.ZoomFac(1) = ZoomFac
 
End Function
 
'''''''''''''''''''''''''''''''''''''''''
Function FF.LBWF.Camera(CamX, CamY, CamZ, VCtrX, VCtrY, VCtrZ, ZoomFac)
 
    LBWF.CamX(1) = CamX
    LBWF.CamY(1) = CamY
    LBWF.CamZ(1) = CamZ
    LBWF.VCtrX(1) = VCtrX
    LBWF.VCtrY(1) = VCtrY
    LBWF.VCtrZ(1) = VCtrZ
    LBWF.ZoomFac(1) = ZoomFac
 
end Function
 
'''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.ScreenCenter(ScrCenterX, ScrCenterY)
 
    LBWF.ScrCenterX(1) = ScrCenterX
    LBWF.ScrCenterY(1) = ScrCenterY
 
end Function
 
'''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.BackGroundColor(BGColor$)
 
    LBWF.BackGroundColor$(1) = BGColor$
 
end Function
 
 
'''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.ClearGraphicScreen()
 
    print #main.wfscene, "cls"
    print #main.wfscene, "fill "; LBWF.BackGroundColor$(1)
 
end Function
''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.DrawObjectsOfType(ObjectType$)
 
    OC = LBWF.ObjectCount(1)
 
    for q = 1 to OC
 
        if (LBWF.ObjectType$(q) = ObjectType$) then
 
            ObjectToDraw = q
 
            FirstNodeOfObject = LBWF.ObjectFirstNode(ObjectToDraw)
            LastNodeOfObject  = LBWF.ObjectLastNode(ObjectToDraw)
            FirstLineOfObject = LBWF.ObjectFirstLine(ObjectToDraw)
            LastLineOfObject  = LBWF.ObjectLastLine(ObjectToDraw)
 
            'The documentation for this elaborate procedure will
            'not be contained herein.  To see the documentation,
            'visit the function FF.LBWF.DrawAllObjects()

            Cam2CtrX = (LBWF.VCtrX(1) - LBWF.CamX(1))
            Cam2CtrY = (LBWF.VCtrY(1) - LBWF.CamY(1))
            Cam2CtrZ = (LBWF.VCtrZ(1) - LBWF.CamZ(1))
 
            LenCam2Ctr = sqr(Cam2CtrX^2 + Cam2CtrY^2 + Cam2CtrZ^2)
 
            virtualXi = (-1)*(Cam2CtrZ)
            virtualXj = 0
            virtualXk = Cam2CtrX
 
            LenVirtualX = sqr(virtualXi^2 + virtualXj^2 + virtualXk^2)
            virtualXi = virtualXi / LenVirtualX
            virtualXj = virtualXj / LenVirtualX
            virtualXk = virtualXk / LenVirtualX
 
            virtualYi = (-1)*(virtualXk * Cam2CtrY)
            virtualYj = (virtualXk * Cam2CtrX) - (virtualXi * Cam2CtrZ)
            virtualYk = (virtualXi * Cam2CtrY)
 
            LenVirtualY = sqr(virtualYi^2 + virtualYj^2 + virtualYk^2)
            virtualYi = virtualYi / LenVirtualY
            virtualYj = virtualYj / LenVirtualY
            virtualYk = virtualYk / LenVirtualY
 
            virtualXi = virtualXi / LenCam2Ctr
            virtualXj = virtualXj / LenCam2Ctr
            virtualXk = virtualXk / LenCam2Ctr
 
            virtualYi = virtualYi / LenCam2Ctr
            virtualYj = virtualYj / LenCam2Ctr
            virtualYk = virtualYk / LenCam2Ctr
 
            '''''''''''''''''''''''''''''''''''''''''''''''
            'FIND SCREEN COORDINATES OF OBJECT NODES
            '''''''''''''''''''''''''''''''''''''''''''''''
    
            for i = FirstNodeOfObject to LastNodeOfObject
 
                'Establish the vector components of the Camera-to-Node Vector
                Cam2NodeX = (LBWF.NodeWX(i) - LBWF.CamX(1))
                Cam2NodeY = (LBWF.NodeWY(i) - LBWF.CamY(1))
                Cam2NodeZ = (LBWF.NodeWZ(i) - LBWF.CamZ(1))
 
                numerator   = Cam2CtrX^2 + Cam2CtrY^2 + Cam2CtrZ^2
                denominator = (Cam2NodeX * Cam2CtrX) + (Cam2NodeY * Cam2CtrY) + (Cam2NodeZ * Cam2CtrZ)
                t = (numerator / denominator)
 
                ipX = LBWF.CamX(1) + Cam2NodeX*t
                ipY = LBWF.CamY(1) + Cam2NodeY*t
                ipZ = LBWF.CamZ(1) + Cam2NodeZ*t
 
                Ctr2ipX = (ipX - LBWF.VCtrX(1))
                Ctr2ipY = (ipY - LBWF.VCtrY(1))
                Ctr2ipZ = (ipZ - LBWF.VCtrZ(1))
 
                PX = (Ctr2ipX*virtualXi) + (Ctr2ipY*virtualXj) + (Ctr2ipZ*virtualXk)
 
                SCM = 500   'Note: SCM is an acronym for "Secondary Scale Multiplier".
                            '      This value was found by experimentation when it was
                            '      observed that the Scale factor by itself was
                            '      too small without a multiplier.

                LBWF.NodeSX(i) = LBWF.ScrCenterX(1) + (SCM*LBWF.ZoomFac(1) * PX)
 
                PY = (Ctr2ipX*virtualYi) + (Ctr2ipY*virtualYj) + (Ctr2ipZ*virtualYk)
 
                LBWF.NodeSY(i) = LBWF.ScrCenterY(1) - (SCM*LBWF.ZoomFac(1) * PY)
 
            next i
 
            'With the the screen coordinates of the nodes determined,
            'it is time to draw each line of the object...

                'Set the drawing color for the object...
                DrawingColor$ = LBWF.ObjectColor$(ObjectToDraw)
                print #main.wfscene, "color "; DrawingColor$
 
                'Set the line thickness for the object...
                LineThickness = LBWF.ObjectLineThickness(ObjectToDraw)
                print #main.wfscene, "size "; LineThickness
 
                for i = FirstLineOfObject to LastLineOfObject
                    x1 = LBWF.NodeSX(LBWF.LineInode(i))
                    y1 = LBWF.NodeSY(LBWF.LineInode(i))
                    x2 = LBWF.NodeSX(LBWF.LineJnode(i))
                    y2 = LBWF.NodeSY(LBWF.LineJnode(i))
 
                    print #main.wfscene, "line "; x1; " "; y1; " "; x2; " "; y2
                next i
 
        end if
 
    next q
 
    'Reset the default line thickness back to 1...
    print #main.wfscene, "size 1" 
 
    'Set the default drawing color back to black...
    print #main.wfscene, "color black"
 
End Function
 
''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.DrawObject(ObjectName$)
 
    ObjectToDraw = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectToDraw = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    FirstNodeOfObject = LBWF.ObjectFirstNode(ObjectToDraw)
    LastNodeOfObject  = LBWF.ObjectLastNode(ObjectToDraw)
    FirstLineOfObject = LBWF.ObjectFirstLine(ObjectToDraw)
    LastLineOfObject  = LBWF.ObjectLastLine(ObjectToDraw)
 
    'The documentation for this elaborate procedure will
    'not be contained herein.  To see the documentation,
    'visit the function FF.LBWF.DrawAllObjects()

    Cam2CtrX = (LBWF.VCtrX(1) - LBWF.CamX(1))
    Cam2CtrY = (LBWF.VCtrY(1) - LBWF.CamY(1))
    Cam2CtrZ = (LBWF.VCtrZ(1) - LBWF.CamZ(1))
 
    LenCam2Ctr = sqr(Cam2CtrX^2 + Cam2CtrY^2 + Cam2CtrZ^2)
 
    virtualXi = (-1)*(Cam2CtrZ)
    virtualXj = 0
    virtualXk = Cam2CtrX
 
    LenVirtualX = sqr(virtualXi^2 + virtualXj^2 + virtualXk^2)
    virtualXi = virtualXi / LenVirtualX
    virtualXj = virtualXj / LenVirtualX
    virtualXk = virtualXk / LenVirtualX
 
    virtualYi = (-1)*(virtualXk * Cam2CtrY)
    virtualYj = (virtualXk * Cam2CtrX) - (virtualXi * Cam2CtrZ)
    virtualYk = (virtualXi * Cam2CtrY)
 
    LenVirtualY = sqr(virtualYi^2 + virtualYj^2 + virtualYk^2)
    virtualYi = virtualYi / LenVirtualY
    virtualYj = virtualYj / LenVirtualY
    virtualYk = virtualYk / LenVirtualY
 
    virtualXi = virtualXi / LenCam2Ctr
    virtualXj = virtualXj / LenCam2Ctr
    virtualXk = virtualXk / LenCam2Ctr
 
    virtualYi = virtualYi / LenCam2Ctr
    virtualYj = virtualYj / LenCam2Ctr
    virtualYk = virtualYk / LenCam2Ctr
 
    '''''''''''''''''''''''''''''''''''''''''''''''
    'FIND SCREEN COORDINATES OF OBJECT NODES
    '''''''''''''''''''''''''''''''''''''''''''''''
    
    for i = FirstNodeOfObject to LastNodeOfObject
 
        'Establish the vector components of the Camera-to-Node Vector
        Cam2NodeX = (LBWF.NodeWX(i) - LBWF.CamX(1))
        Cam2NodeY = (LBWF.NodeWY(i) - LBWF.CamY(1))
        Cam2NodeZ = (LBWF.NodeWZ(i) - LBWF.CamZ(1))
 
        numerator   = Cam2CtrX^2 + Cam2CtrY^2 + Cam2CtrZ^2
        denominator = (Cam2NodeX * Cam2CtrX) + (Cam2NodeY * Cam2CtrY) + (Cam2NodeZ * Cam2CtrZ)
        t = (numerator / denominator)
 
        ipX = LBWF.CamX(1) + Cam2NodeX*t
        ipY = LBWF.CamY(1) + Cam2NodeY*t
        ipZ = LBWF.CamZ(1) + Cam2NodeZ*t
 
        Ctr2ipX = (ipX - LBWF.VCtrX(1))
        Ctr2ipY = (ipY - LBWF.VCtrY(1))
        Ctr2ipZ = (ipZ - LBWF.VCtrZ(1))
 
        PX = (Ctr2ipX*virtualXi) + (Ctr2ipY*virtualXj) + (Ctr2ipZ*virtualXk)
 
        SCM = 500   'Note: SCM is an acronym for "Secondary Scale Multiplier".
                    '      This value was found by experimentation when it was
                    '      observed that the Scale factor by itself was
                    '      too small without a multiplier.

        LBWF.NodeSX(i) = LBWF.ScrCenterX(1) + (SCM*LBWF.ZoomFac(1) * PX)
 
        PY = (Ctr2ipX*virtualYi) + (Ctr2ipY*virtualYj) + (Ctr2ipZ*virtualYk)
 
        LBWF.NodeSY(i) = LBWF.ScrCenterY(1) - (SCM*LBWF.ZoomFac(1) * PY)
 
    next i
 
    'With the the screen coordinates of the nodes determined,
    'it is time to draw each line of the object...

        'Set the drawing color for the object...
        DrawingColor$ = LBWF.ObjectColor$(ObjectToDraw)
        print #main.wfscene, "color "; DrawingColor$
 
        'Set the line thickness for the object...
        LineThickness = LBWF.ObjectLineThickness(ObjectToDraw)
        print #main.wfscene, "size "; LineThickness
 
        for i = FirstLineOfObject to LastLineOfObject
            x1 = LBWF.NodeSX(LBWF.LineInode(i))
            y1 = LBWF.NodeSY(LBWF.LineInode(i))
            x2 = LBWF.NodeSX(LBWF.LineJnode(i))
            y2 = LBWF.NodeSY(LBWF.LineJnode(i))
 
            print #main.wfscene, "line "; x1; " "; y1; " "; x2; " "; y2
        next i
 
    'Reset the default line thickness back to 1...
    print #main.wfscene, "size 1" 
 
    'Set the default drawing color back to black...
    print #main.wfscene, "color black"
 
end Function
 
''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.DrawAllObjects()
 
    'Find the camera-to-viewing-center vector...

    Cam2CtrX = (LBWF.VCtrX(1) - LBWF.CamX(1))
    Cam2CtrY = (LBWF.VCtrY(1) - LBWF.CamY(1))
    Cam2CtrZ = (LBWF.VCtrZ(1) - LBWF.CamZ(1))
 
    'Length of the camera-to-viewing-center vector...

    LenCam2Ctr = sqr(Cam2CtrX^2 + Cam2CtrY^2 + Cam2CtrZ^2)
 
    'The vector equation for the virtual image plane can be written
    'as follows:
    '
    'Cam2CtrX*(x - CtrX) + Cam2CtrY*(y - CtrY) + Cam2CtrZ*(z - CtrZ) = 0

    'Imagine a unit vector pointing in the -Y direction.  The
    'components of this vector are 0i -1j + 0k.  When we take
    'the cross product of this vector with the Camera-to-Center
    'vector, the result is the virtual x-axis vector imposed
    'upon the virtual image plane.  These are the vector
    'components of the virtual x-axis vector.

    virtualXi = (-1)*(Cam2CtrZ)
    virtualXj = 0
    virtualXk = Cam2CtrX
 
    'Find the length of this vector, then divide components
    'by this length.

    LenVirtualX = sqr(virtualXi^2 + virtualXj^2 + virtualXk^2)
    virtualXi = virtualXi / LenVirtualX
    virtualXj = virtualXj / LenVirtualX
    virtualXk = virtualXk / LenVirtualX
 
 
    'In order to find the virtual y-axis on the image plane,
    'we need to take the cross product of the virtual x-axis
    'vector with the Camera-to-Center Vector.  Given below is
    'the result of that cross product.

    virtualYi = (-1)*(virtualXk * Cam2CtrY)
    virtualYj = (virtualXk * Cam2CtrX) - (virtualXi * Cam2CtrZ)
    virtualYk = (virtualXi * Cam2CtrY)
 
    'Find the length of this vector, then divide the
    'components by this length

    LenVirtualY = sqr(virtualYi^2 + virtualYj^2 + virtualYk^2)
    virtualYi = virtualYi / LenVirtualY
    virtualYj = virtualYj / LenVirtualY
    virtualYk = virtualYk / LenVirtualY
 
    'Divide the unit virtual X-axis vector and the
    'virtual Y-axis vector by LenCam2Ctr.  This transformation
    'of these two vectors will allow the objects to get
    'smaller as the camera moves away from the viewing
    'center, or get larger as the camera moves toward
    'the viewing center.

    virtualXi = virtualXi / LenCam2Ctr
    virtualXj = virtualXj / LenCam2Ctr
    virtualXk = virtualXk / LenCam2Ctr
 
    virtualYi = virtualYi / LenCam2Ctr
    virtualYj = virtualYj / LenCam2Ctr
    virtualYk = virtualYk / LenCam2Ctr
 
    '''''''''''''''''''''''''''''''''''''''''''''''
    'OBJECT NODES *** OBJECT NODES *** OBJECT NODES
    '''''''''''''''''''''''''''''''''''''''''''''''
    'For each and every node in every object,
    'find the screen coordinates

    for i = 1 to LBWF.NodeCount(1)
 
        'Establish the vector components of the Camera-to-Node Vector
        Cam2NodeX = (LBWF.NodeWX(i) - LBWF.CamX(1))
        Cam2NodeY = (LBWF.NodeWY(i) - LBWF.CamY(1))
        Cam2NodeZ = (LBWF.NodeWZ(i) - LBWF.CamZ(1))
 
        'The parametric equations for the Camera-to-Node Vector
        'can be written as follows:
        '
        'x = CamX + Cam2NodeX*t
        'y = CamY + Cam2NodeY*t
        'z = CamZ + Cam2NodeZ*t
        '
        'Plug these three equations into the vector equation
        'for the virtual image plane...
        '
        'Cam2CtrX*(x - CtrX) + Cam2CtrY*(y - CtrY) + Cam2CtrZ*(z - CtrZ) = 0
        '
        '...and then solve for t

        numerator   = Cam2CtrX^2 + Cam2CtrY^2 + Cam2CtrZ^2
        denominator = (Cam2NodeX * Cam2CtrX) + (Cam2NodeY * Cam2CtrY) + (Cam2NodeZ * Cam2CtrZ)
        t = (numerator / denominator)
 
        'Having solved for t, determine the point in space
        '(ipx, ipy, ipz) where 'the Camera-to-Node vector intersects
        'the virtual image plane.

        ipX = LBWF.CamX(1) + Cam2NodeX*t
        ipY = LBWF.CamY(1) + Cam2NodeY*t
        ipZ = LBWF.CamZ(1) + Cam2NodeZ*t
 
        'Establish the vector components of the vector from the
        'center to (ipx, ipy, ipz).

        Ctr2ipX = (ipX - LBWF.VCtrX(1))
        Ctr2ipY = (ipY - LBWF.VCtrY(1))
        Ctr2ipZ = (ipZ - LBWF.VCtrZ(1))
 
        'The projection of this vector along the virtual X-axis
        'is the dot product of this vector with the unit vector
        'along the virtual X-Axis"

        PX = (Ctr2ipX*virtualXi) + (Ctr2ipY*virtualXj) + (Ctr2ipZ*virtualXk)
 
        SCM = 500   'Note: SCM is an acronym for "Secondary Scale Multiplier".
                    '      This value was found by experimentation when it was
                    '      observed that the Scale factor by itself was
                    '      too small without a multiplier.

        LBWF.NodeSX(i) = LBWF.ScrCenterX(1) + (SCM*LBWF.ZoomFac(1) * PX)
 
        'The projection of this vector along the virtual Y-axis
        'is the dot product of this vector with the unit vector
        'along the virtual Y-Axis"

        PY = (Ctr2ipX*virtualYi) + (Ctr2ipY*virtualYj) + (Ctr2ipZ*virtualYk)
 
        LBWF.NodeSY(i) = LBWF.ScrCenterY(1) - (SCM*LBWF.ZoomFac(1) * PY)
 
    next i
 
    '''''''''''''''''''''''''''''''''''''''''
    'AXES NODES *** AXES NODES *** AXES NODES 
    '''''''''''''''''''''''''''''''''''''''''

    for i = 1 to 4
 
        'Establish the vector components of the Camera-to-Node Vector
        Cam2NodeX = (LBWF.AxesWorldX(i) - LBWF.CamX(1))
        Cam2NodeY = (LBWF.AxesWorldY(i) - LBWF.CamY(1))
        Cam2NodeZ = (LBWF.AxesWorldZ(i) - LBWF.CamZ(1))
 
        numerator   = Cam2CtrX^2 + Cam2CtrY^2 + Cam2CtrZ^2
        denominator = (Cam2NodeX * Cam2CtrX) + (Cam2NodeY * Cam2CtrY) + (Cam2NodeZ * Cam2CtrZ)
        t = (numerator / denominator)
 
        ipX = LBWF.CamX(1) + Cam2NodeX*t
        ipY = LBWF.CamY(1) + Cam2NodeY*t
        ipZ = LBWF.CamZ(1) + Cam2NodeZ*t
 
        Ctr2ipX = (ipX - LBWF.VCtrX(1))
        Ctr2ipY = (ipY - LBWF.VCtrY(1))
        Ctr2ipZ = (ipZ - LBWF.VCtrZ(1))
 
        PX = (Ctr2ipX*virtualXi) + (Ctr2ipY*virtualXj) + (Ctr2ipZ*virtualXk)
 
        SCM = 500   
 
        LBWF.AxesScreenX(i) = LBWF.ScrCenterX(1) + (SCM*LBWF.ZoomFac(1) * PX)
 
        PY = (Ctr2ipX*virtualYi) + (Ctr2ipY*virtualYj) + (Ctr2ipZ*virtualYk)
 
        LBWF.AxesScreenY(i) = LBWF.ScrCenterY(1) - (SCM*LBWF.ZoomFac(1) * PY)
 
    next i
 
    'If the "visible" property of the axes is set to 1,
    'then draw the axes on the screen...
    
    if (LBWF.AxesVisible(1) = 1) then
 
        'Set the line thickness for the axes...
        print #main.wfscene, "size "; LBWF.AxesLineThickness(1)
 
        'Draw the x-axis (set color for x-axis first)
        print #main.wfscene, "color "; LBWF.XaxisColor$(1)
        x1 = LBWF.AxesScreenX(1) : y1 = LBWF.AxesScreenY(1)
        x2 = LBWF.AxesScreenX(2) : y2 = LBWF.AxesScreenY(2)
        print #main.wfscene, "line "; x1; " "; y1; " "; x2; " "; y2
 
        'Draw the y-axis (set color for y-axis first)
        print #main.wfscene, "color "; LBWF.YaxisColor$(1)
        x1 = LBWF.AxesScreenX(1) : y1 = LBWF.AxesScreenY(1)
        x2 = LBWF.AxesScreenX(3) : y2 = LBWF.AxesScreenY(3)
        print #main.wfscene, "line "; x1; " "; y1; " "; x2; " "; y2
 
        'Draw the z-axis (set color for z-axis first)
        print #main.wfscene, "color "; LBWF.ZaxisColor$(1)
        x1 = LBWF.AxesScreenX(1) : y1 = LBWF.AxesScreenY(1)
        x2 = LBWF.AxesScreenX(4) : y2 = LBWF.AxesScreenY(4)
        print #main.wfscene, "line "; x1; " "; y1; " "; x2; " "; y2
 
        'Reset the line thickness back to 1...
        print #main.wfscene, "size 1"
 
    end if
 
    'Now that the screen coordinates of all of the nodes
    'have been determined, it is time to draw all of the
    'lines.  Draw the lines one object at a time, so
    'that line colors can be changed between objects...

    For obj = 1 to LBWF.ObjectCount(1)
 
    'Draw the object only if its "visible" property is set to 1...
    
    if (LBWF.ObjectVisible(obj) = 1) then
 
        'Set the drawing color for the object...
        DrawingColor$ = LBWF.ObjectColor$(obj)
        print #main.wfscene, "color "; DrawingColor$
 
        'Set the line thickness for the object...
        LineThickness = LBWF.ObjectLineThickness(obj)
        print #main.wfscene, "size "; LineThickness
 
        FirstLine = LBWF.ObjectFirstLine(obj)
        LastLine  = LBWF.ObjectLastLine(obj)
 
        for i = FirstLine to LastLine
            x1 = LBWF.NodeSX(LBWF.LineInode(i))
            y1 = LBWF.NodeSY(LBWF.LineInode(i))
            x2 = LBWF.NodeSX(LBWF.LineJnode(i))
            y2 = LBWF.NodeSY(LBWF.LineJnode(i))
 
            print #main.wfscene, "line "; x1; " "; y1; " "; x2; " "; y2
        next i
 
        'If needed, pause during testing of drawn objects...
        'PPP = FF.LBWF.PauseMilliseconds(1000)

    end if
 
 
    next obj
 
    'Reset the default line thickness back to 1...
    print #main.wfscene, "size 1" 
 
    'Set the default drawing color back to black...
    print #main.wfscene, "color black"
 
end Function
 
''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.RequestLibraryResources$()
 
    FF.LBWF.RequestLibraryResources$ = str$(LBWF.NodeResources(1)) + "  " + _
                                       str$(LBWF.LineResources(1)) + "  " + _
                                       str$(LBWF.ObjectResources(1))
 
end Function
 
''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.RequestRemainingResources$()
 
    RemainingNodes   = LBWF.NodeResources(1) - LBWF.NodeCount(1)
    RemainingLines   = LBWF.LineResources(1) - LBWF.LineCount(1)
    RemainingObjects = LBWF.ObjectResources(1) - LBWF.ObjectCount(1)
 
    FF.LBWF.RequestRemainingResources$ = str$(RemainingNodes) + "  " + _
                                         str$(RemainingLines) + "  " + _
                                         str$(RemainingObjects)
 
end Function
 
''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.RequestObjectGeometricCenter$(ObjectName$)
 
    'Determine the object on which to generate a report
    'by comparing the name argument against a list of object names...
    
    ObjectOfReport = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectOfReport = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    ObjectCenterX = LBWF.ObjectCenterX(ObjectOfReport)
    ObjectCenterY = LBWF.ObjectCenterY(ObjectOfReport)
    ObjectCenterZ = LBWF.ObjectCenterZ(ObjectOfReport)
 
    FF.LBWF.RequestObjectGeometricCenter$ = str$(ObjectCenterX) + "  " + _
                                            str$(ObjectCenterY) + "  " + _
                                            str$(ObjectCenterZ)
 
end Function
'''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.MoveObjectAbsolute(ObjectName$, pX, pY, pZ)
 
    ObjectCenter$ = FF.LBWF.RequestObjectGeometricCenter$(ObjectName$)
 
    currentCenterX = val(word$(ObjectCenter$, 1))
    currentCenterY = val(word$(ObjectCenter$, 2))
    currentCenterZ = val(word$(ObjectCenter$, 3))
 
    transX = pX - currentCenterX
    transY = pY - currentCenterY
    transZ = pZ - currentCenterZ
 
    'Now, call the function which translates an object.
    'This will translate the object to the absolute
    'point identified by (pX,pY,pZ).
    
    AAA = FF.LBWF.TranslateObject(ObjectName$, transX, transY, transZ)
 
end Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.RequestObjectColor$(ObjectName$)
 
    'Find the index number of the object by comparing
    'it against all the names in the list of objects...
    
    ObjectOfReport = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectOfReport = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    FF.LBWF.RequestObjectColor$ = LBWF.ObjectColor$(ObjectOfReport)
 
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.RequestObjectLineThickness(ObjectName$)
 
    'Find the index number of the object by comparing
    'it against all the names in the list of objects...
    
    ObjectOfReport = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectOfReport = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    FF.LBWF.RequestObjectLineThickness = LBWF.ObjectLineThickness(ObjectOfReport)
 
End Function
 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function FF.LBWF.HideAllObjects()
 
    OC = LBWF.ObjectCount(1)
 
    for i = 1 to OC
        LBWF.ObjectVisible(i) = 0
    next i
 
 
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.ShowAllObjects()
 
    OC = LBWF.ObjectCount(1)
 
    for i = 1 to OC
        LBWF.ObjectVisible(i) = 1
    next i
 
 
End Function
 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function FF.LBWF.RequestObjectType$(ObjectName$)
 
    ObjectToIdentifyType = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectToIdentifyType = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    FF.LBWF.RequestObjectType$ = LBWF.ObjectType$(ObjectToIdentifyType)
 
End Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function FF.LBWF.RotateObjectAboutY(ObjectName$, YRotationInDegrees)
 
    'Multiply the rotation angle by (-1)
    YRotationInDegrees = (-1) * YRotationInDegrees
 
    pi = 3.14159
    YRotRads = (YRotationInDegrees/360)*(2*pi)
 
    ObjectToRotate = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectToRotate = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    ObjectCenter$ = FF.LBWF.RequestObjectGeometricCenter$(ObjectName$)
 
    CenterX = val(word$(ObjectCenter$,1))
    CenterY = val(word$(ObjectCenter$,2))
    CenterZ = val(word$(ObjectCenter$,3))
 
 
    ObjectsFirstNode = LBWF.ObjectFirstNode(ObjectToRotate)
    ObjectsLastNode  = LBWF.ObjectLastNode(ObjectToRotate)
 
    for i = ObjectsFirstNode to ObjectsLastNode
 
        deltaX = (LBWF.NodeWX(i) - CenterX)
        deltaZ = (LBWF.NodeWZ(i) - CenterZ)
        R      = sqr(deltaX^2 + deltaZ^2)
        OldAngleRads = FF.LBWF.ATAN2(deltaX, deltaZ)
 
        NewAngleRads = OldAngleRads + YRotRads
 
        LBWF.NodeWX(i) = CenterX + R*cos(NewAngleRads)
        LBWF.NodeWZ(i) = CenterZ + R*sin(NewAngleRads)
 
    next i
 
 
 
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function FF.LBWF.RotateObjectAboutX(ObjectName$, XRotationInDegrees)
 
    'Multiply the rotation angle by (-1)...
    XRotationInDegrees = (-1)*XRotationInDegrees
 
    pi = 3.14159
    XRotRads = (XRotationInDegrees/360)*(2*pi)
 
    ObjectToRotate = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectToRotate = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    ObjectCenter$ = FF.LBWF.RequestObjectGeometricCenter$(ObjectName$)
 
    CenterX = val(word$(ObjectCenter$,1))
    CenterY = val(word$(ObjectCenter$,2))
    CenterZ = val(word$(ObjectCenter$,3))
 
    ObjectsFirstNode = LBWF.ObjectFirstNode(ObjectToRotate)
    ObjectsLastNode  = LBWF.ObjectLastNode(ObjectToRotate)
 
    for i = ObjectsFirstNode to ObjectsLastNode
 
        deltaY = (LBWF.NodeWY(i) - CenterY)
        deltaZ = (LBWF.NodeWZ(i) - CenterZ)
        R      = sqr(deltaY^2 + deltaZ^2)
        OldAngleRads = FF.LBWF.ATAN2(deltaZ, deltaY)
 
        NewAngleRads = OldAngleRads + XRotRads
 
        LBWF.NodeWZ(i) = CenterZ + R*cos(NewAngleRads)
        LBWF.NodeWY(i) = CenterY + R*sin(NewAngleRads)
 
    next i
 
 
End Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.RotateObjectAboutZ(ObjectName$, ZRotationInDegrees)
 
    pi = 3.14159
    ZRotRads = (ZRotationInDegrees/360)*(2*pi)
 
    ObjectToRotate = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectToRotate = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    ObjectCenter$ = FF.LBWF.RequestObjectGeometricCenter$(ObjectName$)
 
    CenterX = val(word$(ObjectCenter$,1))
    CenterY = val(word$(ObjectCenter$,2))
    CenterZ = val(word$(ObjectCenter$,3))
 
    ObjectsFirstNode = LBWF.ObjectFirstNode(ObjectToRotate)
    ObjectsLastNode  = LBWF.ObjectLastNode(ObjectToRotate)
 
    for i = ObjectsFirstNode to ObjectsLastNode
 
        deltaY = (LBWF.NodeWY(i) - CenterY)
        deltaX = (LBWF.NodeWX(i) - CenterX)
        R      = sqr(deltaY^2 + deltaX^2)
        OldAngleRads = FF.LBWF.ATAN2(deltaX, deltaY)
 
        NewAngleRads = OldAngleRads + ZRotRads
 
        LBWF.NodeWX(i) = CenterX + R*cos(NewAngleRads)
        LBWF.NodeWY(i) = CenterY + R*sin(NewAngleRads)
 
    next i
 
 
End Function
 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.RequestObjectVisibleState(ObjectName$)
 
    'Find the index number of the object by comparing
    'it against all the names in the list of objects...
    
    ObjectOfReport = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectOfReport = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    FF.LBWF.RequestObjectVisibleState = LBWF.ObjectVisible(ObjectOfReport)
 
End Function
 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.RequestObjectExtents$(ObjectName$)
 
    'Find the index number of the object by comparing
    'it against all the names in the list of objects...
    
    ObjectOfReport = 0
 
    for i = 1 to LBWF.ObjectCount(1)
        if (ObjectName$ = LBWF.ObjectName$(i)) then
            ObjectOfReport = i
            i = LBWF.ObjectCount(1)
        end if
    next i
 
    FirstNode = LBWF.ObjectFirstNode(ObjectOfReport)
    LastNode  = LBWF.ObjectLastNode(ObjectOfReport)
 
    Xmin = LBWF.NodeWX(FirstNode)
    Xmax = LBWF.NodeWX(FirstNode)
    Ymin = LBWF.NodeWY(FirstNode)
    Ymax = LBWF.NodeWY(FirstNode)
    Zmin = LBWF.NodeWZ(FirstNode)
    Zmax = LBWF.NodeWZ(FirstNode)
 
    for i = (FirstNode + 1) to LastNode
 
        if (LBWF.NodeWX(i) < Xmin) then
            Xmin = LBWF.NodeWX(i)
        end if
        if (LBWF.NodeWX(i) > Xmax) then
            Xmax = LBWF.NodeWX(i)
        end if
 
        if (LBWF.NodeWY(i) < Ymin) then
            Ymin = LBWF.NodeWY(i)
        end if
        if (LBWF.NodeWY(i) > Ymax) then
            Ymax = LBWF.NodeWY(i)
        end if
 
        if (LBWF.NodeWZ(i) < Zmin) then
            Zmin = LBWF.NodeWZ(i)
        end if
        if (LBWF.NodeWZ(i) > Zmax) then
            Zmax = LBWF.NodeWZ(i)
        end if
 
    next i
 
    FF.LBWF.RequestObjectExtents$ = str$(Xmin) + " " + str$(Xmax) + " " + str$(Ymin) + " " + str$(Ymax) + " " + str$(Zmin) + " " + str$(Zmax)
 
 
End Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''

 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.ATAN2(x, y)
 
    pi = 3.14159265
    Result$ = "Undetermined"
    If (x = 0) and (y > 0) then
        FF.LBWF.ATAN2 = pi / 2
        Result$ = "Determined"
    end if
    if (x = 0) and (y < 0) then
        FF.LBWF.ATAN2 = 3 * pi / 2
        Result$ = "Determined"
    end if
    if (x > 0) and (y = 0) then
        FF.LBWF.ATAN2 = 0
        Result$ = "Determined"
    end if
    if (x < 0) and (y = 0) then
        FF.LBWF.ATAN2 = pi
        Result$ = "Determined"
    end if
    if (x = 0) and (y = 0) then
        FF.LBWF.ATAN2 = 0
        Result$ = "Determined"
    end if
 
    If Result$ = "Determined" then [End.of.function]
 
 
    BaseAngle = ATN(abs(y)/abs(x))
    If (x > 0) and (y > 0) then FF.LBWF.ATAN2 = BaseAngle
    If (x < 0) and (y > 0) then FF.LBWF.ATAN2 = pi - BaseAngle
    If (x < 0) and (y < 0) then FF.LBWF.ATAN2 = pi + BaseAngle
    If (x > 0) and (y < 0) then FF.LBWF.ATAN2 = 2*pi - BaseAngle
 
    [End.of.function]
 
End Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function FF.LBWF.FindPerpendicularDistance$(xa, ya, xb, yb, xc, yc)
 
    Distance.Is.Found = 0
 
    'Handle the case where the line between (xa,ya) and (xb,yb)
    'is a horizontal line...
    
    if (ya = yb) then
 
        primaryLineType$ = "horizontal"
        distance = abs(yc - ya)
        xd = xc
        yd = ya
        Distance.Is.Found = 1
 
    end if
 
    if (Distance.Is.Found = 1) then [Distance.Calc.Is.Complete] 
 
    'Handle the case where the line between (xa,ya) and (xb,yb)
    'is a vertical line...
    
    if (xa = xb) then
 
        primaryLineType$ = "vertical"
        distance = abs(xc - xa)
        xd = xa
        yd = yc
        Distance.Is.Found = 1
 
    end if
 
    if (Distance.Is.Found = 1) then [Distance.Calc.Is.Complete]
 
    'If program control has arrived at this location, then
    'the line between (xa, ya) and (xb, yb) is a diagonal
    'line.  Find the distance for this case...
    
    primaryLineType$ = "diagonal"
 
    'slope of the primary line...
    m1 = (ya - yb)/(xa - xb)
 
    'y-intercept of the primary line...
    b1 = ya - (m1 * xa)
 
    'slope of the perpendicular line...
    m2 = (-1)/m1
 
    'y-intercept of the perpendicular line...
    b2 = yc - (m2 * xc)
 
    'Calculate xd and yd, which are the coordinates
    'of the point where the perpendicular line intersects
    'the primary line...

    xd = (b2 - b1)/(m1 - m2)
    yd = (m2 * xd) + b2
 
    'Find the distance between (xc, yc) and (xd, yd)...
    distance = sqr((xc-xd)^2 + (yc-yd)^2)
 
    [Distance.Calc.Is.Complete]
 
    'Find out if the intersecting point in question
    'actually resides between (xa, ya) and (xb, yb)...
    
    xdydBetweenEndpoints$ = "no"
 
    if (primaryLineType$ = "vertical") then
 
        if ((yd >= min(ya,yb)) and (yd <= max(ya,yb))) then
            xdydBetweenEndpoints$ = "yes"
        end if
 
    end if 
 
    if (primaryLineType$ = "horizontal") then
 
        if ((xd >= min(xa,xb)) and (xd <= max(xa,xb))) then
            xdydBetweenEndpoints$ = "yes"
        end if 
 
    end if
 
    if (primaryLineType$ = "diagonal") then
 
        if ((xd >= min(xa,xb)) and (xd <= max(xa,xb))) then
            xdydBetweenEndpoints$ = "yes"
        end if
 
    end if
 
 
    FF.LBWF.FindPerpendicularDistance$ = str$(distance) + "  " + xdydBetweenEndpoints$
 
End Function
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' LBWF.ObjectFirstNode(LBWF.ObjectResources(1))
' LBWF.ObjectLastNode(LBWF.ObjectResources(1))

 
'LBWF.ObjectCount(1)

' LBWF.ObjectVisible(LBWF.ObjectResources(1))

 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
'LBWF.ObjectName$(LBWF.ObjectResources(1))

 
'''''''''''''''''''''''''''''''''''''''''''''
                                                                                                                                                                                                                                                           

Top of Page

Return to the companion article for these functions, Chapter 5:Using Wire (Focusing on the FF.LBWF.RequestObjectNameFromXY$() Function).



Tom Nally
Steelweaver52@aol.com


Note: This linked source code accompanies Using Wire (Focusing on the FF.LBWF.RequestObjectNameFromXY$() Function), which originally appeared in the Liberty BASIC Newsletter, Issue #139. It is reprinted here with the permission of the author. - JanetTerra JanetTerra