Exemplo n.º 1
0
            /// <summary>
            /// This is the resolution and zoom of things we see on the screen.
            /// The image is simply shifted and flipped
            /// </summary>
            /// <param name="camera"></param>
            /// <returns></returns>
            public virtual Thing ToScreenResolution()
            {
                var zoom = videoProcessing.GetZoom();

                switch (pointMode)
                {
                case PointMode.ScreenUnzoomed:
                    X *= zoom;
                    Y *= zoom;
                    break;

                case PointMode.Raw:
                    X = (X - videoProcessing.FrameCenter.X);
                    Y = (videoProcessing.FrameCenter.Y - Y);     //flip Y axis to switch from graphic coordinates to table coordinates
                    break;

                case PointMode.MM:
                    // convert to unzoomed pixels
                    X = X / videoProcessing.XmmPerPixel * zoom;
                    Y = Y / videoProcessing.YmmPerPixel * zoom;
                    // apply appropriate zoom
                    break;
                }
                pointMode = PointMode.Screen;
                return(this);
            }
Exemplo n.º 2
0
            /// <summary>
            /// This is the MM representation of what we see on the table
            /// </summary>
            /// <param name="camera"></param>
            /// <returns></returns>
            public virtual Thing ToMMResolution()
            {
                var zoom = videoProcessing.GetZoom();

                switch (pointMode)
                {
                case PointMode.ScreenUnzoomed:
                    X *= videoProcessing.XmmPerPixel;
                    Y *= videoProcessing.YmmPerPixel;
                    break;

                case PointMode.Raw:
                    ToScreenResolution();
                    X *= videoProcessing.XmmPerPixel / zoom;
                    Y *= videoProcessing.YmmPerPixel / zoom;
                    break;

                case PointMode.Screen:
                    X *= videoProcessing.XmmPerPixel / zoom;
                    Y *= videoProcessing.YmmPerPixel / zoom;
                    break;
                }
                pointMode = PointMode.MM;
                return(this);
            }
Exemplo n.º 3
0
            public virtual Thing ToScreenUnzoomedResolution()
            {
                var zoom = videoProcessing.GetZoom();

                switch (pointMode)
                {
                case PointMode.Screen:
                    X /= zoom;
                    Y /= zoom;
                    break;

                case PointMode.Raw:
                    ToScreenResolution();
                    X /= zoom;
                    Y /= zoom;
                    break;

                case PointMode.MM:
                    ToScreenResolution();
                    X /= zoom;
                    Y /= zoom;
                    break;
                }
                pointMode = PointMode.ScreenUnzoomed;
                return(this);
            }
Exemplo n.º 4
0
            public virtual Thing ToRawResolution()
            {
                if (videoProcessing == null)
                {
                    throw new Exception("Camera Not Set For Object " + this);
                }
                var zoom = videoProcessing.GetZoom();

                switch (pointMode)
                {
                case PointMode.ScreenUnzoomed:
                    X        *= zoom;
                    Y        *= zoom;
                    pointMode = PointMode.Screen;
                    return(ToRawResolution());

                case PointMode.Screen:
                    X = X + videoProcessing.FrameCenter.X;
                    Y = videoProcessing.FrameCenter.Y - Y;
                    break;

                case PointMode.MM:
                    ToScreenResolution();
                    X = X + videoProcessing.FrameCenter.X;
                    Y = videoProcessing.FrameCenter.Y - Y;
                    break;
                }
                pointMode = PointMode.Raw;
                return(this);
            }
Exemplo n.º 5
0
 public Thing(PartLocation p, PointMode mode)
 {
     X         = p.X;
     Y         = p.Y;
     A         = p.A;
     pointMode = mode;
 }
Exemplo n.º 6
0
    public void DrawLines(List <Vector2> points, Color color, PointMode pointMode = PointMode.ScreenPoint)
    {
        if (points == null || points.Count == 0)
        {
            return;
        }

        if (pointMode == PointMode.ScreenPoint)
        {
            for (int i = 0; i < points.Count; i++)
            {
                points[i] = ScreenToGLPoint(points[i]);
            }
        }

        GL.PushMatrix();

        GL.LoadOrtho();

        GL.Begin(GL.LINES);

        GL.Color(color);

        for (int i = 0; i < points.Count; i++)
        {
            GL.Vertex(points[i]);
        }

        GL.End();

        GL.PopMatrix();
    }
