4
\$\begingroup\$

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.

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ That is wonderful! While looking around, I also found ScanFont to turn images into vector fonts: fontlab.com/font-converter/scanfont \$\endgroup\$
    – CodeSmile
    Commented Sep 23, 2010 at 9:43
  • \$\begingroup\$ 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. \$\endgroup\$
    – CodeSmile
    Commented Sep 23, 2010 at 9:48
1
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .