Sign in to follow this  

[SlimDX] Draw a stroked spline?

This topic is 3316 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I should preface this post by saying I'm pretty new to Direct3D and SlimDX. I want to create a stroked spline tool, kind of like the path tools in Photoshop/Illustrator. My hope is to stroke the spline with a texture, not just a solid color. My problem is that I have no idea where to begin. :P My Google-fu must be weak; all I can find are references to tools that let you draw splines, but nothing about actually creating one programatically, let alone stroking it. Any suggestions, pointings in the right direction, etc.?

Share this post


Link to post
Share on other sites
Native D3DX9 includes an "ID3DXLine" class that will do a little bit of what you're after (not sure how SlimDX exposes this) but it's probably not extensible enough to get exactly what you describe.

Unfortunately, with D3D being a low-level graphics API, you don't get much help with this sort of thing - you have to implement the base graphics algorithms yourself or find a 3rd party library that'll do it for you.

Have a look around online for SVG / "Scalable Vector Graphics" and see if any can interface with Direct3D. I don't know of any off the top of my head.

D3DX has maths routines for some splines - Hermite and Catmull I do believe, but these won't draw stroked/thick splines so its still up to you to extend the mathematical definition.

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Native D3DX9 includes an "ID3DXLine" class that will do a little bit of what you're after (not sure how SlimDX exposes this)

It's exposed as the SlimDX.Direct3D9.Line class.

Jollyjeffers is right. SlimDX doesn't have native support for vector graphics; you'll have to do it yourself. You may find this article on XNA line drawing useful as a starting point.

Share this post


Link to post
Share on other sites
Hmm... thanks for those replies. It looks like my course might be to look at what the available spline math stuff, and then use that to build up a triangle strip that follows the spline, and apply whatever texturing/coloring I want to that strip. Maybe I could use a pixel shader across that geometry to help sit the "stroked" spline into the background.

Now to learn how to manage splines... and write pixel shaders. LOL. :D

Share this post


Link to post
Share on other sites
I went through many of the same hoops. I implemented a basic cubic spline class to produce this beautiful thing. You are welcome to download the attached code. It's OpenGL/C++, but the math part works for anything. I went through a lot of mental exercise to put that together, so if you find it useful, some thanks would be appreciated.

Share this post


Link to post
Share on other sites

This topic is 3316 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this