Quote: "By the way, I'm using your copy object function (October 2006) from the codebase in my level editor."
Huh? I don't even know what that is. 2006 ? I wrote that when I started using DarkBasic if that's the date. I better find it to see if it's badly written.
[a little later]
Ah ha! There's code in it referencing a memblock that isn't necessary, and two calls to extra functions that aren't necessary.
Here's an updated version, if you want to use it. I eliminate the 2 extra functions to get a memblock or a mesh and just include it in the function. That speeds it up a bit. However, the added scale feature probably brings it back to the original speed. It will allow you to scale the copied object all in one shot. If you leave the scale values at zero, it won't scale. So a scale value of 0 or 100 = original scale. 200 would be 200% or twice the original object's x y or z dimension.
rem copy object
rem latch october 2006
rem update august 19,2009
set display mode 800,600,32
sync on
sync rate 60
autocam off
randomize timer()
rem create a texture
box 0,0,55,100
ink rgb(255,0,0),0
box 40,120,128,128
ink rgb(255,255,255),0
get image 1,0,0,128,128
rem create an object
make object cube 1,10
texture object 1,1
`hide object 1
rem copy object
for copy = 2 to 20
copy_object(1,copy,1,xscale#,0.0+rnd(200),zscale#)
position object copy,80+(5*copy),(10*copy)-100,0
sync
next copy
rem position camera
position camera 140,0,-150
rem rotate cube copies
do
ang#=wrapvalue(ang#+1)
for cubes = 1 to 20
yrotate object cubes,ang#
next cubes
sync
loop
end
function copy_object(inobj,outobj,texture,xscale#,yscale#,zscale#)
rem get available memblock and mesh
msh=1
while mesh exist(msh)
inc msh
endwhile
if xscale#=0 then xscale#=100
if yscale#=0 then yscale#=100
if zscale#=0 then zscale#=100
make mesh from object msh,inobj
make object outobj,msh,texture
delete mesh msh
scale object outobj,xscale#,yscale#,zscale#
make mesh from object msh,outobj
delete object outobj
make object outobj,msh,texture
delete mesh msh
endfunction
Enjoy your day.