예제 #1
0
        private void DrawDisk()
        {
            for (int angle = 0; angle <= 360; angle += 72)
            {
                DrawingService.PickTexture(TextureNames.Metal);
                Gl.glBegin(Gl.GL_POLYGON);
                double x1 = Math.Cos(Angle3d.DegreeToRadian(angle));
                double y1 = Math.Sin(Angle3d.DegreeToRadian(angle));
                double x2 = Math.Cos(Angle3d.DegreeToRadian(angle - 35));
                double y2 = Math.Sin(Angle3d.DegreeToRadian(angle - 35));

                //Gl.glNormal3b(0, 0, 1);
                Gl.glTexCoord2d(1, 1);
                Gl.glVertex3d(x1, y1, 0);

                //Gl.glNormal3b(0, 0, 1);
                Gl.glTexCoord2d(0.7, 0.7);
                Gl.glVertex3d(x1 * 0.2, y1 * 0.2, 0);

                //Gl.glNormal3b(0, 0, 1);
                Gl.glTexCoord2d(0.35, 0.35);
                Gl.glVertex3d(x2, y2, 0);

                //Gl.glNormal3b(0, 0, 1);
                Gl.glTexCoord2d(0, 0);
                Gl.glVertex3d(x2 * 0.2, y2 * 0.2, 0);

                DrawingService.UnloadTexture();
                Gl.glEnd();
            }
        }
예제 #2
0
 public static void DrawCircle(double x, double y, double z)
 {
     Gl.glBegin(Gl.GL_POLYGON);
     for (int i = 360; i >= 1; i--)
     {
         double x1 = Math.Cos(Angle3d.DegreeToRadian(i));
         double y1 = Math.Sin(Angle3d.DegreeToRadian(i));
         Gl.glVertex3d(x + x1 / 2, y + y1 / 2, z);
     }
     Gl.glEnd();
 }
예제 #3
0
        public void Drive(MoveDirection direction)
        {
            if (driveAvailable)
            {
                double enlarger = direction == MoveDirection.Forward ? MaxSpeed / 4 : direction == MoveDirection.Backward ? -MaxSpeed / 4 : 0;
                this.Speed -= enlarger;

                double addAngle = driveWheels[0].Angle.Y;
                if (addAngle < -1 || addAngle > 1)
                {
                    double enlargerAngle = addAngle / Math.Abs(addAngle);
                    this.Angle.Y += enlarger * Math.Sin(Angle3d.DegreeToRadian(driveWheels[0].Angle.Y)) * 3;
                }
            }
        }
예제 #4
0
        public static void DrawRim(Point3d p1, Point3d p2, double size = 1, double radius = 1,
                                   string textureName = null)
        {
            for (int i = 360; i >= 1; i--)
            {
                if (textureName != null)
                {
                    DrawingService.PickTexture(textureName);
                }

                Gl.glBegin(Gl.GL_POLYGON);
                double x1 = Math.Cos(Angle3d.DegreeToRadian(i));
                double y1 = Math.Sin(Angle3d.DegreeToRadian(i));
                double x2 = Math.Cos(Angle3d.DegreeToRadian(i - 3));
                double y2 = Math.Sin(Angle3d.DegreeToRadian(i - 3));

                Gl.glNormal3d(x1, y1, y1);
                Gl.glTexCoord3d(x2, 0, 0);
                //Gl.glNormal3b(0, 1, 0);
                Gl.glVertex3d(x2 * size + p2.X, y2 * radius + p2.Y, y2 * radius + p2.Z);

                Gl.glNormal3d(x1, y1, y1);
                Gl.glTexCoord3d(x2, 1, 0);
                //Gl.glNormal3b(0, 1, 0);
                Gl.glVertex3d(x2 * size + p1.X, y2 * radius + p1.Y, y2 * radius + p1.Z);

                Gl.glNormal3d(x1, y1, y1);
                Gl.glTexCoord3d(x1, 1, 0);
                //Gl.glNormal3b(0, 1, 0);
                Gl.glVertex3d(x1 * size + p1.X, y1 * radius + p1.Y, y1 * radius + p1.Z);

                Gl.glNormal3d(x1, y1, y1);
                Gl.glTexCoord3d(x1, 0, 0);
                //Gl.glNormal3b(0, 1, 0);
                Gl.glVertex3d(x1 * size + p2.X, y1 * radius + p2.Y, y1 * radius + p2.Z);
                Gl.glEnd();
                DrawingService.UnloadTexture();
            }
        }
예제 #5
0
        private void DrawRim(double depth = 1, double size = 1)
        {
            if (size == 0)
            {
                size = 1;
            }

            bool flag = depth == 1 && size == 1;

            for (int i = 360; i >= 0; i--)
            {
                if (flag)
                {
                    DrawingService.PickTexture(TextureNames.Bus);
                }
                else
                {
                    DrawingService.PickTexture(TextureNames.Body);
                }

                Gl.glBegin(Gl.GL_POLYGON);
                double x1 = Math.Cos(Angle3d.DegreeToRadian(i));
                double y1 = Math.Sin(Angle3d.DegreeToRadian(i));
                double x2 = Math.Cos(Angle3d.DegreeToRadian(i - 2));
                double y2 = Math.Sin(Angle3d.DegreeToRadian(i - 2));
                if (flag)
                {
                    Gl.glTexCoord3d(x2, 0, 0);
                }
                else
                {
                    Gl.glTexCoord3d(x2 - 0.5, y2 - 1, 0);
                }
                Gl.glNormal3d(x2, y2, 0);
                Gl.glVertex3d(x2, y2, 0);

                Gl.glNormal3d(0, 0, 1);
                if (flag)
                {
                    Gl.glTexCoord3d(x2, 1, 0);
                }
                else
                {
                    Gl.glTexCoord3d(x2 / size - 0.5, y2 / size - 1, 0);
                }
                Gl.glVertex3d(x2 / size, y2 / size, -depth);

                Gl.glNormal3d(0, 0, 1);
                if (flag)
                {
                    Gl.glTexCoord3d(x1, 1, 0);
                }
                else
                {
                    Gl.glTexCoord3d(x1 / size - 0.5, y1 / size - 1, 0);
                }
                Gl.glVertex3d(x1 / size, y1 / size, -depth);

                Gl.glNormal3d(0, 0, 1);
                if (flag)
                {
                    Gl.glTexCoord3d(x1, 0, 0);
                }
                else
                {
                    Gl.glTexCoord3d(x1 - 0.5, y1 - 1, 0);
                }
                Gl.glVertex3d(x1, y1, 0);


                DrawingService.UnloadTexture();
                Gl.glEnd();
            }
        }