Advertisement Jump to content
Sign in to follow this  

[XNA] Drawing a spline of arbitrary length.

This topic is 3110 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

Hi folks,

I'm trying to figure out a good way of drawing a spline of arbitrary length.

Currently I generate all the indices at load time:

static readonly ushort[] splineIndices = GenerateSplineIndices();

private static ushort[] GenerateSplineIndices()
ushort[] indices = new ushort[MAXINDICES];
int j = 0;

for (ushort i = 0; i < MAXINDICES / 2; ++i)
indices[j++] = i;
indices[j++] = (ushort)(i + 1);

return indices;

The indices are then chopped to fit the size of the spline as follows:

public void DrawSpline(Vector3[] interpolatedPoints, Color color)
ushort[] indices = new ushort[interpolatedPoints.Length * 2];
int numIndices = indices.Length - 1;

for (int i = 0; i < numIndices; ++i)
indices = splineIndices;

indices[numIndices] = indices[numIndices - 1];

DrawWireShape(interpolatedPoints, indices, color);

Currently I am not happy that I have to copy each value over to a new array each time I wish to draw the spline.

Unfortunately this has to be case because I must have a degenerate index at the end of the array in order to stop the end point linking up with the next shape drawn.

Can anyone suggest where improvements could be made and how I could avoid this?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!