12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using OpenTK.Graphics.OpenGL;
- using MathNet.Numerics.LinearAlgebra.Single;
- namespace bbiwarg.Graphics
- {
- class Point : IGraphicElement
- {
- public Vertex position;
- public Color color;
- public float size;
- public Point(Vertex position, Color color, float size)
- {
- this.position = position;
- this.color = color;
- this.size = size;
- }
- public void draw(int width, int height)
- {
- GL.Color4(color);
- float relX = position.x - width / 2;
- float relY = height / 2 - position.y;
- GL.Begin(BeginMode.Polygon);
- GL.Vertex3(relX - size, relY + size, -position.z);
- GL.Vertex3(relX + size, relY + size, -position.z);
- GL.Vertex3(relX + size, relY - size, -position.z);
- GL.Vertex3(relX - size, relY - size, -position.z);
- GL.End();
- }
- public List<Vector> getVertices(int width, int height)
- {
- float relX = position.x - width / 2;
- float relY = height / 2 - position.y;
- List<Vector> result = new List<Vector>();
- Vector temp = new DenseVector(new float[] { relX - size, relY + size, -position.z });
- result.Add(temp);
- temp = new DenseVector(new float[] { relX + size, relY + size, -position.z });
- result.Add(temp);
- temp = new DenseVector(new float[] { relX + size, relY - size, -position.z });
- result.Add(temp);
- temp = new DenseVector(new float[] { relX - size, relY - size, -position.z });
- result.Add(temp);
- return result;
- }
- public uint[] getTriangleIndices()
- {
- return new uint[] { 0, 1, 2, 0, 2, 3 };
- }
- public Color getColor()
- {
- return color;
- }
- }
- }
|