Esempio n. 1
0
        static void Main(string[] args)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH | Glut.GLUT_MULTISAMPLE);   // multisampling makes things beautiful!
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("OpenGL Tutorial");

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);

            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutKeyboardUpFunc(OnKeyboardUp);

            Glut.glutCloseFunc(OnClose);
            Glut.glutReshapeFunc(OnReshape);

            // add our mouse callbacks for this tutorial
            Glut.glutMouseFunc(OnMouse);
            Glut.glutMotionFunc(OnMove);

            Gl.Enable(EnableCap.DepthTest);

            // create our shader program
            program = new ShaderProgram(VertexShader, FragmentShader);

            // set up the projection and view matrix
            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, new Vector3(0, 1, 0)));

            program["light_direction"].SetValue(new Vector3(0, 0, 1));
            program["enable_lighting"].SetValue(lighting);
            program["normalTexture"].SetValue(1);
            program["enable_mapping"].SetValue(normalMapping);

            brickDiffuse = new Texture("AlternatingBrick-ColorMap.png");
            brickNormals = new Texture("AlternatingBrick-NormalMap.png");

            Vector3[] vertices = new Vector3[] {
                new Vector3(1, 1, -1), new Vector3(-1, 1, -1), new Vector3(-1, 1, 1), new Vector3(1, 1, 1),         // top
                new Vector3(1, -1, 1), new Vector3(-1, -1, 1), new Vector3(-1, -1, -1), new Vector3(1, -1, -1),     // bottom
                new Vector3(1, 1, 1), new Vector3(-1, 1, 1), new Vector3(-1, -1, 1), new Vector3(1, -1, 1),         // front face
                new Vector3(1, -1, -1), new Vector3(-1, -1, -1), new Vector3(-1, 1, -1), new Vector3(1, 1, -1),     // back face
                new Vector3(-1, 1, 1), new Vector3(-1, 1, -1), new Vector3(-1, -1, -1), new Vector3(-1, -1, 1),     // left
                new Vector3(1, 1, -1), new Vector3(1, 1, 1), new Vector3(1, -1, 1), new Vector3(1, -1, -1)
            };
            cube = new VBO <Vector3>(vertices);

            Vector2[] uvs = new Vector2[] {
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1)
            };
            cubeUV = new VBO <Vector2>(uvs);

            List <uint> triangles = new List <uint>();

            for (uint i = 0; i < 6; i++)
            {
                triangles.Add(i * 4);
                triangles.Add(i * 4 + 1);
                triangles.Add(i * 4 + 2);
                triangles.Add(i * 4);
                triangles.Add(i * 4 + 2);
                triangles.Add(i * 4 + 3);
            }
            cubeTriangles = new VBO <uint>(triangles.ToArray(), BufferTarget.ElementArrayBuffer);

            Vector3[] normals = Geometry.CalculateNormals(vertices, triangles.ToArray());
            cubeNormals = new VBO <Vector3>(normals);

            Vector3[] tangents = CalculateTangents(vertices, normals, triangles.ToArray(), uvs);
            cubeTangents = new VBO <Vector3>(tangents);

            // load the bitmap font for this tutorial
            font        = new BMFont("font24.fnt", "font24.png");
            fontProgram = new ShaderProgram(BMFont.FontVertexSource, BMFont.FontFragmentSource);

            fontProgram.Use();
            fontProgram["ortho_matrix"].SetValue(Matrix4.CreateOrthographic(width, height, 0, 1000));
            fontProgram["color"].SetValue(new Vector3(1, 1, 1));

            information = font.CreateString(fontProgram, "OpenGL  C#  Tutorial  14");

            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