Exemplo n.º 7
0
            public new void ClearData()
            {
                base.ClearData();

                Points.Clear();
                SegmentLength = new float[0, 0];
                PointMode.Clear();

                RecalculateLengthBias();
            }
Exemplo n.º 8
0
    public void DrawPolygon(List <Vector2> points, Color fillColor, Color lineColor, PointMode pointMode = PointMode.ScreenPoint)
    {
        if (points == null || points.Count == 0)
        {
            return;
        }

        if (pointMode == PointMode.ScreenPoint)
        {
            for (int i = 0; i < points.Count; i++)
            {
                points[i] = ScreenToGLPoint(points[i]);
            }
        }

        GL.PushMatrix();

        GL.LoadOrtho();

        GL.Begin(GL.TRIANGLES);

        GL.Color(fillColor);

        for (int i = 0; i < points.Count; i++)
        {
            if (i < points.Count - 2)
            {
                GL.Vertex(points[0]);
                GL.Vertex(points[i + 1]);
                GL.Vertex(points[i + 2]);
            }
        }

        GL.End();

        GL.Begin(GL.LINES);

        GL.Color(lineColor);

        for (int i = 0; i < points.Count; i++)
        {
            GL.Vertex(points[i]);

            if (i != points.Count - 1)
            {
                GL.Vertex(points[i + 1]);
            }
        }

        GL.Vertex(points[0]);

        GL.End();

        GL.PopMatrix();
    }
Exemplo n.º 9
0
    public override void Enable()
    {
        clearedLineCount  = 0;
        pointMode         = PointMode.Normal;
        multiBonusValue   = 1;
        warningBonusValue = 1;
        nowScore          = 0;
        doubleBonusCount  = 0;

        UpdateScore();
    }
Exemplo n.º 10
0
    private void EnforceMode(int index)
    {
        int       modeIndex = (index + 1) / 3;
        PointMode mode      = modes[modeIndex];

        if (mode == PointMode.Free || !loop && (modeIndex == 0 || modeIndex == modes.Length - 1))
        {
            return;
        }

        int middleIndex = modeIndex * 3;
        int fixedIndex, enforcedIndex;

        if (index <= middleIndex)
        {
            fixedIndex = middleIndex - 1;
            if (fixedIndex < 0)
            {
                fixedIndex = points.Length - 2;
            }
            enforcedIndex = middleIndex + 1;
            if (enforcedIndex >= points.Length)
            {
                enforcedIndex = 1;
            }
        }
        else
        {
            fixedIndex = middleIndex + 1;
            if (fixedIndex >= points.Length)
            {
                fixedIndex = 1;
            }
            enforcedIndex = middleIndex - 1;
            if (enforcedIndex < 0)
            {
                enforcedIndex = points.Length - 2;
            }
        }

        Vector3 middle          = points[middleIndex];
        Vector3 enforcedTangent = middle - points[fixedIndex];

        if (mode == PointMode.Aligned)
        {
            enforcedTangent = enforcedTangent.normalized * Vector3.Distance(middle, points[enforcedIndex]);
        }
        points[enforcedIndex] = middle + enforcedTangent;
    }
Exemplo n.º 11
0
    public void SetControlPointMode(int index, PointMode mode)
    {
        int modeIndex = (index + 1) / 3;

        modes[modeIndex] = mode;
        if (loop)
        {
            if (modeIndex == 0)
            {
                modes[modes.Length - 1] = mode;
            }
            else if (modeIndex == modes.Length - 1)
            {
                modes[0] = mode;
            }
        }
        EnforceMode(index);
    }
    private void DrawSelectedPointInspector()
    {
        GUILayout.Label("Selected Point");
        EditorGUI.BeginChangeCheck();
        Vector3 point = EditorGUILayout.Vector3Field("Position", spline.GetControlPoint(selectedIndex));

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(spline, "Move Point");
            EditorUtility.SetDirty(spline);
            spline.SetControlPoint(selectedIndex, point);
        }
        EditorGUI.BeginChangeCheck();
        PointMode mode = (PointMode)EditorGUILayout.EnumPopup("Mode", spline.GetControlPointMode(selectedIndex));

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(spline, "Change Point Mode");
            spline.SetControlPointMode(selectedIndex, mode);
            EditorUtility.SetDirty(spline);
        }
    }
Exemplo n.º 13
0
    public void DrawLine(Vector2 start, Vector2 end, Color color, PointMode pointMode = PointMode.ScreenPoint)
    {
        if (pointMode == PointMode.ScreenPoint)
        {
            start = ScreenToGLPoint(start);
            end   = ScreenToGLPoint(end);
        }

        GL.PushMatrix();

        GL.LoadOrtho();

        GL.Begin(GL.LINES);

        GL.Color(color);

        GL.Vertex(start);
        GL.Vertex(end);

        GL.End();

        GL.PopMatrix();
    }
Exemplo n.º 14
0
            public static PartLocation Convert(VideoProcessing videoProcessing, PartLocation p, PointMode fromMode, PointMode toMode)
            {
                Thing t = new Thing(p, fromMode);

                t.videoProcessing = videoProcessing;
                switch (toMode)
                {
                case PointMode.MM: return(t.ToMMResolution().ToPartLocation());

                case PointMode.Raw: return(t.ToRawResolution().ToPartLocation());

                case PointMode.Screen: return(t.ToScreenResolution().ToPartLocation());

                case PointMode.ScreenUnzoomed: return(t.ToScreenUnzoomedResolution().ToPartLocation());
                }
                return(null);
            }
Exemplo n.º 15
0
 /// <summary>
 /// This is the resolution and zoom of things we see on the screen.
 /// The image is simply shifted and flipped
 /// </summary>
 /// <param name="camera"></param>
 /// <returns></returns>
 public virtual Thing ToScreenResolution()
 {
     var zoom = videoProcessing.GetZoom();
     switch (pointMode) {
         case PointMode.ScreenUnzoomed:
             X *= zoom;
             Y *= zoom;
             break;
         case PointMode.Raw:
             X = (X - videoProcessing.FrameCenter.X);
             Y = (videoProcessing.FrameCenter.Y - Y); //flip Y axis to switch from graphic coordinates to table coordinates
             break;
         case PointMode.MM:
             // convert to unzoomed pixels
             X = X / videoProcessing.XmmPerPixel * zoom;
             Y = Y / videoProcessing.YmmPerPixel * zoom;
             // apply appropriate zoom
             break;
     }
     pointMode = PointMode.Screen;
     return this;
 }
Exemplo n.º 16
0
 public virtual Thing ToScreenUnzoomedResolution()
 {
     var zoom = videoProcessing.GetZoom();
     switch (pointMode) {
         case PointMode.Screen:
             X /= zoom;
             Y /= zoom;
             break;
         case PointMode.Raw:
             ToScreenResolution();
             X /= zoom;
             Y /= zoom;
             break;
         case PointMode.MM:
             ToScreenResolution();
             X /= zoom;
             Y /= zoom;
             break;
     }
     pointMode = PointMode.ScreenUnzoomed;
     return this;
 }
Exemplo n.º 17
0
 public virtual Thing ToRawResolution()
 {
     if (videoProcessing == null) throw new Exception("Camera Not Set For Object " + this);
     var zoom = videoProcessing.GetZoom();
     switch (pointMode) {
         case PointMode.ScreenUnzoomed:
             X *= zoom;
             Y *= zoom;
             pointMode = PointMode.Screen;
             return ToRawResolution();
         case PointMode.Screen:
             X = X + videoProcessing.FrameCenter.X;
             Y = videoProcessing.FrameCenter.Y - Y;
             break;
         case PointMode.MM:
             ToScreenResolution();
             X = X + videoProcessing.FrameCenter.X;
             Y = videoProcessing.FrameCenter.Y - Y;
             break;
     }
     pointMode = PointMode.Raw;
     return this;
 }
