Here is an example. Instructions are shown on-screen.
set display mode desktop width(), desktop height(), 32, 1
sync on : sync rate 30 : sync
global scrW, scrH
scrW = screen width()
scrH = screen height()
// find all model files ("something.x").
perform checklist for files
cq = checklist quantity()
numFiles = 0
dim files(-1) as string
for n = 1 to cq
s$ = checklist string$(n)
if right$(s$, 2) = ".x"
array insert at bottom files()
files(numFiles) = s$
inc numFiles
endif
next n
if numFiles = 0
print "put some .x files in the .exe's folder first. Press key..."
end
endif
// setup scene.
autocam off : set camera view 160, 0, scrW, scrH : set camera aspect (scrW-160)*1.0/scrH
position camera 0, 50, -90 : point camera 0,0,0
ground = 1 : make object plane ground, 100, 100 : xrotate object ground, 90
fileDrag = -1
// main loop.
do
oMc = mc
mx = mousex()
my = mousey()
mc = mouseclick()
// interact with and draw file list.
ink 0xffffffff, 0 : box 0, 0, 160, scrH // file list background
line 161, 0, 161, scrH // draw file list/viewport divider.
y = 0
mouseOver = -1
nMax = numFiles-1
for n = 0 to nMax
if mx < 160 and my => y and my < y+15 // test mouse position.
if fileDrag = -1
ink 0, 0 : box 0, y, 160, y+14 // highlight draggable item with black box.
ink 0xffffffff, 0 : text 0, y, files(n)
mouseOver = n
else
ink 0xff808080, 0 : box 0, y, 160, y+14 // highlight move-dragged-item-to-position item with grey box.
ink 0xffffffff, 0 : text 0, y, files(n)
endif
else
ink 0, 0 : text 0, y, files(n)
endif
inc y, 15
next n
// handle mouse interactions (may be edge-cases where it breaks, but it's just for example).
select mc
case 1 // Left-Mouse Down.
if oMc = 0
if mouseOver <> -1
// begin dragging an item from the file list.
fileDrag = mouseOver
endif
endif
endcase
case 2 // Right-Mouse Down
if oMc = 0
// look for object to delete.
if mx > 160
pickedObj = pick object(mx, my, 2, 65535) // (don't pick ground)
if pickedObj <> 0
// delete picked object.
delete object pickedObj
endif
endif
endif
endcase
case 0 // Mouse Up.
if oMc = 1
if fileDrag <> -1
// drop dragged item...
if mx > 160
// onto scene.
pickedObj = pick object(mx, my, ground, ground)
if pickedObj <> 0
// find where in 3d to place.
x# = camera position x() + get pick vector x()
y# = camera position y() + get pick vector y()
z# = camera position z() + get pick vector z()
// load up and position the object.
obj = newObjId()
load object files(fileDrag), obj
position object obj, x#, y#, z#
endif
else
// back on list - and just for fun, rearrange.
i = my / 15
if i > numFiles-1 then i = numFiles-1
if i <> fileDrag // don't do anything if placed back where item already is.
// temporarily keep a copy of item.
item$ = files(fileDrag)
// first remove item from old position in list.
if fileDrag < numFiles-1
for n = fileDrag to numFiles-2
files(n) = files(n+1)
next n
endif
// then insert item at new position.
minN = i : if minN < 1 then minN = 1
for n = numFiles-1 to minN step -1
files(n) = files(n-1)
next n
files(i) = item$
endif
endif
fileDrag = -1
endif
endif
endcase
endselect
// draw dragged item.
if fileDrag <> -1
ink 0, 0 : box mx-80, my-7, mx+80, my+7
ink 0xffffffff, 0 : center text mx, my-7, files(fileDrag)
endif
// user prompt.
ink 0xffffffff
text 165, 5, "drag items from list onto scene."
text 165, 20, "right-click an object to delete it."
text 165, 35, "items can be rearranged in list by dragging."
// update screen.
sync
`nice wait 15 // recommended, but requires Matrix1Utils.
loop
// returns id of first available object.
function newObjId()
for n = 1 to 65535
if object exist(n) = 0 then exitfunction n
next n
endfunction 0
[edit: fixed bug that disallowed dragging, works again now]
Note that this code is just for demonstration, and won't scale into a bigger project without modification.