PDA

View Full Version : collecting multiple bounding box entries



bendingiscool
12-23-2008, 01:45 PM
Hey,

A few weeks back I got some help about running commands on entry to bounding box's..

Here was the final code I had from here...

{

int $objectIsInside;// on/off switch
int $time = `currentTime -query`;// get current frame
vector $cylBBox[] = `xform -q -ws -boundingBox pCylinder1`;// cylinder's BBox
vector $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
}

}

What I would like to be able to do to add to this, is to be able to select a group of objects, like the cylinder thats used in the above code, and select a second group of objects, like cubes from the above code, and have the time recorded each time one of the cylinders enters or exits the bounding box of the cubes.

I am getting really confused about the way in which to do this, any help would be very much appreciated.

Thanks, Chris

chrisg
12-24-2008, 11:04 AM
Hi Chris,

I guess I have a question on what this would be used for. If it's collision checking to fix collisions, I would use red toon outlines on black objects to see what you need to fix. Toon Outlines (http://www.digitaltutors.com/store/video.php?vid=710). I would think there would have to be a better way to check collisions.

If you still want to do this bounding box stuff, I would probably write a script and an expression. The script would store all of the objects in two groups in two global variables, then I would plug the script you have above into an expression and press play. I would just use an expression because it has the interface to progress through the scene and execute the script on every frame. If you want to just use a script, you would need some sort of pause or dialogue box to pause the script while you select the other group of objects, then just use a for loop to run the above script and changing the current time.

bendingiscool
12-26-2008, 05:26 AM
I like your suggestion about a script and an expression, bascically what I want to do is collect each time an object goes inside the bounding box of a specific area, in this case a cube, and collect the entry time and either the exit time or the entry time of a new bounding box. I am currently making a crowd simulation tool and I need the times at which objects enter other objects so that I can plug these times into the start times of animation clips (like when placing clips into the trax editor).


My original plan was to have a script and an expression on each object but it is the set up and syntaxing of getting the times that I am stuck with. Anymore help would be greatly appreciated.

Thanks, Chris