scale an object relative to anothers bounding box

   12736   9   4
User Avatar
Member
70 posts
Joined: March 2015
Offline
I want to scale objects in my scene in relation to a simple box which controls the scenes overall scale - could anyone help me out with the needed expression. I seem to remember a tutorial which referred to this as unitization, and it seemed useful at the time but its gone in one ear out the other and I can't remember where that tut is now ops:
User Avatar
Member
443 posts
Joined: Sept. 2012
Offline
You can wire that object to parent input or can use null with referenced scale parameter to that object.
User Avatar
Member
258 posts
Joined:
Offline
Don't think the parent scale thing will work…I have done this with Lattice deformer.

The idea is that you use the boundSop to drive a lattice deformer (Lattice needs to be a bound with only 6 sides and 8 points- no extra divisions). You can then procedurally link the lattice deformer points, to the bounds of the object that you want to match (In your case, the box for the scene).

If set up correctly, this works every time flawlessly - you might need to merge everything and split it out, depending on your needs.
User Avatar
Member
443 posts
Joined: Sept. 2012
Offline
I think user is asking about scaling up or down overall scene. I always use null for that and it's easier to control.
User Avatar
Member
258 posts
Joined:
Offline
How would you scale a scene to match a bounding box automatically with a null. If you want to create a bounding box and have your scene fit it exactly this wont' work. Sure you could use the null to “scale” your whole scene and find a number that will work by visual adjustment but…

if you want a procedural way that makes it match a box's bounds exactly. I.e here is a box, let me scale it up and down and watch my scene automatically update and fit, unless you unify your box and scene first so the scales match, the null will break and fail.

Have your whole scenes, creating a bound around it, and use that to match your box will work every time and does not need to be tweaked manually with a null.

If all you want is to be able to scale your whole scenes, then yes, just parent a null and go to town. if you want a procedural way to match a box's scale without them matching, and you want it to be exact, not almost exact, but exact, then use the lattice method.

I guess you could also normalize the scene to 0-1 then find the scaler value for the box and multiply…
User Avatar
Member
70 posts
Joined: March 2015
Offline
Is it possible you could upload an example of the lattice method you're describing? Sorry to be a pain ops:
User Avatar
Member
483 posts
Joined: Dec. 2006
Offline
something like this?
Edited by matthias_k - July 30, 2016 06:05:39

Attachments:
scale_by_box.hip (102.6 KB)
scale_by_box_extended.hip (105.6 KB)

English is not my native language, sorry in advance for any misunderstanding :-)
User Avatar
Member
252 posts
Joined: Jan. 2008
Offline
Have a look at the match size SOP
User Avatar
Member
483 posts
Joined: Dec. 2006
Offline
Cool, thanks for the info :-)
English is not my native language, sorry in advance for any misunderstanding :-)
User Avatar
Member
22 posts
Joined: Sept. 2015
Offline
this works nicely get get everything “unitized”. Enter the expression in the uniform scale parameter of the transform sop. I just have it saved as a preset.

1/max(max(bbox(opinputpath(“.”,0), D_XSIZE), bbox(opinputpath(“.”,0), D_YSIZE)), bbox(opinputpath(“.”,0), D_ZSIZE))
  • Quick Links