Beispiel #1
0
        private void PaintStartInterval(P3dInputManager.Finger finger, float pixelSpacing, bool stretch)
        {
            var preview = finger.Up == false;
            var pointS  = finger.StartScreenPosition;
            var pointE  = finger.ScreenPosition;
            var pointV  = pointE - pointS;
            var pointM  = pointV.magnitude;
            var steps   = 0;

            if (pixelSpacing > 0.0f)
            {
                steps = Mathf.FloorToInt(pointM / pixelSpacing);

                if (stretch == true && steps > 0)
                {
                    pixelSpacing = pointM / steps;
                }
            }

            for (var i = 0; i <= steps; i++)
            {
                PaintAt(connector, connector.HitCache, pointS, pointS - pointV, preview, finger.Pressure, finger);

                pointS = Vector2.MoveTowards(pointS, pointE, pixelSpacing);
            }
        }
        protected override void Paint(P3dInputManager.Finger finger)
        {
            var link = GetLink(finger);

            if (finger.Down == true)
            {
                link.StartDrawn = false;

                link.LastPointA = link.LastPointB = link.LastPointC = link.LastPointD = finger.ScreenPosition;

                PaintAt(finger.ScreenPosition, false, finger.Pressure);
            }

            if (CalculateSteps(finger.ScreenPosition - link.LastPointD) >= minimumStep || finger.Up == true)
            {
                link.LastPointA = link.LastPointB;
                link.LastPointB = link.LastPointC;
                link.LastPointC = link.LastPointD;
                link.LastPointD = finger.ScreenPosition;

                if (link.StartDrawn == false)
                {
                    link.StartDrawn = true;

                    Draw(link.LastPointA, link.LastPointA, link.LastPointB, link.LastPointC, finger.Pressure);
                }

                Draw(link.LastPointA, link.LastPointB, link.LastPointC, link.LastPointD, finger.Pressure);
            }

            if (finger.Up == true)
            {
                Draw(link.LastPointB, link.LastPointC, link.LastPointD, link.LastPointD, finger.Pressure);
            }
        }
Beispiel #3
0
        private void PaintStartEnd(P3dInputManager.Finger finger)
        {
            var preview = finger.Up == false;
            var pointS  = finger.StartScreenPosition;
            var pointE  = finger.ScreenPosition;
            var pointV  = pointE - pointS;

            PaintAt(connector, connector.HitCache, pointS, pointS - pointV, preview, finger.Pressure, finger);
            PaintAt(connector, connector.HitCache, pointE, pointE - pointV, preview, finger.Pressure, finger);
        }
        private void HandleFingerUp(P3dInputManager.Finger finger)
        {
            if (fingers.Remove(finger) == true)
            {
                var delta = Vector2.Distance(finger.StartScreenPosition, finger.ScreenPosition) * P3dInputManager.ScaleFactor;

                if (finger.Age < 0.5f && delta < 20.0f)
                {
                    DoThrow(finger.ScreenPosition);
                }
            }
        }
Beispiel #5
0
        private void HandleFingerDown(P3dInputManager.Finger finger)
        {
            if (finger.Index != P3dInputManager.HOVER_FINGER_INDEX)
            {
                if (P3dInputManager.PointOverGui(finger.ScreenPosition, guiLayers) == true)
                {
                    return;
                }

                if (key != KeyCode.None && P3dInputManager.IsDown(key) == false)
                {
                    return;
                }
            }

            fingers.Add(finger);
        }
Beispiel #6
0
        private Link GetLink(P3dInputManager.Finger finger)
        {
            for (var i = links.Count - 1; i >= 0; i--)
            {
                var link = links[i];

                if (link.Finger == finger)
                {
                    return(link);
                }
            }

            var newLink = new Link();

            newLink.Finger = finger;

            links.Add(newLink);

            return(newLink);
        }
