fitting arbitrary shapes in a box

   10418   5   2
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
Is there a very clever way to fit multiple arbitrary shapes within a box (i.e using DOPs or anything like it). I wanted to try to come up with a good UV layout fitting algorithm and I was thinking to explore the problem in an abstract fashion

thanks!
-G
User Avatar
Member
453 posts
Joined: Feb. 2013
Offline
I would normalize and place the shape with a transform node. Not sure what more you need.
User Avatar
Member
23 posts
Joined: April 2012
Offline
Some interesting stuff here: http://forums.odforce.net/index.php?/topic/15903-filling-grid-with-circle-shapes/ [forums.odforce.net]
User Avatar
Member
390 posts
Joined: Jan. 2012
Offline
had to do this once and although not perfect i got it to work by placing each object, and then growing each object, and then checking for intersections. when an object intersected with another object, it stopped growing.

this was kind of slow for complicated objects because i was using volumes for collision detection, but for 2d shapes you dont need that so it should be pretty fast
.
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
thank you guys for the suggestions! In my particular case, I have the difficulty that I have to pack pretty arbitrary shapes within a single square and wasting very little space, which is why I cannot use standard square packing.

In the screenshot below, you can see some of my progress: shapes (big or small), try to find the most optimal place they can find. What I do is that I attack pieces from larger to smaller when I do the placement to ensure that they pack in an ideal fashion. Because this is for UVs, I am also trying to avoid weird shape transformations (I plan to only allow 90 degree transformation and no scale, other than a uniform scale on all the pieces to match the ratio of the box)

the most difficult part so far has been trying to figure out how to best scale them to fit them within the square (the larger pieces are actually more difficult to deal with than the small ones )

zdimaria, your approach to this seems very similar to what I am trying… in your case, did you have to also have to resolve the pieces fitting within a box?

thank you again!

Attachments:
uvpackingTest.jpg (83.8 KB)

-G
User Avatar
Member
390 posts
Joined: Jan. 2012
Offline
they had to fit in any arbitrary shape. again all of that was in 3d, so slightly different. i am not sure how to efficiently set up 2d collision detection in houdini. the quickest way for me to set it up would be to convert the planes to a thin volume in 3d, but im sure you could set up some simple point in polygon detection using python.

itd be a bit of work to change what i was doing to fit this though. my workflow was essentially

scatter points inside volume of object, copy small spheres or boxes or w.e. to points.

make of volume of each sphere, then for each sphere, peak a small amount, and see if it intersects any other sphere, if not go to the next sphere.

this would grow all of the objects until they were all very close to touching.

then id scatter more points in between and repeat.

again this works for packing objects, but i dont think its really directly applicable to packing uvs. i dont think you'd want to scale your uvs drastically different from eachother
.
  • Quick Links