DrawUserIndexedPrimitives - OutOfRangeException mimo robienia jak w dokumentacji

0

Witam. Próbując narysować linię, które znaczą BoundingBox'a użyłem takiej metody: GraphicsDevice.DrawUserIndexedPrimitives<T>(...); Niestety pomimo to, że robię jak napisali w dokumentacji XNA dostaję wyjątek:

System.ArgumentOutOfRangeException was unhandled
Message = This parameter must be a valid index within the array.
Parameter name: primitiveCount

Ten parametr to ostatni parametr metody (patrz kody niżej).
Mój kod:

VertexPositionColor[] vertices = new VertexPositionColor[8]; // tablica wierzchołków
for (int i = 0; i < vertices.Length; i++)
{
	vertices[i] = new VertexPositionColor(BoundingBox.GetCorners()[i], Color.Yellow);
}
short[] lineListIndices = new short[(vertices.Length * 2) - 2]; // tablica indexów wierzchołków (w sumie nie wiem po co to)
// Populate the array with references to indices in the vertex buffer
for (int i = 0; i < vertices.Length - 1; i++)
{
	lineListIndices[i * 2] = (short)(i);
	lineListIndices[(i * 2) + 1] = (short)(i + 1);
}
World.GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, 8, lineListIndices, 0, 7);

Dokumentacja metody:

public void DrawUserIndexedPrimitives<T> (
         PrimitiveType primitiveType, // The primitive type.
         T[] vertexData, // The vertex data.
         int vertexOffset, // Offset (in bytes) from the beginning of the vertex buffer to the first vertex to draw.
         int numVertices, // Number of vertices to draw.
         int[] indexData, // The index data.
         int indexOffset, // Offset (in bytes) from the beginning of the index buffer to the first index to use.
         int primitiveCount // Number of primitives to render.
) where T : // Per-vertex data type - to już nieważne, metoda jaką ustalam wierzchołki

Najpierw próbowałem metodą DrawUserPrimitives tej bez indeksowania, ale miałem to samo. Zrobiłem dokładnie jak w dokumentacji i dupa blada.. Wie ktoś o co może chodzić?

1
World.GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
    PrimitiveType.LineList, // LineList?
    vertices, 
    0, 
    8, // 8 vertexów
    lineListIndices,
    0,
    7 // 7? 7 * 2 = 14);

Dla wytłumaczenia:
lineList: user image
lineStrip: user image

0

Niestety, po daniu LineStrip i 14 w miejsce primitiveCount to samo... Wcześniej próbowałem 14 do LineList, ale też nic. :|

1 użytkowników online, w tym zalogowanych: 0, gości: 1