list llGetBoundingBox(key object)
Returns the
bounding box around the object or
avatar with the
key object (including any
linked prims) relative to the
root prim, in a list:
[ (vector) min_corner, (vector) max_corner ]
Note: when an avatar
sits on an object, it becomes linked to it--and the avatar's bounding box then includes the object it is sitting on.
If the object defined by
object does not exist, the list returned will contain no items.
Example:
// Ezhar's bounding box visualizer
default {
state_entry() {
llListen(3, "", llGetOwner(), ""); // listen for a target
}
listen(integer channel, string name, key id, string message) {
llSensor(message, NULL_KEY, AGENT | ACTIVE | PASSIVE, 10, PI); // find the target
}
sensor(integer num_detected) {
list bb;
vector min;
vector max;
vector offset;
bb = llGetBoundingBox(llDetectedKey(0)); // get the bounding box
min = llList2Vector(bb, 0); // min corner
max = llList2Vector(bb, 1); // max corner
offset = (min + max) / 2; // calculate the offset from the targets root prim center
offset *= llDetectedRot(0); // rotate it by the targets rotation
llSetText((string)min + "\n" + (string)max, <1, 1, 1>, 1.0); // display the bounding box corners as text
llSetScale(-min + max); // change to the size of the bounding box
llSetPos(llDetectedPos(0) + offset); // move to the target
llSetRot(llDetectedRot(0)); // and match the targets rotation
}
}
This article wasn't helpful for you? Maybe the
related article at the LSL Portal is able to bring enlightenment.
Functions |
Bounding Box |
Center |
Prim |
Object