vector llGetGeometricCenter();
Forced delay: 0.0 seconds. Energy: 10.0.
Returns a vector that is the geometric center of the object relative to the root prim.
The "geometric center" is different from the "center" in viewer's build tools and also different from what llRezObject considers to be the "center" of a linkset.
default
{
touch_start(integer total_number)
{
llOwnerSay("Geometric center of the object relative to the root prim: " + (string)llGetGeometricCenter());
}
}
vector GetGeometricCenter(){
vector center = ZERO_VECTOR;
integer p = llGetNumberOfPrims();
//since we skip the root prim, we can ignore the single prim case.
//If we weren't skipping the root, this would be more complicated.
integer i = 1;
while(i < p)
center += llList2Vector(llGetLinkPrimitiveParams(++i, [PRIM_POS_LOCAL]), 0);
return center / p;
}