Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using OpenTK.Graphics.OpenGL;
  6. using OpenTK;
  7.  
  8. namespace Wrak.Objects
  9. {
  10. class Spring : GameObject, IRunable, IDrawable
  11. {
  12.  
  13. private double height;
  14. float width= 1;
  15. int key;
  16. BeginMode bg;
  17.  
  18. public Spring(Vector3 position, double height)
  19. {
  20. this.position = position;
  21. this.height = height;
  22. }
  23.  
  24.  
  25. #region IRunable Members
  26.  
  27. public void Run(float dt)
  28. {
  29.  
  30. if (Wrak.keyboard[OpenTK.Input.Key.P]) bg=BeginMode.Points;
  31. else bg=BeginMode.LineStrip;
  32.  
  33. if (Wrak.keyboard[OpenTK.Input.Key.LBracket]) width += 2;
  34. if (Wrak.keyboard[OpenTK.Input.Key.RBracket]) width -= 2;
  35. }
  36.  
  37. #endregion
  38.  
  39.  
  40.  
  41.  
  42.  
  43. #region IDrawable Members
  44. public void Draw()
  45. {
  46. GL.MatrixMode(MatrixMode.Modelview);
  47. GL.PushMatrix();
  48.  
  49. GL.Translate(position);
  50.  
  51. for (int q = 0; q < 5; q++)
  52. {
  53. if (bg == BeginMode.Points) GL.PointSize(width);
  54. else GL.LineWidth(width);
  55. GL.Begin(bg);
  56. {
  57.  
  58.  
  59. for (int i = 0; i < 6; i++)
  60. {
  61. double d = 0.005 * i;
  62.  
  63.  
  64. /*
  65. double x = Math.Sin(d);
  66. double y = Math.Cos(d);
  67. double z = d *height/10;
  68. */
  69.  
  70. int x = i;
  71.  
  72. int y = (i % 2 == 0) ? 1 : 0;
  73. int z = q+10;
  74. GL.Vertex3(x, y, z);
  75. }
  76.  
  77. }
  78.  
  79. GL.End();
  80. }
  81.  
  82.  
  83.  
  84. GL.PopMatrix();
  85. }
  86. #endregion
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement