loading multiple mesh's with one comand

Blitz3D Forums/Blitz3D Programming/loading multiple mesh's with one comand

Dim mesh(totalmesh)
for n=0 to totalmesh
	mesh(n) = loadmesh(blah blah)
next

Or better if you use types then you can store additional info about the mesh
type nmesh
	field mesh
	field id
	field xscale#
	field yscale#
	field zscale#
	field numberoffins
	field cupsofcoffee
	field etc
end type

function loadnmesh(filename$,id=0)
	if id = 0 then id = millisecs()
	n.nmesh = new nmesh
	n\mesh = loadmesh(filename$)
	n\id = id
end function

then just use loadnmesh instead of loadmesh.
Use the id to identify the mesh uniquely. Or use a name or something.

On top of this you could make the fields into global variables:
global meshhandle
global xscale#
global yscale#
global zscale#
global numberoffins
global cupsofcoffee
global etc


The have a function:
function getmesh(id)
	for n.nmesh = each mesh
		if n\id = id
			meshhandle = n\meshhandle
			xscale# = n\xscale
			yscale# = n\yscale
			zscale# = n\zscale
			numberoffins = numberoffins
			cupsofcoffee = cupsofcoffee
			etc = etc
			return true
		endif
	next
	return false
end function
Then you'd just use

if getmesh(400) then print "Found" else print "Not Found"

And all your globals will be populated if the mesh is found.

Note: All of this code is off the top of my head untested stuff so it might not work, however, it's there to explain the principle.