Exemplo n.º 18
0
        /// <summary>
        /// Draws the given point.
        /// </summary>
        /// <param name="canvas">The canvas.</param>
        /// <param name="point">The point.</param>
        /// <param name="color">The fill color.</param>
        /// <param name="size">The point size.</param>
        /// <param name="mode">The point mode.</param>
        public static void DrawPoint(this ICanvas canvas, Point point, Color color, float size, PointMode mode)
        {
            IShape shape;

            if (mode == PointMode.Square)
            {
                shape = Rectangle();
            }
            else if (mode == PointMode.Circle)
            {
                shape = Ellipse();
            }
            else
            {
                return;
            }

            canvas.Add(point.X - (size / 2), point.Y - (size / 2), shape.Width(size).Height(size).Fill(SolidColorBrush().Color(color)));
        }
Exemplo n.º 19
0
 public void SetSkillPointMode()
 {
     pointMode = PointMode.Skill;
 }
Exemplo n.º 20
0
 public void SetNormalPointMode(int clearedLineCount)
 {
     pointMode             = PointMode.Normal;
     this.clearedLineCount = clearedLineCount;
 }
Exemplo n.º 21
0
 public static PartLocation Convert(VideoProcessing videoProcessing, PartLocation p, PointMode fromMode, PointMode toMode)
 {
     Thing t = new Thing(p, fromMode);
     t.videoProcessing = videoProcessing;
     switch (toMode) {
         case PointMode.MM: return t.ToMMResolution().ToPartLocation();
         case PointMode.Raw: return t.ToRawResolution().ToPartLocation();
         case PointMode.Screen: return t.ToScreenResolution().ToPartLocation();
         case PointMode.ScreenUnzoomed: return t.ToScreenUnzoomedResolution().ToPartLocation();
     }
     return null;
 }
Exemplo n.º 22
0
 /// <summary>
 /// This is the MM representation of what we see on the table
 /// </summary>
 /// <param name="camera"></param>
 /// <returns></returns>
 public virtual Thing ToMMResolution()
 {
     var zoom = videoProcessing.GetZoom();
     switch (pointMode) {
         case PointMode.ScreenUnzoomed:
             X *= videoProcessing.XmmPerPixel;
             Y *= videoProcessing.YmmPerPixel;
             break;
         case PointMode.Raw:
             ToScreenResolution();
             X *= videoProcessing.XmmPerPixel / zoom;
             Y *= videoProcessing.YmmPerPixel / zoom;
             break;
         case PointMode.Screen:
             X *= videoProcessing.XmmPerPixel / zoom;
             Y *= videoProcessing.YmmPerPixel / zoom;
             break;
     }
     pointMode = PointMode.MM;
     return this;
 }
Exemplo n.º 23
0
        /// <summary>
        /// Draws the given point.
        /// </summary>
        /// <param name="canvas">The canvas.</param>
        /// <param name="point">The point.</param>
        /// <param name="color">The fill color.</param>
        /// <param name="size">The point size.</param>
        /// <param name="mode">The point mode.</param>
        public static void DrawPoint(this SKCanvas canvas, SKPoint point, SKColor color, float size, PointMode mode)
        {
            using (var paint = new SKPaint
            {
                Style = SKPaintStyle.Fill,
                IsAntialias = true,
                Color = color,
            })
            {
                switch (mode)
                {
                case PointMode.Square:
                    canvas.DrawRect(SKRect.Create(point.X - (size / 2), point.Y - (size / 2), size, size), paint);
                    break;

                case PointMode.Circle:
                    paint.IsAntialias = true;
                    canvas.DrawCircle(point.X, point.Y, size / 2, paint);
                    break;
                }
            }
        }
Exemplo n.º 24
0
 public Thing(PartLocation p, PointMode mode)
 {
     X = p.X;
     Y = p.Y;
     A = p.A;
     pointMode = mode;
 }