Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Assume you have several 1024x1024 textures which contain an arbitrarily shaped and relatively complex cave system whose walls need to have collision polygons defined. The polygons need to be convex to work with the physics engine.

What kind of process and tools can you think of that would make editing the vertices of these walls as efficient and painless as possible? Especially considering that the polygons need to be convex, and the designer needs to see when that is not the case.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Why not let the Artist/Level-Designer draw the rough outline of the cave, then use an algorithm like the ear-clip algorithm to create convex polygons from that outline?

You could even use a tool like potrace or autotrace to create vector outline from you images. Then use these directly or provide them to your Artist/Level-Designer as a starting-point.

share|improve this answer
    
That is wonderful! While looking around, I also found ScanFont to turn images into vector fonts: fontlab.com/font-converter/scanfont –  LearnCocos2D Sep 23 '10 at 9:43
    
I was also thinking about drawing just the lines, then turning them into quads by adding two more points along the normal vector and half the angle between connected lines. That way you'd easily turn a series of lines into a series of quads which aren't regular on the inside but that doesn't really matter. Only need to be careful about the direction of line-drawing, but that needs to be done CCW anyway for physics engines. –  LearnCocos2D Sep 23 '10 at 9:48

You could run your textures through an algorithm to generate polygons based on images, and store the polygon data for use separately.

Several open source physics engines, such as FarseerPhysics, already incorporate a similar feature that you could inspect.

Alternatively, write a simple tool to load the image and allow you to manually 'draw' collision polygons. Depending on how detailed you need your polygons to be, and how many you'd need to create, this may actually be an easier option.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.