@GG You are right...any way, I found a bug...it works only in positive values ...let see if I can mend it
Edited
Looks like I have solved the problem....now it works with negative and positive values...but I have to say than I don't understan why it works.
@GG It wasn't necesary to add initial values, .... the bucle increase or decrease variables automatically. Some times vertex 0 use to be out of the mesh...in its original 0,0,0.
Here's the first working Update.
autocam off
sync on
make object box 1,5+rnd(10),3,5+rnd(10)
`change this values to test
x=20
z=-25 rem added negative value
offset limb 1,0,x,0,z rem giving a wrong center
make mesh from object 1,1
delete object 1
make object 1,1
set object radius 1,-1
color object 1,rgb(0,200,0)
make object box 2,0,0,0 rem vertex position check
make object box 100,0.3,30,0.3 rem axis object
lock vertexdata for limb 1,0
vert=get vertexdata vertex count()
for i= 0 to vert-1
x#=get vertexdata position x(i)
y#=get vertexdata position y(i)
z#=get vertexdata position z(i)
position object 2,x#,y#,z#
lax#=object position x(2)
laz#=object position z(2)
if x#<0 then recx#=x# `new line added
if z#<0 then recz#=z# `new line added
if object position x(2)>dex# then dex#=lax#
if object position z(2)>dez# then dez#=laz#
next i
unlock vertexdata
`ADDING NEW CENTER TO THE MESH
rem old line (offset limb 1,0,-dex#+object size x(1)/2,0,-dez#+object size z(1)/2)
offset limb 1,0,(-dex#+object size x(1)/2)-recx#/2,0,(-dez#+object size z(1)/2)-recz#
position camera 0,50,-50
point camera 0,0,0
do
set cursor 0,0
print recx#
print recz#
g#=g#+0.1
yrotate object 1,g#
sync
loop
I'm not a grumpy grandpa
