Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2D vector modelling for game development

Making my Asteroids clone (in C) I've rather fallen in love with vector-based entities, but I've simply coded them in as x,y-point arrays. That's been fine for something like Asteroids, but what should I do if I want to make more complex 2D models?

I note that there is an awful lot of 3D modelling software out there, as well as ample tutorials and help on importing 3D models into one's C/C++ program for use with Open GL.

However I'm rather more interested in creating 2D vector-based models than 3D, as I'm perfectly happy to keep trying 2D games for a while yet. Does such a concept as 2D modelling exist? Are there tools for creating and exporting 2D models and libraries for importing 2D models specifically, or does one just create flat models in 3D software and then import those files (e.g. .3ds, .ms3d) and lay them flat onto the z-axis?

My only thought so far was perhaps using something like Inkscape for modelling, generate SVG files, and then use Cairo to import and render them. Will that work well, or do you have other recommendations?

Note I'm a bit of a newbie to modelling of any kind, so I may be asking a silly question...

like image 467
Gavin Avatar asked Jan 16 '10 23:01

Gavin


People also ask

What is 2D vector in game programming?

In game development, vectors have two or three dimensions (depending on whether you are making a 2D or 3D game) and are generally used to represent geometrical properties of objects within the game world (rotation, position, etc.).

How are vectors used in game development?

More often, Game Developers use Vectors to determine the position of an object, the speed of a moving entity, the length of a certain object, and the distance between two specific positions. Further, it also helps in getting the direction which is mostly used in games having automatic following mechanics.

Do games use vector graphics?

Vector is present both in old and modern games; the graphic holds specific advantages, making them useful even with the current technology in game development. Moreover, various game developers use certain assets made of Vectors while applying different graphic technologies to the game's main content.

What are vector graphics in video games?

Vector graphics refer to the use of geometrical primitives such as points, lines, and curves (i.e., shapes based on mathematical equations) instead of resolution-dependent bitmap graphics to represent images in computer graphics.


2 Answers

No need to upvote my own answer, but I've done a bit more research into using SVG. As I'm using OpenGL, it seems that OpenVG might be a good match.

  • AmanithVG - a commercial implementation of OpenVG built on OpenGL, with both software and hardware rendering. Download available for evaluation only, and it works beautifully, though I don't know how much it costs.
  • ShivaVG - the author was annoyed that AmanithVG was commercial, so made his own opensource implementation in pure ANSI C. Hasn't been updated for a while though. At SourceForge.
  • Anti-Grain Geometry - not sure about this one. I think there is support for SVG, but I think software-rendering only.
  • librsvg - uses Cairo as a primary backend to render SVGs. Looks good.

It seems that all except librsvg stop short of actually allowing SVG files to be loaded in, so presumably there needs to be another step where SVGs are parsed into appropriate OpenVG structures (which mostly seem to be big float arrays, so not too hard). There likewise seems to be a one-to-one mapping of items from SVG to OpenVG, which is promising. As far as I can tell, OpenVG was pretty much made for SVGs.

I will probably use ShivaVG. Maybe it's not perfect, but it draws the tiger and I love a pure C / OpenGL implementation, and I seriously doubt I'll be doing anything all that complex just yet.

like image 75
Gavin Avatar answered Sep 21 '22 11:09

Gavin


As far as 2D vector game programming goes, it usually is the domain of Flash and Flex.

Still SVG and loading it via Cairo seems to be a viable solution. Although I'd take care to make sure that you have hardware acceleration enabled (OpenGL backend preferably).

As far as 2D formats go, you won't get as good support as for SVG for any format, so I'd stick with it. Technically things like Collada or X3D do support 2D graphics, but practically they have a lot of useless (for a 2D programmer) bloat.

like image 25
Kornel Kisielewicz Avatar answered Sep 21 '22 11:09

Kornel Kisielewicz