just a cool function i made while playing with 3d mesh memblocks
when used on an object centered over 0,0,0 (in terms of offset) this works exactly like a scale (except it applys it to a new object)
but when used on an object offset then it will expand that offset in the same fashion you dilate a 2d figure, out and away from a point, except this only dilates away fro 0,0,0 (again in offset terms)
so if you create a sphere of size 10, then use offset limb obj,0,0,0,20 (move the main limb 20 units forward on the z axis) then dilate it to a scale of 300 (in terms of percent) then it will create a new object 3 times the size of the orignal and will be centered over 0,0,60 (offset terms)
the parameters are as follows:
objectnum - the object being dilated
scale - the scale (in terms of percent, 100 means same size)
newobjectnum - the object number of the dilated object
cullflipflag - set to 0 if you wish to be able to see the figure from the inside as opposed to from outside it)
function dilate_object(objectnum,scale,newobjectnum,cullflipflag)
make mesh from object 1000,objectnum
make memblock from mesh 1,1000
vertnum= memblock dword(1,0)
sizefactor#=scale/100.0
for vert=1 to vertnum
oldx=memblock float(1,(vert-1)*12+32)
oldy=memblock float(1,(vert-1)*12+36)
oldz=memblock float(1,(vert-1)*12+40)
write memblock float 1,(vert-1)*12+32,oldx*sizefactor#
write memblock float 1,(vert-1)*12+36,oldy*sizefactor#
write memblock float 1,(vert-1)*12+40,oldz*sizefactor#
next vert
make mesh from memblock 1,1
make object newobjectnum,1,0
position object newobjectnum,object position x(objectnum),object position y(objectnum), object position z(objectnum)
set object newobjectnum,1,1,cullflipflag
endfunction
run this to see what it does:
sync on : hide mouse
make object sphere 1,40
offset limb 1,0,0,0,50
color object 1,rgb(255,0,0)
dilate_object(1,300,2,1)
color object 2,rgb(0,255,0)
dilate_object(2,300,3,1)
color object 3,rgb(0,0,255)
do
turn camera right rightkey()+(-1*leftkey() )
pitch camera up upkey()+(-1*downkey() )
move camera (3*spacekey() )- (3*returnkey() )
sync
loop
function dilate_object(objectnum,scale,newobjectnum,cullflipflag)
make mesh from object 1000,objectnum
make memblock from mesh 1,1000
vertnum= memblock dword(1,0)
sizefactor#=scale/100.0
for vert=1 to vertnum
oldx=memblock float(1,(vert-1)*12+32)
oldy=memblock float(1,(vert-1)*12+36)
oldz=memblock float(1,(vert-1)*12+40)
write memblock float 1,(vert-1)*12+32,oldx*sizefactor#
write memblock float 1,(vert-1)*12+36,oldy*sizefactor#
write memblock float 1,(vert-1)*12+40,oldz*sizefactor#
next vert
make mesh from memblock 1,1
make object newobjectnum,1,0
position object newobjectnum,object position x(objectnum),object position y(objectnum), object position z(objectnum)
set object newobjectnum,1,1,cullflipflag
endfunction
There are only 10 kinds of people in the world, those who understand binary and those who dont