Example #1
0
        public static void DrawRotatedTeaPot(OpenGLWindow _window, float _angle)
        {
            //ThrowIfNull(_window);

            // Clear The Screen And The Depth Buffer
            _window.Context.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            // Move Left And Into The Screen
            _window.Context.LoadIdentity();
            _window.Context.Rotate(_angle, 0.0f, 1.0f, 0.0f);

            Teapot teapot = new Teapot();

            teapot.Draw(_window.Context, 14, 1, OpenGL.GL_FILL);
        }
Example #2
0
        private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args)
        {
            OpenGL gl = args.OpenGL;

            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            gl.LoadIdentity();

            gl.Translate(0.0f, 0.0f, -6.0f);

            //dibujar una piramide. Primero rotar el modelo de ls matriz
            gl.Rotate(rotation, 0.0f, 1.0f, 0.0f);
            //rotatePyramid

            //comenzar a dibujar los triangulos

            //gl.Begin(OpenGL.GL_TRIANGLES);

            //gl.Color(1.0f, 0.0f, 0.0f);
            //gl.Vertex(0.0f, 1.0f, 0.0f);
            //gl.Color(0.0f, 1.0f, 0.0f);
            //gl.Vertex(-1.0f, -1.0f, 1.0f);
            //gl.Color(0.0f, 0.0f, 1.0f);
            //gl.Vertex(1.0f, -1.0f, 1.0f);

            //gl.End();

            //IntPtr quadric = gl.NewQuadric();
            //gl.QuadricNormals(quadric, OpenGL.GLU_SMOOTH);
            //gl.Sphere(quadric, 1.0, 200, 200);

            //tetera
            Teapot tp = new Teapot();

            tp.Draw(gl, 14, 1, OpenGL.GL_FILL);

            rotation += 3.0f;

            //Reiniciar el modelo

            //rotar la geometria en un bit
            rotatePyramid += 3.0f;
            rquad         -= 3.0f;
        }
Example #3
0
        /// <summary>
        /// Handles the OpenGLDraw event of the OpenGLControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The <see cref="SharpGL.SceneGraph.OpenGLEventArgs"/> instance containing the event data.</param>
        private void OpenGLControl_OpenGLDraw(object sender, OpenGLEventArgs args)
        {
            OpenGL gl = args.OpenGL;	
            
            // Clear The Screen And The Depth Buffer
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            
            // Move Left And Into The Screen
            gl.LoadIdentity();
            gl.Translate(0.0f, 0.0f, -6.0f);				


            gl.Rotate(rotation, 0.0f, 1.0f, 0.0f);

            Teapot tp = new Teapot();
            tp.Draw(gl, 14, 1, OpenGL.GL_FILL);

            rotation += 3.0f;
        }
Example #4
0
        private void OpenGLControl_OpenGLDraw(object sender, OpenGLEventArgs args)
        {
            OpenGL gl = args.OpenGL;

            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            gl.LoadIdentity();
            gl.Translate(0.0f, 0.0f, -6.0f);

            program.Push(gl, null);
            gl.Rotate(rotation, 0.0f, 1.0f, 0.0f);

            Teapot tp = new Teapot();

            tp.Draw(gl, 14, 1, OpenGL.GL_FILL);

            rotation += 1.0f;
            program.Pop(gl, null);
        }
Example #5
0
        /// <summary>
        /// Handles the OpenGLDraw event of the OpenGLControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The <see cref="SharpGL.SceneGraph.OpenGLEventArgs"/> instance containing the event data.</param>
        private void OpenGLControl_OpenGLDraw(object sender, OpenGLEventArgs args)
        {
            OpenGL gl = args.OpenGL;

            // Clear The Screen And The Depth Buffer
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            // Move Left And Into The Screen
            gl.LoadIdentity();
            gl.Translate(0.0f, 0.0f, -6.0f);

            gl.Rotate(rotation, 0.0f, 1.0f, 0.0f);

            Teapot tp = new Teapot();

            tp.Draw(gl, 14, 1, OpenGL.GL_FILL);

            rotation += 3.0f;
        }
