I know most of you on this forum are fond of making 2d games.
One common need is to pack a group of textures into the smallest possible space that has powers of two for the sides.
I have made an application that uses the powerful MaxRects algorithm(The same one used in TexturePackerPro) to pack the textures. It then outputs the locations in a json file. (If you do not know what json is, it is a simpler version of XML)
Enough talk, here are some pictures. NOTE: I do not have or claim copywrite for any of the following sprites.
General large amount of sprites to pack:
[URL=http://i55.tinypic.com/r258he.png][IMG]http://i55.tinypic.com/r258he_th.png[/IMG][/URL]
Gui interface for above:
[URL=http://i53.tinypic.com/25hkg2t.png][IMG]http://i53.tinypic.com/25hkg2t_th.png[/IMG][/URL]
Json output:
[URL=http://i56.tinypic.com/2d7et5v.png][IMG]http://i56.tinypic.com/2d7et5v_th.png[/IMG][/URL]
Command line options:
[URL=http://i55.tinypic.com/rkbxxu.png][IMG]http://i55.tinypic.com/rkbxxu_th.png[/IMG][/URL]
Trys to fit it in a smaller box if possible:
[URL=http://i54.tinypic.com/2q8op39.png][IMG]http://i54.tinypic.com/2q8op39_th.png[/IMG][/URL]
Command line interface(I think it is simpler) to make above:
[URL=http://i51.tinypic.com/23kxapl.png][IMG]http://i51.tinypic.com/23kxapl_th.png[/IMG][/URL]
The program is licensed under the permissive FreeBSD license.
(The terms can be summarized as do not claim you made it)
I have yet to have success compiling for windows, but I have the source available on github at [url=http://bit.ly/f8gfXU]https://github.com/Lalaland/PixelPacker[/url](read the README for my notes about building from source).
I do have precompiled versions for Linux, both 32-bit and 64-bit.
Make sure you have libgtkmm, libboost, and libgraphicsmagick++ installed before running.
[url=http://bit.ly/gDXwgO]https://github.com/downloads/Lalaland/PixelPacker/PixelPacker-1.0-64bit.tar.gz[/url]
[url=http://bit.ly/ezuj0r]https://github.com/downloads/Lalaland/PixelPacker/PixelPacker-1.0-32bit.tar.gz[/url]
To use you need to 'tar xfv' the file, then cd into the directory and run the executable PixelPacker found under bin.
One last thing to note is that the guillotine algorithm is buggy. Not planning on fixing it as the Shelf algorithm is faster if you want speed, and the MaxRects is better at packing.
Hope you find it useful.
Looks awesome, I may have use for this for the contest.
"Gui interface"...Reminds me of that one CSI scene. "Graphical User Interface interface"?
None the less, looks useful ;)
RAS Syndrome
I do want to note that for anyone who wants to use this with OpenGL, that OpenGL works with 0,0 in the [B]lower[/B] left corner.
This is different from the usual standard of 0,0 in the [b]upper[/b] left corner for most software rendering.
In order to use these coordinates for OpenGL, the texture cords are as follows:
[url=http://tinypic.com/view.php?pic=1256ngm&s=7][img]http://i53.tinypic.com/1256ngm_th.png[/img][/url]
You should also divide the text cordinates by the size of the atlas to get a number between 0 and 1.
[QUOTE=killman;28535407]I do want to note that for anyone who wants to use this with OpenGL, that OpenGL works with 0,0 in the [B]lower[/B] left corner.
This is different from the usual standard of 0,0 in the [b]upper[/b] left corner for most software rendering.
In order to use these coordinates for OpenGL, the texture cords are as follows:
[url=http://tinypic.com/view.php?pic=1256ngm&s=7][img_thumb]http://i53.tinypic.com/1256ngm_th.png[/img_thumb][/url]
You should also divide the text cordinates by the size of the atlas to get a number between 0 and 1.[/QUOTE]
If you've set up your projection correctly, that shouldn't be necessary. If you are talking about the default projection, the coordinate 0, 0 is in the middle of the screen, not in the bottom-left.
Sorry, you need to Log In to post a reply to this thread.