Jump to content

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.
01.thumb.JPG.7faf1e5c8868785f3b231e2f4d83b61f.JPG
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.
2.thumb.JPG.34e8e3b8ade2121a2c21e2a164c65321.JPG  03.thumb.JPG.01316b0c2d4151aa0f6adce71651a455.JPG


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

Link to comment
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.

MaxVector.thumb.JPG.58d05ba8e760b35c63bde8f8aa57f0d7.JPG

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.

Link to comment
Share on other sites

8 hours ago, Noobini said:

hey i got sumfin'...

 

vu alignY.hipnc

alignY.JPG

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!

Link to comment
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.

Link to comment
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);
image.thumb.png.149ee7a1c4857f85f45d52e6a35f7b65.png

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.

VOP.JPG.ee0022eb8ce06dc715bd2411eb96bdcd.JPG

yes.JPG.9886869dfb5d7798d20bc6d250434a26.JPG

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!

 

all.JPG

Link to comment
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.

vu alignY_17.5.hipnc

Thanks mate but still no luck.

noluck.JPG.7800b132dd80d52e3e117714aac88204.JPG

Link to comment
Share on other sites

Here's my take on it

image.thumb.png.af57d79d03dc527932e0497ad19b168e.png

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.

align_bounds_longest_shortest.hipnc

  • Thanks 1
Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...