/// <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); }
/// <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); }
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); }
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); }
public Thing(PartLocation p, PointMode mode) { X = p.X; Y = p.Y; A = p.A; pointMode = mode; }
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(); }
public new void ClearData() { base.ClearData(); Points.Clear(); SegmentLength = new float[0, 0]; PointMode.Clear(); RecalculateLengthBias(); }
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(); }
public override void Enable() { clearedLineCount = 0; pointMode = PointMode.Normal; multiBonusValue = 1; warningBonusValue = 1; nowScore = 0; doubleBonusCount = 0; UpdateScore(); }
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; }
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); } }
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(); }
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); }
/// <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; }
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; }
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; }
/// <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))); }
public void SetSkillPointMode() { pointMode = PointMode.Skill; }
public void SetNormalPointMode(int clearedLineCount) { pointMode = PointMode.Normal; this.clearedLineCount = clearedLineCount; }
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; }
/// <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; }
/// <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; } } }