public static Submesh CreateTeapot(GraphicsDevice graphicsDevice, float size, int tessellation) { if (graphicsDevice == null) throw new ArgumentNullException("graphicsDevice"); if (tessellation < 1) throw new ArgumentOutOfRangeException("tessellation"); var submesh = new Submesh { PrimitiveType = PrimitiveType.TriangleList, }; var teapot = new Teapot(size, tessellation); submesh.VertexBuffer = new VertexBuffer( graphicsDevice, VertexPositionNormal.VertexDeclaration, teapot.Vertices.Length, BufferUsage.None); submesh.VertexBuffer.SetData(teapot.Vertices); submesh.VertexCount = submesh.VertexBuffer.VertexCount; submesh.IndexBuffer = new IndexBuffer( graphicsDevice, IndexElementSize.SixteenBits, teapot.Indices.Length, BufferUsage.None); submesh.IndexBuffer.SetData(teapot.Indices); submesh.PrimitiveCount = teapot.Indices.Length / 3; return submesh; }
public static Submesh CreateTeapot(GraphicsDevice graphicsDevice, float size, int tessellation) { if (graphicsDevice == null) { throw new ArgumentNullException("graphicsDevice"); } if (tessellation < 1) { throw new ArgumentOutOfRangeException("tessellation"); } var submesh = new Submesh { PrimitiveType = PrimitiveType.TriangleList, }; var teapot = new Teapot(size, tessellation); submesh.VertexBuffer = new VertexBuffer( graphicsDevice, VertexPositionNormal.VertexDeclaration, teapot.Vertices.Length, BufferUsage.None); submesh.VertexBuffer.SetData(teapot.Vertices); submesh.VertexCount = submesh.VertexBuffer.VertexCount; submesh.IndexBuffer = new IndexBuffer( graphicsDevice, IndexElementSize.SixteenBits, teapot.Indices.Length, BufferUsage.None); submesh.IndexBuffer.SetData(teapot.Indices); submesh.PrimitiveCount = teapot.Indices.Length / 3; return(submesh); }