Bezier curve question

Started by
6 comments, last by strtok 16 years ago
I am trying to make a curved like and I believe what I want to do is a 'bezier curve'. What I want to do is get a texture, then curve it around about four points (I could use this as a billboarded sprite). Does anyone know where I could find a tutorial on how to do this? [Edited by - simotix on March 24, 2008 8:41:52 AM]
Advertisement
Did you perhaps make a typing error?

You say you want to curve a texture around four textures. People aren't sure exactly what you want to do. :)

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Some how I did not notice that, thanks =)
Yes, you can use cubic Bezier curves to do this. The 4 points are the control points and are used in a parametric equation that defines the points on the curve. You can probably google this or find it in any reasonable text on computer graphics. Once you write the code to parametrically compute points along the Bezier curve, you can easily find a few points along the curve at which to place billboards.
Well, I did not want to just place sprites at the location (if I did this then there would be open spaces). I want to be able to sort of "bend a texture" in the way that a bezier curve would. Should I use a pixel shader to do this?
In order to do this, you'll need to build some geometry (i.e. triangles) that follow the curve and then texture them.
Do you or anyone happen to know some sort of place that would show a tutorial or demo to do this? I believe I have a grasp with the math behind it, however, I do not see how this could accurately been done in DirectX. Not even with a shader.
Well, you can't create geometry from within a vertex or pixel shader. I suppose this might be possible with a geometry shader (DX10), but I've never used them so I don't know for sure. You're probably going to have to build your geometry on the CPU.

Once you have your control points for the actual curve, you can take the first derivative to find a second curve (with one less control point) that evaluates to a tangent vector at each point on the original. This first derivative is called the hodograph, and there is a really simple method to calculate it (you can google for it). Once you have these two curves (the original and the hodograph), you can evaluate points along the curve and the corresponding tangent vectors. If you translate the points by some distance along a vector perpendicular to the tangent, and alternate to either side of the curve, you can construct a series of triangles that follows the curve and has a "width" sufficient to texture.

Hopefully this makes sense. While I haven't done exactly what you are trying to accomplish before, I have done some neat stuff with Bezier curves and it's really not as difficult as it sounds.

This topic is closed to new replies.

Advertisement