Exemplo n.º 1
0
 public static void DrawLine3D(GLPen pen, float aX, float aY, float aZ, float bX, float bY, float bZ)
 {
     pen.GLApplyPen();
       Gl.glBegin(Gl.GL_LINES);
       Gl.glVertex3f(aX, aY, aZ);
       Gl.glVertex3f(bX, bY, bZ);
       Gl.glEnd();
 }
Exemplo n.º 2
0
 public static void DrawLines(GLPen pen, Vector2[] points)
 {
     pen.GLApplyPen();
     Gl.glBegin(Gl.GL_LINE_STRIP);
     foreach (Vector2 p in points)
         Gl.glVertex2d(p.X, p.Y);
     Gl.glEnd();
 }
Exemplo n.º 3
0
 public static void DrawLine(GLPen pen, Vector2 p1, Vector2 p2)
 {
     pen.GLApplyPen();
     Gl.glBegin(Gl.GL_LINE_STRIP);
     Gl.glVertex2f((float)p1.X, (float)p1.Y);
     Gl.glVertex2f((float)p2.X, (float)p2.Y);
     Gl.glEnd();
 }
Exemplo n.º 4
0
 public static void DrawLine3D(GLPen pen, Vector3 a, Vector3 b)
 {
     pen.GLApplyPen();
       Gl.glBegin(Gl.GL_LINES);
       Gl.glVertex3d(a.X, a.Y, a.Z);
       Gl.glVertex3d(b.X, b.Y, b.Z);
       Gl.glEnd();
 }
Exemplo n.º 5
0
        private void DrawLine(int i, int j)
        {
            double x, y;
            GLPen pen;
            float heightVal = (float)(grid.GetCellByIdx(i, j));
            if (heightVal >= .01)
            {
                grid.GetReals(i, j, out x, out y);
                pen = new GLPen(ColorFromHeight(heightVal), 20f);

                pen.GLApplyPen();
                Gl.glVertex3f((float)x, (float)y, heightVal);
                Gl.glVertex3f((float)x, (float)y, 0);
            }
        }
Exemplo n.º 6
0
        public static void DrawGrid3D(int gridStep, WorldTransform w, float z, Color lineColor, Color textColor, Color radiiColor)
        {
            GLUtility.DisableNiceLines();
              GLPen pen = new GLPen(lineColor, 1.0f);
            pen.GLApplyPen();
            Gl.glBegin(Gl.GL_LINES);

            for (int i = (int)w.WorldLowerLeft.Y; i < w.WorldUpperRight.Y; i++)
              {
            if (i % gridStep == 0)
            {
                    Gl.glVertex3f((float)w.WorldLowerLeft.X, i, z);
                    Gl.glVertex3f((float)w.WorldUpperRight.X, i, z);
              //GLUtility.DrawString(i.ToString() + "m", new Font("verdana", 1), textColor, new PointF(0, i + .25f));
            }
              }
              for (int i = (int)w.WorldLowerLeft.X; i < w.WorldUpperRight.X; i++)
              {
            if (i % gridStep == 0)
            {
                    Gl.glVertex3f(i,(float)w.WorldLowerLeft.Y,z);
                    Gl.glVertex3f(i, (float)w.WorldUpperRight.Y, z);
              //GLUtility.DrawString(i.ToString() + "m", new Font("verdana", 1), textColor, new PointF(i, (float)(w.WorldUpperRight.Y - w.WorldLowerLeft.Y) / 2.0f));
            }
              }
            Gl.glEnd();
              GLUtility.EnableNiceLines();
        }
