View Single Post
# 1 13-01-2009 , 08:13 AM
bendingiscool's Avatar
Subscriber
Join Date: Jul 2006
Location: London
Posts: 567

Exiting bouding box

Hey, back to bug some more user added image

Here is some code to check when a cylinder enters a bounding box of a group of cubes. When it enters it prints a word, what I need is for it to record when it exits aswell.

Code:
 int $objectIsInside;// on/off switch

float $cylBBox[] = `xform -q -ws -boundingBox pCylinder1`;// cylinder's BBox
float $cubeBBox[] = `xform -q -ws -boundingBox group1`;// group's BBox

if (     ($cylBBox[0] < $cubeBBox[0]) && ($cylBBox[2] > $cubeBBox[2]) ||//check X BBox
            ($cylBBox[3] < $cubeBBox[3]) && ($cylBBox[5] > $cubeBBox[5]) ||//check Y BBox
                ($cylBBox[3] < $cubeBBox[3]) && ($cylBBox[4] > $cubeBBox[4]) ||//check Z BBox
                    ($cylBBox[2] < $cubeBBox[2]) && ($cylBBox[0] > $cubeBBox[0]) ||//check -X BBox
                        ($cylBBox[4] < $cubeBBox[4]) && ($cylBBox[3] > $cubeBBox[3]) ) //check -Z BBox
{
     if (!$objectIsInside){// if not inside set to yes
      $objectIsInside = yes;// check if object is in BBox
    }
} else {
    if ($objectIsInside) // if inside set to no
        print "entered BBox";// print word
    $objectIsInside = no;// check if object is in BBox
}
It only prints the word when the cylinder enters the first bounding box, I presume this is because of the off switch, but I can't work out how to switch it back on when it leaves the bounding box so that it can be used again.

Anyhelp with this one would be great as I am not sure how to get it to turn back on.

Thanks, Chris