sync on : sync rate 50 `Constants #constant sph 1 #constant cub 2 #constant s 2.5 `Types type pos x# as float y# as float z# as float endtype `Make the object make object sphere 1, 2*s, 40, 40 set object wireframe 1, 1 set object cull 1, 0 `Get number of verteces and store it in an array global vd as integer lock vertexdata for limb 1, 0 vd = get vertexdata vertex count() dim vert(vd) as pos for v = 0 to vd vert(v).x# = get vertexdata position x(v) vert(v).y# = get vertexdata position y(v) vert(v).z# = get vertexdata position z(v) next v unlock vertexdata `Distance vector r = make vector3(1) `Global global t as integer t = sph do `Toggle if upkey() = 1 and hold = 0 hold = 1 inc t endif if downkey() = 1 and hold = 0 hold = 1 dec t endif if downkey() + upkey() = 0 then hold = 0 `Change type if t = sph `Edit to a sphere lock vertexdata for limb 1, 0 `Run through all verteces for v = 0 to vd `Get vertex data vx# = get vertexdata position x(v) vy# = get vertexdata position y(v) vz# = get vertexdata position z(v) `Get target values tx# = vert(v).x# ty# = vert(v).y# tz# = vert(v).z# `Get distance to position set vector3 1, tx# - vx#, ty# - vy#, tz# - vz# d# = length vector3(1) `Change to new vertex data multiply vector3 1, 0.5 set vertexdata position v, vx# + x vector3(1), vy# + y vector3(1), vz# + z vector3(1) next v unlock vertexdata endif if t = cub `Edit to a cube lock vertexdata for limb 1, 0 `Run through all verteces for v = 0 to vd `Get vertex data vx# = get vertexdata position x(v) vy# = get vertexdata position y(v) vz# = get vertexdata position z(v) `Get origin data ox# = vert(v).x# oy# = vert(v).y# oz# = vert(v).z# `Based on the origin data from in the sphere, assign target position set vector3 1, ox#, oy#, oz# if ox# <> 0.0 multiply vector3 1, s / ab(ox#) if ab(y vector3(1)) > s set vector3 1, ox#, oy#, oz# multiply vector3 1, s / ab(oy#) if ab(z vector3(1)) > s set vector3 1, ox#, oy#, oz# multiply vector3 1, s / ab(oz#) endif else if ab(z vector3(1)) > s set vector3 1, ox#, oy#, oz# multiply vector3 1, s / ab(oz#) endif endif else multiply vector3 1, s / ab(oy#) if ab(z vector3(1)) > s set vector3 1, ox#, oy#, oz# multiply vector3 1, s / ab(oz#) endif endif tx# = x vector3(1) ty# = y vector3(1) tz# = z vector3(1) `scale vector set vector3 1, tx# - vx#, ty# - vy#, tz# - vz# multiply vector3 1, 0.5 `position set vertexdata position v, vx# + x vector3(1), vy# + y vector3(1), vz# + z vector3(1) next v unlock vertexdata endif `Position camera angle# = wrapvalue(angle# + rightkey() - leftkey()) position camera cos(angle#)*10, 10, sin(angle#) * 10 point camera 0, 0, 0 sync loop function ab(nr#) if nr# < 0 then exitfunction -nr# endfunction nr#