Difference between revisions of "LlGetBoundingBox"

From Second Life Wiki
Jump to: navigation, search
(Added an example, although I am not sure if it is the best possible demonstration of the function.)
(How about a avatar ruler type of thing instead? remotely useful and shows how to get the center and size of the box)
Line 9: Line 9:
 
|caveats
 
|caveats
 
|constants
 
|constants
|examples=<lsl>vector min = <1, 1, 1>;
+
|examples=<lsl>default//An avatar bounding box ruler thingy
 
+
default
+
 
{
 
{
     touch_start(integer total_number)
+
     state_entry()
 
     {
 
     {
         llSensor("", NULL_KEY, PASSIVE, 96.0, PI);
+
         llSetStatus(STATUS_PHANTOM, TRUE);
 
     }
 
     }
 
+
   
     sensor(integer num_detected)
+
     touch_start(integer total_number)
 
     {
 
     {
         list box;
+
         key target = llDetectedKey(0);
        integer i;
+
         list box = llGetBoundingBox(target);
        for(i; i < num_detected; ++i)
+
        vector center = (llList2Vector(box, 0) + llList2Vector(box, 1)) * 0.5;
         {
+
        vector size = llList2Vector(box, 1) - llList2Vector(box, 0);
            box = llGetBoundingBox(llDetectedKey(i));
+
        llSetPrimitiveParams([PRIM_POSITION, center, PRIM_SIZE, size]);
            if(llVecDist(llList2Vector(box, 0), llList2Vector(box, 1)) > llVecMag(min))
+
        llSetText("Name: " + llDetectedName(0) + ", UUID: " + (string)target + "\nBounding Box Size: " + (string)size, <1.0, 1.0, 1.0>, 1.0);
            {
+
                llOwnerSay(llDetectedName(i) + "'s diagonal is longer than " + (string)llVecMag(min) + " meters.");
+
            }
+
        }
+
 
     }
 
     }
 
}</lsl>
 
}</lsl>

Revision as of 19:42, 16 June 2008

Summary

Function: list llGetBoundingBox( key object );

Returns a list that is the bounding box of object relative to it's root prim.
Format: [ (vector) min_corner, (vector) max_corner ]

• key object Object or agent in the sim.

The bounding box is for the entire link set, not just the requested prim.

Examples

<lsl>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 = (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);
   }
}</lsl>

See Also

Functions

•  llGetAgentSize

Deep Notes

Search JIRA for related Issues

Signature

function list llGetBoundingBox( key object );