Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any tutorials on coding a parser for SVG files to be used by box2D?

I am trying to create an iPhone game with fairly large levels. Hard coding the platforms and physics objects is very time consuming. I have seen some people have made their own parsers for svg files to use in box2D, and Riq is selling levelSVG but it is a little pricey for me at the moment, and I only need basic features. Is there a tutorial on how to code a parser available online?

like image 627
kai Taylor Avatar asked Apr 02 '11 10:04

kai Taylor


People also ask

What is SVG parser?

svgparser is a pull-based parser for SVG 1.1 Full data format without heap allocations.

What language does SVG use?

Scalable Vector Graphics (SVG) are an XML-based markup language for describing two-dimensional based vector graphics.

What program works with SVG files?

Google Chrome, Firefox, IE, Opera, and every popular browser has the capacity to render SVG images. SVG files are also supported in basic text editors and high-end Graphics editors like CorelDRAW.


2 Answers

Have you taken a look at SVGQuartzRenderer? It is designed to render SVG files in Quartz, so I imagine you might be able to pull out the SVG parsing code from this. It's opensource, MIT license.

like image 87
Tyler Avatar answered Oct 06 '22 08:10

Tyler


I don't know about any tutorials but its fairly easy to do this using an XML parsing library. In my project I use MiniDOM to load an svg file and then I convert the elements into objects in the box2d word. The only thing that I had to do manually was the parsing of the path element.

like image 21
dabski Avatar answered Oct 06 '22 07:10

dabski