Rectangle3D.cs 950 B

1234567891011121314151617181920212223242526272829303132333435
  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.GraphicElements3D
  10. {
  11. class Rectangle3D : IGraphicElement3D
  12. {
  13. private Vector[] corners;
  14. private Color color;
  15. public Rectangle3D(Vector[] corners, Color color)
  16. {
  17. this.corners = corners;
  18. this.color = color;
  19. }
  20. public void draw()
  21. {
  22. GL.Color4(color);
  23. GL.Begin(BeginMode.Quads);
  24. GL.Vertex3(corners[0][0], corners[0][1], -corners[0][2]);
  25. GL.Vertex3(corners[1][0], corners[1][1], -corners[1][2]);
  26. GL.Vertex3(corners[2][0], corners[2][1], -corners[2][2]);
  27. GL.Vertex3(corners[3][0], corners[3][1], -corners[3][2]);
  28. GL.End();
  29. }
  30. }
  31. }