Exemplo n.º 7
0
 public static void DrawCube(GLPen pen, Vector3 p, float size)
 {
     pen.GLApplyPen();
       Gl.glPushMatrix();
       Gl.glTranslated(p.X, p.Y, p.Z);
       Gl.glScalef(size, size, size);
       Gl.glBegin(Gl.GL_QUADS);
       // Front Face
       Gl.glNormal3f(0.0f, 0.0f, 1.0f);
       Gl.glVertex3f(-1.0f, -1.0f, 1.0f);
       Gl.glVertex3f(1.0f, -1.0f, 1.0f);
       Gl.glVertex3f(1.0f, 1.0f, 1.0f);
        Gl.glVertex3f(-1.0f, 1.0f, 1.0f);
       // Back Face
       Gl.glNormal3f(0.0f, 0.0f, -1.0f);
       Gl.glVertex3f(-1.0f, -1.0f, -1.0f);
       Gl.glVertex3f(-1.0f, 1.0f, -1.0f);
       Gl.glVertex3f(1.0f, 1.0f, -1.0f);
       Gl.glVertex3f(1.0f, -1.0f, -1.0f);
       // Top Face
       Gl.glNormal3f(0.0f, 1.0f, 0.0f);
       Gl.glVertex3f(-1.0f, 1.0f, -1.0f);
       Gl.glVertex3f(-1.0f, 1.0f, 1.0f);
       Gl.glVertex3f(1.0f, 1.0f, 1.0f);
       Gl.glVertex3f(1.0f, 1.0f, -1.0f);
       // Bottom Face
       Gl.glNormal3f(0.0f, -1.0f, 0.0f);
       Gl.glVertex3f(-1.0f, -1.0f, -1.0f);
       Gl.glVertex3f(1.0f, -1.0f, -1.0f);
       Gl.glVertex3f(1.0f, -1.0f, 1.0f);
       Gl.glVertex3f(-1.0f, -1.0f, 1.0f);
       // Right face
       Gl.glNormal3f(1.0f, 0.0f, 0.0f);
       Gl.glVertex3f(1.0f, -1.0f, -1.0f);
       Gl.glVertex3f(1.0f, 1.0f, -1.0f);
       Gl.glVertex3f(1.0f, 1.0f, 1.0f);
       Gl.glVertex3f(1.0f, -1.0f, 1.0f);
       // Left Face
       Gl.glNormal3f(-1.0f, 0.0f, 0.0f);
       Gl.glVertex3f(-1.0f, -1.0f, -1.0f);
       Gl.glVertex3f(-1.0f, -1.0f, 1.0f);
       Gl.glVertex3f(-1.0f, 1.0f, 1.0f);
       Gl.glVertex3f(-1.0f, 1.0f, -1.0f);
       Gl.glEnd();
       Gl.glPopMatrix();
 }
Exemplo n.º 8
0
 public static void DrawRectangle(GLPen pen, RectangleF rect)
 {
     PointF p1 = new PointF (rect.Left, rect.Top);
     PointF p2 = new PointF (rect.Right, rect.Top);
     PointF p3 = new PointF(rect.Right, rect.Bottom);
     PointF p4 = new PointF(rect.Left, rect.Bottom);
     pen.GLApplyPen();
     Gl.glBegin(Gl.GL_LINE_LOOP);
         Gl.glVertex2f(p1.X, p1.Y);
         Gl.glVertex2f(p2.X, p2.Y);
         Gl.glVertex2f(p3.X, p3.Y);
         Gl.glVertex2f(p4.X, p4.Y);
     Gl.glEnd();
 }
Exemplo n.º 9
0
        public static void DrawCircle(GLPen p, PointF center, float radius, double thetaStart, double thetaEnd )
        {
            p.GLApplyPen();
            Gl.glPushMatrix();
            Gl.glTranslatef(center.X, center.Y, 0);
            RectangleF rect = new RectangleF(-radius, -radius, radius * 2, radius * 2);

            Gl.glPushMatrix();
            Gl.glTranslatef(rect.Left+rect.Width /2, rect.Top + rect.Height /2 , 0);
            Gl.glBegin(Gl.GL_LINE_STRIP);
            if (thetaStart < thetaEnd)
            {
                for (double i = thetaStart; i < thetaEnd; i += 0.05)
                    Gl.glVertex2f((float)(Math.Cos(i) * rect.Width / 2), (float)(Math.Sin(i) * rect.Height / 2));
            }
            Gl.glEnd();
            Gl.glPopMatrix();
            Gl.glPopMatrix();
        }