Esempio n. 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_RGB | Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);

            Gl.glClearColor(255, 255, 255, 1);
            Gl.glViewport(0, 0, openGlControl.Width, openGlControl.Height);

            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();

            if (openGlControl.Width <= openGlControl.Height)
            {
                Glu.gluOrtho2D(0.0, 120.0 * openGlControl.Height / openGlControl.Width, 0.0, 120.0);
            }

            else
            {
                Glu.gluOrtho2D(0.0, 120.0 * openGlControl.Width / openGlControl.Height, 0.0, 120.0);
            }

            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glLoadIdentity();

            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);

            // очистка матриці
            Gl.glLoadIdentity();

            // встановлення червоного кольору поточним
            Gl.glColor3f(30, 0, 0);
            Gl.glClearColor(255, 255, 255, 1);

            // hours
            if (cusTime.hours < 9)
            {
                DrawTime(0, 50, "0" + cusTime.hours.ToString(), Brushes.Black);
            }

            else
            {
                DrawTime(0, 50, cusTime.hours.ToString(), Brushes.Black);
            }

            // minutes
            if (cusTime.minutes < 9)
            {
                DrawTime(50, 50, "0" + cusTime.minutes.ToString(), Brushes.Black);
            }

            else
            {
                DrawTime(50, 50, cusTime.minutes.ToString(), Brushes.Black);
            }

            // seconds
            if (cusTime.seconds < 9)
            {
                DrawTime(100, 50, "0" + cusTime.seconds.ToString(), Brushes.Black);
            }

            else
            {
                DrawTime(100, 50, cusTime.seconds.ToString(), Brushes.Black);
            }

            // miliseconds
            if (cusTime.miliSeconds < 9)
            {
                DrawTime(150, 50, "0" + cusTime.miliSeconds.ToString(), Brushes.Black);
            }

            else
            {
                DrawTime(150, 50, cusTime.miliSeconds.ToString(), Brushes.Black);
            }

            DrawTime(35, 55, ":", Brushes.Black);
            DrawTime(85, 55, ":", Brushes.Black);
            DrawTime(135, 55, ":", Brushes.Black);


            cusTime.miliSeconds++;
            if (cusTime.miliSeconds == 100)
            {
                cusTime.miliSeconds = 0;
                cusTime.seconds++;
            }

            if (cusTime.seconds == 60)
            {
                cusTime.seconds = 0;
                cusTime.minutes++;
            }

            if (cusTime.minutes == 60)
            {
                cusTime.minutes = 0;
                cusTime.hours++;
            }

            if (cusTime.hours == 60)
            {
                cusTime.miliSeconds = 0;
                cusTime.seconds     = 0;
                cusTime.minutes     = 0;
                cusTime.hours       = 0;
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            //Create OpenGL window
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("Fractal");

            //Glut callbacks for rendering
            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Glut.glutCloseFunc(OnClose);

            //Enable depth testing - ensures correct z-ordering of fragments
            Gl.Enable(EnableCap.DepthTest);

            //Compile shaders
            program = new ShaderProgram(VertexShader, FragmentShader);

            //Create initial squares for shape
            s1 = new Square(
                new Vector3[] { new Vector3(-1, 1, -1), new Vector3(1, 1, -1), new Vector3(1, -1, -1), new Vector3(-1, -1, -1) },
                new Vector3[] { new Vector3(0, 0.5f, 1), new Vector3(0, 0.5f, 1), new Vector3(0, 0.5f, 1), new Vector3(0, 0.5f, 1) }
                ); //back
            s2 = new Square(
                new Vector3[] { new Vector3(-1, 1, -1), new Vector3(1, 1, -1), new Vector3(1, 1, 1), new Vector3(-1, 1, 1) },
                new Vector3[] { new Vector3(0.5f, 0.5f, 1), new Vector3(0.5f, 0.5f, 1), new Vector3(0.5f, 0.5f, 1), new Vector3(0.5f, 0.5f, 1) }
                ); //top
            s3 = new Square(
                new Vector3[] { new Vector3(-1, 1, 1), new Vector3(1, 1, 1), new Vector3(1, -1, 1), new Vector3(-1, -1, 1) },
                new Vector3[] { new Vector3(1, 0.5f, 1), new Vector3(1, 0.5f, 1), new Vector3(1, 0.5f, 1), new Vector3(1, 0.5f, 1) }
                ); //front
            s4 = new Square(
                new Vector3[] { new Vector3(-1, -1, -1), new Vector3(1, -1, -1), new Vector3(1, -1, 1), new Vector3(-1, -1, 1) },
                new Vector3[] { new Vector3(0.5f, 0.5f, 0), new Vector3(0.5f, 0.5f, 0), new Vector3(0.5f, 0.5f, 0), new Vector3(0.5f, 0.5f, 0) }
                ); //bottom
            s5 = new Square(
                new Vector3[] { new Vector3(1, 1, -1), new Vector3(1, -1, -1), new Vector3(1, -1, 1), new Vector3(1, 1, 1) },
                new Vector3[] { new Vector3(1, 0.5f, 0), new Vector3(1, 0.5f, 0), new Vector3(1, 0.5f, 0), new Vector3(1, 0.5f, 0) }
                ); //right
            s6 = new Square(
                new Vector3[] { new Vector3(-1, 1, -1), new Vector3(-1, -1, -1), new Vector3(-1, -1, 1), new Vector3(-1, 1, 1) },
                new Vector3[] { new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0) }
                ); //left

            //Create initial cube
            Cube initialCube = new Cube();

            //Add squares to cube
            initialCube.Add(s1, s2, s3, s4, s5, s6);
            //Initialize cubes list and add initial cube
            cubes = new List <Cube>();
            cubes.Add(initialCube);

            //Call recursive method for first time
            addCubes(n, initialCube, 2f);

            //Output to obj file
            exportToObj(cubes);

            //Set projection and view matricies
            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.75f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, Vector3.Up));

            //Start stopwatch for rotation timing
            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            // create an OpenGL window
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("OpenGL Tutorial");

            // provide the Glut callbacks that are necessary for running this tutorial
            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Glut.glutCloseFunc(OnClose);

            // enable depth testing to ensure correct z-ordering of our fragments
            Gl.Enable(EnableCap.DepthTest);

            // compile the shader program
            program = new ShaderProgram(VertexShader, FragmentShader);

            // set the view and projection matrix, which are static throughout this tutorial
            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, new Vector3(0, 1, 0)));

            // create a pyramid with vertices and colors
            pyramid = new VBO <Vector3>(new Vector3[] {
                new Vector3(0, 1, 0), new Vector3(-1, -1, 1), new Vector3(1, -1, 1),        // front face
                new Vector3(0, 1, 0), new Vector3(1, -1, 1), new Vector3(1, -1, -1),        // right face
                new Vector3(0, 1, 0), new Vector3(1, -1, -1), new Vector3(-1, -1, -1),      // back face
                new Vector3(0, 1, 0), new Vector3(-1, -1, -1), new Vector3(-1, -1, 1)
            });                                                                             // left face
            pyramidColor = new VBO <Vector3>(new Vector3[] {
                new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1),
                new Vector3(1, 0, 0), new Vector3(0, 0, 1), new Vector3(0, 1, 0),
                new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1),
                new Vector3(1, 0, 0), new Vector3(0, 0, 1), new Vector3(0, 1, 0)
            });
            pyramidTriangles = new VBO <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, BufferTarget.ElementArrayBuffer);

            // create a cube with vertices and colors
            cube = new VBO <Vector3>(new Vector3[] {
                new Vector3(1, 1, -1), new Vector3(-1, 1, -1), new Vector3(-1, 1, 1), new Vector3(1, 1, 1),
                new Vector3(1, -1, 1), new Vector3(-1, -1, 1), new Vector3(-1, -1, -1), new Vector3(1, -1, -1),
                new Vector3(1, 1, 1), new Vector3(-1, 1, 1), new Vector3(-1, -1, 1), new Vector3(1, -1, 1),
                new Vector3(1, -1, -1), new Vector3(-1, -1, -1), new Vector3(-1, 1, -1), new Vector3(1, 1, -1),
                new Vector3(-1, 1, 1), new Vector3(-1, 1, -1), new Vector3(-1, -1, -1), new Vector3(-1, -1, 1),
                new Vector3(1, 1, -1), new Vector3(1, 1, 1), new Vector3(1, -1, 1), new Vector3(1, -1, -1)
            });
            cubeColor = new VBO <Vector3>(new Vector3[] {
                new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0),
                new Vector3(1, 0.5f, 0), new Vector3(1, 0.5f, 0), new Vector3(1, 0.5f, 0), new Vector3(1, 0.5f, 0),
                new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0),
                new Vector3(1, 1, 0), new Vector3(1, 1, 0), new Vector3(1, 1, 0), new Vector3(1, 1, 0),
                new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1),
                new Vector3(1, 0, 1), new Vector3(1, 0, 1), new Vector3(1, 0, 1), new Vector3(1, 0, 1)
            });
            cubeQuads = new VBO <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }, BufferTarget.ElementArrayBuffer);

            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            //Open GL init
            #region
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(1280, 720);
            Glut.glutCreateWindow("Tu mama es maraca");

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Glut.glutCloseFunc(OnClose);
            Glut.glutReshapeFunc(OnReshape);
            //Keyboard functions
            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutKeyboardUpFunc(OnKeyboardUp);

            Gl.ClearColor(0, 0, 0, 1);

            //Alpha enabled

            Gl.Enable(EnableCap.DepthTest);
            Gl.Enable(EnableCap.Blend);
            //Gl.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            #endregion

            //Load shader
            program = new ShaderProgram(VertexShader, FragmentShader);

            //Create perspective
            program.Use();
            program["projection_matrix"].SetValue(
                Matrix4.CreatePerspectiveFieldOfView(0.45f,
                                                     (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(
                Matrix4.LookAt(new Vector3(0, 0, 10),
                               new Vector3(xCam, 0, zCam),
                               new Vector3(0, 1, 0)));
            //Create light
            program["light_direction"].SetValue(new Vector3(0, 0, 1));
            program["enable_lighting"].SetValue(lighting);



            //Cube vertices and uv
            #region
            crateTexture = new Texture("crate.jpg");
            cube         = new VBO <Vector3>(
                new Vector3[] {
                new Vector3(1, 1, -1), new Vector3(-1, 1, -1), new Vector3(-1, 1, 1), new Vector3(1, 1, 1),
                new Vector3(1, -1, 1), new Vector3(-1, -1, 1), new Vector3(-1, -1, -1), new Vector3(1, -1, -1),
                new Vector3(1, 1, 1), new Vector3(-1, 1, 1), new Vector3(-1, -1, 1), new Vector3(1, -1, 1),
                new Vector3(1, -1, -1), new Vector3(-1, -1, -1), new Vector3(-1, 1, -1), new Vector3(1, 1, -1),
                new Vector3(-1, 1, 1), new Vector3(-1, 1, -1), new Vector3(-1, -1, -1), new Vector3(-1, -1, 1),
                new Vector3(1, 1, -1), new Vector3(1, 1, 1), new Vector3(1, -1, 1), new Vector3(1, -1, -1),
            }
                );
            cubeElements = new VBO <int>(
                new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 },
                BufferTarget.ElementArrayBuffer
                );
            cubeUV = new VBO <Vector2>(
                new Vector2[] {
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1)
            }
                );
            #endregion

            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(Data.width, Data.height);
            Glut.glutCreateWindow("OpenGL Ind");

            Glut.glutIdleFunc(Functions.OnRenderFrame);
            Glut.glutDisplayFunc(Functions.OnDisplay);
            Glut.glutKeyboardFunc(Functions.OnKeyboardDown);
            Glut.glutKeyboardUpFunc(Functions.OnKeyboardUp);
            Glut.glutCloseFunc(Functions.OnClose);
            Glut.glutReshapeFunc(Functions.OnReshape);

            Gl.Enable(EnableCap.DepthTest);
            Gl.ClearColor(0, 0.6f, 0.56f, 1);

            Shader VertexShader   = new Shader("\\shaders\\vertex_shader.txt");
            Shader FragmentShader = new Shader("\\shaders\\fragment_shader.txt");

            Data.program = new ShaderProgram(VertexShader.shaderCode,
                                             FragmentShader.shaderCode);

            Data.program.Use();

            Data.program["projection_matrix"].SetValue(
                Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)Data.width /
                                                     Data.height, 0.1f, 1000f));
            Data.program["view_matrix"].SetValue(Matrix4.LookAt(Data.cameraPos,
                                                                Data.cameraFront, Data.cameraUp));
            Data.program["light_direction"].SetValue(Data.lightDir);
            Data.program["enable_lighting"].SetValue(Data.lighting);

            Data.objects.Add(new Pyramid());
            Data.curTexture = new Texture(Data.dir + "\\im\\crate.jpg");
            Data.objects.Add(new Cube(true));
            Data.objects.Add(new Plane(
                                 new Vector3(-2, 20, -40),
                                 new Vector3(100, 20, -10),
                                 new Vector3(100, -0.5f, -5),
                                 new Vector3(-2, -0.5f, -35),
                                 new Vector3(0.6f, 0.75f, 0.6f)
                                 ));

            Data.objects.Add(new Plane(
                                 new Vector3(-2, 20, -40),
                                 new Vector3(-100, 20, -10),
                                 new Vector3(-100, -0.5f, -5),
                                 new Vector3(-2, -0.5f, -35),
                                 new Vector3(0.2f, 0.2f, 0.64f)
                                 ));


            Data.objects.Add(new Plane(
                                 new Vector3(-200, -1.0f, 1000),
                                 new Vector3(-200, -1.0f, -1000),
                                 new Vector3(200, -1.0f, -1000),
                                 new Vector3(200, -1.0f, 1000),
                                 new Vector3(0.2f, 0.85f, 0.64f)
                                 ));

            if (Data.isTimeRotate)
            {
                Data.watch = System.Diagnostics.Stopwatch.StartNew();
            }
            Glut.glutMainLoop();
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            //Open GL init
            #region
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(1280, 720);
            Glut.glutCreateWindow("Tu mama es maraca");

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Glut.glutCloseFunc(OnClose);
            Glut.glutReshapeFunc(OnReshape);
            //Keyboard functions
            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutKeyboardUpFunc(OnKeyboardUp);

            //Gl.ClearColor(0,0,0,1);

            //Alpha enabled
            Gl.Disable(EnableCap.DepthTest);
            Gl.Enable(EnableCap.Blend);
            Gl.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);

            #endregion

            //Load shader
            program = new ShaderProgram(VertexShader, FragmentShader);

            //Create perspective
            program.Use();
            program["projection_matrix"].SetValue(
                Matrix4.CreatePerspectiveFieldOfView(0.45f,
                                                     (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(
                Matrix4.LookAt(new Vector3(0, 0, 10),
                               new Vector3(0, 0, 0),
                               new Vector3(0, 1, 0)));

            starTexture   = new Texture("star.bmp");
            playerTexture = new Texture("crate.jpg");
            enemyTexture  = new Texture("tile.jpg");
            playerColor   = new Vector3(1, 1, 1);
            //start vertices and uv
            #region
            start = new VBO <Vector3>(
                new Vector3[] {
                new Vector3(-1, 1, 0), new Vector3(1, 1, 0),
                new Vector3(1, -1, 0), new Vector3(-1, -1, 0)
            }
                );
            startElements = new VBO <int>(
                new int[] { 0, 1, 2, 3 },
                BufferTarget.ElementArrayBuffer
                );
            startUV = new VBO <Vector2>(
                new Vector2[] {
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1)
            }
                );
            #endregion

            //Player

            player = new VBO <Vector3>(
                new Vector3[] {
                new Vector3(0, 0.7, 0), new Vector3(1, 0, 0), new Vector3(0, -0.7, 0), new Vector3(-0.5, 0, 0)
            }
                );
            playerElements = new VBO <int>(
                new int[] { 0, 1, 2, 3 },
                BufferTarget.ElementArrayBuffer
                );
            playerUV = new VBO <Vector2>(
                new Vector2[] {
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1)
            }
                );



            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH | Glut.GLUT_MULTISAMPLE);   // multisampling makes things beautiful!
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("OpenGL Tutorial");

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);

            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutKeyboardUpFunc(OnKeyboardUp);

            Glut.glutCloseFunc(OnClose);
            Glut.glutReshapeFunc(OnReshape);

            // enable blending and set to accumulate the star colors
            Gl.Enable(EnableCap.Blend);
            Gl.Enable(EnableCap.ProgramPointSize);
            Gl.Enable(EnableCap.Multisample);
            Gl.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);

            // create our shader program
            program = new ShaderProgram(VertexShader, FragmentShader);

            // set up the projection and view matrix
            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 20), Vector3.Zero, new Vector3(0, 1, 0)));
            program["model_matrix"].SetValue(Matrix4.Identity);
            program["static_colors"].SetValue(true);

            // load the particle texture
            particleTexture = new Texture("smoke.bmp");

            // set up the particlePoints VBO, which will stay constant
            int[] points = new int[particleCount];
            for (int i = 0; i < points.Length; i++)
            {
                points[i] = i;
            }
            particlePoints = new VBO <int>(points, BufferTarget.ElementArrayBuffer);

            // set up the particleColors, which we'll just keep static
            Vector3[] colors = new Vector3[particleCount];
            for (int i = 0; i < colors.Length; i++)
            {
                colors[i] = new Vector3(0.1f, 0.1f, 0.1f);
            }
            particleColors = new VBO <Vector3>(colors);

            // build up our first batch of 1000 particles and 1000 static colors
            for (int i = 0; i < particleCount; i++)
            {
                particles.Add(new Particle(Vector3.Zero, 0));
            }

            // load the bitmap font for this tutorial
            font        = new BMFont("font24.fnt", "font24.png");
            fontProgram = new ShaderProgram(BMFont.FontVertexSource, BMFont.FontFragmentSource);

            fontProgram.Use();
            fontProgram["ortho_matrix"].SetValue(Matrix4.CreateOrthographic(width, height, 0, 1000));
            fontProgram["color"].SetValue(new Vector3(0.2f, 0.2f, 0.2f));

            information = font.CreateString(fontProgram, "OpenGL  C#  Tutorial  12");

            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH | Glut.GLUT_MULTISAMPLE);   // multisampling makes things beautiful!
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("OpenGL Tutorial");

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);

            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutKeyboardUpFunc(OnKeyboardUp);

            Glut.glutCloseFunc(OnClose);
            Glut.glutReshapeFunc(OnReshape);

            // add our mouse callbacks for this tutorial
            Glut.glutMouseFunc(OnMouse);
            Glut.glutMotionFunc(OnMove);

            Gl.Enable(EnableCap.DepthTest);
            Gl.Enable(EnableCap.Blend);
            Gl.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            // create our shader program
            program = new ShaderProgram(VertexShader, FragmentShader);

            // create our camera
            camera = new Camera(new Vector3(0, 0, 0), Quaternion.Identity);
            camera.SetDirection(new Vector3(0, 0, -1));

            // set up the projection and view matrix
            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            //program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, Vector3.Up));

            program["light_direction"].SetValue(new Vector3(0, 0, 1));

            program["normalTexture"].SetValue(1);

            brickDiffuse = new Texture("333.jpg");


            var sphereCoordinates = CoordinatesManager.GetSphereCoordinates().ToArray();

            var UVcoordinates = new List <Vector2>();

            for (int i = 0; i < sphereCoordinates.Length / 4; i++)
            {
                UVcoordinates.Add(new Vector2(0, 0));
                UVcoordinates.Add(new Vector2(1, 0));
                UVcoordinates.Add(new Vector2(1, 1));
                UVcoordinates.Add(new Vector2(0, 1));
            }
            var sphereUV = new VBO <Vector2>(UVcoordinates.ToArray());


            Vector3[] vertices = new Vector3[] {
                new Vector3(1, 1, -1), new Vector3(-1, 1, -1), new Vector3(-1, 1, 1), new Vector3(1, 1, 1),         // top
                new Vector3(1, -1, 1), new Vector3(-1, -1, 1), new Vector3(-1, -1, -1), new Vector3(1, -1, -1),     // bottom
                new Vector3(1, 1, 1), new Vector3(-1, 1, 1), new Vector3(-1, -1, 1), new Vector3(1, -1, 1),         // front face
                new Vector3(1, -1, -1), new Vector3(-1, -1, -1), new Vector3(-1, 1, -1), new Vector3(1, 1, -1),     // back face
                new Vector3(-1, 1, 1), new Vector3(-1, 1, -1), new Vector3(-1, -1, -1), new Vector3(-1, -1, 1),     // left
                new Vector3(1, 1, -1), new Vector3(1, 1, 1), new Vector3(1, -1, 1), new Vector3(1, -1, -1)
            };
            cube = new VBO <Vector3>(sphereCoordinates);

            Vector2[] uvs = new Vector2[] {
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1)
            };
            cubeUV = CoordinatesManager.GetSphereUVCoordinates();

            List <uint> triangles = new List <uint>();

            for (uint i = 0; i < 6; i++)
            {
                triangles.Add(i * 4);
                triangles.Add(i * 4 + 1);
                triangles.Add(i * 4 + 2);
                triangles.Add(i * 4);
                triangles.Add(i * 4 + 2);
                triangles.Add(i * 4 + 3);
            }
            //cubeTriangles = new VBO<uint>(triangles.ToArray(), BufferTarget.ElementArrayBuffer);
            cubeTriangles =
                new VBO <uint>(Enumerable.Range(0, sphereCoordinates.Length * 4).Select(t => (uint)t).ToArray(),
                               BufferTarget.ElementArrayBuffer);

            // Vector3[] normals = Geometry.CalculateNormals(vertices, triangles.ToArray());
            //cubeNormals = new VBO<Vector3>(normals);



            // load the bitmap font for this tutorial
            font        = new BMFont("font24.fnt", "font24.png");
            fontProgram = new ShaderProgram(BMFont.FontVertexSource, BMFont.FontFragmentSource);

            fontProgram.Use();
            fontProgram["ortho_matrix"].SetValue(Matrix4.CreateOrthographic(width, height, 0, 1000));
            fontProgram["color"].SetValue(new Vector3(1, 1, 1));

            information = font.CreateString(fontProgram, "OpenGL C# Tutorial 15");

            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("Project");

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutKeyboardFunc(OnKeyboardUp);
            Glut.glutCloseFunc(OnClose);
            Glut.glutReshapeFunc(OnReshape);

            Gl.Enable(EnableCap.DepthTest);

            //program = new ShaderProgram(VertexShader, FragmentShader);
            program = new ShaderProgram(VertexShaderTexture, FragmentShaderTexture);

            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, new Vector3(0, 1, 0)));

            program["light_direction"].SetValue(new Vector3(0, 1, 1));
            //program["light_direction2"].SetValue(new Vector3(0, 0, 1));
            program["enable_lighting"].SetValue(lighting);

            //load texture
            crateTexture = new Texture("texture2.jpg");

            //create cube vertices
            cube = new VBO <Vector3>(new Vector3[] {
                new Vector3(1, 1, -1), new Vector3(-1, 1, -1), new Vector3(-1, 1, 1), new Vector3(1, 1, 1),     //top
                new Vector3(1, -1, 1), new Vector3(-1, -1, 1), new Vector3(-1, -1, -1), new Vector3(1, -1, -1), //bottom
                new Vector3(1, 1, 1), new Vector3(-1, 1, 1), new Vector3(-1, -1, 1), new Vector3(1, -1, 1),     //front
                new Vector3(1, -1, -1), new Vector3(-1, -1, -1), new Vector3(-1, 1, -1), new Vector3(1, 1, -1), //back
                new Vector3(-1, 1, 1), new Vector3(-1, 1, -1), new Vector3(-1, -1, -1), new Vector3(-1, -1, 1), //left
                new Vector3(1, 1, -1), new Vector3(1, 1, 1), new Vector3(1, -1, 1), new Vector3(1, -1, -1)      //right
            });
            //cube normals
            cubeNormals = new VBO <Vector3>(new Vector3[] {
                new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0),
                new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0),
                new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1),
                new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1),
                new Vector3(-1, 0, 0), new Vector3(-1, 0, 0), new Vector3(-1, 0, 0), new Vector3(-1, 0, 0),
                new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0)
            });
            //texture for cube
            cubeUV = new VBO <Vector2>(new Vector2[] {
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1)
            });

            cubeElements = new VBO <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
                                                     21, 22, 23 }, BufferTarget.ElementArrayBuffer);

            Glut.glutMainLoop();
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            // Инициализируем главное окно
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(Width, Height);
            Glut.glutCreateWindow("OpenGL Ex. #44");
            Gl.Viewport(0, 0, Width, Height);

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Glut.glutCloseFunc(OnClose);

            Gl.Enable(EnableCap.Blend);
            Gl.Enable(EnableCap.DepthTest);
            Gl.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            Gl.DepthFunc(DepthFunction.Less);
            Gl.ClearColor(0.44f, 0.49f, 0.527f, 1);

            program          = new ShaderProgram(VertexShader, FragmentShader);
            program_cyrcle   = new ShaderProgram(VertexShader_Cyrcle, FragmentShader);
            program_cylindre = new ShaderProgram(VertexShader_Cylinder, FragmentShader);

            ProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView(0.41f, (float)Width / Height, 0.1f, 1000f);
            ViewMatrix       = Matrix4.LookAt(new Vector3(32.5f, 10.8f, -54.8f), new Vector3(13.4f, 0.7f, -3.0f), new Vector3(0, 1, 0));

            program.Use();
            program["projection_matrix"].SetValue(ProjectionMatrix);
            program["view_matrix"].SetValue(ViewMatrix);

            program_cyrcle.Use();
            program_cyrcle["projection_matrix"].SetValue(ProjectionMatrix);
            program_cyrcle["view_matrix"].SetValue(ViewMatrix);

            program_cylindre.Use();
            program_cylindre["projection_matrix"].SetValue(ProjectionMatrix);
            program_cylindre["view_matrix"].SetValue(ViewMatrix);

            ChessboardTexrute  = loadTexture("ChessBoard.png");
            panelTexture       = loadTexture("panel.png");
            cornerTexture      = loadTexture("corner.png");
            crossTexture       = loadTexture("cross.png");
            cyrcleTexture      = loadTexture("cyrcle.png");
            cylindrBodyTexture = loadTexture("Wood.jpg");
            sphereTexture      = loadTexture("Earth.jpg");

            panel = new VBO <Vector3>(new Vector3[] {
                new Vector3(0.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f)
            });
            panelUV = new VBO <Vector2>(new Vector2[]  {
                new Vector2(0, 0),
                new Vector2(1, 0),
                new Vector2(1, 1),
                new Vector2(0, 1)
            });
            panelTriangles = new VBO <uint>(new uint[] {
                0, 1, 2,
                0, 2, 3
            }, BufferTarget.ElementArrayBuffer);

            corner = new VBO <Vector3>(new Vector3[] {
                new Vector3(0.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.5f),
                new Vector3(0.5f, 0.0f, 0.5f),
                new Vector3(0.5f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f)
            });
            cornerUV = new VBO <Vector2>(new Vector2[]  {
                new Vector2(0.0f, 0.0f),
                new Vector2(1.0f, 0.0f),
                new Vector2(1.0f, 0.5f),
                new Vector2(0.5f, 0.5f),
                new Vector2(0.5f, 1.0f),
                new Vector2(0.0f, 1.0f)
            });
            cornerTriangles = new VBO <uint>(new uint[] {
                0, 1, 5,
                1, 2, 3,
                3, 4, 5
            }, BufferTarget.ElementArrayBuffer);

            cross = new VBO <Vector3>(new Vector3[] {
                new Vector3(0.0f, 0.0f, 0.0f),
                new Vector3(0.25f, 0.0f, 0.0f),
                new Vector3(0.5f, 0.0f, 0.25f),
                new Vector3(0.75f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.25f),
                new Vector3(0.75f, 0.0f, 0.5f),
                new Vector3(1.0f, 0.0f, 0.75f),
                new Vector3(1.0f, 0.0f, 1.0f),
                new Vector3(0.75f, 0.0f, 1.0f),
                new Vector3(0.5f, 0.0f, 0.75f),
                new Vector3(0.25f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 0.75f),
                new Vector3(0.25f, 0.0f, 0.5f),
                new Vector3(0.0f, 0.0f, 0.25f)
            });
            crossUV = new VBO <Vector2>(new Vector2[]  {
                new Vector2(0.0f, 0.0f),
                new Vector2(0.25f, 0.0f),
                new Vector2(0.5f, 0.25f),
                new Vector2(0.75f, 0.0f),
                new Vector2(1.0f, 0.0f),
                new Vector2(1.0f, 0.25f),
                new Vector2(0.75f, 0.5f),
                new Vector2(1.0f, 0.75f),
                new Vector2(1.0f, 1.0f),
                new Vector2(0.75f, 1.0f),
                new Vector2(0.5f, 0.75f),
                new Vector2(0.25f, 1.0f),
                new Vector2(0.0f, 1.0f),
                new Vector2(0.0f, 0.75f),
                new Vector2(0.25f, 0.5f),
                new Vector2(0.0f, 0.25f)
            });
            crossTriangles = new VBO <uint>(new uint[] {
                0, 1, 15,
                1, 2, 15,
                2, 14, 15,
                3, 6, 13,
                3, 4, 5,
                3, 5, 6,
                11, 12, 13,
                6, 11, 13,
                6, 9, 10,
                7, 8, 9,
                6, 7, 9
            }, BufferTarget.ElementArrayBuffer);

            cyrcle = new VBO <Vector3>(new Vector3[] {
                new Vector3(0.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(0.5f, 0.0f, 0.5f),
            });
            cyrcleUV = new VBO <Vector2>(new Vector2[]  {
                new Vector2(0.5f, 0.5f),
                new Vector2(1.0f, 0.5f),
                new Vector2(0, 0)
            });
            cyrcleTriangles = new VBO <uint>(new uint[] {
                0, 1, 2
            }, BufferTarget.ElementArrayBuffer);

            float angle = (float)((Math.PI) / n);

            List <Vector3> sphere_vertex  = new List <Vector3>();
            List <Vector2> sphere_to      = new List <Vector2>();
            List <uint>    sphere_indeses = new List <uint>();

            sphere_vertex.Add(new Vector3(0, 1, 0));
            sphere_to.Add(new Vector2(0, 1));
            sphere_vertex.Add(new Vector3((float)Math.Cos(Math.PI / 2 - angle), (float)Math.Sin(Math.PI / 2 - angle), 0));
            sphere_to.Add(new Vector2(0, 1.0f - 1.0f / n));
            sphere_vertex.Add(Matrix4.CreateFromAxisAngle(Vector3.UnitY, angle) * sphere_vertex[sphere_vertex.Count - 1]);
            sphere_to.Add(new Vector2(1.0f / (2 * n), 1.0f - 1.0f / n));
            sphere_indeses.Add(0);
            sphere_indeses.Add(1);
            sphere_indeses.Add(2);

            for (uint i = 2; i < n; i++)
            {
                sphere_vertex.Add(new Vector3((float)Math.Cos(Math.PI / 2 - angle * i), (float)Math.Sin(Math.PI / 2 - angle * i), 0));
                sphere_to.Add(new Vector2(0, 1.0f - i / n));
                sphere_vertex.Add(Matrix4.CreateFromAxisAngle(Vector3.UnitY, angle) * sphere_vertex[sphere_vertex.Count - 1]);
                sphere_to.Add(new Vector2(1.0f / (2 * n), 1.0f - i / n));
                sphere_indeses.Add(2 * i - 3);
                sphere_indeses.Add(2 * i - 2);
                sphere_indeses.Add(2 * i - 1);
                sphere_indeses.Add(2 * i - 2);
                sphere_indeses.Add(2 * i - 1);
                sphere_indeses.Add(2 * i);
            }

            sphere_vertex.Add(new Vector3(0, -1, 0));
            sphere_to.Add(new Vector2(0, 0));
            sphere_indeses.Add(2 * (uint)n - 3);
            sphere_indeses.Add(2 * (uint)n - 2);
            sphere_indeses.Add(2 * (uint)n - 1);

            sphere          = new VBO <Vector3>(sphere_vertex.ToArray());
            sphereUV        = new VBO <Vector2>(sphere_to.ToArray());
            sphereTriangles = new VBO <uint>(sphere_indeses.ToArray(), BufferTarget.ElementArrayBuffer);


            Glut.glutMainLoop();
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH | Glut.GLUT_MULTISAMPLE);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("Project #3");

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);

            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutKeyboardUpFunc(OnKeyboardUp);

            Glut.glutCloseFunc(OnClose);
            Glut.glutReshapeFunc(OnReshape);

            // add our mouse callbacks for this tutorial
            Glut.glutMouseFunc(OnMouse);
            Glut.glutMotionFunc(OnMove);

            Gl.Enable(EnableCap.DepthTest);

            // create our shader program
            program = new ShaderProgram(VertexShader, FragmentShader);

            // set up the projection and view matrix
            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, new Vector3(0, 1, 0)));

            program["light_direction"].SetValue(new Vector3(0, 0, 1));
            program["enable_lighting"].SetValue(lighting);
            program["normalTexture"].SetValue(1);
            program["enable_mapping"].SetValue(normalMapping);

            brickDiffuse = new Texture(@"D:\Diego Jacobs\Google Dirve\UVG\Semestre 9\Graficas\Proyecto 3\3D-House\3D-House\Images\AlternatingBrick-ColorMap.png");
            brickNormals = new Texture(@"D:\Diego Jacobs\Google Dirve\UVG\Semestre 9\Graficas\Proyecto 3\3D-House\3D-House\Images\AlternatingBrick-NormalMap.png");

            // create a pyramid
            pyramid = new VBO<Vector3>(new Vector3[] {
                new Vector3(-1, 1, 1), new Vector3(1, 1, 1), new Vector3(0, 2, 0),        // front face
                new Vector3(1, 1, 1), new Vector3(0, 2, 0), new Vector3(1, 1, -1),        // right face
                new Vector3(-1, 1, -1), new Vector3(0, 2, 0), new Vector3(1, 1, -1),      // back face
                new Vector3(-1, 1, 1), new Vector3(0, 2, 0), new Vector3(-1, 1, -1) });   // left face
            pyramidTriangles = new VBO<int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, BufferTarget.ElementArrayBuffer);


            Vector3[] vertices = new Vector3[] {
                new Vector3(1, 1, -1), new Vector3(-1, 1, -1), new Vector3(-1, 1, 1), new Vector3(1, 1, 1),         // top
                new Vector3(1, -1, 1), new Vector3(-1, -1, 1), new Vector3(-1, -1, -1), new Vector3(1, -1, -1),     // bottom
                new Vector3(1, 1, 1), new Vector3(-1, 1, 1), new Vector3(-1, -1, 1), new Vector3(1, -1, 1),         // front face
                new Vector3(1, -1, -1), new Vector3(-1, -1, -1), new Vector3(-1, 1, -1), new Vector3(1, 1, -1),     // back face
                new Vector3(-1, 1, 1), new Vector3(-1, 1, -1), new Vector3(-1, -1, -1), new Vector3(-1, -1, 1),     // left
                new Vector3(1, 1, -1), new Vector3(1, 1, 1), new Vector3(1, -1, 1), new Vector3(1, -1, -1) };       // right
            cube = new VBO<Vector3>(vertices);

            Vector2[] uvs = new Vector2[] {
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1) };
            cubeUV = new VBO<Vector2>(uvs);

            List<int> triangles = new List<int>();
            for (int i = 0; i < 6; i++)
            {
                triangles.Add(i * 4);
                triangles.Add(i * 4 + 1);
                triangles.Add(i * 4 + 2);
                triangles.Add(i * 4);
                triangles.Add(i * 4 + 2);
                triangles.Add(i * 4 + 3);
            }
            cubeTriangles = new VBO<int>(triangles.ToArray(), BufferTarget.ElementArrayBuffer);

            Vector3[] normals = Geometry.CalculateNormals(vertices, triangles.ToArray());
            cubeNormals = new VBO<Vector3>(normals);

            Vector3[] tangents = CalculateTangents(vertices, normals, triangles.ToArray(), uvs);
            cubeTangents = new VBO<Vector3>(tangents);
            
            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
        public static void Run()
        {
            string filePath         = Path.Combine("..", "..");
            string fileDirectory    = "Data";
            string vertexFileName   = "C3E4v_twist.cg";
            string fragmentFileName = "C2E2f_passthru.cg";

            if (File.Exists(vertexFileName))
            {
                filePath      = "";
                fileDirectory = "";
            }
            else if (File.Exists(Path.Combine(fileDirectory, vertexFileName)))
            {
                filePath = "";
            }

            string myVertexProgramFileName   = Path.Combine(Path.Combine(filePath, fileDirectory), vertexFileName);
            string myFragmentProgramFileName = Path.Combine(Path.Combine(filePath, fileDirectory), fragmentFileName);

            // Callback Delegates
            keyboardDelegate += keyboard;
            menuDelegate     += menu;
            idleDelegate     += idle;

            Glut.glutInitWindowSize(400, 400);
            Glut.glutInitDisplayMode(Glut.GLUT_RGB | Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInit();

            Glut.glutCreateWindow(myProgramName);
            Glut.glutDisplayFunc(display);
            Glut.glutKeyboardFunc(keyboardDelegate);

            Gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);  /* White background */

            myCgContext = Cg.cgCreateContext();
            checkForCgError("creating context");

            myCgVertexProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_VERTEX);
            CgGl.cgGLSetOptimalOptions(myCgVertexProfile);
            checkForCgError("selecting vertex profile");

            myCgVertexProgram =
                Cg.cgCreateProgramFromFile(
                    myCgContext,             /* Cg runtime context */
                    Cg.CG_SOURCE,            /* Program in human-readable form */
                    myVertexProgramFileName, /* Name of file containing program */
                    myCgVertexProfile,       /* Profile: OpenGL ARB vertex program */
                    myVertexProgramName,     /* Entry function name */
                    null);                   /* No extra compiler options */
            checkForCgError("creating vertex program from file");
            CgGl.cgGLLoadProgram(myCgVertexProgram);
            checkForCgError("loading vertex program");

            myCgVertexParam_twisting =
                Cg.cgGetNamedParameter(myCgVertexProgram, "twisting");
            checkForCgError("could not get twisting parameter");

            myCgFragmentProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_FRAGMENT);
            CgGl.cgGLSetOptimalOptions(myCgFragmentProfile);
            checkForCgError("selecting fragment profile");

            myCgFragmentProgram =
                Cg.cgCreateProgramFromFile(
                    myCgContext,               /* Cg runtime context */
                    Cg.CG_SOURCE,              /* Program in human-readable form */
                    myFragmentProgramFileName, /* Name of file containing program */
                    myCgFragmentProfile,       /* Profile: OpenGL ARB vertex program */
                    myFragmentProgramName,     /* Entry function name */
                    null);                     /* No extra compiler options */
            checkForCgError("creating fragment program from file");
            CgGl.cgGLLoadProgram(myCgFragmentProgram);
            checkForCgError("loading fragment program");

            /* No uniform fragment program parameters expected. */

            Glut.glutCreateMenu(menuDelegate);
            Glut.glutAddMenuEntry("[ ] Animate", ' ');
            Glut.glutAddMenuEntry("[w] Wireframe", 'w');
            Glut.glutAttachMenu(Glut.GLUT_RIGHT_BUTTON);

            // Change Animation to true, so that it starts with action ;-)
            keyboard((byte)' ', 0, 0);

            Glut.glutMainLoop();
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("OpenGL Tutorial");

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);

            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutKeyboardUpFunc(OnKeyboardUp);

            Glut.glutCloseFunc(OnClose);
            Glut.glutReshapeFunc(OnReshape);

            // enable blending and set to accumulate the star colors
            Gl.Enable(EnableCap.DepthTest);
            Gl.Enable(EnableCap.Blend);

            // create our shader program
            program = new ShaderProgram(VertexShader, FragmentShader);

            // set up the projection and view matrix
            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 20), Vector3.Zero, Vector3.Up));
            program["model_matrix"].SetValue(Matrix4.Identity);

            // load the flag texture
            flagTexture = new Texture("flag.png");

            // create the flag, which is just a plane with a certain number of segments
            List <Vector3> vertices  = new List <Vector3>();
            List <Vector2> uvs       = new List <Vector2>();
            List <int>     triangles = new List <int>();

            for (int x = 0; x < 40; x++)
            {
                for (int y = 0; y < 40; y++)
                {
                    vertices.Add(new Vector3((x - 20) / 5.0, (y - 20) / 10.0, 0));
                    uvs.Add(new Vector2(x / 39.0, 1 - y / 39.0));

                    if (y == 39 || x == 39)
                    {
                        continue;
                    }

                    triangles.Add(x * 40 + y);
                    triangles.Add((x + 1) * 40 + y);
                    triangles.Add((x + 1) * 40 + y + 1);

                    triangles.Add(x * 40 + y);
                    triangles.Add((x + 1) * 40 + y + 1);
                    triangles.Add(x * 40 + y + 1);
                }
            }

            flagVertices  = new VBO <Vector3>(vertices.ToArray());
            flagUVs       = new VBO <Vector2>(uvs.ToArray());
            flagTriangles = new VBO <int>(triangles.ToArray(), BufferTarget.ElementArrayBuffer);

            // load the bitmap font for this tutorial
            font        = new BMFont("font24.fnt", "font24.png");
            fontProgram = new ShaderProgram(BMFont.FontVertexSource, BMFont.FontFragmentSource);

            fontProgram.Use();
            fontProgram["ortho_matrix"].SetValue(Matrix4.CreateOrthographic(width, height, 0, 1000));
            fontProgram["color"].SetValue(new Vector3(1, 1, 1));

            information = font.CreateString(fontProgram, "OpenGL  C#  Tutorial  11");

            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_RGB | Glut.GLUT_DOUBLE);

            Gl.glClearColor(255, 255, 255, 1);
            Gl.glViewport(0, 0, mainScene.Width, mainScene.Height);
            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();

            Glu.gluPerspective(45, (float)mainScene.Width / (float)mainScene.Height, 0.1, 200);

            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glLoadIdentity();
            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Gl.glEnable(Gl.GL_LIGHTING);
            Gl.glEnable(Gl.GL_LIGHT0);
            Gl.glEnable(Gl.GL_COLOR_MATERIAL);

            Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
            Gl.glEnable(Gl.GL_BLEND);
            Gl.glEnable(Gl.GL_LINE_SMOOTH);
            Gl.glLineWidth(1.0f);

            //Установка значений для поворота и переноса точки обзора
            CameraPosition[0, 0] = 0;
            CameraPosition[0, 1] = 2;
            CameraPosition[0, 2] = -45;
            CameraPosition[0, 3] = -45;
            CameraPosition[0, 4] = 1;
            CameraPosition[0, 5] = 0;
            CameraPosition[0, 6] = 0;

            CameraPosition[1, 0] = 0;
            CameraPosition[1, 1] = 0;
            CameraPosition[1, 2] = -50;
            CameraPosition[1, 3] = -80;
            CameraPosition[1, 4] = 1;
            CameraPosition[1, 5] = 0;
            CameraPosition[1, 6] = 0;

            CameraPosition[2, 0] = 0;
            CameraPosition[2, 1] = 0;
            CameraPosition[2, 2] = -45;
            CameraPosition[2, 3] = 0;
            CameraPosition[2, 4] = 1;
            CameraPosition[2, 5] = 0;
            CameraPosition[2, 6] = 0;

            CameraPosition[3, 0] = 0;
            CameraPosition[3, 1] = 3;
            CameraPosition[3, 2] = -55;
            CameraPosition[3, 3] = -90;
            CameraPosition[3, 4] = 0;
            CameraPosition[3, 5] = 0;
            CameraPosition[3, 6] = 1;

            CameraPosition[4, 0] = 0;
            CameraPosition[4, 1] = 3;
            CameraPosition[4, 2] = -55;
            CameraPosition[4, 3] = 90;
            CameraPosition[4, 4] = 0;
            CameraPosition[4, 5] = 0;
            CameraPosition[4, 6] = 1;

            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 0;
            comboBox3.SelectedIndex = 0;

            timer1.Start();
        }
