Example #1
0
 private unsafe void StartDrawing(VertexFragment vertexFragment, out VertexPositionColor* vertices, out VertexPositionNormalTexture* textures, out short* indices, out short baseIndex)
 {
     textures = null;
     if (vertexFragment.PrimitiveType == PrimitiveType.LineList)
     {
         if ((this.SortMode == DrawingSortMode.Order) && (this._triangleVertexCount > 0))
         {
             Flush();
             StartLineDrawing(vertexFragment, out vertices, out indices, out baseIndex);
         }
         else
         {
             StartLineDrawing(vertexFragment, out vertices, out indices, out baseIndex);
         }
     }
     else if (vertexFragment.PrimitiveType == PrimitiveType.TriangleList)
     {
         if ((this.SortMode == DrawingSortMode.Order) && (this._lineVertexCount > 0))
         {
             Flush();
             StartTriangleDrawing(vertexFragment, out vertices, out textures, out indices, out baseIndex);
         }
         else
         {
             StartTriangleDrawing(vertexFragment, out vertices, out textures, out indices, out baseIndex);
         }
     }
     else
     {
         throw new NotSupportedException(string.Format("PrimitiveType: {0} is not supported.", vertexFragment.PrimitiveType));
     }
 }
Example #2
0
 private unsafe void StartDrawing(VertexFragment vertexFragment, out VertexPositionColor* vertices, out short* indices, out short baseIndex)
 {
     VertexPositionNormalTexture* textures;
     StartDrawing(vertexFragment, out vertices, out textures, out indices, out baseIndex);
 }
Example #3
0
 /// <summary>
 /// Draws the polyline.
 /// </summary>
 /// <param name="points">The array with points of polyline.</param>
 /// <param name="start">The start element in array to use.</param>
 /// <param name="count">The element count to use.</param>
 /// <param name="closed">if set to <c>true</c> to connect last point with the first one.</param>
 /// <param name="color">The color tint.</param>
 protected virtual void ProcessDrawPolyline(Vector2[] points, int start, int count, bool closed, Color color)
 {
     count = CheckPoints(points, start, count);
     if (count > 1)
     {
         if (count <= MAX_ATOMIC_POLYGON_LENGTH)
         {
             int vertexCount = count, lineCount = count - (closed ? 0 : 1);
             VertexFragment vertexFragment = new VertexFragment(vertexCount, lineCount * 2, PrimitiveType.LineList);
             unsafe
             {
                 VertexPositionColor* vertices;
                 short* indices;
                 short baseIndex;
                 StartDrawing(vertexFragment, out vertices, out indices, out baseIndex);
                 short index = baseIndex;
                 //populate core line vertices
                 for (int n = 0; n < vertexCount; ++n)
                 {
                     //---------------------------------------------------
                     Vector2 vector = points[n + start];
                     vertices->Position = new Vector3(
                     _transform.M11 * vector.X + _transform.M12 * vector.Y + _transform.TX - 0.5f, //fix line alignment issue
                     _transform.M21 * vector.X + _transform.M22 * vector.Y + _transform.TY - 0.5f, //fix line alignment issue
                     _Z
                     );
                     vertices->Color = color;
                     //---------------------------------------------------
                     if (n < vertexCount - 1)
                     {
                         indices[0] = (short)index;
                         indices[1] = (short)(index + 1);
                         indices += 2;
                         index++;
                     }
                     else
                     {
                         //if need to connect last and first - lets do it
                         if (closed)
                         {
                             indices[0] = index;
                             indices[1] = baseIndex;
                         }
                     }
                     vertices++;
                 }
             }
             FinishDrawing(vertexFragment);
         }
         else
         {
             int step = MAX_ATOMIC_POLYGON_LENGTH - 1;
             //split polygon/polyline into less parts
             for (int n = 0; n < count; n += step)
             {
                 ProcessDrawPolyline(points, start + n - (n != 0 ? 1 : 0), Math.Min(step, count - n) + (n != 0 ? 1 : 0), false, color);
             }
             if (closed)
             {
                 ProcessDrawPolyline(new Vector2[] { points[start + count - 1], points[start] }, 0, 2, false, color);
             }
         }
     }
     else
     {
         throw new ArgumentException("Drawing polyline/polygon required at least 2 points");
     }
 }
Example #4
0
 private void FinishDrawing(VertexFragment vertexFragment)
 {
 }
Example #5
0
 private unsafe void StartTriangleDrawing(VertexFragment vertexFragment, out VertexPositionColor* vertices, out VertexPositionNormalTexture* textures, out short* indices, out short baseIndex)
 {
     int vertexCount = vertexFragment.VertexCount;
     int indexCount = vertexFragment.IndexCount;
     StartTriangleDrawing(vertexCount, indexCount, out vertices, out textures, out indices, out baseIndex);
 }
Example #6
0
 private unsafe void StartLineDrawing(VertexFragment vertexFragment, out VertexPositionColor* vertices, out short* indices, out short baseIndex)
 {
     int vertexCount = vertexFragment.VertexCount;
     int indexCount = vertexFragment.IndexCount;
     StartLineDrawing(vertexCount, indexCount, out vertices, out indices, out baseIndex);
 }