Jump to content
Stevie Mac

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

Share this post


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

Share this post


Link to post
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!

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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 this post


Link to post
Share on other sites
Posted (edited)

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 this post


Link to post
Share on other sites

close !!!!

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

planks.jpg

Share this post


Link to post
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 this post


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

vu alignY.hipnc

Didn't work again but if you do this it will better!
Yours
5e77d073b460f_Notworking.thumb.JPG.e4d4d41b70009c47995a0028fd8d7a42.JPG


Added the first part of mine.
Working.thumb.JPG.3f33933d97b49c15d33e377b1b58dfec.JPG

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

haha great, got there in the end.

Share this post


Link to post
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 this post


Link to post
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 this post


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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×