コード例 #1
0
        private void ActiveNextMotion()
        {
            Current_?.Exit();

            Index_ = GetNextMotionIndex();
            if (Index_ == -1)
            {
                Current_ = null;
                IsEnd    = true;
            }
            else
            {
                Current_ = SubMotions_[Index_];
            }

            if (Current_ != null)
            {
                Current_.Master = Master;
                Current_?.Enter();

                if (Current_?.IsEnd == true)
                {
                    ActiveNextMotion();
                }
            }
        }
コード例 #2
0
        private Color GCodeToColor(BaseMotion motion)
        {
            if (motion is CoordinatMotion)
            {
                var cm = (CoordinatMotion)motion;
                return(Color.FromRgb(cm.Color.R, cm.Color.G, cm.Color.B));
            }

            if (motion is RapidMotion)
            {
                return(Colors.HotPink);
            }

            return(Colors.HotPink);
        }
コード例 #3
0
        private void VisualiseGCode(DrawingContext dc)
        {
            if (Data == null || !(Data is IEnumerable <BaseGCode>) || ((IEnumerable <BaseGCode>)Data).Count() == 0)
            {
                return;
            }

            var data = (IList <BaseGCode>)Data;

            BaseMotion firstMotion = null;

            foreach (BaseGCode item in data)
            {
                if (!(item is BaseMotion))
                {
                    continue;
                }

                var curMotion = (BaseMotion)item;

                if (firstMotion != null)
                {
                    Point start = VectorToPoint(firstMotion.Position);
                    Point end   = VectorToPoint(curMotion.Position);

                    dc.DrawLine(new Pen(new SolidColorBrush(GCodeToColor(curMotion)), 1.0), start, end);

                    if (curMotion is RapidMotion)
                    {
                        var dir = (curMotion.Position - firstMotion.Position).Normalize();
                        var v1  = dir.Rotate(15.0 / 180.0 * Math.PI) * 5;
                        var v2  = dir.Rotate(-15.0 / 180.0 * Math.PI) * 5;
                        v1 = curMotion.Position - v1;
                        v2 = curMotion.Position - v2;
                        dc.DrawLine(new Pen(new SolidColorBrush(Colors.Magenta), 1.0), end, VectorToPoint(v1));
                        dc.DrawLine(new Pen(new SolidColorBrush(Colors.Magenta), 1.0), end, VectorToPoint(v2));
                    }
                }

                firstMotion = curMotion;
            }

            DrawArrows(dc);
        }
コード例 #4
0
        private IEnumerator TransitionToState(MotionState s)
        {
            if (currentMotion != null)
            {
                myAnim.SetTrigger("Exit");

                /*
                 * while (myAnim.GetCurrentAnimatorStateInfo(0).normalizedTime % 1 < 0.95f)// myAnim.GetBool("Exit"))
                 * {
                 *  yield return null;
                 * }
                 */
                currentMotion.Stop();
            }
            currentMotion = availableStates[s];
            currentMotion.Start();
            currentState = s;
            myAnim.SetInteger("MotionState", (int)s);
            myAnim.SetTrigger("ChangeMotionState");
            yield return(null);
        }
コード例 #5
0
 public MotionContainer Motion(BaseMotion Motion)
 {
     MotionList_.Add(Motion);
     return(this);
 }
コード例 #6
0
 public void AbandonMotion(BaseMotion Motion)
 {
     MotionManager.Abandon(Motion);
 }
コード例 #7
0
 public BaseMotion ExecuteMotion(string ChildPath, BaseMotion Motion)
 {
     return(MotionManager.Execute(FindChild(ChildPath), Motion));
 }
コード例 #8
0
 public BaseMotion ExecuteMotion(BaseMotion Motion)
 {
     return(MotionManager.Execute(UITransform, Motion));
 }