Ejemplo n.º 1
0
        private void DrawAllMatrix()
        {
            if (Correct_Height != AnT.Size.Height || Correct_Width != AnT.Size.Width)
            {
                if (Correct_Height != AnT.Size.Height)
                {
                    Correct_Height = AnT.Size.Height;
                }
                if (Correct_Width != AnT.Size.Width)
                {
                    Correct_Width = AnT.Size.Width;
                }
                Gl.glViewport(0, 0, AnT.Width, AnT.Height);
            }

            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();
            Glu.gluPerspective(45, (float)AnT.Width / (float)AnT.Height, 0.1, 200);
            Gl.glMatrixMode(Gl.GL_MODELVIEW);

            Gl.glClearColor(0.7f * 1.2f, 0.999f * 1.2f, 0.568f * 1.2f, 1.0f);//фон редактить здесь
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);

            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Gl.glEnable(Gl.GL_LIGHTING);
            Gl.glEnable(Gl.GL_LIGHT0);
            Gl.glEnable(Gl.GL_COLOR_MATERIAL);

            Gl.glColor3d(0.31, 0.31, 0.31);
            Gl.glRotated(-90, 1, 0, 0);
            Gl.glRotated(90, 0, 0, 1);

            Shtativ.DrawModel();
            DrawGround();//КАТЯ, СТОЛ УБИРАЕТСЯ ЗДЕСЬ!!!
            Gl.glRotated(-90, 0, 0, 1);
            Gl.glRotated(90, 1, 0, 0);
            Gl.glColor3d(0.31, 0.31, 0.31);
            Gl.glPushMatrix();
            Gl.glRotatef(-90, 1, 0, 0);
            Gl.glTranslatef(0, 0, 1);
            Gl.glRotated(Angle, 0, -1, 0);
            Gl.glTranslatef(0, 0, -1);

            if (TopMount_radioButton.Checked == true)
            {
                Gl.glTranslatef(0, 0, 1 - Object3.Get_Height() / 10);
                Glut.glutSolidCylinder(0.01d, 1, 200, 1);
                Gl.glColor3d(0, 0.0, 0.0);
                for (int i = 1; i < 20; i++)
                {
                    Gl.glTranslatef(0, 0, 0.05f);
                    Glut.glutSolidCylinder(0.0101d, 0.002, 200, 1);
                }
                Gl.glTranslatef(0, 0, -0.95f);
                Gl.glColor3d(0.75, 0, 0);
                Glut.glutSolidCylinder(0.0120d, 0.025, 200, 1);
                Gl.glColor3d(0.31, 0.31, 0.31);
            }
            if (BottomMount_radioButton.Checked == true)
            {
                Gl.glTranslatef(0, 0, 1 + Object4.Get_Height() / 10);
                Gl.glRotatef(-180, 1, 0, 0);
                Glut.glutSolidCylinder(0.01d, 1, 200, 1);
                Gl.glColor3d(0, 0.0, 0.0);
                for (int i = 1; i < 20; i++)
                {
                    Gl.glTranslatef(0, 0, 0.05f);
                    Glut.glutSolidCylinder(0.0101d, 0.002, 200, 1);
                }
                Gl.glColor3d(0.75, 0, 0);
                Gl.glTranslatef(0, 0, 0.025f);
                Glut.glutSolidCylinder(0.0120d, 0.025, 200, 1);
                Gl.glTranslatef(0, 0, -0.975f);
                Gl.glColor3d(0.31, 0.31, 0.31);
            }

            Gl.glColor3d(0.31, 0.31, 0.31);
            Gl.glDisable(Gl.GL_COLOR_MATERIAL);
            Gl.glPushMatrix();


            Object1.Drawobject();
            Object2.Drawobject();
            Object3.Drawobject(false);
            Object4.Drawobject(true);
            Gl.glPopMatrix();
            Gl.glPopMatrix();

            Gl.glDisable(Gl.GL_DEPTH_TEST);
            Gl.glDisable(Gl.GL_LIGHTING);
            Gl.glDisable(Gl.GL_LIGHT0);
            Gl.glLoadIdentity();

            Gl.glRotated(camXRot, 1, 0, 0);
            Gl.glRotated(camYRot, 0, 1, 0);
            Gl.glTranslated(camXPos, camYPos, camZPos);
            Gl.glTranslated(0, -0.5, -2.5);
            Gl.glFlush();//?
            AnT.Invalidate();
        }