SVGTextureRegionExtension

  ... information about changes and new features of AndEngine,

Do you think the new SVGTextureRegionExtension is useful?

Fuck yeah!
51
85%
I don't know...?
8
13%
No!
1
2%
 
Total votes : 60

SVGTextureRegionExtension

Postby Nicolas Gramlich » Sun May 22, 2011 10:49 pm

Hello Community,

over the past couple of months the SVG-->Texture(Region) idea was floating through the forums. (Not only) My opinion was that it would be to slow to be well usable, especially thinking of startup times.
Inspired by the library behind Androidify ( http://code.google.com/p/svg-android/ ), I worked a little on this now ... :)
I had to rewrite their path-parser so it can handle both formats that are used by Inkscape and Adobe Illustrator. Together with some many bugfixes and lots of refactoring and enhancements here are some examples:

From left to right:
  1. Created from scratch using Inkscape
  2. Created from scratch using Inkscape (including gradients)
  3. Created using Adobe Illustrator (does excellent and clean export btw!)
  4. Created by opening previous image and saving it using Inkscape ( :exclamation: need to fix gradients as Inkscape saves weird things when importing a svg created with Adobe Illustrator :exclamation: )
andenginesvgtextureregionextension_2.png
Note: The second monkey-thing looks blurrier, as it is rendered at a lower resolution as the first one and is then upscaled by opengl.
andenginesvgtextureregionextension_2.png (45.78 KiB) Viewed 4843 times


This is how you would use it:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. int size = (isHighResDevice()) ? 128 : 64;
  2. ITextureRegion textureRegion = SVGTextureRegionFactory.createFromAsset(this.mBuildableTexture, this, "gfx/vector.svg", size, size);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

Also you'll be able to render svg files to PNGs so that you have to render them only once, i.e. when the game is first started, and after that only have to load them i.e. from the SDCard.

Example: The FarmTower SVG Chicken rendered in different sizes! (8x8, 16x16, 32x32, 64x64, 128x128, 256x256)
andenginesvgtextureregionextension_3.png
andenginesvgtextureregionextension_3.png (102.19 KiB) Viewed 4837 times

:lighbulb: The compressed SVG is about 1.5kB where the size of the images (png) is about 20kB. :exclamation:

:lighbulb: Conclusion: You'll be able to render your sprites directly from svg to textures in the perfect device-specific size, which you determine during runtime, instead of putting a pre-rendered png into each and every resource-folder (ldpi/mdpi/hpdi/xhdpi/xlarge/... ). :) :D

That's it for today.
Will fix the remaining issues tomorrow :) Done. :check:
[Edit]Now working on allowing to specify the width/height to render the svgs at.[/Edit] Done. :check:
[Edit]Now working on gradient strokes.[/Edit] Done. :check:
[Edit]Adding support for "Optimized Inkscape-SVG" (has all redundant and Inkscape specific tags/attributes stripped!)[/Edit] Done. :check:
There will be a public release in a couple of days. Done. :check:

Download

Jar: http://code.google.com/p/andengineexamp ... ension.jar
Repository: http://code.google.com/p/andenginesvgte ... extension/

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: SVGTextureRegionExtension

Postby Nicolas Gramlich » Mon May 23, 2011 4:46 pm

*Updated*
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: SVGTextureRegionExtension

Postby rkpost » Mon May 23, 2011 5:59 pm

Nice job!!!

About performance, is possible to load SVG only once, right? (SVG needs more CPU than PNG)
rkpost
 
Posts: 201
Joined: Tue Sep 14, 2010 5:52 am
Location: Buenos Aires

Re: SVGTextureRegionExtension

Postby Nicolas Gramlich » Mon May 23, 2011 7:27 pm

rkpost wrote:Nice job!!!

About performance, is possible to load SVG only once, right? (SVG needs more CPU than PNG)

Parsing a SVG and rendering it is probably at least 10x slower than simply loading+decoding a png.
Yes, the developer should implement some kind of "initial loading", i.e. when the game is started first. (Maybe I'll add some kind of caching on the Engine level).
BUT: For an "average game" the slower loading might still be fast enough, though!

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: SVGTextureRegionExtension

Postby Nicolas Gramlich » Tue May 24, 2011 10:45 am

[Edit]Adding support for "Optimized Inkscape-SVG" (has all redundant and Inkscape specific tags/attributes stripped!)[/Edit] Done. :check:

"Optimized Inkscape-SVG" and "Adobe Illustrator SVG Basic 1.1" will be the desired export options! (Both create: clean short and readable svg data!)

I'm currently porting FarmTower to use this extension. When I'm finished I'll probably have stumbled over most bugs/SVG corner cases :lol:

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: SVGTextureRegionExtension

Postby pep_dj » Tue May 24, 2011 9:09 pm

Great work Nicolas. Would be nice to see andengine games in HD :)
Image
pep_dj
 
Posts: 170
Joined: Fri Nov 12, 2010 9:05 pm

Re: SVGTextureRegionExtension

Postby Nicolas Gramlich » Thu May 26, 2011 10:19 am

FYI: FarmTower HD (old package, new name) is out! ( https://market.android.com/details?id=o ... mtower.eco )

Would be great if you could give it a try.

Btw: I'm not caching any svg, all are rendered when the a game is started! Startup is about 1 second longer (but still acceptable imo).

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: SVGTextureRegionExtension

Postby angel.ivorra » Sat May 28, 2011 4:14 pm

Great work, it looks amazing... i'm excited to see the the sources in the repository...

Great work !!
angel.ivorra
 
Posts: 37
Joined: Mon Mar 21, 2011 11:49 pm

Re: SVGTextureRegionExtension

Postby Obg1 » Sun Jun 05, 2011 5:57 pm

Farm Tower HD Looks great on my Tablet, the only issue is texture bleeding, but its not related to the SVG Extension
Obg1
 
Posts: 67
Joined: Tue Oct 05, 2010 10:43 am

Re: SVGTextureRegionExtension

Postby nikit87 » Sun Jun 05, 2011 9:38 pm

Hi, Nicolas!
I realy want to use this extension but it's like a bug in repositiry or something else.

There are many revisions in project activity (http://code.google.com/p/andenginesvgte ... dates/list), but when i'm tried click on it the error appeared. And when i'm tried to browse source appear error "Error retrieving directory contents." Checkout empty too. Is it temporary problem or something else?

P.S. You project realy, realy awesome! 8-)
nikit87
 
Posts: 2
Joined: Sun Jun 05, 2011 8:55 am

Next

Return to Updates

Who is online

Users browsing this forum: No registered users and 2 guests