Introduction to Maya - Modeling Fundamentals Vol 1
This course will look at the fundamentals of modeling in Maya with an emphasis on creating good topology. We'll look at what makes a good model in Maya and why objects are modeled in the way they are.
# 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

# 2 14-01-2009 , 11:43 PM
bendingiscool's Avatar
Subscriber
Join Date: Jul 2006
Location: London
Posts: 567
I tried some suggestions, made a couple of changes to sort out syntax, now it says its ok as is doesn't give any errors, but for some reason its not printing out anything, no matter where the cylinder is.

Code:
$boolPrinted = 0;

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

if (     ($cylBBox[0] < $grpBBox[0]) && ($cylBBox[3] > $grpBBox[3]) ||//check X BBox
        ($cylBBox[2] < $grpBBox[2]) && ($cylBBox[5] > $grpBBox[5]) )//check Z BBox
{
    if ($boolPrinted == 0)
    {
print "Object is in";
$boolPrinted = 1;
    }
}
    else
    {
    if ($boolPrinted == 1)
    {
print "Object is out";
$boolPrinted = 0;
    }

}
The bouding box numbers should be ok but for some reason it isn't printing the words.

Any ideas on this one?

Thanks, Chris

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads