# BBox Rotate by Max Length?

## Recommended Posts

Hi Guys I'm making a wood fracture HDA & I need to be able to go through the input geo & roate it all so the longest length is pointing up.

So I was thinking on a For Loop get the Max BBox then find the longest edge of that then rotate the obejct so that longest edge is always rotated to Houdini's World up or a Transform Y etc.
I've only been using Houdni a few years so I don't know how to get these bits & put them in the corrrect way for it to work.

So a Shed model made of planks comes in.  Each plank needs to be orientated up.

I've managed to get some pieces to rotate correctly but some arn't & I know this is down to the Bound node Orientated BBox Option not knowing which way around it is.

So is there simple solution to do this?  I do understand VEX a bit but this'll take me ages to figure out.
Can I get the Max Length of the Geo then some how tell houdini to rotate the geo so that longest edge is paralel to up?

I then need to put the Geo back to it's original position & rotation but thats the next bit I gues or I was hopeing to just use Rest before then call it back at the end.

Can anyone help me achieve this?
Thanks
Steve

##### Share on other sites

hey i got sumfin'...

vu alignY.hipnc

##### Share on other sites

Ok I managed to store the BBox in a Attrib Wrangle

v@bbox = getbbox_max(0);

then find the longest & set that as a Prim Attribute called Max Vecter using VOPs.

So maybe I can do this in VOP's easier?
So now I need to find out what angle that MaxVextor is on x y or z (using P maybe?) then rotate the BBox so that MaxVector is UP.
Looking at the spreadsheet & my plank, up is BBox[1] so I need to change anything not in BBox[1] to rotate 90 until the Max matches BBox[1] slot. No idea how to do that.

Thanks if you can help.

##### Share on other sites
8 hours ago, Noobini said:

hey i got sumfin'...

Hey thanks for the help mate I think I managed to do it.
I'm not sure if you file saved ok but the Copy to points is a merge node? Either way I swapped that & yours works great in you example but on mine it didn't work.
I think it's because your boxes already know what XYZ are where my shed is brought in as an Alembic file as one object. Yours is a lot simple than mine tho!

##### Share on other sites

that merge thing is a PIA....lemme guess you're on H17 ?

some H18 nodes for some unfathomable reason appear as merger in 17...go figure

##### Share on other sites

btw, in the bound,  tick Transform Attrib...then you get xform[12], [13], [14] that represent the alignment of the bbox...once you got this

I think using dihedral can line it up with Y...but I'm not a VEX guru.

surely someone here can do it.

##### Share on other sites

also, here's the 17.5 version, I left the stupid merge in there anyway but it really was a copytopoints in H18

the align and distribute is from sidefx labs tools so make sure you have updated it. It just lines them up nicely left to right that's all.

vu alignY_17.5.hipnc

##### Share on other sites

Ok I use the Connectivity node to split the geo up
The For loop to go every piece
Each piece gets a Bound
The TransformAttrib inverts then saves to the xform attrib
Wrangle then saves the BBox
v@bbox = getbbox_max(0);

The VOP then gets that saved BBox & finds the largest size then compares that to all 3 XYZ to find if the largest is Y if not it writes to a Variable Called Yes.

The Attrib 'Yes' is used to Switch the transform on which rotates X & Z to 90 since I just need the Geo to point up.
Then the rest moves it all back to where it was in the begining for after I add my changes to each piece.

This all seems to work so far.  Hopefully this'll help someone else who's not a coder! =0)
Thanks for looking & the help guys!

##### Share on other sites
4 minutes ago, Noobini said:

also, here's the 17.5 version, I left the stupid merge in there anyway but it really was a copytopoints in H18

the align and distribute is from sidefx labs tools so make sure you have updated it. It just lines them up nicely left to right that's all.

Thanks mate but still no luck.

##### Share on other sites

what's the problem here ? try a convert after unpack ?

##### Share on other sites
2 minutes ago, Noobini said:

what's the problem here ? try a convert after unpack ?

Nope still didn't work.

Here's the shed Alembic it's just some test geo I made in 3ds Max then reset the XForm then collapsed it to an Edit Poly.
The exported to AlembicShed_Low.ABC

Shed_Low.ABC

##### Share on other sites

i reckon it's pivot related...ie. each piece has the pivot at Origin instead of say at the base of each 'plank'...(or centered to each plank)

Edited by Noobini

##### Share on other sites

close !!!!

if I line up the pivot with the base of the planks.

##### Share on other sites

just change the 'merge' to copytopoints.

ignore the wrangle..i was just foolin around with dihedral...but as said useless at VEX.

vu alignY.hipnc

##### Share on other sites
17 minutes ago, Noobini said:

just change the 'merge' to copytopoints.

ignore the wrangle..i was just foolin around with dihedral...but as said useless at VEX.

Didn't work again but if you do this it will better!
Yours

Added the first part of mine.

##### Share on other sites

Here's my take on it

By the way, thanks Noobini, I've always wondered what dihedral did. With this, I now got a better understanding of it

This is a VEX-heavy method of doing it. I compute the rotation matrix and bring back to the origin, then find the longest and shortest side, and finally align the piece according the orientation we want, using dihedral.

• 1

##### Share on other sites

haha great, got there in the end.

##### Share on other sites

just to step back abit... was this all because you need to fracture the wood grain in the correct longest axis wherever the piece of wood happen to point ? coz I thought the RBDmaterialfracture already catered for this situation.

##### Share on other sites

YEEEEEEEEEEEESSSSSSSSSSSSSS.

here's my virtually no VEX effort. The VEX I used is so basic any dunce would be able to decipher.

vu_AlignY.hiplc

##### Share on other sites
15 hours ago, Noobini said:

just to step back abit... was this all because you need to fracture the wood grain in the correct longest axis wherever the piece of wood happen to point ? coz I thought the RBDmaterialfracture already catered for this situation.

Yes but I've made my own Fracture tool.  Maybe there's an answer in the RBDFracture tool then too.
Thanks for the help man.

## Create an account

Register a new account

×
• Donations