View Single Post
# 3 23-11-2008 , 10:22 AM
bendingiscool's Avatar
Subscriber
Join Date: Jul 2006
Location: London
Posts: 567
Thanks fot the reply Xander, this is what I have so far...

//////////////////////////////
int $objectIsInside;// on/off switch
int $time = `currentTime -query`;// get current frame
float $cylBBox[] = `xform -q -ws -boundingBox pCylinder1`;// cylinder's BBox
float $cubeBBox[] = `xform -q -ws -boundingBox pCube1`;// cube'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 true set to yes
$objectIsInside = yes;//check if object is in BBox
}
} else {
if ($objectIsInside) //if true set to no
print ($time);//print current frame
$objectIsInside = no;//check if object is in BBox
}
//////////////////////////////

it stores the current frame when it enters the bounding box of the cube (am using this to chuck into a switch statement to go between animation clips), shall post more updates as I go.

Chris

PS: I'm guessing there must be a simpler, cleaner way to do this but this is working at the mo, any other solutions are very much welcome.