Exemplo n.º 10
0
 public static void DrawCross3D(GLPen pen, Vector3 p, float size)
 {
     pen.GLApplyPen();
       Gl.glBegin(Gl.GL_LINES);
       Gl.glVertex3d(p.X + size, p.Y, p.Z);
       Gl.glVertex3d(p.X - size, p.Y, p.Z);
       Gl.glVertex3d(p.X, p.Y + size, p.Z);
       Gl.glVertex3d(p.X, p.Y - size, p.Z);
       Gl.glVertex3d(p.X, p.Y, p.Z + size);
       Gl.glVertex3d(p.X, p.Y, p.Z - size);
       Gl.glEnd();
 }
Exemplo n.º 11
0
 public static void DrawCircle(GLPen p, PointF center, float radius)
 {
     p.GLApplyPen();
     Gl.glPushMatrix();
     Gl.glTranslatef(center.X, center.Y, 0);
     GLUtility.DrawEllipse(p, new RectangleF(-radius, -radius, radius * 2, radius*2));
     Gl.glPopMatrix();
 }
Exemplo n.º 12
0
        public static void DrawBezier(GLPen pen, Vector2 startP, Vector2 ctrl1, Vector2 ctrl2, Vector2 endP)
        {
            CubicBezier cb = new CubicBezier(startP, ctrl1, ctrl2, endP);
            pen.GLApplyPen();
            Gl.glBegin(Gl.GL_LINE_STRIP);
            //iterate this bitch
            for (double i = 0; i < 1.0; i += .025)
            {
                Vector2 p = (cb.Bt(i));
                Gl.glVertex2f((float)p.X, (float)p.Y);
            }

            Vector2 p1 = (cb.Bt(1));
            Gl.glVertex2f((float)p1.X, (float)p1.Y);

            Gl.glEnd();
        }
Exemplo n.º 13
0
        public static void Draw3DRectangle(GLPen pen, Vector3 bl, Vector3 br, Vector3 tl, Vector3 tr)
        {
            pen.GLApplyPen();

            Gl.glShadeModel(Gl.GL_SMOOTH);
            //Gl.glColor4ub(color.R, color.G, color.B, color.A);
            Gl.glBegin(Gl.GL_QUADS);

            Gl.glVertex3f((float)tl.X, (float)tl.Y, (float)tl.Z);
            Gl.glVertex3f((float)tr.X, (float)tr.Y, (float)tr.Z);
            Gl.glVertex3f((float)br.X, (float)br.Y, (float)br.Z);
            Gl.glVertex3f((float)bl.X, (float)bl.Y, (float)bl.Z);
            Gl.glEnd();
        }
Exemplo n.º 14
0
 public static void DrawPoint(GLPen pen, Vector2 p, bool ApplyPen)
 {
     if (ApplyPen) pen.GLApplyPen();
     Gl.glBegin(Gl.GL_POINT);
     Gl.glVertex2f((float)p.X, (float)p.Y);
     Gl.glEnd();
 }
Exemplo n.º 15
0
 public static void DrawEllipse(GLPen p, RectangleF rect)
 {
     p.GLApplyPen();
     Gl.glPushMatrix();
     Gl.glTranslatef(rect.Left+rect.Width /2, rect.Top + rect.Height /2 , 0);
     Gl.glBegin(Gl.GL_LINE_LOOP);
     for (double i = 0; i < Math.PI * 2; i += 0.05)
         Gl.glVertex2f((float)(Math.Cos(i) * rect.Width/2), (float)(Math.Sin(i) * rect.Height/2));
     Gl.glEnd();
     Gl.glPopMatrix();
 }
Exemplo n.º 16
0
 public static void DrawPoint3D(GLPen pen, Vector3 p)
 {
     pen.GLApplyPen();
       Gl.glBegin(Gl.GL_POINT);
       Gl.glVertex3d(p.X, p.Y, p.Z);
       Gl.glEnd();
 }
