SVG Loader Extension

  ... the SVG Extension for AndEngine.

SVG Loader Extension

Postby eric » Mon Feb 28, 2011 5:22 am

Hi to all,

I recently uploaded my SVG Extension.
It uses the EntityContainer branch!
(it is merged with the default now so u can use default branch from Andengine)

Currently it's more a beta version.
So feel free to check it out and help me developing if u like.

http://code.google.com/p/andenginesvgextension/
http://code.google.com/p/andenginesvgextensionexamples/
http://code.google.com/p/andenginesvgex ... apeplugin/

Some performance and memory leak saving tips would be nice. ;)

Best regards to all :)
Last edited by eric on Tue Mar 29, 2011 4:14 pm, edited 1 time in total.
eric
 
Posts: 44
Joined: Wed Feb 16, 2011 9:53 pm

Re: SVG Loader Extension

Postby adeluiz » Mon Mar 07, 2011 12:35 pm

Very, very interesting and promising, but a brief tutoria/introduction is needed. BTW, the examples looks fantastic.
adeluiz
 
Posts: 22
Joined: Wed Sep 22, 2010 10:59 am

Re: SVG Loader Extension

Postby eric » Mon Mar 07, 2011 12:53 pm

Thank u :)

I'am currently in a better texture management.
Actually Textures loading twice for now :(
Later comes joints and body fixture groups...
Also i have to find some memory wasting stuff.

I'll make some little Tutorials in the Wiki soon.
Unfortunatly i have to work a lot this Month...

Thanks for reply ;)
eric
 
Posts: 44
Joined: Wed Feb 16, 2011 9:53 pm

Re: SVG Loader Extension

Postby Merllinas » Tue Mar 08, 2011 10:18 am

Wow, that is awesome!!! I just checked it - it rocks. I'm going to do a project based on your parser!
Merllinas
 
Posts: 82
Joined: Tue Nov 30, 2010 11:32 am
Location: Vilnius, Lithuania

Re: SVG Loader Extension

Postby eric » Tue Mar 08, 2011 11:15 am

Thx :)

I commited some texture management yesterday.
If you find errors or you have any idea to make the parser a bit smoother let me know.
Currently it is wasting some memory.
I'am sure it can be more optimized.
Take it as a beta.

good luck :)
eric
 
Posts: 44
Joined: Wed Feb 16, 2011 9:53 pm

Re: SVG Loader Extension

Postby Supergeek » Tue Mar 08, 2011 5:24 pm

I would love to do the animation of my main character with SVG bits so I don't have to create 2700 different sprite poses.

How bad is this on memory and performance? Is it good enough for a market app?
Supergeek
 
Posts: 52
Joined: Mon Feb 14, 2011 12:20 am

Re: SVG Loader Extension

Postby eric » Tue Mar 08, 2011 5:58 pm

Hi,

I'm not really sure what u mean.
But SVG animation is not supported yet.
It has to use EntityModifiers anyways.

Or if u try to load 2700 SVG's this would increase the memory usage a lot.

So I think you should use Tiled or Animated Sprites for this.
Or u load the charachter parts and use EntityModifiers for animation.
Keep in mind that the center from the objects loaded via SVG are allways in the center of the bounding box.
Setting a center is on my TODO list and its half done but i need time to test some Stuff.

Loading some SVG's schould be ok for market but memory usage increases with every loading. :(
Performance is good so far.
eric
 
Posts: 44
Joined: Wed Feb 16, 2011 9:53 pm

Re: SVG Loader Extension

Postby Merllinas » Wed Mar 09, 2011 10:32 am

Hey,
is there anything to know about SVG for beginners? I'm using Inkscape and there are like 4 different formats, bunch of settings and so on... Should my SVG's be "clean" as in your examples or can it contain inlined images? Any other pointers we should know about?
Merllinas
 
Posts: 82
Joined: Tue Nov 30, 2010 11:32 am
Location: Vilnius, Lithuania

Re: SVG Loader Extension

Postby eric » Wed Mar 09, 2011 12:51 pm

Hi,

did u saw my Inkscape plugin?
It can set all supported attributes.
The SVG file has not to be clean u can use the Inkscape file.

Images are not supported.
If u like to have an image (sprite with texture) the SVG Element looks like this:
<circle andengine-hasshape="true" andengine-spritesrc="gfx/ball.png" ... (src relative to assets folder in ur andengine project)
U can use the Inkscape Plugin for that. (Extension->Shape->Sprite...)

Some things to know:
  • Inkscape does not make circles if u use the cirlce tool. It creates a path!
    If u like to have a perfect circle u have to insert it ur self.
  • Every SVG Node needs an id! This is the name u can call from in the source.
  • All colors should be hexa (#ff0000).
  • Transformation should be without skewing cuase it is not realizable in andengine.
    Only scaling, translation and rotation are supported. (u can transform groups as well)
    If u have a skewed rectangle for example u can make a path out of it ;)
  • Rectangles does not support rounded corners. U should make a path out of it.
  • If a Path is sticky and crash ur game it has the wrong direction.
    U can switch it in Inkscape.
  • A Path should have only one z or Z (closing) inside and dont cross itself.
If u have a curved path or ellipse (roundish objects) and you like to draw primitives or your object has physic,
u should check this attribute andengine-curvesegments="10". (Extension->Shape->Sprite Properties...)
With that u can make things smoother. (in this case u have 10 Segments per curve)
Keep in mind that all is for the game engine. (smoother == more objects == more memory and cpu usage)

One good choice is to make a texture from all static objects and only import physic from SVG.
So that u only have one texture in background and the physic objects stay invesible in the foreground.

You can find all u need in the SVG Examples. (SVGLoaderExamples\assets\svg\*)

In future it'll be possible to group many objects to one object. (childs or fixture groups)
For now every SVG objects is a single object in the game.

Ok i have to work a bit :)
eric
 
Posts: 44
Joined: Wed Feb 16, 2011 9:53 pm

Re: SVG Loader Extension

Postby Giszmo » Thu Mar 10, 2011 2:51 am

Hi,

nice you did this but it took me some time to figure out what was going on there. All those andengine-... tags are not visible in the example code.
Tomorrow I will look into it to see if I can use your lib to load an svg, iterate over the entities and make my game entities from that spacial information. In the end I want to be able to edit my levels in Inkscape only. Without having to add tons of andengine-specific tags in the svg.

So what I need is to get the type and the color and maybe an id/label. This way I intend to do something like:
circle: unit. color=team color. label=team name.
blue box: wall
red box: level outline
green line: wind direction
...
getShapes() looks like the only way to get the shapes but shapes are only Line, Text, TriangleShape and Rectangle. Hmm... tomorrow ...
FluxCards allows you to learn 20 words per day with only 15 minutes repeating per day. Try it out. It's free and amazing ;)
Image Image
Giszmo
 
Posts: 113
Joined: Thu Mar 03, 2011 11:07 pm

Next

Return to SVG

Who is online

Users browsing this forum: No registered users and 2 guests