Point.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using OpenTK.Graphics.OpenGL;
  8. using MathNet.Numerics.LinearAlgebra.Single;
  9. namespace bbiwarg.Graphics
  10. {
  11. class Point : IGraphicElement
  12. {
  13. public Vertex position;
  14. public Color color;
  15. public float size;
  16. public Point(Vertex position, Color color, float size)
  17. {
  18. this.position = position;
  19. this.color = color;
  20. this.size = size;
  21. }
  22. public void draw()
  23. {
  24. GL.Color4(color);
  25. GL.Begin(BeginMode.Polygon);
  26. GL.Vertex3(position.x - size/2, position.y + size/2, -position.z);
  27. GL.Vertex3(position.x + size/2, position.y + size/2, -position.z);
  28. GL.Vertex3(position.x + size/2, position.y - size/2, -position.z);
  29. GL.Vertex3(position.x - size/2, position.y - size/2, -position.z);
  30. GL.End();
  31. }
  32. public List<Vector> getVertices()
  33. {
  34. List<Vector> result = new List<Vector>();
  35. result.Add(new DenseVector(new float[] { position.x - size/2, position.y + size/2, -position.z }));
  36. result.Add(new DenseVector(new float[] { position.x + size/2, position.y + size/2, -position.z }));
  37. result.Add(new DenseVector(new float[] { position.x + size/2, position.y - size/2, -position.z }));
  38. result.Add(new DenseVector(new float[] { position.x - size/2, position.y - size/2, -position.z }));
  39. return result;
  40. }
  41. public uint[] getTriangleIndices()
  42. {
  43. return new uint[] { 0, 1, 2, 0, 2, 3 };
  44. }
  45. public Color getColor()
  46. {
  47. return color;
  48. }
  49. }
  50. }