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();
        }
        public static void DrawBox(PointF p, float h, float width, float length, string label, bool rotate90, DrawRef drawRef, Color color)
        {
            GLUtility.GoToVehicleCoordinates(h, p, rotate90);
            RectangleF r = new RectangleF();

            if (drawRef == DrawRef.RearAxle)
            {
                r = new RectangleF(-width / 2, 0, width, length);
            }
            else if (drawRef == DrawRef.Center)
            {
                r = new RectangleF(-width / 2, -length / 2, width, length);
            }
            else if (drawRef == DrawRef.BottomCorner)
            {
                r = new RectangleF(0, 0, width, length);
            }
            GLPen pen = new GLPen(color, 1.0f);

            GLUtility.DrawRectangle(pen, r);
            GLUtility.DrawLine(pen, r.Left + 0.2f, r.Bottom - r.Width / 2, r.Left + r.Width / 2, r.Bottom - .2f);
            GLUtility.DrawLine(pen, r.Right - 0.2f, r.Bottom - r.Width / 2, r.Right - r.Width / 2, r.Bottom - .2f);
            if (label != "")
            {
                GLUtility.DrawString(label, new Font("verdana", 1.0f), Color.Black, r.Location);
            }
            GLUtility.ComeBackFromVehicleCoordinates();
        }
        public static void DrawWireframeBox3D(v3f a, v3f b, GLPen pen)
        {
            pen.GLApplyPen();
            Gl.glBegin(Gl.GL_LINES);
            Gl.glVertex3f(a.x, a.y, a.z);
            Gl.glVertex3f(b.x, a.y, a.z);
            Gl.glVertex3f(a.x, b.y, a.z);
            Gl.glVertex3f(b.x, b.y, a.z);
            Gl.glVertex3f(a.x, a.y, b.z);
            Gl.glVertex3f(b.x, a.y, b.z);
            Gl.glVertex3f(a.x, b.y, b.z);
            Gl.glVertex3f(b.x, b.y, b.z);

            Gl.glVertex3f(a.x, a.y, a.z);
            Gl.glVertex3f(a.x, b.y, a.z);
            Gl.glVertex3f(a.x, a.y, b.z);
            Gl.glVertex3f(a.x, b.y, b.z);
            Gl.glVertex3f(b.x, a.y, a.z);
            Gl.glVertex3f(b.x, b.y, a.z);
            Gl.glVertex3f(b.x, a.y, b.z);
            Gl.glVertex3f(b.x, b.y, b.z);

            Gl.glVertex3f(a.x, a.y, a.z);
            Gl.glVertex3f(a.x, a.y, b.z);
            Gl.glVertex3f(b.x, a.y, a.z);
            Gl.glVertex3f(b.x, a.y, b.z);
            Gl.glVertex3f(a.x, b.y, a.z);
            Gl.glVertex3f(a.x, b.y, b.z);
            Gl.glVertex3f(b.x, b.y, a.z);
            Gl.glVertex3f(b.x, b.y, b.z);

            Gl.glEnd();
        }
 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();
 }
 public static void DrawLine(GLPen pen, PointF p1, PointF p2)
 {
     pen.GLApplyPen();
     Gl.glBegin(Gl.GL_LINE_STRIP);
     Gl.glVertex2f(p1.X, p1.Y);
     Gl.glVertex2f(p2.X, p2.Y);
     Gl.glEnd();
 }
 public static void DrawPoint3D(GLPen pen, v3f p)
 {
     pen.GLApplyPen();
     Gl.glBegin(Gl.GL_POINT);
     //Gl.glVertex3f(p.x, p.y, 0.0f);//p.z);
     Gl.glVertex2f(p.x, p.y);
     Gl.glEnd();
 }
 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();
 }
 public static void DrawLine3D(GLPen pen, v3f a, v3f b)
 {
     pen.GLApplyPen();
     Gl.glBegin(Gl.GL_LINES);
     Gl.glVertex3f(a.x, a.y, a.z);
     Gl.glVertex3f(b.x, b.y, b.z);
     Gl.glEnd();
 }
 public static void DrawPoint(GLPen pen, PointF p, bool ApplyPen)
 {
     if (ApplyPen)
     {
         pen.GLApplyPen();
     }
     Gl.glBegin(Gl.GL_POINT);
     Gl.glVertex2f(p.X, p.Y);
     Gl.glEnd();
 }
        public static void DrawCross(GLPen pen, PointF p, float size)
        {
            PointF p1 = new PointF(p.X, p.Y + size / 2.0f);
            PointF p2 = new PointF(p.X, p.Y - size / 2.0f);
            PointF p3 = new PointF(p.X + size / 2.0f, p.Y);
            PointF p4 = new PointF(p.X - size / 2.0f, p.Y);

            DrawLine(pen, p1, p2);
            DrawLine(pen, p3, p4);
        }
 public static void DrawLines(GLPen pen, PointF[] points)
 {
     pen.GLApplyPen();
     Gl.glBegin(Gl.GL_LINE_STRIP);
     foreach (PointF p in points)
     {
         Gl.glVertex2f(p.X, p.Y);
     }
     Gl.glEnd();
 }
 public static void DrawCross3D(GLPen pen, v3f p, float size)
 {
     pen.GLApplyPen();
     Gl.glBegin(Gl.GL_LINES);
     Gl.glVertex3f(p.x + size, p.y, p.z);
     Gl.glVertex3f(p.x - size, p.y, p.z);
     Gl.glVertex3f(p.x, p.y + size, p.z);
     Gl.glVertex3f(p.x, p.y - size, p.z);
     Gl.glVertex3f(p.x, p.y, p.z + size);
     Gl.glVertex3f(p.x, p.y, p.z - size);
     Gl.glEnd();
 }
        public static void DrawCluster(PointF p, float h, float width, string label, bool rotate90)
        {
            GLUtility.GoToVehicleCoordinates(h, p, rotate90);
            GLPen pen = new GLPen(Color.Blue, 1.0f);

            GLUtility.DrawLine(pen, -width / 2, 0, width / 2, 0);
            GLUtility.DrawLine(pen, 0, .1f, 0, -.1f);
            if (label != "")
            {
                GLUtility.DrawString(label, new Font("verdana", 1.0f), Color.Black, new PointF(0, 0));
            }
            GLUtility.ComeBackFromVehicleCoordinates();
        }
 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();
 }
        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();
        }
 public static void DrawCube(GLPen pen, v3f p, float size)
 {
     pen.GLApplyPen();
     Gl.glPushMatrix();
     Gl.glTranslatef(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();
 }
        public static void DrawBezier(GLPen pen, PointF startP, PointF ctrl1, PointF ctrl2, PointF endP)
        {
            CubicBezier cb = new CubicBezier(Utility.ToCoord(startP), Utility.ToCoord(ctrl1), Utility.ToCoord(ctrl2), Utility.ToCoord(endP));

            pen.GLApplyPen();
            Gl.glBegin(Gl.GL_LINE_STRIP);
            //iterate this bitch
            for (double i = 0; i < 1.0; i += .025)
            {
                PointF p = Utility.ToPointF(cb.Bt(i));
                Gl.glVertex2f(p.X, p.Y);
            }

            PointF p1 = Utility.ToPointF(cb.Bt(1));

            Gl.glVertex2f(p1.X, p1.Y);

            Gl.glEnd();
        }
        /*	public static void DrawCar(PointF rearAxle, float h, int txid)
         *      {
         *
         *              //the rear axle point is just the center of the car in x and the rear of the car in y
         *              PointF carPoint = new PointF(rearAxle.X - (carWidth / 2), rearAxle.Y);
         *              GLUtility.GoToVehicleCoordinates(h, carPoint);
         *              RectangleF r = new RectangleF(0, 0, carWidth, carHeight);
         *              GLPen pen = new GLPen(Color.LightBlue, 1.0f);
         *              GLUtility.FillTexturedRectangle(txid, r);
         *              GLUtility.ComeBackFromVehicleCoordinates();
         *      }
         */

        //0 degree heading means positive X and means EAST
        public static void DrawCar(PointF rearAxle, float h, Color color, string label, bool rotate90, Color labelColor)
        {
            float carWidth      = (float)TahoeParams.T;
            float carIMUtoFront = (float)(TahoeParams.FL - TahoeParams.IL);
            float carHeight     = (float)TahoeParams.VL;
            //the rear axle point is just the center of the car in x and the rear of the car in y
            PointF IMU = new PointF(rearAxle.X, rearAxle.Y);

            GLUtility.GoToVehicleCoordinates(h, IMU, rotate90);
            RectangleF r   = new RectangleF(-carWidth / 2, carIMUtoFront - carHeight, carWidth, carHeight);
            GLPen      pen = new GLPen(color, 1.0f);

            GLUtility.DrawRectangle(pen, r);
            GLUtility.DrawLine(pen, r.Left + 0.2f, r.Bottom - r.Width / 2, r.Left + r.Width / 2, r.Bottom - .2f);
            GLUtility.DrawLine(pen, r.Right - 0.2f, r.Bottom - r.Width / 2, r.Right - r.Width / 2, r.Bottom - .2f);
            if (label != "")
            {
                GLUtility.DrawString(label, new Font("verdana", 1.0f), labelColor, new PointF(+.20f, 0));
            }
            GLUtility.DrawCross(new GLPen(Color.Pink, 1.0f), new PointF(0, 0), r.Width / 2);
            GLUtility.ComeBackFromVehicleCoordinates();
        }
 public static void DrawEllipse(GLPen p, float x, float y, float width, float height)
 {
     DrawEllipse(p, new RectangleF(x, y, width, height));
 }
 public static void DrawPoint(GLPen pen, PointF p)
 {
     DrawPoint(pen, p, true);
 }
 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();
 }
 public static void DrawEllipse(GLPen p, float x, float y, float width, float height)
 {
     DrawEllipse(p, new RectangleF(x, y, width, height));
 }
 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();
 }
 public static void DrawCross3D(GLPen pen, v3f p, float size)
 {
     pen.GLApplyPen();
       Gl.glBegin(Gl.GL_LINES);
       Gl.glVertex3f(p.x + size, p.y, p.z);
       Gl.glVertex3f(p.x - size, p.y, p.z);
       Gl.glVertex3f(p.x, p.y + size, p.z);
       Gl.glVertex3f(p.x, p.y - size, p.z);
       Gl.glVertex3f(p.x, p.y, p.z + size);
       Gl.glVertex3f(p.x, p.y, p.z - size);
       Gl.glEnd();
 }
 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();
 }
 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();
 }
 public static void DrawLine3D(GLPen pen, v3f a, v3f b)
 {
     pen.GLApplyPen();
       Gl.glBegin(Gl.GL_LINES);
       Gl.glVertex3f(a.x, a.y, a.z);
       Gl.glVertex3f(b.x, b.y, b.z);
       Gl.glEnd();
 }
 public static void DrawPoint(GLPen pen, PointF p)
 {
     DrawPoint(pen, p, true);
 }
 public static void DrawLines(GLPen pen, PointF[] points)
 {
     pen.GLApplyPen();
     Gl.glBegin(Gl.GL_LINE_STRIP);
     foreach (PointF p in points)
         Gl.glVertex2f(p.X, p.Y);
     Gl.glEnd();
 }
 public static void DrawPoint(GLPen pen, PointF p, bool ApplyPen)
 {
     if (ApplyPen) pen.GLApplyPen();
     Gl.glBegin(Gl.GL_POINT);
     Gl.glVertex2f(p.X, p.Y);
     Gl.glEnd();
 }
 public static void DrawBox(PointF p, float h, float width, float length, string label, bool rotate90, DrawRef drawRef, Color color)
 {
     GLUtility.GoToVehicleCoordinates(h, p, rotate90);
     RectangleF r = new RectangleF();
     if (drawRef == DrawRef.RearAxle)
         r = new RectangleF(-width / 2, 0, width, length);
     else if (drawRef == DrawRef.Center)
         r = new RectangleF(-width / 2, -length / 2, width, length);
     else if (drawRef == DrawRef.BottomCorner)
         r = new RectangleF(0, 0, width, length);
     GLPen pen = new GLPen(color, 1.0f);
     GLUtility.DrawRectangle(pen, r);
     GLUtility.DrawLine(pen, r.Left + 0.2f, r.Bottom - r.Width / 2, r.Left + r.Width / 2, r.Bottom - .2f);
     GLUtility.DrawLine(pen, r.Right - 0.2f, r.Bottom - r.Width / 2, r.Right - r.Width / 2, r.Bottom - .2f);
     if (label != "") GLUtility.DrawString(label, new Font("verdana", 1.0f), Color.Black, r.Location);
     GLUtility.ComeBackFromVehicleCoordinates();
 }
        public static void DrawWireframeBox3D(v3f a, v3f b, GLPen pen)
        {
            pen.GLApplyPen();
              Gl.glBegin(Gl.GL_LINES);
              Gl.glVertex3f(a.x, a.y, a.z);
              Gl.glVertex3f(b.x, a.y, a.z);
              Gl.glVertex3f(a.x, b.y, a.z);
              Gl.glVertex3f(b.x, b.y, a.z);
              Gl.glVertex3f(a.x, a.y, b.z);
              Gl.glVertex3f(b.x, a.y, b.z);
              Gl.glVertex3f(a.x, b.y, b.z);
              Gl.glVertex3f(b.x, b.y, b.z);

              Gl.glVertex3f(a.x, a.y, a.z);
              Gl.glVertex3f(a.x, b.y, a.z);
              Gl.glVertex3f(a.x, a.y, b.z);
              Gl.glVertex3f(a.x, b.y, b.z);
              Gl.glVertex3f(b.x, a.y, a.z);
              Gl.glVertex3f(b.x, b.y, a.z);
              Gl.glVertex3f(b.x, a.y, b.z);
              Gl.glVertex3f(b.x, b.y, b.z);

              Gl.glVertex3f(a.x, a.y, a.z);
              Gl.glVertex3f(a.x, a.y, b.z);
              Gl.glVertex3f(b.x, a.y, a.z);
              Gl.glVertex3f(b.x, a.y, b.z);
              Gl.glVertex3f(a.x, b.y, a.z);
              Gl.glVertex3f(a.x, b.y, b.z);
              Gl.glVertex3f(b.x, b.y, a.z);
              Gl.glVertex3f(b.x, b.y, b.z);

              Gl.glEnd();
        }
 public static void DrawDiamond(GLPen pen, PointF p, float size)
 {
     PointF p1 = new PointF(p.X, p.Y + size / 2.0f);
       PointF p2 = new PointF(p.X, p.Y - size / 2.0f);
       PointF p3 = new PointF(p.X + size / 2.0f, p.Y);
       PointF p4 = new PointF(p.X - size / 2.0f, p.Y);
       DrawLine(pen, p1, p3);
       DrawLine(pen, p3, p2);
       DrawLine(pen, p2, p4);
       DrawLine(pen, p4, p1);
 }
 public static void DrawLine(GLPen pen, PointF p1, PointF p2)
 {
     pen.GLApplyPen();
     Gl.glBegin(Gl.GL_LINE_STRIP);
     Gl.glVertex2f(p1.X, p1.Y);
     Gl.glVertex2f(p2.X, p2.Y);
     Gl.glEnd();
 }
 public static void DrawCube(GLPen pen, v3f p, float size)
 {
     pen.GLApplyPen();
       Gl.glPushMatrix();
       Gl.glTranslatef(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();
 }
 public static void DrawLine(GLPen pen, float x1, float y1, float x2, float y2)
 {
     DrawLine(pen, new PointF(x1, y1), new PointF(x2, y2));
 }
 public static void DrawCluster(PointF p, float h, float width, string label, bool rotate90)
 {
     GLUtility.GoToVehicleCoordinates(h, p, rotate90);
     GLPen pen = new GLPen(Color.Blue, 1.0f);
     GLUtility.DrawLine(pen,-width/2,0,width/2,0);
     GLUtility.DrawLine(pen, 0, .1f, 0, -.1f);
     if (label != "") GLUtility.DrawString(label, new Font("verdana", 1.0f), Color.Black, new PointF(0,0));
     GLUtility.ComeBackFromVehicleCoordinates();
 }
 public static void DrawLine(GLPen pen, float x1, float y1, float x2, float y2)
 {
     DrawLine(pen, new PointF(x1, y1), new PointF(x2, y2));
 }
        /*	public static void DrawCar(PointF rearAxle, float h, int txid)
        {

            //the rear axle point is just the center of the car in x and the rear of the car in y
            PointF carPoint = new PointF(rearAxle.X - (carWidth / 2), rearAxle.Y);
            GLUtility.GoToVehicleCoordinates(h, carPoint);
            RectangleF r = new RectangleF(0, 0, carWidth, carHeight);
            GLPen pen = new GLPen(Color.LightBlue, 1.0f);
            GLUtility.FillTexturedRectangle(txid, r);
            GLUtility.ComeBackFromVehicleCoordinates();
        }
        */
        //0 degree heading means positive X and means EAST
        public static void DrawCar(PointF rearAxle, float h, Color color, string label, bool rotate90, Color labelColor)
        {
            float carWidth = (float)TahoeParams.T;
            float carIMUtoFront = (float)(TahoeParams.FL - TahoeParams.IL);
            float carHeight = (float)TahoeParams.VL;
            //the rear axle point is just the center of the car in x and the rear of the car in y
            PointF IMU = new PointF (rearAxle.X,rearAxle.Y);
            GLUtility.GoToVehicleCoordinates(h, IMU,rotate90);
            RectangleF r = new RectangleF(-carWidth / 2, carIMUtoFront - carHeight, carWidth, carHeight);
            GLPen pen = new GLPen(color, 1.0f);
            GLUtility.DrawRectangle(pen, r);
            GLUtility.DrawLine(pen, r.Left + 0.2f, r.Bottom - r.Width / 2, r.Left + r.Width / 2, r.Bottom - .2f);
            GLUtility.DrawLine(pen, r.Right - 0.2f, r.Bottom - r.Width / 2, r.Right - r.Width / 2, r.Bottom - .2f);
              if (label != "") GLUtility.DrawString(label, new Font("verdana", 1.0f), labelColor, new PointF(+.20f, 0));
            GLUtility.DrawCross(new GLPen (Color.Pink,1.0f), new PointF(0, 0), r.Width / 2);
            GLUtility.ComeBackFromVehicleCoordinates();
        }
        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();
        }
        public static void DrawBezier(GLPen pen, PointF startP, PointF ctrl1, PointF ctrl2, PointF endP)
        {
            CubicBezier cb = new CubicBezier(Utility.ToCoord(startP), Utility.ToCoord(ctrl1), Utility.ToCoord(ctrl2), Utility.ToCoord(endP));
            pen.GLApplyPen();
            Gl.glBegin(Gl.GL_LINE_STRIP);
            //iterate this bitch
            for (double i = 0; i < 1.0; i += .025)
            {
                PointF p = Utility.ToPointF(cb.Bt(i));
                Gl.glVertex2f(p.X, p.Y);
            }

            PointF p1 = Utility.ToPointF(cb.Bt(1));
            Gl.glVertex2f(p1.X, p1.Y);

            Gl.glEnd();
        }
 public static void DrawPoint3D(GLPen pen, v3f p)
 {
     pen.GLApplyPen();
       Gl.glBegin(Gl.GL_POINT);
       //Gl.glVertex3f(p.x, p.y, 0.0f);//p.z);
       Gl.glVertex2f(p.x, p.y);
       Gl.glEnd();
 }