TextureAtlas generator

Nibbie
Posts: 2
Joined: 2009.08
Post: #1
Hi iPhone developers,

If you spend a lot of time merging individual images into one TextureAtlas, this might be interesting for you: I posted a Perl script for generating a TextureAtlas png from a config files, which basically enumerates the texture images that should go into the TextutreAtlas..

http://zombiesmash.gamedrs.com/?p=114

Check it out!

We are working on upcoming ZombieSmash! using cocos2d.

- Zombie

----
http://www.zombiesmash.gamedrs.com
http://www.twitter.com/zombiesmash
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2
I wonder how that algorithm compares to the one I wrote a couple weeks ago in terms of spacial efficiency. Mine sorted by height, picked the tallest box that would fit in the given area. That gave you a strip to the right and box below to recursively descend into. Throwing in randomly sized boxes it usually got > 96% full.

I never got around to implementing actual image packing as I didn't really have a use for it, but I liked the simplicity of the recursion in Ruby.

Code:
def pack_strips(w, h, boxes)
    avail = boxes.select{|box_w, box_h| box_w <= w and box_h <= h}
    return [] if avail.empty?
    
    box_w, box_h = box = avail.pop
    strip = pack_strips(w - box_w, box_h, avail)
    remain = pack_strips(w, h - box_h, avail - strip)
    return (strip + remain) << box
end

Now I'm going to have to try that algorithm too. Rasp

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Nibbie
Posts: 2
Joined: 2009.08
Post: #3
Quote this message in a reply
Nibbie
Posts: 2
Joined: 2009.08
Post: #4
thanks for the link. very nice.
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2009.07
Post: #5
Or you could just use the command line tool ImageMagic. That tool saved my sanity, and it can do image conversion etc on the fly.
Quote this message in a reply
Member
Posts: 129
Joined: 2009.03
Post: #6
I made one too (with packing algorithm based on the blackpawn.com one too), check out my sig.
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2009.08
Post: #7
I'm doing this in my sprite engine by runtime. works like a charm. An interesting idea is to size sort all images and adding them in "largest to smallest" order.
Quote this message in a reply
Nibbie
Posts: 2
Joined: 2009.03
Post: #8
I built one tooSmile
I made a simple photoshop script using information from the aforementioned blackpawn article: http://richardjdare.com/blog/2009/08/tex...las-maker/
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2009.02
Post: #9
Here's another free tool that I found useful for making texture atlases:

http://zwoptex.zwopple.com/

It's an online flash app that can optimally pack sprites into a sheet. It then lets you export the texture and a plist file (easy to read in objc) with all of the details. It's a very nice tool. one of the benefits of this over some of these scripts is that it also will trim any excess empty space from the edges of the uploaded images. This is a big win when trying to pack things optimally.

Looks like they are also working on integrating this with Cocos 2D, which would be great as I found the texture atlas generation script that comes with Cocos2D to be lacking since it doesn't trim sprites before adding them to the sheet.

-Keith
Quote this message in a reply
Member
Posts: 446
Joined: 2002.09
Post: #10
Telemachus Wrote:I built one tooSmile
I made a simple photoshop script using information from the aforementioned blackpawn article: http://richardjdare.com/blog/2009/08/tex...las-maker/
The custom data template and the fact that you're left with a layered Photoshop file makes this especially useful. Thanks!
Quote this message in a reply
Post Reply