// This method is used to adjust a radius of the sphere the coordinate system of the camera
 // is based on. This means that the larger the radius, the further zoomed out you are.
 private void trackBar_zoom_ValueChanged(object sender, System.EventArgs e)
 {
     viewingAngle[6] = (trackBar_zoom.Value);
     SphereCoordinates.setRadius(viewingAngle[6]);
     SphereCoordinates.updateCoordinates(viewingAngle[0], viewingAngle[1], viewingAngle[2]);
     glControl1.Invalidate();
 }
 // Constructor and Initializer
 // Creates the form/window
 public QTELRMainWindow()
 {
     InitializeComponent();
     SphereCoordinates.setCoordinates(0, 0, 1000);
     SphereCoordinates.setRadius(1000);
     //trackBar_rotateX.Value = 0;
     //trackBar_rotateY.Value = 0;
     //trackBar_rotateZ.Value = 0;
     trackBar_panX.Value = 0;
     trackBar_panY.Value = 0;
     trackBar_panZ.Value = 0;
     //trackBar_zoom.Value = 1000;
     createModelGroup();
     setUpKinect();
 }
 // Event Methods for Controlling Perspective on GUI
 // RotateX value changed event
 // This method assigns a new value to the angle to be used in calculating camera position on the XZ plane
 private void trackBar_rotateX_ValueChanged(object sender, System.EventArgs e)
 {
     viewingAngle[0] = (trackBar_rotateX.Value / 10000.0);
     SphereCoordinates.updateCoordinates(viewingAngle[0], viewingAngle[1], viewingAngle[2]);
     glControl1.Invalidate();
 }
        // This is the main function for determining what will be rendered
        private void glControl1_Paint(object sender, PaintEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            //Basic Setup for viewing
            Matrix4d perspective = Matrix4d.CreatePerspectiveFieldOfView(1.04f, 3 / 4f, 1f, 100000f);

            //Setup Perspective
            //the first argument (Set of 3) is the location of your camera, so m_eye seems correct
            //the second argument (Set of 3) is the point the camera centers on, so you'll want a
            //location relative to your eye location or you'll always be focused on a single point in space
            //the third argument (Set of 3) is to indicate what direction should be considered "up"
            Matrix4d lookat = Matrix4d.LookAt(SphereCoordinates.getX(),
                                              SphereCoordinates.getY(), SphereCoordinates.getZ(), viewingAngle[3], viewingAngle[4], viewingAngle[5],
                                              0, -1, 0);

            //Set labels
            cameraPositionLabel.Text = "<" + Math.Round(SphereCoordinates.getX()) + ", " + Math.Round(SphereCoordinates.getY()) + ", " +
                                       Math.Round(SphereCoordinates.getZ()) + "> with Radius: " + SphereCoordinates.getRadius();
            lookingAtLabel.Text = "<" + Math.Round(viewingAngle[3]) + ", " + Math.Round(viewingAngle[4]) + ", " +
                                  Math.Round(viewingAngle[5]) + ">";

            //Setup camera
            GL.MatrixMode(MatrixMode.Projection);

            //Load Perspective
            GL.LoadIdentity();
            GL.LoadMatrix(ref perspective);
            GL.MatrixMode(MatrixMode.Modelview);

            //Load Camera
            GL.LoadIdentity();
            GL.LoadMatrix(ref lookat);
            GL.Viewport(0, 0, glControl1.Width, glControl1.Height);

            //Size of window
            GL.Enable(EnableCap.DepthTest);

            //Enable correct Z Drawings
            GL.DepthFunc(DepthFunction.Less);

            // GL.Rotate(1, 0, 1, 0);

            GL.PushMatrix();

            //Rotating
            //GL.Rotate(1, 0, 0, 1);
            //GL.Rotate(1, 0, 1, 0);
            // Translation of object across axii
            //GL.Translate(new Vector3((float)this.viewingAngle[3], (float)this.viewingAngle[4], (float)this.viewingAngle[5]));



            // Objects to be displayed go here.
            //Draw pyramid, Y is up and down, Z is towards you, X is left and right
            //Vertex goes (X,Y,Z)
            GL.Begin(PrimitiveType.Points);
            paintVertices();
            GL.End();


            GL.Begin(PrimitiveType.Lines);
            //Line X
            GL.Color3(Color.Red);
            GL.Vertex3(0, 0, 0);
            GL.Vertex3(100, 0, 0);

            //Line Y
            GL.Color3(Color.Blue);
            GL.Vertex3(0, 0, 0);
            GL.Vertex3(0, 100, 0);

            //Line Z
            GL.Color3(Color.Green);
            GL.Vertex3(0, 0, 0);
            GL.Vertex3(0, 0, 100);

            GL.End();

            GL.PopMatrix();

            //Rotating
            //GL.Rotate(1, 0, 0, 1);
            //GL.Rotate(1, 0, 1, 0);

            glControl1.SwapBuffers();
        }