Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using OpenTK.Graphics.OpenGL;
- using OpenTK;
- namespace Wrak.Objects
- {
- class Spring : GameObject, IRunable, IDrawable
- {
- private double height;
- float width= 1;
- int key;
- BeginMode bg;
- public Spring(Vector3 position, double height)
- {
- this.position = position;
- this.height = height;
- }
- #region IRunable Members
- public void Run(float dt)
- {
- if (Wrak.keyboard[OpenTK.Input.Key.P]) bg=BeginMode.Points;
- else bg=BeginMode.LineStrip;
- if (Wrak.keyboard[OpenTK.Input.Key.LBracket]) width += 2;
- if (Wrak.keyboard[OpenTK.Input.Key.RBracket]) width -= 2;
- }
- #endregion
- #region IDrawable Members
- public void Draw()
- {
- GL.MatrixMode(MatrixMode.Modelview);
- GL.PushMatrix();
- GL.Translate(position);
- for (int q = 0; q < 5; q++)
- {
- if (bg == BeginMode.Points) GL.PointSize(width);
- else GL.LineWidth(width);
- GL.Begin(bg);
- {
- for (int i = 0; i < 6; i++)
- {
- double d = 0.005 * i;
- /*
- double x = Math.Sin(d);
- double y = Math.Cos(d);
- double z = d *height/10;
- */
- int x = i;
- int y = (i % 2 == 0) ? 1 : 0;
- int z = q+10;
- GL.Vertex3(x, y, z);
- }
- }
- GL.End();
- }
- GL.PopMatrix();
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement