Пример #1
0
        private void mouseUp(object sender, EventArgs e)
        {
            this.rotating = false;
            this.rotatingAxis = typeRotating.NUL;

            System.Windows.Forms.MouseEventArgs me = (e as System.Windows.Forms.MouseEventArgs);
            if (Math.Abs(me.X - this.x2) < 5 && Math.Abs(me.Y - this.y2) < 5)
            {
                click = true;
                /*this.x2 = me.X;
                this.y2 = me.Y;*/
            }
        }
Пример #2
0
        private void mouseMove(object sender, EventArgs e)
        {
            if (!this.rotating)
            {
                return;
            }
            click = false;

            System.Windows.Forms.MouseEventArgs me = (e as System.Windows.Forms.MouseEventArgs);

            int w = glControl1.Width;
            int h = glControl1.Height;

            float dx = -(float)(me.X - this.x1);
            float dy = -(float)(me.Y - this.y1);

            if (Math.Abs(dx) < 1 && Math.Abs(dy) < 1 && rotatingAxis == typeRotating.NUL)
            {
                return;
            }

            rotatingAxis = typeRotating.X;

            float drotation = (dx / w) * 180;
            float drotation2 = (dy / h) * 180;

            vp.angle_view_beta -= drotation2;
            drotation *= vp.orintation_y;
            if (changedx)
            {
                drotation *= -1;
            }
            if ((vp.angle_view_beta > 90 && vp.angle_view_beta < 135) ||
            (vp.angle_view_beta > 270 && vp.angle_view_beta < 315))
            {
                drotation *= -1;
            }

            vp.angle_view_alfa += drotation;

            G_modelview = Matrix4.LookAt(vp.viewX, vp.viewY, vp.viewZ, 0, 0, 0, 0, vp.orintation_y, 0);

            this.x1 = me.X;
            this.y1 = me.Y;

            glControl1.Invalidate();
        }