JanetTerra
Jul 23, 2006
Source Code WF_DEMO06.bas
Tomas P Nally -
steelweaver52
Return to Chapter 2: The Liberty BASIC Wire Frame Library - Version 0.6
If you prefer to download the WF_DEMO06.bas , Click .
' Created by Liberty BASIC Workshop - 7/8/2005 10:13:33 PM
' LBWF 0.6 Demo
'
' Hat tip to Janet Terra
'
'
gosub [Initialize.Liberty.BASIC.WireFrame.Library]
True = 1 : False = 0
DIM FunctionList$(20)
FunctionList$(1) = "Select function from list below"
FunctionList$(2) = "--------------------------------"
FunctionList$(3) = "-- FF.LBWF.CreateBox()"
FunctionList$(4) = "-- FF.LBWF.CreateCylinder()"
FunctionList$(5) = "-- FF.LBWF.CreatePyramid()"
FunctionList$(6) = "-- FF.LBWF.CreateCone()"
FunctionList$(7) = "-- FF.LBWF.CreatePolygon()"
FunctionList$(8) = "-- FF.LBWF.CreateGridObject()"
FunctionList$(9) = "-- FF.LBWF.CreateDome()"
FunctionList$(10) = "-- FF.LBWF.CreateLine()"
FunctionList$(11) = "-- FF.LBWF.CreateCyl2()"
FunctionList$(12) = "--------------------------------"
FunctionList$(13) = "-- FF.LBWF.TranslateObject()"
FunctionList$(14) = "-- FF.LBWF.RotateObjectAboutY()"
FunctionList$(15) = "-- FF.LBWF.RotateObjectAboutX()"
FunctionList$(16) = "-- FF.LBWF.RotateObjectAboutZ()"
FunctionList$(17) = "-- FF.LBWF.HideObject()"
FunctionList$(18) = "-- FF.LBWF.ShowObject()"
FunctionList$(19) = "-- FF.LBWF.ObjectSetColor()"
FunctionList$(20) = "-- FF.LBWF.ObjectSetLineThickness()"
FunctionListIndex = 1
[WindowSetup]
NOMAINWIN
WindowWidth = 420 : WindowHeight = 680
UpperLeftX = INT((DisplayWidth-WindowWidth)/2)
UpperLeftY = INT((DisplayHeight-WindowHeight)/2)
[ControlSetup]
'Setup the listbox...
listbox #main.listFunctions, FunctionList$(),[listFunctions.click], 25, 30, 360, 175
'Setup the graphicbox...
graphicbox #main.wfscene, 25, 220, 360, 360
'Setup the previous and next buttons...
button #main.btnPrev, "< Prev", [btnPrev.click], UL, 25, 590, 75, 30
button #main.btnNext, "Next >", [btnNext.click], UL, 110, 590, 75, 30
'Setup the "made with" button...
button #main.btnMade, "Made with...", [btnMadeWith.click], UL, 210, 590, 90, 30
'Setup the quit button...
button #main.btnQuit, "Quit", [btnQuit.click], UL, 310, 590, 75, 30
Open "LBWF 0.6 Demo" for Window as #main
#main "trapclose [btnQuit.click]"
#main.wfscene "down; fill White; flush"
#main "font arial 10"
'#main.wfscene "setfocus; when mouseMove [MouseChange1]"
print #main.wfscene, "setfocus "
print #main.listFunctions, "font courier_new 10"
print #main.listFunctions, "singleclickselect"
print #main.listFunctions, "selectindex "; FunctionListIndex
goto [listFunctions.click]
[loop]
Wait
[btnQuit.click]
close #main : END
wait
[quit]
close #main : END
[btnNext.click]
'place code here
FunctionListIndex = FunctionListIndex + 1
if (FunctionListIndex = 21) then
FunctionListIndex = 1
end if
print #main.listFunctions, "selectindex "; FunctionListIndex
goto [listFunctions.click]
wait
[btnPrev.click]
'place code here
FunctionListIndex = FunctionListIndex - 1
if (FunctionListIndex = 0) then
FunctionListIndex = 20
end if
print #main.listFunctions, "selectindex "; FunctionListIndex
goto [listFunctions.click]
wait
[btnMadeWith.click]
AAA = FF.LBWF.ClearGraphicScreen()
print #main.wfscene, "place 50 80"
print #main.wfscene, "\This demo and the Liberty Basic Wire\Frame Library were made with\the following:"
print #main.wfscene, "place 50 170"
print #main.wfscene, "\Liberty BASIC by Carl Gundel\See it at http://www.libertybasic.com"
print #main.wfscene, "place 50 240"
print #main.wfscene, "\Liberty BASIC Workshop by Alyce Watson\See it at http://alycesrestaurant.com"
Wait
[listFunctions.click]
print #main.listFunctions, "selectionindex? FunctionListIndex"
Call ToggleControlDisable 0
'Display message in graphicbox...
If ((FunctionListIndex = 1) or (FunctionListIndex = 2)) then
AAA = FF.LBWF.ClearGraphicScreen()
print #main.wfscene, "place 60 160"
print #main.wfscene, "\Click on any function in\the listbox to see a demo..."
end if
'Create a box...
If (FunctionListIndex = 3) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Drawing a box in 2 seconds..."
AAA = FF.LBWF.PauseUsingTimer(2000)
AAA = FF.LBWF.CreateBox("box1", 30, 30, 60, "darkblue")
AAA = FF.LBWF.DrawObject("box1")
end if
'Create a cylinder...
If (FunctionListIndex = 4) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Drawing a cylinder in 2 seconds..."
AAA = FF.LBWF.PauseUsingTimer(2000)
AAA = FF.LBWF.CreateCylinder("cyl1", 20, 20, 20, "darkred")
AAA = FF.LBWF.DrawObject("cyl1")
end if
'Create a pyramid...
If (FunctionListIndex = 5) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Drawing a pyramid in 2 seconds..."
AAA = FF.LBWF.PauseUsingTimer(2000)
AAA = FF.LBWF.CreatePyramid("pyr1", 30, 30, 30, "darkgreen")
AAA = FF.LBWF.DrawObject("pyr1")
end if
'Create a cone...
If (FunctionListIndex = 6) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Drawing a cone in 2 seconds..."
AAA = FF.LBWF.PauseUsingTimer(2000)
AAA = FF.LBWF.CreateCone("cone1", 30, 20, 60, "black")
AAA = FF.LBWF.DrawObject("cone1")
end if
'Create a polygon...
If (FunctionListIndex = 7) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Drawing a 10-sided polygon in 2 seconds...\Set line thickness to 3..."
AAA = FF.LBWF.PauseUsingTimer(2000)
AAA = FF.LBWF.CreatePolygon("poly1", 60, 10, "black")
AAA = FF.LBWF.ObjectSetLineThickness("poly1", 3)
AAA = FF.LBWF.DrawObject("poly1")
end if
'Create a grid object...
If (FunctionListIndex = 8) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Drawing a grid object in 2 seconds..."
AAA = FF.LBWF.PauseUsingTimer(2000)
AAA = FF.LBWF.CreateGridObject("TheGrid", 10, 10, 15, "darkblue")
AAA = FF.LBWF.DrawObject("TheGrid")
end if
'Create a dome...
If (FunctionListIndex = 9) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Drawing a dome in 2 seconds..."
AAA = FF.LBWF.PauseUsingTimer(2000)
AAA = FF.LBWF.CreateDome("dome1", 30, 20, "blue")
AAA = FF.LBWF.DrawObject("dome1")
end if
'Create 30 lines...
If (FunctionListIndex = 10) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Drawing 30 lines in 2 seconds..."
AAA = FF.LBWF.PauseUsingTimer(1000)
for i = 1 to 30
angleR = ((i*12)/360)*(2*3.14159)
radius = 50
AAA = FF.LBWF.CreateLine("line"+str$(i), 0, 1, 0, radius*cos(angleR), 1, radius*sin(angleR), "green")
AAA = FF.LBWF.DrawObject("line"+str$(i))
next i
end if
'Create two cyl2s...
If (FunctionListIndex = 11) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Drawing two cyl2s in 2 seconds..."
AAA = FF.LBWF.PauseUsingTimer(2000)
AAA = FF.LBWF.CreateCyl2("cyl2a", 30, 15, 12, 50, "darkgray")
AAA = FF.LBWF.TranslateObject("cyl2a", -30, 0, 30)
AAA = FF.LBWF.DrawObject("cyl2a")
AAA = FF.LBWF.PauseUsingTimer(1000)
AAA = FF.LBWF.CreateCyl2("cyl2b", 10, 25, 12, 70, "darkred")
AAA = FF.LBWF.TranslateObject("cyl2b", 30, 0, -30)
AAA = FF.LBWF.DrawObject("cyl2b")
end if
'Display message in graphicbox...
If (FunctionListIndex = 12) then
AAA = FF.LBWF.ClearGraphicScreen()
print #main.wfscene, "place 60 160"
print #main.wfscene, "\Click on any function in\the listbox to see a demo..."
end if
'Translate an object...
If (FunctionListIndex = 13) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 100, -100)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Draw a cylinder, then \translate it across the grid..."
AAA = FF.LBWF.PauseUsingTimer(2000)
AAA = FF.LBWF.CreateCylinder("cyl1", 20, 10, 20, "darkred")
AAA = FF.LBWF.TranslateObject("cyl1", 30, 0, -30)
AAA = FF.LBWF.DrawObject("cyl1")
print #main.wfscene, "rule XOR"
AAA = FF.LBWF.PauseUsingTimer(1000)
AAA = FF.LBWF.DrawObject("cyl1") 'This undraws the cylinder for the first time...
transX = -1.5
transY = 0
transZ = 1.5
for i = 1 to 60
AAA = FF.LBWF.TranslateObject("cyl1", transX, transY, transZ)
AAA = FF.LBWF.DrawObject("cyl1") 'This redraws the object...
AAA = FF.LBWF.PauseUsingTimer(100) 'Pause a small time period
AAA = FF.LBWF.DrawObject("cyl1") 'Undraw the object again
next i
print #main.wfscene, "rule over" 'Reset the drawing rul back to "over"
AAA = FF.LBWF.DrawObject("cyl1") 'Redraw the object again
end if
'Draw a pyramid, rotate it about the y-axis...
If (FunctionListIndex = 14) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Draw a pyramid, then rotate it about\its local y-axis..."
AAA = FF.LBWF.CreatePyramid("pyr1", 30, 30, 30, "darkgreen")
AAA = FF.LBWF.TranslateObject("pyr1", 30, 0, 30)
AAA = FF.LBWF.DrawObject("pyr1")
AAA = FF.LBWF.PauseUsingTimer(2000)
print #main.wfscene, "rule XOR"
AAA = FF.LBWF.DrawObject("pyr1") 'This undraws the pyramid...
for i = 1 to 48
AAA = FF.LBWF.RotateObjectAboutY("pyr1", 7.5)
AAA = FF.LBWF.DrawObject("pyr1") ' This redraws the object
AAA = FF.LBWF.PauseUsingTimer(100)
AAA = FF.LBWF.DrawObject("pyr1") 'This undraws the pyramid...
next i
print #main.wfscene, "rule over"
AAA = FF.LBWF.DrawObject("pyr1") ' This redraws the object
end if
'Draw a box, rotate it about the x-axis...
If (FunctionListIndex = 15) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Draw a box, then rotate it about\its local x-axis..."
AAA = FF.LBWF.CreateBox("box1", 5, 15, 60, "darkblue")
AAA = FF.LBWF.TranslateObject("box1", 30, 0, 30)
AAA = FF.LBWF.DrawObject("box1")
AAA = FF.LBWF.PauseUsingTimer(2000)
print #main.wfscene, "rule XOR"
AAA = FF.LBWF.DrawObject("box1") 'This undraws the box...
for i = 1 to 48
AAA = FF.LBWF.RotateObjectAboutX("box1", 7.5)
AAA = FF.LBWF.DrawObject("box1") ' This redraws the object
AAA = FF.LBWF.PauseUsingTimer(100)
AAA = FF.LBWF.DrawObject("box1") 'This undraws the box...
next i
print #main.wfscene, "rule over"
AAA = FF.LBWF.DrawObject("box1") ' This redraws the object
end if
'Draw a Cylinder, rotate it about the z-axis...
If (FunctionListIndex = 16) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Draw a cylinder, then rotate it about\its local z-axis..."
AAA = FF.LBWF.CreateCylinder("cyl1", 5, 8, 60, "darkred")
AAA = FF.LBWF.TranslateObject("cyl1", 30, 0, 30)
AAA = FF.LBWF.DrawObject("cyl1")
AAA = FF.LBWF.PauseUsingTimer(2000)
print #main.wfscene, "rule XOR"
AAA = FF.LBWF.DrawObject("cyl1") 'This undraws the cylinder...
for i = 1 to 48
AAA = FF.LBWF.RotateObjectAboutZ("cyl1", 7.5)
AAA = FF.LBWF.DrawObject("cyl1") ' This redraws the object
AAA = FF.LBWF.PauseUsingTimer(100)
AAA = FF.LBWF.DrawObject("cyl1") 'This undraws the cylinder...
next i
print #main.wfscene, "rule over"
AAA = FF.LBWF.DrawObject("cyl1") ' This redraws the object
end if
'Draw 5 boxes, then hide 2...
If (FunctionListIndex = 17) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Draw 5 boxes, then hide the\second and fourth ones..."
for i = 1 to 5
AAA = FF.LBWF.CreateBox("box"+str$(i), 15, 15, 20, "darkpink")
AAA = FF.LBWF.TranslateObject("box"+str$(i), 70 - 30*(i-1), 0, 0)
AAA = FF.LBWF.ObjectSetLineThickness("box"+str$(i), 2)
AAA = FF.LBWF.DrawObject("box"+str$(i))
next i
AAA = FF.LBWF.HideObject("box2")
AAA = FF.LBWF.HideObject("box4")
AAA = FF.LBWF.PauseUsingTimer(2000)
AAA = FF.LBWF.ClearGraphicScreen()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Draw 5 boxes, then hide the\second and fourth ones..."
AAA = FF.LBWF.DrawAllObjects()
end if
'Draw 5 boxes, hide 2, then show those 2...
If (FunctionListIndex = 18) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Draw 5 boxes, hide 2 of them\then show the two that were hidden..."
for i = 1 to 5
AAA = FF.LBWF.CreateBox("box"+str$(i), 15, 15, 20, "darkcyan")
AAA = FF.LBWF.TranslateObject("box"+str$(i), 0, 0, 60 - 30*(i-1))
AAA = FF.LBWF.ObjectSetLineThickness("box"+str$(i), 2)
AAA = FF.LBWF.DrawObject("box"+str$(i))
next i
AAA = FF.LBWF.HideObject("box2")
AAA = FF.LBWF.HideObject("box4")
AAA = FF.LBWF.PauseUsingTimer(2000)
AAA = FF.LBWF.ClearGraphicScreen()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Draw 5 boxes, hide 2 of them\then show the two that were hidden..."
AAA = FF.LBWF.DrawAllObjects()
AAA = FF.LBWF.PauseUsingTimer(1000)
AAA = FF.LBWF.ShowObject("box2")
AAA = FF.LBWF.ShowObject("box4")
AAA = FF.LBWF.ClearGraphicScreen()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Draw 5 boxes, hide 2 of them\then show the two that were hidden..."
AAA = FF.LBWF.DrawAllObjects()
end if
'Create a dome, then change its color...
If (FunctionListIndex = 19) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Drawing a dark green dome,\then change its color to dark red..."
AAA = FF.LBWF.PauseUsingTimer(2000)
AAA = FF.LBWF.CreateDome("dome1", 30, 20, "darkgreen")
AAA = FF.LBWF.DrawObject("dome1")
AAA = FF.LBWF.PauseUsingTimer(1500)
AAA = FF.LBWF.ObjectSetColor("dome1", "darkred")
AAA = FF.LBWF.DrawObject("dome1")
end if
'Draw a cone, then change its line thickness to 3...
If (FunctionListIndex = 20) then
AAA = FF.LBWF.ZeroAllData()
AAA = FF.LBWF.ShowAxes()
AAA = FF.LBWF.CameraLocation(200, 150, 150)
AAA = FF.LBWF.ViewingCenter(0, 0, 0)
AAA = FF.LBWF.ZoomFactor(1.30)
AAA = FF.LBWF.ScreenCenter(180,220)
AAA = FF.LBWF.CreateGridObject("TheGrid", 5, 5, 25, "lightgray")
AAA = FF.LBWF.ClearGraphicScreen()
AAA = FF.LBWF.DrawAllObjects()
print #main.wfscene, "place 20 20"
print #main.wfscene, "\Draw a cone, then change its\line thickness to 3..."
AAA = FF.LBWF.PauseUsingTimer(2000)
AAA = FF.LBWF.CreateCone("cone1", 30, 15, 40, "darkcyan")
AAA = FF.LBWF.DrawObject("cone1")
AAA = FF.LBWF.PauseUsingTimer(1500)
AAA = FF.LBWF.ObjectSetLineThickness("cone1", 3)
AAA = FF.LBWF.DrawObject("cone1")
end if
Call ToggleControlDisable 1
wait
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ToggleControlDisable TheSwitch
If (TheSwitch = 1) then
print #main.listFunctions, "enable"
print #main.btnPrev, "!enable"
print #main.btnNext, "!enable"
print #main.btnMade, "!enable"
print #main.btnQuit, "!enable"
else
print #main.listFunctions, "disable"
print #main.btnPrev, "!disable"
print #main.btnNext, "!disable"
print #main.btnMade, "!disable"
print #main.btnQuit, "!disable"
end if
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'---Insert library below this line----
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Begin Liberty BASIC WireFrame Library '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'''''''''''''''''''''''''''''''''''''''''''''''''''
'List of Liberty BASIC Wire Frame Library Functions
'''''''''''''''''''''''''''''''''''''''''''''''''''
'
'function count = 52
'
'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.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.ATAN2()
'
'
'
'
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
[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) '
Return
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
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
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
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
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Top of Page
Return to the companion article for these functions, Chapter 2: The Liberty BASIC Wire Frame Library - Version 0.6 .
If you prefer to download the WF_DEMO06.bas , Click .
Tom Nally
Steelweaver52@aol.com
Note: This linked source code accompanies Chapter 2: The Liberty BASIC Wire Frame Library - Version 0.6 which originally appeared in the Liberty BASIC Newsletter, Issue #135 . It is reprinted here with the permission of the author.
-