Example #1
0
        /// <summary>
        /// Рисует прямоугольник
        /// </summary>
        /// <param name="lenght"></param>
        /// <param name="width"></param>
        /// <param name="r"></param>
        /// <param name="g"></param>
        /// <param name="b"></param>
        /// <param name="depth"></param>
        public static void Rectangle(Shaft shaft, float depth)
        {
            Gl.glTranslatef(0.0f, 0.0f, depth);
            Gl.glBegin(Gl.GL_QUADS);

            Gl.glColor3f(shaft.Color.R,shaft.Color.G,shaft.Color.B);

            Gl.glVertex3f((float)shaft._lenght, (float)shaft._width, 0);                                         // Top Right Of The Quad (Front)
            Gl.glVertex3f(0, (float)shaft._width, 0);
            Gl.glVertex3f(0, 0, 0);                                       // Bottom Left Of The Quad (Front)
            Gl.glVertex3f((float)shaft._lenght, 0, 0);

            Gl.glEnd();
        }
Example #2
0
        /*
        public static void fixedLeft(Node pnt,float r, float g, float b)
        {
            Gl.glColor3f(r,g,b);
            Gl.glBegin(Gl.GL_TRIANGLES);
            Gl.glVertex2f((float)pnt.X,(float)pnt.Y);
            Gl.glVertex2f((float)pnt.X - 0.01f, (float)pnt.Y + 0.01f);
            Gl.glVertex2f((float)pnt.X - 0.01f, (float)pnt.Y - 0.01f);
            Gl.glEnd();
        }

        public static void fixedRight(Node pnt, float r, float g, float b)
        {
            Gl.glColor3f(r, g, b);
            Gl.glBegin(Gl.GL_TRIANGLES);
            Gl.glVertex2f((float)pnt.X, (float)pnt.Y);
            Gl.glVertex2f((float)pnt.X + 0.01f, (float)pnt.Y - 0.01f);
            Gl.glVertex2f((float)pnt.X + 0.01f, (float)pnt.Y + 0.01f);
            Gl.glEnd();
        }

        public static void LoadTop(Node pnt, float r, float g, float b)
        {
            Gl.glColor3f(r, g, b);
            Gl.glBegin(Gl.GL_TRIANGLES);
            Gl.glVertex2f((float)pnt.X, (float)pnt.Y);
            Gl.glVertex2f((float)pnt.X + 0.005f, (float)pnt.Y + 0.01f);
            Gl.glVertex2f((float)pnt.X - 0.005f, (float)pnt.Y + 0.01f);

            Gl.glVertex2f((float)pnt.X + 0.002f, (float)pnt.Y + 0.01f);
            Gl.glVertex2f((float)pnt.X - 0.002f, (float)pnt.Y + 0.01f + 0.05f);
            Gl.glVertex2f((float)pnt.X - 0.002f, (float)pnt.Y + 0.01f);

            Gl.glVertex2f((float)pnt.X + 0.002f, (float)pnt.Y + 0.01f );
            Gl.glVertex2f((float)pnt.X + 0.002f, (float)pnt.Y + 0.01f + 0.05f);
            Gl.glVertex2f((float)pnt.X - 0.002f, (float)pnt.Y + 0.01f + 0.05f);

            Gl.glEnd();
        }*/
        public static void Shaft(Shaft shaft, float depth)
        {
            Gl.glTranslatef(0.0f, 0.0f, depth);

            //Gl.glClearColor(0.5f, 0.5f, 0.75f, 1.0f); // цвет фона
            //Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);      // очистка буфера цвета
            /*Gl.glEnable(Gl.GL_BLEND);
            Gl.glEnable(Gl.GL_ALPHA_TEST);
            Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
            Gl.glPointSize(5);
            Gl.glEnable(Gl.GL_POINT_SMOOTH);        // включаем режим сглаживания точек
            */

            Gl.glBegin(Gl.GL_QUADS);

            Gl.glColor3f(shaft.Color.R, shaft.Color.G, shaft.Color.B);
            Gl.glVertex3f((float)shaft._lenght, (float)shaft._width, 0);                                         // Top Right Of The Quad (Front)
            Gl.glVertex3f(0, (float)shaft._width, 0);
            Gl.glVertex3f(0, 0, 0);                                       // Bottom Left Of The Quad (Front)
            Gl.glVertex3f((float)shaft._lenght, 0, 0);

               /* Gl.glColor3f(0.0f, 0.0f, 0.0f);

            Gl.glVertex3f((float)shaft._lenght + (float)(shaft._lenght/50), (float)shaft._width*1.5f, 0);                                         // Top Right Of The Quad (Front)
            Gl.glVertex3f((float)shaft._lenght, (float)shaft._width*1.5f, 0);
            Gl.glVertex3f((float)shaft._lenght, -(float)shaft._width*1.5f, 0);                                       // Bottom Left Of The Quad (Front)
            Gl.glVertex3f((float)shaft._lenght + (float)(shaft._lenght / 50), -(float)shaft._width*1.5f, 0);

            Gl.glVertex3f(0, (float)shaft._width*1.5f, 0);                                         // Top Right Of The Quad (Front)
            Gl.glVertex3f(- (float)(shaft._lenght / 50), (float)shaft._width*1.5f, 0);
            Gl.glVertex3f(-(float)(shaft._lenght / 50), -(float)shaft._width*1.5f, 0);                                       // Bottom Left Of The Quad (Front)
            Gl.glVertex3f(0, -(float)shaft._width*1.5f, 0);
            */

            Gl.glEnd();
        }
Example #3
0
        public void MeshRectangle(Shaft shaft, int NcntOX, int NcntOY)
        {
            //Количество узлов сетки
            int nodeCount = NcntOX * NcntOY;
            //Генерирование массива узлов
            nodes = new Node[nodeCount];
            bondary = new Bondary();

            double stepOX = shaft._lenght / ((double)NcntOX - 1);
            double stepOY = shaft._width / ((double)NcntOY - 1);

            double baseX = 0;
            double baseY = 0;

            int k = 0;
            for (int i = 0; i < NcntOY; i++)
                for (int j = 0; j < NcntOX; j++)
                {
                    nodes[k] = new Node(baseX + j * stepOX, baseY + i * stepOY);

                    if (j == 0)
                    {
                        bondary.left.Add(k);
                    }
                    else if (j == (NcntOX - 1))
                    {
                        bondary.right.Add(k);
                    }

                    if (i == 0)
                    {
                        bondary.bottom.Add(k);
                    }
                    else if (i == (NcntOY - 1))
                    {
                        bondary.top.Add(k);
                    }

                    k++;
                }

            //Формирование сетки
            //количество квадаратов
            int ElementCount = (NcntOX - 1) * (NcntOY - 1);
            elements = new ElementType.Trigle2D[ElementCount * 2];
            k = 0;

            for (int i = 0; i < NcntOY - 1; i++)
                for (int j = 0; j < NcntOX - 1; j++)
                {
                    elements[k] = new ElementType.Trigle2D(j + i * NcntOX,
                                                           j + i * NcntOX + 1,
                                                          (i + 1) * NcntOX + j);
                    k++;
                    elements[k] = new ElementType.Trigle2D((i + 1) * NcntOX + j + 1,
                                                           (i + 1) * NcntOX + j,
                                                           i * NcntOX + 1 + j);
                    k++;
                }
        }