private void SetPrimitiveCount(GeometryPrimitiveType primitiveType, int pointCount) { PrimitiveType = primitiveType; switch (primitiveType) { case GeometryPrimitiveType.TriangleList: PrimitiveCount = pointCount / 3; break; case GeometryPrimitiveType.TriangleStrip: PrimitiveCount = pointCount; break; case GeometryPrimitiveType.LineList: PrimitiveCount = pointCount / 2; break; case GeometryPrimitiveType.LineStrip: PrimitiveCount = pointCount; break; default: break; } }
/// <summary> /// Fills the color type buffer (VertexPositionColor) /// </summary> /// <param name="points">The points.</param> /// <param name="primitiveType">Type of the primitive.</param> public override void FillColor(List<PointF> points, GeometryPrimitiveType primitiveType) { SetPrimitiveCount(primitiveType, points.Count); VertexPositionColor[] vertex = new VertexPositionColor[points.Count]; for (int i = 0; i < points.Count; i++) { vertex[i] = new VertexPositionColor(new Vector3(points[i].X, points[i].Y, 0), Color.White); } VertexBuffer = new VertexBuffer(MonoGameRenderer.GraphicsDevice, VertexPositionColor.VertexDeclaration, vertex.Length, BufferUsage.WriteOnly); VertexBuffer.SetData<VertexPositionColor>(vertex); }
/// <summary> /// Fills the color type buffer (VertexPositionColor) /// </summary> /// <param name="points">The points.</param> /// <param name="primitiveType">Type of the primitive.</param> public override void FillColor(List <PointF> points, GeometryPrimitiveType primitiveType) { SetPrimitiveCount(primitiveType, points.Count); VertexPositionColor[] vertex = new VertexPositionColor[points.Count]; for (int i = 0; i < points.Count; i++) { vertex[i] = new VertexPositionColor(new Vector3(points[i].X, points[i].Y, 0), Color.White); } VertexBuffer = new VertexBuffer(FNARenderer.GraphicsDevice, VertexPositionColor.VertexDeclaration, vertex.Length, BufferUsage.WriteOnly); VertexBuffer.SetData <VertexPositionColor>(vertex); }
/// <summary> /// Fills the texture type buffer (VertexPositionTexture) /// </summary> /// <param name="points">The points.</param> /// <param name="destinationSize">Size of the destination.</param> /// <param name="sourceRect">The source rect.</param> /// <param name="primitiveType">Type of the primitive.</param> public override void FillTexture(List<PointF> points, Size destinationSize, Rect sourceRect, GeometryPrimitiveType primitiveType) { SetPrimitiveCount(primitiveType, points.Count); VertexPositionTexture[] vertex = new VertexPositionTexture[points.Count]; for (int i = 0; i < points.Count; i++) { Vector2 uv = new Vector2(sourceRect.X + (points[i].X / destinationSize.Width) * sourceRect.Width, sourceRect.Y + (points[i].Y / destinationSize.Height) * sourceRect.Height); vertex[i] = new VertexPositionTexture(new Vector3(points[i].X, points[i].Y, 0), uv); } VertexBuffer = new VertexBuffer(MonoGameRenderer.GraphicsDevice, VertexPositionTexture.VertexDeclaration, vertex.Length, BufferUsage.WriteOnly); VertexBuffer.SetData<VertexPositionTexture>(vertex); }
/// <summary> /// Fills the color type buffer (VertexPositionColor) /// </summary> /// <param name="points">The points.</param> /// <param name="primitiveType">Type of the primitive.</param> public override void FillColor(List <PointF> points, GeometryPrimitiveType primitiveType) { SetPrimitiveCount(primitiveType, points.Count); VertexPositionNormalTexture[] vertex = new VertexPositionNormalTexture[points.Count]; for (int i = 0; i < points.Count; i++) { vertex[i] = new VertexPositionNormalTexture(new Vector3(points[i].X, points[i].Y, 0), new Vector3(0, 0, 1), Vector2.Zero); } VertexBuffer = VertexBuffer.Vertex.New(XenkoRenderer.GraphicsDevice, vertex); VertexBuffer.Reload = (graphicsResource) => ((VertexBuffer)graphicsResource).Recreate(vertex); VertexBufferBinding = new VertexBufferBinding(VertexBuffer, VertexPositionNormalTexture.Layout, vertex.Length, VertexPositionNormalTexture.Size); InputElementDescriptions = VertexBufferBinding.Declaration.CreateInputElements(); }
private void SetPrimitiveCount(GeometryPrimitiveType primitiveType, int pointCount) { PrimitiveType = primitiveType; switch (primitiveType) { case GeometryPrimitiveType.TriangleList: PrimitiveCount = pointCount / 3; break; case GeometryPrimitiveType.TriangleStrip: PrimitiveCount = pointCount - 2; break; case GeometryPrimitiveType.LineList: PrimitiveCount = pointCount / 2; break; case GeometryPrimitiveType.LineStrip: PrimitiveCount = pointCount - 1; break; default: break; } }
/// <summary> /// Fills the texture type buffer (VertexPositionTexture) /// </summary> /// <param name="points">The points.</param> /// <param name="destinationSize">Size of the destination.</param> /// <param name="sourceRect">The source rect.</param> /// <param name="primitiveType">Type of the primitive.</param> public override void FillTexture(List <PointF> points, Size destinationSize, Rect sourceRect, GeometryPrimitiveType primitiveType) { SetPrimitiveCount(primitiveType, points.Count); VertexPositionNormalTexture[] vertex = new VertexPositionNormalTexture[points.Count]; for (int i = 0; i < points.Count; i++) { Vector2 uv = new Vector2(sourceRect.X + (points[i].X / destinationSize.Width) * sourceRect.Width, sourceRect.Y + (points[i].Y / destinationSize.Height) * sourceRect.Height); vertex[i] = new VertexPositionNormalTexture(new Vector3(points[i].X, points[i].Y, 0), new Vector3(0, 0, 1), uv); } VertexBuffer = VertexBuffer.Vertex.New(XenkoRenderer.GraphicsDevice, vertex); VertexBuffer.Reload = (graphicsResource) => ((VertexBuffer)graphicsResource).Recreate(vertex); VertexBufferBinding = new VertexBufferBinding(VertexBuffer, VertexPositionNormalTexture.Layout, vertex.Length, VertexPositionNormalTexture.Size); InputElementDescriptions = VertexBufferBinding.Declaration.CreateInputElements(); }
/// <summary> /// Fills the texture type buffer (VertexPositionTexture) /// </summary> /// <param name="points">The points.</param> /// <param name="destinationSize">Size of the destination.</param> /// <param name="sourceRect">The source rect.</param> /// <param name="primitiveType">Type of the primitive.</param> public abstract void FillTexture(List <PointF> points, Size destinationSize, Rect sourceRect, GeometryPrimitiveType primitiveType);
/// <summary> /// Fills the color type buffer (VertexPositionColor) /// </summary> /// <param name="points">The points.</param> /// <param name="primitiveType">Type of the primitive.</param> public abstract void FillColor(List <PointF> points, GeometryPrimitiveType primitiveType);
/// <summary> /// Fills the texture type buffer (VertexPositionTexture) /// </summary> /// <param name="points">The points.</param> /// <param name="destinationSize">Size of the destination.</param> /// <param name="sourceRect">The source rect.</param> /// <param name="primitiveType">Type of the primitive.</param> public override void FillTexture(List <PointF> points, Size destinationSize, Rect sourceRect, GeometryPrimitiveType primitiveType) { SetPrimitiveCount(primitiveType, points.Count); VertexPositionTexture[] vertex = new VertexPositionTexture[points.Count]; for (int i = 0; i < points.Count; i++) { Vector2 uv = new Vector2(sourceRect.X + (points[i].X / destinationSize.Width) * sourceRect.Width, sourceRect.Y + (points[i].Y / destinationSize.Height) * sourceRect.Height); vertex[i] = new VertexPositionTexture(new Vector3(points[i].X, points[i].Y, 0), uv); } VertexBuffer = new VertexBuffer(FNARenderer.GraphicsDevice, VertexPositionTexture.VertexDeclaration, vertex.Length, BufferUsage.WriteOnly); VertexBuffer.SetData <VertexPositionTexture>(vertex); }
/// <summary> /// Fills the texture type buffer (VertexPositionTexture) /// </summary> /// <param name="points">The points.</param> /// <param name="destinationSize">Size of the destination.</param> /// <param name="sourceRect">The source rect.</param> /// <param name="primitiveType">Type of the primitive.</param> public abstract void FillTexture(List<PointF> points, Size destinationSize, Rect sourceRect, GeometryPrimitiveType primitiveType);
/// <summary> /// Fills the color type buffer (VertexPositionColor) /// </summary> /// <param name="points">The points.</param> /// <param name="primitiveType">Type of the primitive.</param> public abstract void FillColor(List<PointF> points, GeometryPrimitiveType primitiveType);
/// <summary> /// Fills the texture type buffer (VertexPositionTexture) /// </summary> /// <param name="points">The points.</param> /// <param name="destinationSize">Size of the destination.</param> /// <param name="sourceRect">The source rect.</param> /// <param name="primitiveType">Type of the primitive.</param> public override void FillTexture(List<PointF> points, Size destinationSize, Rect sourceRect, GeometryPrimitiveType primitiveType) { SetPrimitiveCount(primitiveType, points.Count); VertexPositionNormalTexture[] vertex = new VertexPositionNormalTexture[points.Count]; for (int i = 0; i < points.Count; i++) { Vector2 uv = new Vector2(sourceRect.X + (points[i].X / destinationSize.Width) * sourceRect.Width, sourceRect.Y + (points[i].Y / destinationSize.Height) * sourceRect.Height); vertex[i] = new VertexPositionNormalTexture(new Vector3(points[i].X, points[i].Y, 0), new Vector3(0,0,1), uv); } VertexBuffer = VertexBuffer.Vertex.New(XenkoRenderer.GraphicsDevice, vertex); VertexBuffer.Reload = (graphicsResource) => ((VertexBuffer)graphicsResource).Recreate(vertex); VertexBufferBinding = new VertexBufferBinding(VertexBuffer, VertexPositionNormalTexture.Layout, vertex.Length, VertexPositionNormalTexture.Size); InputElementDescriptions = VertexBufferBinding.Declaration.CreateInputElements(); }
/// <summary> /// Fills the color type buffer (VertexPositionColor) /// </summary> /// <param name="points">The points.</param> /// <param name="primitiveType">Type of the primitive.</param> public override void FillColor(List<PointF> points, GeometryPrimitiveType primitiveType) { SetPrimitiveCount(primitiveType, points.Count); VertexPositionNormalTexture[] vertex = new VertexPositionNormalTexture[points.Count]; for (int i = 0; i < points.Count; i++) { vertex[i] = new VertexPositionNormalTexture(new Vector3(points[i].X, points[i].Y, 0), new Vector3(0, 0, 1), Vector2.Zero); } VertexBuffer = VertexBuffer.Vertex.New(XenkoRenderer.GraphicsDevice, vertex); VertexBuffer.Reload = (graphicsResource) => ((VertexBuffer)graphicsResource).Recreate(vertex); VertexBufferBinding = new VertexBufferBinding(VertexBuffer, VertexPositionNormalTexture.Layout, vertex.Length, VertexPositionNormalTexture.Size); InputElementDescriptions = VertexBufferBinding.Declaration.CreateInputElements(); }