public GetPosition ( int pointIndex ) : Vector2 | ||
pointIndex | int | |
return | Vector2 |
public override void OnPreviewGUI(Rect r, GUIStyle background) { base.OnPreviewGUI(r, background); float size = 0.95f * Mathf.Min(r.width, r.height); Rect canvasRect = new Rect(r.center.x - 0.5f * size, r.center.y - 0.5f * size, size, size); PointCloudGestureTemplate template = target as PointCloudGestureTemplate; Vector2 center = canvasRect.center; float scale = 0.95f * size; Handles.color = Color.white; for (int i = 1; i < template.PointCount; ++i) { Vector2 p1 = template.GetPosition(i - 1); Vector2 p2 = template.GetPosition(i); p1.y = -p1.y; p2.y = -p2.y; p1 = center + scale * p1; p2 = center + scale * p2; if (canvasRect.width > 100) { float handleSize = canvasRect.width / 200.0f; Handles.CircleHandleCap(0, p1, Quaternion.identity, handleSize, EventType.MouseDown); } Handles.DrawLine(p1, p2); } }
public bool Render( PointCloudGestureTemplate template ) { if( template.PointCount < 2 ) return false; lineRenderer.SetVertexCount( template.PointCount ); for( int i = 0; i < template.PointCount; ++i ) lineRenderer.SetPosition( i, template.GetPosition( i ) ); return true; }
void DrawTemplate() { float size = 0.95f * GestureAreaSize; Rect canvasRect = new Rect(0.5f * (GestureAreaSize - size), 0.5f * (GestureAreaSize - size), size, size); Vector2 center = canvasRect.center; float scale = 0.95f * size; for (int i = 1; i < template.PointCount; ++i) { Vector2 p1 = template.GetPosition(i - 1); Vector2 p2 = template.GetPosition(i); p1.y = -p1.y; p2.y = -p2.y; p1 = center + scale * p1; p2 = center + scale * p2; Handles.DrawLine(p1, p2); } }
public bool Render(PointCloudGestureTemplate template) { if (template.PointCount < 2) { return(false); } lineRenderer.positionCount = template.PointCount; for (int i = 0; i < template.PointCount; ++i) { lineRenderer.SetPosition(i, template.GetPosition(i)); } return(true); }
public bool AddTemplate(PointCloudGestureTemplate template) { if (FindNormalizedTemplate(template) != null) { Debug.LogWarning("The PointCloud template " + template.name + " is already present in the list"); return(false); } // convert template point entry to recognizer point List <Point> points = new List <Point>(); for (int i = 0; i < template.PointCount; ++i) { points.Add(new Point(template.GetStrokeId(i), template.GetPosition(i))); } NormalizedTemplate nt = new NormalizedTemplate(); nt.Source = template; nt.Points = Normalize(points); normalizedTemplates.Add(nt); return(true); }