Exemplo n.º 17
0
        public static void DrawEllipse(GLPen p, Vector2 firstPoint, Vector2 secondPoint, float height)
        {
            Vector2 deltaPoint = new Vector2(firstPoint.X - secondPoint.X, firstPoint.Y - secondPoint.Y);
            double angle = deltaPoint.ToRadians();
            deltaPoint = deltaPoint.Rotate90();
            //Vector2 thirdPoint = deltaPoint.Normalize() * height;
            float length = (float)firstPoint.DistanceTo(secondPoint);

            Vector2 PreRotDrawpoint = new Vector2(0, 0);
            Vector2 PostRotDrawPoint = new Vector2(0, 0);
            p.GLApplyPen();
            Gl.glPushMatrix();
            Gl.glTranslatef((float)firstPoint.X, (float)firstPoint.Y, 0);
            Gl.glBegin(Gl.GL_LINE_LOOP);
            for (double i = 0; i < Math.PI * 2; i += 0.05)
            {
                PreRotDrawpoint = new Vector2((float)(Math.Cos(i) * length), (float)(Math.Sin(i) * height));
                PostRotDrawPoint = PreRotDrawpoint.Rotate(angle);
                Gl.glVertex2f((float)PostRotDrawPoint.X, (float)PostRotDrawPoint.Y);
            }
            Gl.glEnd();
            Gl.glPopMatrix();
        }
Exemplo n.º 18
0
        public static void DrawWireframeBox3D(Vector3 a, Vector3 b, GLPen pen)
        {
            pen.GLApplyPen();
              Gl.glBegin(Gl.GL_LINES);
              Gl.glVertex3d(a.X, a.Y, a.Z);
              Gl.glVertex3d(b.X, a.Y, a.Z);
              Gl.glVertex3d(a.X, b.Y, a.Z);
              Gl.glVertex3d(b.X, b.Y, a.Z);
              Gl.glVertex3d(a.X, a.Y, b.Z);
              Gl.glVertex3d(b.X, a.Y, b.Z);
              Gl.glVertex3d(a.X, b.Y, b.Z);
              Gl.glVertex3d(b.X, b.Y, b.Z);

              Gl.glVertex3d(a.X, a.Y, a.Z);
              Gl.glVertex3d(a.X, b.Y, a.Z);
              Gl.glVertex3d(a.X, a.Y, b.Z);
              Gl.glVertex3d(a.X, b.Y, b.Z);
              Gl.glVertex3d(b.X, a.Y, a.Z);
              Gl.glVertex3d(b.X, b.Y, a.Z);
              Gl.glVertex3d(b.X, a.Y, b.Z);
              Gl.glVertex3d(b.X, b.Y, b.Z);

              Gl.glVertex3d(a.X, a.Y, a.Z);
              Gl.glVertex3d(a.X, a.Y, b.Z);
              Gl.glVertex3d(b.X, a.Y, a.Z);
              Gl.glVertex3d(b.X, a.Y, b.Z);
              Gl.glVertex3d(a.X, b.Y, a.Z);
              Gl.glVertex3d(a.X, b.Y, b.Z);
              Gl.glVertex3d(b.X, b.Y, a.Z);
              Gl.glVertex3d(b.X, b.Y, b.Z);

              Gl.glEnd();
        }
Exemplo n.º 19
0
        private void DrawFlagLine(float X, float Y, Color color)
        {
            //double x, y;
            GLPen pen;

            pen = new GLPen(color, 50f);
            //pen.GLApplyPen();
            //Gl.glVertex3f(x, y, 20);
            //Gl.glVertex3f(x, y, 1);

            pen.GLApplyPen();
            Gl.glBegin(Gl.GL_LINES);
            Gl.glVertex3f(X, Y, 0);
            Gl.glVertex3f(X, Y, 5);
            Gl.glEnd();
        }