Example #6
0
        private void OpenGLControl_OpenGLDraw(object sender, OpenGLEventArgs args)
        {
            OpenGL gl = args.OpenGL;

            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            gl.LoadIdentity();

            gl.Translate(0.0, 0.0F, -4.0F);

            gl.Rotate(rotation, 1.0f, 1.0f, 0.0f);


            /*gl.Begin(OpenGL.GL_TRIANGLES);
             *
             * gl.Color(1.0f, 0.0f, 0.0f);
             * gl.Vertex(0.0f, 1.0f, 0.0f);
             * gl.Color(0.0f, 1.0f, 0.0f);
             * gl.Vertex(-1.0f, -1.0f, 1.0f);
             * gl.Color(0.0f, 0.0f, 1.0f);
             * gl.Vertex(1.0f, -1.0f, 1.0f);
             *
             * gl.End();
             */
            /*
             * IntPtr quadric = gl.NewQuadric();
             * gl.QuadricNormals(quadric, OpenGL.GLU_SMOOTH);
             * gl.Sphere(quadric, 1.0, 20, 20);
             *
             * gl.End();
             */
            Teapot tp = new Teapot();

            tp.Draw(gl, 14, 1, OpenGL.GL_FILL);


            rotation += 3.0f;
        }
Example #7
0
        private void openGLControl1_OpenGLDraw_1(object sender, RenderEventArgs args)
        {
            Init();
            var gl = openGLControl1.OpenGL;

            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            gl.Enable(OpenGL.GL_LIGHTING);
            gl.ClearColor(0.5f, 0.5f, 0.5f, 0.5f);

            gl.Enable(OpenGL.GL_DEPTH_TEST);
            gl.Enable(OpenGL.GL_TEXTURE_2D);

            gl.Enable(OpenGL.GL_BLEND);          // Разрешить прозрачность.
            gl.Enable(OpenGL.GL_POINT_SMOOTH);   // Разрешить сглаживание точек.
            gl.Enable(OpenGL.GL_COLOR_MATERIAL); // Отключить перелевание цвета.

            gl.LoadIdentity();
            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_POSITION, _l0pos);
            _figureHummer1.Draw(gl, _l0pos[0], _l0pos[1], _l0pos[2], 0, 0, 1f, 0);
            gl.LoadIdentity();

            gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_POSITION, _l1pos);
            _figureHummer2.Draw(gl, _l1pos[0], _l1pos[1], _l1pos[2], 0, 0, 1f, 0);
            gl.LoadIdentity();

            gl.Light(OpenGL.GL_LIGHT2, OpenGL.GL_POSITION, _l2pos);
            _figureHummer3.Draw(gl, _l2pos[0], _l2pos[1], _l2pos[2], 0, 0, 1f, 0);
            gl.LoadIdentity();

            gl.Enable(OpenGL.GL_LIGHT0);
            gl.Enable(OpenGL.GL_LIGHT1);
            gl.Enable(OpenGL.GL_LIGHT2);

//            gl.LightModel(OpenGL.GL_LIGHT_MODEL_AMBIENT, _black);

            gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_DIFFUSE, _light0Diffuse);
            gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_AMBIENT, _light0Ambient);
            gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_SPECULAR, _light0Scpecular);
            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_DIFFUSE, _light0Diffuse);
            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_AMBIENT, _light1Ambient);
            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_SPECULAR, _light1Scpecular);
            gl.Light(OpenGL.GL_LIGHT2, OpenGL.GL_DIFFUSE, _light0Diffuse);
            gl.Light(OpenGL.GL_LIGHT2, OpenGL.GL_AMBIENT, _light2Ambient);
            gl.Light(OpenGL.GL_LIGHT2, OpenGL.GL_SPECULAR, _light1Scpecular);


            gl.LoadIdentity();
//            _figureKub.Draw(gl, 0, 0, -7f);

            gl.Translate(0, 0, -5f);
            var teapot = new Teapot();

//            gl.Rotate(_angleX, 1f, 0f, 0f);
//            gl.Rotate(_angleY, 0f, 1f, 0f);
            gl.Color(0.4f, 0.4f, 0.4f);
            teapot.Draw(gl, 14, 1, OpenGL.GL_FILL);
            gl.ColorMaterial(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_AMBIENT_AND_DIFFUSE);
            gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_SPECULAR, _sRef);
            gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_SHININESS, 64);

            gl.ShadeModel(OpenGL.GL_SMOOTH);
        }
