Example #1
0
 /// <summary>
 /// 设置夹点
 /// </summary>
 public override void SetGripPointAt(int index, GripPoint gripPoint, LitMath.Vector2 newPosition)
 {
     if (index == 0)
     {
         _position = newPosition;
     }
 }
Example #2
0
        /// <summary>
        /// 设置夹点
        /// </summary>
        public override void SetGripPointAt(int index, GripPoint gripPoint, LitMath.Vector2 newPosition)
        {
            switch (gripPoint.type)
            {
            case GripPointType.End:
            {
                this.SetPointAt(index, newPosition);
            }
            break;

            case GripPointType.Mid:
            {
                int numOfVertices = NumberOfVertices;
                int i             = index - numOfVertices;
                if (i >= 0 && i <= numOfVertices - 1)
                {
                    int vIndex1st = i;
                    int vIndex2nd = i + 1;
                    if (vIndex2nd == numOfVertices)
                    {
                        vIndex2nd = 0;
                    }
                    LitMath.Vector2 t = newPosition - gripPoint.position;
                    this.SetPointAt(vIndex1st, (LitMath.Vector2)gripPoint.xData1 + t);
                    this.SetPointAt(vIndex2nd, (LitMath.Vector2)gripPoint.xData2 + t);
                }
            }
            break;

            default:
                break;
            }
        }
Example #3
0
        /// <summary>
        /// 获取夹点
        /// </summary>
        public override List <GripPoint> GetGripPoints()
        {
            List <GripPoint> gripPnts = new List <GripPoint>();
            int numOfVertices         = NumberOfVertices;

            for (int i = 0; i < numOfVertices; ++i)
            {
                gripPnts.Add(new GripPoint(GripPointType.End, _vertices[i]));
            }
            for (int i = 0; i < numOfVertices - 1; ++i)
            {
                GripPoint midGripPnt = new GripPoint(GripPointType.Mid, (_vertices[i] + _vertices[i + 1]) / 2);
                midGripPnt.xData1 = _vertices[i];
                midGripPnt.xData2 = _vertices[i + 1];
                gripPnts.Add(midGripPnt);
            }
            if (_closed && numOfVertices > 2)
            {
                GripPoint midGripPnt = new GripPoint(GripPointType.Mid, (_vertices[0] + _vertices[numOfVertices - 1]) / 2);
                midGripPnt.xData1 = _vertices[0];
                midGripPnt.xData2 = _vertices[numOfVertices - 1];
                gripPnts.Add(midGripPnt);
            }

            return(gripPnts);
        }
Example #4
0
        /// <summary>
        /// 设置夹点
        /// </summary>
        public override void SetGripPointAt(int index, GripPoint gripPoint, LitMath.Vector2 newPosition)
        {
            if (index == 0)
            {
                _center = newPosition;
            }
            else if (index >= 1 && index <= 3)
            {
                LitMath.Vector2 startPoint  = this.startPoint;
                LitMath.Vector2 endPoint    = this.endPoint;
                LitMath.Vector2 middlePoint = this.middlePoint;

                if (index == 1)
                {
                    startPoint  = newPosition;
                    middlePoint = (LitMath.Vector2)gripPoint.xData1;
                }
                else if (index == 2)
                {
                    endPoint    = newPosition;
                    middlePoint = (LitMath.Vector2)gripPoint.xData1;
                }
                else if (index == 3)
                {
                    middlePoint = newPosition;
                }

                LitMath.Circle2 newCircle = LitMath.Circle2.From3Points(
                    startPoint, middlePoint, endPoint);
                if (newCircle.radius > 0)
                {
                    LitMath.Vector2 xPositive  = new LitMath.Vector2(1, 0);
                    double          startAngle = LitMath.Vector2.SignedAngleInRadian(xPositive,
                                                                                     startPoint - newCircle.center);
                    double endAngle = LitMath.Vector2.SignedAngleInRadian(xPositive,
                                                                          endPoint - newCircle.center);
                    double middleAngle = LitMath.Vector2.SignedAngleInRadian(xPositive,
                                                                             middlePoint - newCircle.center);
                    startAngle  = MathUtils.NormalizeRadianAngle(startAngle);
                    endAngle    = MathUtils.NormalizeRadianAngle(endAngle);
                    middleAngle = MathUtils.NormalizeRadianAngle(middleAngle);

                    _center = newCircle.center;
                    _radius = newCircle.radius;
                    if (AngleInArcRange(middleAngle, startAngle, endAngle))
                    {
                        this.startAngle = startAngle;
                        this.endAngle   = endAngle;
                    }
                    else
                    {
                        this.startAngle = endAngle;
                        this.endAngle   = startAngle;
                    }
                }
            }
        }
Example #5
0
 /// <summary>
 /// 设置夹点
 /// </summary>
 public override void SetGripPointAt(int index, GripPoint gripPoint, LitMath.Vector2 newPosition)
 {
     if (index == 0)
     {
         _startPoint = newPosition;
     }
     else if (index == 1)
     {
         _endPoint = newPosition;
     }
 }
Example #6
0
 /// <summary>
 /// 设置夹点
 /// </summary>
 public override void SetGripPointAt(int index, GripPoint gripPoint, LitMath.Vector2 newPosition)
 {
     if (index == 0)
     {
         _center = newPosition;
     }
     else if (index >= 1 && index <= 4)
     {
         _radius = (newPosition - _center).length;
     }
 }
Example #7
0
 /// <summary>
 /// 设置夹点
 /// </summary>
 public override void SetGripPointAt(int index, GripPoint gripPoint, LitMath.Vector2 newPosition)
 {
     if (index == 0)
     {
         _basePoint = newPosition;
     }
     else if (index == 1)
     {
         LitMath.Vector2 dir = (newPosition - _basePoint).normalized;
         if (!dir.Equals(new LitMath.Vector2(0, 0)))
         {
             _direction = dir;
         }
     }
 }
Example #8
0
        /// <summary>
        /// 获取夹点
        /// </summary>
        public override List <GripPoint> GetGripPoints()
        {
            List <GripPoint> gripPnts = new List <GripPoint>();

            //
            gripPnts.Add(new GripPoint(GripPointType.Center, _center));
            //
            GripPoint startGripPnt = new GripPoint(GripPointType.End, startPoint);

            startGripPnt.xData1 = middlePoint;
            gripPnts.Add(startGripPnt);
            //
            GripPoint endGripPnt = new GripPoint(GripPointType.End, endPoint);

            endGripPnt.xData1 = middlePoint;
            gripPnts.Add(endGripPnt);
            //
            gripPnts.Add(new GripPoint(GripPointType.Mid, middlePoint));

            return(gripPnts);
        }
Example #9
0
 /// <summary>
 /// 设置夹点
 /// </summary>
 public virtual void SetGripPointAt(int index, GripPoint gripPoint, LitMath.Vector2 newPosition)
 {
 }