Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
GeometricPrimitiveExtension.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 
4 using SiliconStudio.Paradox.Effects;
5 using SiliconStudio.Paradox.Graphics;
6 
7 namespace SiliconStudio.Paradox.Extensions
8 {
9  /// <summary>
10  /// An extension class for the <see cref="GeometricPrimitive"/>
11  /// </summary>
12  public static class GeometricPrimitiveExtensions
13  {
14  public static MeshDraw ToMeshDraw<T>(this GeometricPrimitive<T> primitive) where T : struct, IVertex
15  {
16  var vertexBufferBinding = new VertexBufferBinding(primitive.VertexBuffer, new T().GetLayout(), primitive.VertexBuffer.ElementCount);
17  var indexBufferBinding = new IndexBufferBinding(primitive.IndexBuffer, primitive.IsIndex32Bits, primitive.IndexBuffer.ElementCount);
18  var data = new MeshDraw
19  {
20  StartLocation = 0,
21  PrimitiveType = PrimitiveType.TriangleList,
22  VertexBuffers = new[] { vertexBufferBinding },
23  IndexBuffer = indexBufferBinding,
24  DrawCount = primitive.IndexBuffer.ElementCount
25  };
26 
27  return data;
28  }
29  }
30 }
PrimitiveType
Defines how vertex data is ordered.
A geometric primitive used to draw a simple model built from a set of vertices and indices...
The base interface for all the vertex data structure.
Definition: IVertex.cs:9
Binding structure that specifies a vertex buffer and other per-vertex parameters (such as offset and ...