Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to create some fairly complex 2d predefined paths for my AI sprites to follow.

I'll need to use curves, splines etc to get the effect I want.

Is there a drawing tool out there that will allow me to draw such curves, "mesh" them by placing lots of points along them at some defined density and then output the coordinates of all of those points for me?

I could write this tool myself but hopefully one of the drawing packages can do this?

Cheers!

share|improve this question
add comment

3 Answers 3

up vote 4 down vote accepted

You could use Inkscape (open-source vector drawing program) to draw bézier curves, add as many nodes as needed in them and then turn them to straight paths.

Inkscape outputs SVG files, which are XML documents. You can then extract points fairly easily from the d attribute of svg:path elements.

A few hints for using Inkscape:

  • Create a rectangle in your document, this will add an svg:rect to your SVG file

  • You can turn it into an svg:path by hitting Ctrl+Shift+C

  • You can then move and distort the nodes however you want. Double-clicking on a segment will add a new node. Dragging anywhere on a segment will turn it into a bézier curve

  • To add more nodes to your path (make it smoother), select all nodes and click the "+" button in the node toolbar.

  • Once you're done editing your curve and you have added enough nodes, you can turn it back into a straight path by clicking on the button named "Make selected segments lines"

  • Ctrl+Shift+X opens an XML editor from which you can copy / paste the path data.

The SVG path data for straight segments is pretty straightforward:

  • "M x,y" moves the pen to the specified location
  • "L x,y" (or just "x,y", the L can be and is ommitted by Inkscape) draws a segment to the specified location

See here for full syntax: http://www.w3.org/TR/SVG/paths.html#PathData


Alternatively, you could try using my VectorLevelProcessor content pipeline processor, which parses SVG files & path data and can generate point list for bézier curves. But it might be too much work to integrate if you only need a few paths.

Here's a link to the main source file: http://nuclearwinter.codeplex.com/SourceControl/changeset/view/1268293a8bff#VectorLevelProcessor%2fVectorLevelProcessor.cs

It's part of a bigger framework that you can check out at http://nuclearwinter.codeplex.com/

share|improve this answer
    
Thanks a lot Elisee that sounds like a great approach. –  TerryB Nov 16 '11 at 23:40
add comment

Try the Curve Editor from App Hub's education catalog.

share|improve this answer
    
Just tried it, it's a neat tool but it's for creating function curves (One Y value for every X), won't work for AI paths which can backtrack and move in all directions. –  Elisée Nov 16 '11 at 12:07
add comment

I recommend that you don't do this. For a useful blog post, with some video demonstrations, see Fixing Pathfinding Once and For All. Some of the most annoying pathing bugs in Everquest are due to the older zones and their waypoint graphs (also known as lattice pathing), where it looks like the NPCs ride on rails once they've reached the mesh.

share|improve this answer
    
cheers Tangurena. That was very interesting. For my case though I'm just making a casual game where the AI simply follow a single predefined path, no pathfinding involved. –  TerryB Nov 17 '11 at 23:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.