Example #8
0
        private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args)
        {
            OpenGL gl = GLcontrol.OpenGL;

            IntPtr quad = gl.NewQuadric();

            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.LoadIdentity();
            if (p_flag == true)
            {
                gl.LookAt(e_x, e_y, e_z, c_x, c_y, c_z, u_x, u_y, u_z);
            }
            if (rot_flag == true)

            {
                if (clock == true)
                {
                    gl.Rotate(rotation, 0.0f, 0.0f, 1.0f);
                }
                else
                {
                    gl.Rotate(rotation, 1.0f, 1.0f, 1.0f);
                }
            }

            gl.Translate(0.0f, 0.0f, 0.0f);
            if (kb.IsChecked == true || Z_o.IsChecked == true)
            {
                gl.Scale(40.3, 40.3, 40.3);
            }
            gl.Scale(0.3, 0.3, 0.3);
            gl.PushMatrix();
            gl.Color(1.0f, 1.0f, 0.0f);
            if (zil.IsChecked == true)
            {
                gl.Cylinder(quad, 50, 30, 30, 20, 20);
                clock = false;
            }
            if (sf.IsChecked == true)
            {
                gl.Sphere(quad, 50, 100, 100);
                clock = false;
            }
            if (ds.IsChecked == true)
            {
                gl.Disk(quad, 40, 50, 50, 50);
                clock = false;
            }
            if (ds_m.IsChecked == true)
            {
                gl.PartialDisk(quad, 40, 50, 50, 50, 50, 50);
                clock = false;
            }
            if (tp.IsChecked == true)
            {
                Teapot tp = new Teapot();
                tp.Draw(gl, 50, 51, OpenGL.GL_FILL);
                clock = false;
            }
            if (kb.IsChecked == true)
            {
                Cube cube = new Cube();
                cube.Render(gl, RenderMode.Render);
                clock = false;
            }
            if (Z_o.IsChecked == true)
            {
                clock = false;
                int   i, N = 20;
                float angleStep    = 360.0f / N;
                float angleCurrent = 0f;
                float Radius1      = 1.0f;
                for (i = 0; i < N; i++)
                {
                    angleCurrent = i * angleStep * 3.14f / 180;
                    gl.PushMatrix();
                    gl.Translate(Radius1 * Math.Sin(angleCurrent), 0, Radius1 * Math.Cos(angleCurrent));
                    gl.Sphere(quad, 0.3, 24, 24);
                    gl.PopMatrix();
                }
            }
            if (S_S.IsChecked == true)
            {
                clock = false;
                //рисуем солнце
                gl.Color(1.0, 1.0, 0.0);
                gl.Sphere(quad, 30, 50, 50);
                gl.Translate(60, 0, 0);
                // Рисуем планету
                gl.Color(0.0, 1.0, 0.0);
                gl.Sphere(quad, 10, 50, 50);
                gl.PopMatrix();
                gl.Flush();
            }
            if (O_O.IsChecked == true)
            {
                clock = false;
                gl.Color(0.7, 0.1, 0.0);
                gl.Sphere(quad, 30, 40, 40);
                gl.Translate(0, 0, 0);
                gl.Color(0.1, 0.3, 0.9);
                int   i, N = 20;
                float angleStep    = 360.0f / N;
                float angleCurrent = 0f;
                float Radius1      = 45.0f;
                for (i = 0; i < N; i++)
                {
                    angleCurrent = i * angleStep * 3.14f / 180;
                    gl.PushMatrix();
                    gl.Translate(Radius1 * Math.Sin(angleCurrent), 0, Radius1 * Math.Cos(angleCurrent));
                    gl.Sphere(quad, 9.9, 40, 40);
                    gl.PopMatrix();
                }
                gl.LookAt(1.1, 1.1, 1.5, 1.1, 1.1, 5.7, 1.1, 0, 0);
                for (i = 0; i < N; i++)
                {
                    angleCurrent = i * angleStep * 3.14f / 180;
                    gl.PushMatrix();
                    gl.Translate(Radius1 * Math.Sin(angleCurrent), 0, Radius1 * Math.Cos(angleCurrent));
                    gl.Sphere(quad, 9.9, 40, 40);
                    gl.PopMatrix();
                }
            }
            if (O_k.IsChecked == true)
            {
                clock = false;
                gl.LineWidth(2.5f);
                gl.Scale(50.3, 50.3, 50.3);
                gl.Begin(OpenGL.GL_LINES);
                gl.Color(1.0, 0.0, 0.0);
                gl.Vertex(-1, -1, 0); //х
                gl.Vertex(1, -1, 0);
                gl.Vertex(-1, 1, 0);  //у
                gl.Vertex(-1, -1, 0);
                gl.Vertex(-1, -1, 0); //z
                gl.Vertex(-1, -1, 2);
                gl.End();
            }
            if (kv.IsChecked == true)
            {
                clock = false;
                gl.MatrixMode(OpenGL.GL_MODELVIEW);
                gl.LoadIdentity();
                gl.PushMatrix();
                gl.Rotate(rotation, 0.0, 0.0, 1.0);
                gl.Color(1.0, 1.0, 1.0);
                gl.Rect(-20.0, -20.0, 20.0, 20.0);
                gl.PopMatrix();
            }
            if (asd.IsChecked == true)
            {
                clock = false;
                gl.LineWidth(3.5f);
                gl.Scale(20.3, 20.3, 20.3);
                gl.Begin(OpenGL.GL_LINE_STRIP);
                gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
                gl.Rotate(rotation, 0.0, 0.0, 1.0);
                gl.Color(1.0, 0.0, 0.0);
                gl.Vertex(0, 0);
                gl.Vertex(0, 3);
                gl.Vertex(2, 2);
                gl.Vertex(4, 3);
                gl.Vertex(4, 0);
                gl.Vertex(3, 0);
                gl.Vertex(3, 1);
                gl.Vertex(1, 1);
                gl.Vertex(1, 0);
                gl.Vertex(0, 0);
                gl.End();
            }
            if (cl.IsChecked == true)
            {
                clock = false;
                gl.LineWidth(3.5f);
                gl.MatrixMode(OpenGL.GL_MODELVIEW);
                gl.LoadIdentity();
                gl.PushMatrix();
                gl.Rotate(rotation, 0.0, 0.0, 1.0);
                gl.Color(1.0, 1.0, 1.0);
                gl.Rect(-0.91, -20.9, 1.0, 1.0);
                gl.PopMatrix();
                gl.Color(0.0f, 1.0f, 0.0f);
                gl.Begin(OpenGL.GL_LINE_LOOP);
                for (int i = 0; i < 100; i++)
                {
                    double a = (float)i / 25.0f * 3.1415f * 2.0f;
                    gl.Vertex(Math.Cos(a) * 28.0f, Math.Sin(a) * 28.0f);
                }
                gl.End();
                gl.Begin(OpenGL.GL_LINE_STRIP);
                gl.PushMatrix();
                gl.Vertex(-21, 0);
                gl.Vertex(-25, 0);
                gl.Vertex(-21, 3);
                gl.Vertex(-25, 6);
                gl.Vertex(-21, 6);
                gl.End();
                gl.Begin(OpenGL.GL_LINE_STRIP);
                gl.Vertex(25, 0);
                gl.Vertex(21, 0);
                gl.Vertex(21, 3);
                gl.Vertex(25, 3);
                gl.Vertex(25, 6);
                gl.Vertex(21, 6);
                gl.Vertex(21, 3);
                gl.End();
                gl.Begin(OpenGL.GL_LINE_STRIP);
                gl.Vertex(2, 25);
                gl.Vertex(1, 27);
                gl.Vertex(1, 23);
                gl.End();
                gl.Begin(OpenGL.GL_LINE_STRIP);
                gl.Vertex(-1, 27);
                gl.Vertex(-3, 27);
                gl.Vertex(-1, 23);
                gl.Vertex(-3, 23);
                gl.End();
                gl.Begin(OpenGL.GL_LINE_STRIP);
                gl.Vertex(-1, -20);
                gl.Vertex(3, -20);
                gl.Vertex(3, -26);
                gl.Vertex(-1, -26);
                gl.Vertex(-1, -23);
                gl.Vertex(3, -23);
                gl.End();
            }
            gl.PopMatrix();
            rotation += Convert.ToSingle(sl.Value);
        }
Example #9
0
        public static void DrawRotatedTeaPot(OpenGLWindow _window, float _angle)
        {
            //ThrowIfNull(_window);

            // Clear The Screen And The Depth Buffer
            _window.Context.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            // Move Left And Into The Screen
            _window.Context.LoadIdentity();
            _window.Context.Rotate(_angle, 0.0f, 1.0f, 0.0f);

            Teapot teapot = new Teapot();
            teapot.Draw(_window.Context, 14, 1, OpenGL.GL_FILL);
        }