Esempio n. 16
0
        public static void Main(string[] args)
        {
            int menuID, subMenuA, subMenuB;

            Glut.glutInitDisplayString("stencil~2 rgb double depth>=16 samples");
            Glut.glutInitDisplayMode(Glut.GLUT_RGB | Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowPosition(100, 100);

            Glut.glutInit();

            subMenuA = Glut.glutCreateMenu(SampleMenu);
            Glut.glutAddMenuEntry("Sub menu A1 (01)", 1);
            Glut.glutAddMenuEntry("Sub menu A2 (02)", 2);
            Glut.glutAddMenuEntry("Sub menu A3 (03)", 3);

            subMenuB = Glut.glutCreateMenu(SampleMenu);
            Glut.glutAddMenuEntry("Sub menu B1 (04)", 4);
            Glut.glutAddMenuEntry("Sub menu B2 (05)", 5);
            Glut.glutAddMenuEntry("Sub menu B3 (06)", 6);
            Glut.glutAddSubMenu("Going to sub menu A", subMenuA);

            menuID = Glut.glutCreateMenu(SampleMenu);
            Glut.glutAddMenuEntry("Entry one", 1);
            Glut.glutAddMenuEntry("Entry two", 2);
            Glut.glutAddMenuEntry("Entry three", 3);
            Glut.glutAddMenuEntry("Entry four", 4);
            Glut.glutAddMenuEntry("Entry five", 5);
            Glut.glutAddSubMenu("Enter sub menu A", subMenuA);
            Glut.glutAddSubMenu("Enter sub menu B", subMenuB);

            Glut.glutCreateWindow("Hello world!");
            Glut.glutDisplayFunc(new Glut.DisplayCallback(SampleDisplay));
            Glut.glutReshapeFunc(new Glut.ReshapeCallback(SampleReshape));
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(SampleKeyboard));
            Glut.glutSpecialFunc(new Glut.SpecialCallback(SampleSpecial));
            Glut.glutIdleFunc(new Glut.IdleCallback(SampleIdle));
            Glut.glutAttachMenu(Glut.GLUT_LEFT_BUTTON);

            Glut.glutInitWindowPosition(200, 200);
            Glut.glutCreateWindow("I am not Jan B.");
            Glut.glutDisplayFunc(new Glut.DisplayCallback(SampleDisplay));
            Glut.glutReshapeFunc(new Glut.ReshapeCallback(SampleReshape));
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(SampleKeyboard));
            Glut.glutSpecialFunc(new Glut.SpecialCallback(SampleSpecial));
            Glut.glutIdleFunc(new Glut.IdleCallback(SampleIdle));
            Glut.glutAttachMenu(Glut.GLUT_LEFT_BUTTON);

            Console.WriteLine("Testing game mode string parsing, don't panic!\n");
            Glut.glutGameModeString("320x240:32@100");
            Glut.glutGameModeString("640x480:16@72");
            Glut.glutGameModeString("1024x768");
            Glut.glutGameModeString(":32@120");
            Glut.glutGameModeString("Toudi glupcze, Danwin bedzie moj!");
            Glut.glutGameModeString("640x480:16@72");

            Glut.glutEnterGameMode();
            Glut.glutDisplayFunc(new Glut.DisplayCallback(SampleDisplay));
            Glut.glutReshapeFunc(new Glut.ReshapeCallback(SampleReshape));
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(SampleGameModeKeyboard));
            Glut.glutIdleFunc(new Glut.IdleCallback(SampleIdle));
            Glut.glutAttachMenu(Glut.GLUT_LEFT_BUTTON);

            Console.WriteLine("current window is %ix%i+%i+%i",
                              Glut.glutGet(Glut.GLUT_WINDOW_X), Glut.glutGet(Glut.GLUT_WINDOW_Y),
                              Glut.glutGet(Glut.GLUT_WINDOW_WIDTH), Glut.glutGet(Glut.GLUT_WINDOW_HEIGHT)
                              );

            /*
             * Enter the main FreeGLUT processing loop
             */
            Glut.glutMainLoop();

            Console.WriteLine("glutMainLoop() termination works fine!\n");
        }
