Fitting many images on smallest possible texture..

Blitz3D Forums/Blitz3D Beginners Area/Fitting many images on smallest possible texture..

Abomination(Posted 2011) [#1]
I want to fit images of "almost" the same size on a texture, as small as possible.
So I create a "imaginary" texture with a surface (width*Height) that is greater than the combined surfaces of the images.
Try and see if they fit. If not, use a larger texture... and so on.
Now I can think of several methods of "fitting", but those ar all slow, messy and kind of smelly.
So my question is: Does anyone know code that does more ore less what I'm looking for?
I know, I saw code that did something similar, in a tutorial about C++, (had to do with fitting aircrafts on a flightdeck), but I can't find that anymore.
(sorry for being a lazy bum)


Gabriel(Posted 2011) [#2]
I'm pretty sure I based my texture-packing code on this :

http://www.blackpawn.com/texts/lightmaps/default.html

I'd post my code but it's not very readable and I really don't remember much about it, so it'd likely be more trouble than it was worth.


Matty(Posted 2011) [#3]
Code archives:

http://blitzbasic.com/codearcs/codearcs.php?code=1208

Box packing by fredborg.


Abomination(Posted 2011) [#4]
WOW!
I'd like to kiss you both on all of your 4 cheeks each. (So I'm kinda glad I can't actually) ;P
The box packing by fredborg is similar to what I was trying to do, but with a nice fragrance, and it's also about ten times faster.
The Packing Lightmaps example is pretty much how I remember that C++ tutorial. So I will convert it to something more Blitzy and compare it with Fredborgs code. If I can brew it into something decent, I'll post it here.