Template:Needs Translation/
函数名
|
Function: list llGetBoundingBox( key object )
|
参数:key object –同一区域组、化身或者物体的UUID
|
返回值:以局部坐标返回一个列表,该列表是对象相对于其根prim的边界框。
|
注意事项
|
注意事项
- 不管object是否是非根的prim,都会返回该对象的边界框。如果object是一个坐在对象上的代理,这也适用——返回坐在对象上的边框(包括代理的形状)。
- 附件没有自己的边界框(因为它们没有物理交互[1]),相反角色的边界框会被返回。
|
示例
|
default//An avatar bounding box ruler thingy
{
state_entry()
{
llSetStatus(STATUS_PHANTOM, TRUE);
}
touch_start(integer total_number)
{
key target = llDetectedKey(0);
list box = llGetBoundingBox(target);
vector center = llDetectedPos(0) + (llList2Vector(box, 0) + llList2Vector(box, 1)) * 0.5;
vector size = llList2Vector(box, 1) - llList2Vector(box, 0);
llSetPrimitiveParams([PRIM_POSITION, center, PRIM_SIZE, size]);
llSetText("Name: " + llDetectedName(0) + ", UUID: " + (string)target +
"\nBounding Box Size: " + (string)size, <1.0, 1.0, 1.0>, 1.0);
}
}
// Enclose a named object in the tightest possible box
// that is aligned with the object's root prim axes.
// Drop this script in a box near the object to enclose
// (must be in a 10m range)
string ObjectNameToEnclose = "SearchMe";
key UUID;
default
{
state_entry()
{
llSensor(ObjectNameToEnclose, "", ACTIVE | PASSIVE, 10, PI);
}
sensor(integer n)
{
UUID = llDetectedKey(0);
llSetTimerEvent(1);
}
timer()
{
list info = llGetObjectDetails(UUID, [OBJECT_POS, OBJECT_ROT]) + llGetBoundingBox(UUID);
vector pos = llList2Vector(info, 0);
rotation rot = llList2Rot(info, 1);
vector corner1 = llList2Vector(info, 2) * rot + pos;
vector corner2 = llList2Vector(info, 3) * rot + pos;
vector size = llList2Vector(info, 3) - llList2Vector(info, 2);
llSetPos((corner1 + corner2) * 0.5); // Set position to the midpoint (average) of the corners
llSetRot(rot);
llSetScale(size);
}
}
|