Skip to main content
GameDev.net gamedev.net
🔒 Locked

2D Vector Graphics in XNA

Started by Wardyahh May 18, 2008 at 1:41 PM 15 replies 12.9k views
Original Post
Wardyahh
Wardyahh
Hey, in my general perusings of cool things to learn i started looking into Vector Graphics in 2D, i'm now at the point where i want to start playing with techniques. i'm looking at the Xbox 360 as the platform for messing around on and so i'm using xna. i'm just wondering what my options are for 2d vector graphics in XNA from what i've seen so far its pretty limited. options i can think of are: 1. Hard code vector values for objects 2. Find an SVG implemenatation for XNA(if there is one) 3. Create a Full SVG implementation myself(not likley) 4. Create a very basic implementation of one of the smaller standards(1.2 tiny etc. ....still not likely) 5. Create a very simple proprietary filetype(probably in XML) that will suits my needs (similar to the way asplode does it) 6. find aother techniques for implementing 2d vector graphics that can be ported to XNA any advice or suggestions on potential solutions would be greatly appreciated. as always ..Thank You in advance. Wardyahh
--------------------------------------EvilMonkeySoft Blog
Ravyne
Ravyne
Depends on what features you need, and how much detail you really want to be able to have. Sufficiently detailed 3D models/graphics with one element simply set to 0 will do a fine job creating the vector look and feel.
throw table_exception("(? ???)? ? ???");
Wardyahh
Wardyahh
Thank you for your replies,

i have decided i'm goig to try and implement a small subset of the official SVG (Path,Basic Shapes and prerequisites) we'll see how it goes.

once i have something workable i'll post it open source in case anybody wants to use it(read: its not crap and can be used by other people).





in case anybody was wondering,the paricle system i was collecting ideas for is still being developed, i've ported it over to XNA and am currently setting up the ability to allocate different systems to CPU/GPU as required.

Thank You

Wardyahh


--------------------------------------EvilMonkeySoft Blog
dave
dave
A challenging place to start is the tesselation of outline fonts, such as TTFs.
Jason Z
Jason Z
I'm not really sure how much GPU programming you can do with XNA Framework, but in GPU Gems 3, Jim Blinn discusses implementing scalable vector graphics on the GPU. It would at least be worth checking out in the bookstore, even if you just see how he implemented it on the GPU and then convert that to C# or whatever.

Remember to post some screenshots once you've finished it up!
Jason Zink :: DirectX MVP   Direct3D 11 engine on CodePlex: Hieroglyph 3 Direct3D Books: 
Wardyahh
Wardyahh
with the particle system i outsourced all the calculations to the gpu using a shader plugin system, that allowed me to control the particles inside the shader(and use multiple layers of controls all at once.
although shaders do lend themselves to particles manipulation, i'm sure that the conversion from svg to vectors could be partially if not fully outsourced to shaders.
as far as direct access to the gpu ...i have no idea :)

i'll look into it

Thank You
--------------------------------------EvilMonkeySoft Blog
NickGravelyn
NickGravelyn
If you need a decent starting ground for paths, I have some pretty basic starting code for bezier curves found here: http://xnawiki.com/index.php?title=Simple_Bezier_Curve_System. Hopefully that's a good kick in the right direction :).

Definitely keep us posted. I'm working on an SWF reader in C# right now so it would be cool to someday combine my work reading that data with your work in rendering it.
Wardyahh
Wardyahh
Just a quick update in case anybody is interested.

Started work on SVG parser (after reading the official specs) i'm using the official BNF to convert paths into structures.

Initial Roadmap:

Path Parser
Basic Shapes
Conversion of structures into renderable objects(i'm probably going to use the standard XNA/DirectX structures (Line,Polyline etc))
Basic Line Rendering

I have an Assembla page for the project but there isnt much there yet i'll put it up once there is something to show (probably friday) :)

Any suggestions or comments are welcome

(also thank you Nick and Ultima both are very helpful in the curve department)




--------------------------------------EvilMonkeySoft Blog
Wardyahh
Wardyahh
http://www.w3.org/Graphics/SVG/

there are a few different iterations 1.0, 1.1 etc and also Tiny and Basic are intended for smaller platforms handhelds/phones.

they are all quite similar though :)
--------------------------------------EvilMonkeySoft Blog
dave
dave
Thanks.

Have you worked out how to tessellate the shapes described, etc? I did my vector font tessellation with the ear clip method.
Wardyahh
Wardyahh
havent even come close to that yet, still on the parser :)

but it is actually on my list of things to do today , any suggestions ?
--------------------------------------EvilMonkeySoft Blog
dave
dave
I followed this guide. It's quite concise and it took me a few iterations to get working.
Wardyahh
Wardyahh
if you're going to be reading the svg specs its really helpful to learn
Backus Naur Form

its how most of the technical implementations are explained for paths and polylines

its quite simple to learn and immensely helpful in implementing the specs

also wsp stands for Whitespace, took me like 3 hours to find that out



--------------------------------------EvilMonkeySoft Blog
dave
dave
Ok thanks. I eventually intend to provide support for loading SVG images. However at the moment i am finding that my implementation of ear clipping is slow. It needs optimisation before i can consider any real-time vector graphics.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.