Пример #1
0
 private void orthographicToolStripMenuItem_Click(object sender, EventArgs e)
 {
     System.Console.WriteLine("To orthographic projection");
     projection = false;
     GLWindow_Resize(this, null);
     GLPanel.Refresh();
 }
Пример #2
0
        private void GLPanel_KeyDown(object sender, KeyEventArgs e)
        {
            System.Console.WriteLine("you pressed: " + e.KeyCode);

            if (e.KeyCode == Keys.X)  // X for +X-view
            {
                cam.x_view(true);
            }
            else if ((e.Shift == true) && (e.KeyCode == Keys.X)) // shift-X for -X-view
            {
                System.Console.WriteLine("shift.X!");            //WE NEVER GET HERE.... FIXME
                cam.x_view(false);
            }
            else if (e.KeyCode == Keys.Y)  // Y for +Y-view
            {
                cam.y_view(true);
            }
            else if (e.KeyCode == Keys.Z)  // Z for +Z-view
            {
                cam.z_view(true);
            }
            else if (e.KeyCode == Keys.Oemplus)
            {
                cam.zoom(+0.1);
            }
            else if (e.KeyCode == Keys.OemMinus)
            {
                cam.zoom(-0.1);
            }

            GLWindow_Resize(this, null);
            //GLPanel_Paint(this, null);
            GLPanel.Refresh(); // this calls paint indirectly.
        }
Пример #3
0
 private void perspectiveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     System.Console.WriteLine("To perspective projection");
     projection = true;
     GLWindow_Resize(this, null);
     GLPanel.Refresh();
     //menuStrip1.Items[2].c
 }
Пример #4
0
        private void GLPanel_MouseWheel(object sender, MouseEventArgs e)
        {
            double zoomratio = 0.01;

            cam.zoom((double)e.Delta * zoomratio);
            GLWindow_Resize(this, null);
            GLPanel.Refresh();
        }
Пример #5
0
        public void addGeom(Geo g)
        {
            g.gengldata(); // generate gl-data.
            int N = g.gldata.Length;

            for (int n = 0; n < N; n++)
            {
                // make renderlist(s)
                Renderer.MakeRenderList(ref g.gldata[n]);
                // add list to display-lists being rendered
                dlist.Add((int)g.gldata[n].dlistID);
            }
            // add object to geo
            geom.add(g);
            GLPanel.Refresh();
        }
Пример #6
0
        private void GLPanel_MouseMove(object sender, MouseEventArgs e)
        {
            // System.Console.WriteLine("mousemove");
            double dragx, dragy;
            // double theta_scale = 0.01;  // multiply drag amount (in pixels) by this to get angle
            // double fi_scale = 0.01;
            // double pan_scale = 0.01;

            double x_limit     = 1; // require this amount of angle change before updating view
            double y_limit     = 1;
            double x_pan_limit = 1; // require this amount of panning before updating view
            double y_pan_limit = 1;

            if (e.Button != MouseButtons.None)
            {
                // System.Console.WriteLine("button=" + e.Button + "delta" + e.Delta + "clicks" + e.Clicks);
                // System.Console.WriteLine("drag x:" + (e.X - mdownx) + " drag y:" + (e.Y - mdowny));
                switch (e.Button)
                {
                case (MouseButtons.Right):
                    dragx = e.X - mdownx;
                    dragy = e.Y - mdowny;
                    if (Math.Abs(dragx) > x_limit)
                    {
                        cam.rotate_theta(dragx);
                        GLWindow_Resize(this, null);
                        GLPanel.Refresh();
                        mdownx = e.X;
                        break;
                    }
                    if (Math.Abs(dragy) > y_limit)
                    {
                        cam.rotate_fi(dragy);
                        GLWindow_Resize(this, null);
                        GLPanel.Refresh();
                        mdowny = e.Y;
                        break;
                    }
                    break;

                case (MouseButtons.Left):
                    dragx = (e.X - mdownx);
                    dragy = (e.Y - mdowny);
                    if (Math.Abs(dragx) > x_pan_limit)
                    {
                        cam.pan_lr(-dragx);
                        GLWindow_Resize(this, null);
                        GLPanel.Refresh();
                        mdownx = e.X;
                        break;
                    }
                    if (Math.Abs(dragy) > y_pan_limit)
                    {
                        cam.pan_ud(dragy);
                        GLWindow_Resize(this, null);
                        GLPanel.Refresh();
                        mdowny = e.Y;
                        break;
                    }
                    break;
                }
            }
        }