scaling along longest axis of OBB

   2973   4   1
User Avatar
Member
187 posts
Joined: Aug. 2011
Offline
Hi ..

I'm trying to find a way how I can do the following:

I have a wooden board which comes into Houdini any way rotated, as an .obj file.

Now, I'd like to take the oriented bounding box for this board and scale along the OBB's longest dimension.

How would I do this ?

Any input welcome !

Matt
User Avatar
Member
361 posts
Joined: Nov. 2008
Offline
It's easy in SOPs:
Get oriented bbox, measure length of 3 orthogonal edges, choose longest one, set it as axis for Transform Axis SOP and scale as you want.

Look at example

Attachments:
pz_scale_by_oriented_bbox.hipnc (85.4 KB)

User Avatar
Member
187 posts
Joined: Aug. 2011
Offline
hey !

thanks for the input. this does exactly what I need. very cool !

but the expression with the prim() to check which edge is the longest .. I don't understand it's logic because it's somewhat nested code. can you explain that code ?

thanks again .. !
User Avatar
Member
678 posts
Joined: July 2005
Offline
deadalvs
I don't understand it's logic because it's somewhat nested code. can you explain that code ?

Than write it down differently. Paste this in the “select_axis” node.

{
p0 = prim(“../measure_edges”,0,“edge_length”,0);
p1 = prim(“../measure_edges”,1,“edge_length”,0);
p2 = prim(“../measure_edges”,2,“edge_length”,0);

myval = 0;

if (p0 > p1)
{
if (p0 > p2) myval = 0;
else myval = 2;
}
else
{
if (p1 > p2) myval = 1;
else myval = 2;
}

return myval;
}


Better?

I hate writing long expressions in one line. You can write multiline expressions in hscript, so use this possibility.
User Avatar
Member
187 posts
Joined: Aug. 2011
Offline
hey !

much better readable..

thank you !!

matt
  • Quick Links