Beispiel #7
0
        private void Paint(P3dInputManager.Finger finger, bool down, bool up)
        {
            var link = GetLink(finger);

            if (spacing > 0.0f)
            {
                var head = finger.GetSmoothScreenPosition(0.0f);

                if (down == true)
                {
                    if (storeStates == true)
                    {
                        P3dStateManager.StoreAllStates();
                    }

                    PaintAt(link, head, false, finger.Pressure, link);
                }

                var steps = Mathf.Max(1, Mathf.FloorToInt(finger.SmoothScreenPositionDelta));
                var step  = P3dHelper.Reciprocal(steps);

                for (var i = 0; i <= steps; i++)
                {
                    var next = finger.GetSmoothScreenPosition(Mathf.Clamp01(i * step));
                    var dist = Vector2.Distance(head, next);
                    var gaps = Mathf.FloorToInt((link.Distance + dist) / spacing);

                    for (var j = 0; j < gaps; j++)
                    {
                        var remainder = spacing - link.Distance;

                        head = Vector2.MoveTowards(head, next, remainder);

                        PaintAt(link, head, false, finger.Pressure, link);

                        dist -= remainder;

                        link.Distance = 0.0f;
                    }

                    link.Distance += dist;
                    head           = next;
                }
            }
            else
            {
                var preview = true;

                if (showPreview == true)
                {
                    if (spacing == 0.0f)                     // Once
                    {
                        if (up == true)
                        {
                            if (storeStates == true)
                            {
                                P3dStateManager.StoreAllStates();
                            }

                            preview = false;
                        }
                    }
                    else                     // Every frame
                    {
                        if (storeStates == true && down == true)
                        {
                            P3dStateManager.StoreAllStates();
                        }

                        preview = false;
                    }
                }
                else
                {
                    if (spacing == 0.0f)                     // Once
                    {
                        if (down == true)
                        {
                            if (storeStates == true)
                            {
                                P3dStateManager.StoreAllStates();
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                    else                     // Every frame
                    {
                        if (storeStates == true && down == true)
                        {
                            P3dStateManager.StoreAllStates();
                        }
                    }

                    preview = false;
                }

                PaintAt(link, finger.PositionA, preview, finger.Pressure, link);
            }

            if (up == true)
            {
                BreakHits(link);

                if (draw == DrawType.PointsIn3DFilled)
                {
                    PaintGridOfPoints(link);
                }

                link.Clear();
            }
        }
Beispiel #8
0
        private void Paint(P3dInputManager.Finger finger, bool down, bool up)
        {
            var link = GetLink(finger);

            if (spacing > 0.0f)
            {
                var tail = finger.SmoothPositions[0];

                if (down == true)
                {
                    link.Distance = 0.0f;

                    if (storeStates == true)
                    {
                        P3dStateManager.StoreAllStates();
                    }

                    PaintAt(tail, false, finger.Pressure, link);
                }

                for (var i = 1; i < finger.SmoothPositions.Count; i++)
                {
                    var head  = finger.SmoothPositions[i];
                    var dist  = Vector2.Distance(tail, head);
                    var steps = Mathf.FloorToInt((link.Distance + dist) / spacing);

                    for (var j = 0; j < steps; j++)
                    {
                        var remainder = spacing - link.Distance;

                        tail = Vector2.MoveTowards(tail, head, remainder);

                        PaintAt(tail, false, finger.Pressure, link);

                        dist -= remainder;

                        link.Distance = 0.0f;
                    }

                    link.Distance += dist;

                    tail = head;
                }
            }
            else
            {
                if (showPreview == true)
                {
                    if (up == true)
                    {
                        if (storeStates == true)
                        {
                            P3dStateManager.StoreAllStates();
                        }

                        PaintAt(finger.PositionA, false, finger.Pressure, link);
                    }
                    else
                    {
                        PaintAt(finger.PositionA, true, finger.Pressure, link);
                    }
                }
                else if (down == true)
                {
                    if (storeStates == true)
                    {
                        P3dStateManager.StoreAllStates();
                    }

                    PaintAt(finger.PositionA, false, finger.Pressure, link);
                }
            }

            if (up == true)
            {
                BreakHits(link);
            }
        }
 private void HandleFingerUp(P3dInputManager.Finger finger)
 {
     fingers.Remove(finger);
 }
Beispiel #10
0
        private void Paint(P3dInputManager.Finger finger, bool down, bool up)
        {
            var link = GetLink(finger);

            if (spacing > 0.0f)
            {
                var tail = finger.SmoothPositions[0];

                if (down == true)
                {
                    link.Distance = 0.0f;

                    if (storeStates == true)
                    {
                        P3dStateManager.StoreAllStates();
                    }

                    PaintAt(link, tail, false, finger.Pressure, link);
                }

                if (finger.SmoothPositions.Count > 1)
                {
                    for (var i = 1; i < finger.SmoothPositions.Count; i++)
                    {
                        var head  = finger.SmoothPositions[i];
                        var dist  = Vector2.Distance(tail, head);
                        var steps = Mathf.FloorToInt((link.Distance + dist) / spacing);

                        for (var j = 0; j < steps; j++)
                        {
                            var remainder = spacing - link.Distance;

                            tail = Vector2.MoveTowards(tail, head, remainder);

                            PaintAt(link, tail, false, finger.Pressure, link);

                            dist -= remainder;

                            link.Distance = 0.0f;
                        }

                        link.Distance += dist;

                        tail = head;
                    }
                }
                else
                {
                    SubmitLastPoint(false, link);
                }
            }
            else
            {
                var preview = true;

                if (showPreview == true)
                {
                    if (spacing == 0.0f)                     // Once
                    {
                        if (up == true)
                        {
                            if (storeStates == true)
                            {
                                P3dStateManager.StoreAllStates();
                            }

                            preview = false;
                        }
                    }
                    else                     // Every frame
                    {
                        if (storeStates == true && down == true)
                        {
                            P3dStateManager.StoreAllStates();
                        }

                        preview = false;
                    }
                }
                else
                {
                    if (spacing == 0.0f)                     // Once
                    {
                        if (down == true)
                        {
                            if (storeStates == true)
                            {
                                P3dStateManager.StoreAllStates();
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                    else                     // Every frame
                    {
                        if (storeStates == true && down == true)
                        {
                            P3dStateManager.StoreAllStates();
                        }
                    }

                    preview = false;
                }

                PaintAt(link, finger.PositionA, preview, finger.Pressure, link);
            }

            if (up == true)
            {
                BreakHits(link);

                if (fill == FillType.GridOfPoints)
                {
                    PaintGridOfPoints(link);
                }

                link.History.Clear();
            }
        }
Beispiel #11
0
        protected virtual void Paint(P3dInputManager.Finger finger)
        {
            var link = GetLink(finger);

            if (dragStep > 0.0f)
            {
                if (finger.Down == true)
                {
                    link.LastPoint = finger.ScreenPosition;

                    if (storeStates == true)
                    {
                        P3dStateManager.StoreAllStates();
                    }

                    PaintAt(finger.ScreenPosition, false, finger.Pressure);
                }

                var steps = CalculateSteps(finger.ScreenPosition - link.LastPoint);

                if (steps > 0)
                {
                    var step           = P3dHelper.Reciprocal(steps);
                    var screenPosition = default(Vector2);

                    for (var i = 1; i <= steps; i++)
                    {
                        screenPosition = Vector2.Lerp(link.LastPoint, finger.ScreenPosition, i * step);

                        PaintAt(screenPosition, false, finger.Pressure);
                    }

                    link.LastPoint = screenPosition;
                }
            }
            else
            {
                if (showPreview == true)
                {
                    if (finger.Up == true)
                    {
                        if (storeStates == true)
                        {
                            P3dStateManager.StoreAllStates();
                        }

                        PaintAt(finger.ScreenPosition, false, finger.Pressure);
                    }
                    else
                    {
                        PaintAt(finger.ScreenPosition, true, finger.Pressure);
                    }
                }
                else if (finger.Down == true)
                {
                    if (storeStates == true)
                    {
                        P3dStateManager.StoreAllStates();
                    }

                    PaintAt(finger.ScreenPosition, false, finger.Pressure);
                }
            }
        }