Esempio n. 17
0
        static void Main(string[] args)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("Texture 3D Car");

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);

            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutKeyboardUpFunc(OnKeyboardUp);

            Glut.glutCloseFunc(OnClose);
            Glut.glutReshapeFunc(OnReshape);

            Gl.Disable(EnableCap.DepthTest);
            Gl.Enable(EnableCap.Blend);
            Gl.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            program = new ShaderProgram(VertexShader, FragmentShader);

            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, new Vector3(0, 1, 0)));

            program["light_direction"].SetValue(new Vector3(0, 0, 1));
            program["enable_lighting"].SetValue(lighting);

            glassTexture = new Texture("glass.bmp");
            kacaTexture  = new Texture("kaca.bmp");
            rodaTexture  = new Texture("tire.bmp");

            cube = new VBO <Vector3>(new Vector3[] {
                /* top of cube.*/
                new Vector3(0.2f, 0.4f, 0.6f),
                new Vector3(0.6f, 0.5f, 0.6f),
                new Vector3(0.6f, 0.5f, 0.2f),
                new Vector3(0.2f, 0.4f, 0.2f),

                /* bottom of, cube*/
                new Vector3(0.2f, 0.2f, 0.6f),
                new Vector3(0.6f, 0.2f, 0.6f),
                new Vector3(0.6f, 0.2f, 0.2f),
                new Vector3(0.2f, 0.2f, 0.2f),

                /* front of cube.*/
                new Vector3(0.2f, 0.2f, 0.6f),
                new Vector3(0.2f, 0.4f, 0.6f),
                new Vector3(0.2f, 0.4f, 0.2f),
                new Vector3(0.2f, 0.2f, 0.2f),

                /* back of cube.*/
                new Vector3(0.6f, 0.2f, 0.6f),
                new Vector3(0.6f, 0.5f, 0.6f),
                new Vector3(0.6f, 0.5f, 0.2f),
                new Vector3(0.6f, 0.2f, 0.2f),

                /* left of cube*/
                new Vector3(0.2f, 0.2f, 0.6f),
                new Vector3(0.6f, 0.2f, 0.6f),
                new Vector3(0.6f, 0.5f, 0.6f),
                new Vector3(0.2f, 0.4f, 0.6f),

                /* Right of cube */
                new Vector3(0.2f, 0.2f, 0.2f),
                new Vector3(0.6f, 0.2f, 0.2f),
                new Vector3(0.6f, 0.5f, 0.2f),
                new Vector3(0.2f, 0.4f, 0.2f),
                //****************************************************************************
                new Vector3(0.7f, 0.65f, 0.6f),
                new Vector3(0.7f, 0.65f, 0.2f),
                new Vector3(1.7f, 0.65f, 0.2f),     //top cover
                new Vector3(1.7f, 0.65f, 0.6f),

                //******************MIDDLE BODY************************************
                new Vector3(0.6f, 0.5f, 0.6f),
                new Vector3(0.6f, 0.2f, 0.6f),
                new Vector3(1.8f, 0.2f, 0.6f),
                new Vector3(1.8f, 0.5f, 0.6f),

                new Vector3(1.8f, 0.2f, 0.6f),
                new Vector3(1.8f, 0.2f, 0.2f),
                new Vector3(1.8f, 0.5f, 0.2f),
                new Vector3(1.8f, 0.5f, 0.6f),
                /* bottom of cube*/
                new Vector3(0.6f, 0.2f, 0.6f),
                new Vector3(0.6f, 0.2f, 0.2f),
                new Vector3(1.8f, 0.2f, 0.2f),
                new Vector3(1.8f, 0.2f, 0.6f),

                /* back of cube.*/
                new Vector3(0.6f, 0.5f, 0.2f),
                new Vector3(0.6f, 0.2f, 0.2f),
                new Vector3(1.8f, 0.2f, 0.2f),
                new Vector3(1.8f, 0.5f, 0.2f),

                new Vector3(0.7f, 0.65f, 0.2f),
                new Vector3(0.7f, 0.5f, .2f),    //first separation
                new Vector3(0.75f, 0.5f, 0.2f),
                new Vector3(0.77f, 0.65f, 0.2f),

                new Vector3(1.2f, 0.65f, 0.2f),
                new Vector3(1.2f, 0.5f, .2f),    //second separation
                new Vector3(1.25f, 0.5f, 0.2f),
                new Vector3(1.27f, 0.65f, 0.2f),

                new Vector3(1.65f, 0.65f, 0.2f),
                new Vector3(1.65f, 0.5f, .2f),  //3d separation
                new Vector3(1.7f, 0.5f, 0.2f),
                new Vector3(1.7f, 0.65f, 0.2f),

                new Vector3(0.75f, 0.65f, 0.2f),
                new Vector3(0.75f, 0.63f, 0.2f),     //line strip
                new Vector3(1.7f, 0.63f, 0.2f),
                new Vector3(1.7f, 0.65f, 0.2f),

                new Vector3(0.75f, 0.65f, 0.6f),
                new Vector3(0.75f, 0.63f, 0.6f),     //line strip
                new Vector3(1.7f, 0.63f, 0.6f),
                new Vector3(1.7f, 0.65f, 0.6f),


                new Vector3(0.7f, 0.65f, 0.6f),
                new Vector3(0.7f, 0.5f, .6f),    //first separation
                new Vector3(0.75f, 0.5f, 0.6f),
                new Vector3(0.77f, 0.65f, 0.6f),

                new Vector3(1.2f, 0.65f, 0.6f),
                new Vector3(1.2f, 0.5f, .6f),    //second separation
                new Vector3(1.25f, 0.5f, 0.6f),
                new Vector3(1.27f, 0.65f, 0.6f),

                new Vector3(1.65f, 0.65f, 0.6f),
                new Vector3(1.65f, 0.5f, .6f),
                new Vector3(1.7f, 0.5f, 0.6f), //3d separation
                new Vector3(1.7f, 0.65f, 0.6f),
            });                                // right


            cubeNormals = new VBO <Vector3>(new Vector3[] {
                new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0),
                new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0),
                new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1),
                new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1),
                new Vector3(-1, 0, 0), new Vector3(-1, 0, 0), new Vector3(-1, 0, 0), new Vector3(-1, 0, 0),
                new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0),
                new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0),
                new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0),
                new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1),
                new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1),
                new Vector3(-1, 0, 0), new Vector3(-1, 0, 0), new Vector3(-1, 0, 0), new Vector3(-1, 0, 0),
                new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0),
                new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0),
                new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0),
                new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1),
                new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1),
                new Vector3(-1, 0, 0), new Vector3(-1, 0, 0), new Vector3(-1, 0, 0), new Vector3(-1, 0, 0),
                new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0),
                new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0)
            });
            cubeUV = new VBO <Vector2>(new Vector2[] {
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1)
            });

            cubeQuads = new VBO <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 61, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107 }, BufferTarget.ElementArrayBuffer);

            window = new VBO <Vector3>(new Vector3[] {
                new Vector3(0.77f, 0.63f, 0.2f),
                new Vector3(0.75f, 0.5f, 0.2f),     //quad front window
                new Vector3(1.2f, 0.5f, 0.2f),
                new Vector3(1.22f, 0.63f, 0.2f),

                new Vector3(1.27f, 0.63f, .2f),
                new Vector3(1.25f, 0.5f, 0.2f),     //quad back window
                new Vector3(1.65f, 0.5f, 0.2f),
                new Vector3(1.67f, 0.63f, 0.2f),


                new Vector3(0.77f, 0.63f, 0.6f),
                new Vector3(0.75f, 0.5f, 0.6f),     //quad front window
                new Vector3(1.2f, 0.5f, 0.6f),
                new Vector3(1.22f, 0.63f, 0.6f),

                new Vector3(1.27f, 0.63f, 0.6f),
                new Vector3(1.25f, 0.5f, 0.6f),     //quad back window
                new Vector3(1.65f, 0.5f, 0.6f),
                new Vector3(1.67f, 0.63f, 0.6f),


                new Vector3(0.6f, 0.5f, 0.6f),
                new Vector3(0.6f, 0.5f, 0.2f),     //quad f,ront window
                new Vector3(0.7f, 0.65f, 0.2f),
                new Vector3(0.7f, 0.65f, 0.6f),

                new Vector3(1.7f, 0.65f, .6f),
                new Vector3(1.7f, 0.65f, 0.2f),     //quad back window
                new Vector3(1.8f, 0.5f, 0.2f),
                new Vector3(1.8f, 0.5f, 0.6f),

                new Vector3(0.6f, 0.5f, 0.6f),
                new Vector3(0.7f, 0.65f, 0.6f),    //tri f,ront window
                new Vector3(0.7f, 0.5f, 0.6f),

                new Vector3(0.6f, 0.5f, 0.2f),
                new Vector3(0.7f, 0.65f, 0.2f),    //tri f,ront window
                new Vector3(0.7f, 0.5f, 0.2f),
                new Vector3(0.7f, 0.5f, 0.3f),

                new Vector3(1.7f, 0.65f, 0.2f),
                new Vector3(1.8f, 0.5f, 0.2f),    //tri back window
                new Vector3(1.7f, 0.5f, 0.2f),
                new Vector3(1.7f, 0.5f, 0.3f),

                new Vector3(1.7f, 0.65f, 0.6f),
                new Vector3(1.8f, 0.5f, 0.6f),    //tri back window
                new Vector3(1.7f, 0.5f, 0.6f),
                new Vector3(1.7f, 0.5f, 0.7f)
            });      // right


            windowNormals = new VBO <Vector3>(new Vector3[] {
                new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0),
                new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0),
                new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1),
                new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1),
                new Vector3(-1, 0, 0), new Vector3(-1, 0, 0), new Vector3(-1, 0, 0), new Vector3(-1, 0, 0),
                new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0),
                new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0),
                new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0),
                new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1),
                new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1)
            });
            windowUV = new VBO <Vector2>(new Vector2[] {
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1)
            });

            windowQuads = new VBO <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 }, BufferTarget.ElementArrayBuffer);

            //wheeel-----------------------------------------------------------------------------------------------
            // Number of segments the circle is divided into.
            const int DIV_COUNT = 32;

            // Will use a triangle fan rooted at the origin to draw the circle. So one additional
            // point is needed for the origin, and another one because the first point is repeated
            // as the last one to close the circle.
            Vector3[] coordA = new Vector3[(DIV_COUNT + 2) * 2];

            // Origin.
            int coordIdx = 0;

            // Calculate angle increment from point to point, and its cos/sin.
            float   angInc = DIV_COUNT * 3.1415926535897932384626433832795f / 180;
            float   cosInc = (float)Math.Cos(angInc);
            float   sinInc = (float )Math.Sin(angInc);
            float   radius = 0.1f;
            float   depth  = 0.1f;
            Vector3 center = new Vector3(0.6f, 0.2f, 0.55f);

            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            float xc = radius;
            float yc = 0.0f;

            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z + depth);

            wheel1 = new VBO <Vector3>(coordA);      // right

            // UM --------------------------------------------------------------------------------------

            // Origin.
            coordIdx = 0;
            center   = new Vector3(0.6f, 0.2f, 0.55f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius / 2;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z + depth);

            wheel11 = new VBO <Vector3>(coordA);      // right

            // Origin.
            coordIdx = 0;
            center   = new Vector3(1.5f, 0.2f, 0.55f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius / 2;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z + depth);

            wheel21 = new VBO <Vector3>(coordA);      // right

            // Origin.
            coordIdx = 0;
            center   = new Vector3(0.6f, 0.2f, 0.15f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius / 2;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z + depth);

            wheel31 = new VBO <Vector3>(coordA);      // right
                                                      // Origin.
            coordIdx = 0;
            center   = new Vector3(1.5f, 0.2f, 0.15f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius / 2;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 2, center.Y, center.Z + depth);

            wheel41 = new VBO <Vector3>(coordA);      // right

            // Origin.
            coordIdx = 0;
            center   = new Vector3(0.6f, 0.2f, 0.55f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius / 4;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z + depth);

            wheel111 = new VBO <Vector3>(coordA);      // right

            // Origin.
            coordIdx = 0;
            center   = new Vector3(1.5f, 0.2f, 0.55f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius / 4;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z + depth);

            wheel211 = new VBO <Vector3>(coordA);      // right

            // Origin.
            coordIdx = 0;
            center   = new Vector3(0.6f, 0.2f, 0.15f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius / 4;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z + depth);

            wheel311 = new VBO <Vector3>(coordA);      // right
                                                       // Origin.
            coordIdx = 0;
            center   = new Vector3(1.5f, 0.2f, 0.15f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius / 4;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 4, center.Y, center.Z + depth);

            wheel411 = new VBO <Vector3>(coordA);      // right

            // Origin.
            coordIdx = 0;
            center   = new Vector3(0.6f, 0.2f, 0.55f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius / 1.5f;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z + depth);

            wheel112 = new VBO <Vector3>(coordA);      // right

            // Origin.
            coordIdx = 0;
            center   = new Vector3(1.5f, 0.2f, 0.55f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius / 1.5f;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z + depth);

            wheel212 = new VBO <Vector3>(coordA);      // right

            // Origin.
            coordIdx = 0;
            center   = new Vector3(0.6f, 0.2f, 0.15f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius / 1.5f;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z + depth);

            wheel312 = new VBO <Vector3>(coordA);      // right
                                                       // Origin.
            coordIdx = 0;
            center   = new Vector3(1.5f, 0.2f, 0.15f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius / 1.5f;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius / 1.5f, center.Y, center.Z + depth);

            wheel412 = new VBO <Vector3>(coordA);      // right

            // UM --------------------------------------------------------------------------------------

            // Origin.
            coordIdx = 0;
            center   = new Vector3(1.5f, 0.2f, 0.55f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z + depth);

            wheel2 = new VBO <Vector3>(coordA);      // right

            // Origin.
            coordIdx = 0;
            center   = new Vector3(0.6f, 0.2f, 0.15f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z + depth);

            wheel3 = new VBO <Vector3>(coordA);      // right
                                                     // Origin.
            coordIdx = 0;
            center   = new Vector3(1.5f, 0.2f, 0.15f);
            // Start with vector (1.0f, 0.0f), ...

            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z + depth);

            // ... and then rotate it by angInc for each point.
            xc = radius;
            yc = 0.0f;
            for (int iDiv = 0; iDiv < DIV_COUNT; ++iDiv)
            {
                float xcNew = cosInc * xc - sinInc * yc;
                yc = sinInc * xc + cosInc * yc;
                xc = xcNew;

                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z);
                coordA[coordIdx++] = new Vector3(xc + center.X, yc + center.Y, center.Z + depth);
            }
            // Start with vector (1.0f, 0.0f), ...
            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z);
            coordA[coordIdx++] = new Vector3(center.X + radius, center.Y, center.Z + depth);

            wheel4 = new VBO <Vector3>(coordA);      // right

            int[]     quads   = new int[(DIV_COUNT + 2) * 2];
            Vector3[] normals = new Vector3[(DIV_COUNT + 2) * 2];
            for (int i = 0; i < (DIV_COUNT + 2) * 2; i++)
            {
                normals[i] = new Vector3(0, 1, 0);
                quads[i]   = i;
            }

            Vector2[] UVs = new Vector2[(DIV_COUNT + 2) * 2];
            for (int i = 0; i < (DIV_COUNT + 2) * 2 - 3; i = i + 4)
            {
                UVs[i]     = new Vector2(0, 0);
                UVs[i + 1] = new Vector2(1, 0);
                UVs[i + 2] = new Vector2(1, 1);
                UVs[i + 3] = new Vector2(0, 1);
            }
            wheel1Normals = new VBO <Vector3>(normals);
            wheel1UV      = new VBO <Vector2>(UVs);
            wheel1Quads   = new VBO <int>(quads, BufferTarget.ElementArrayBuffer);

            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }