Example #1
0
 public CBuildLineAction(CVShape owner, CVPoint point, CVLineSegment segment, Vector3 hitPos) : base(owner)
 {
     point1       = new CVPointWrap(owner, point);
     this.segment = new CVSegmentWrap(owner, segment);
     this.hitPos  = segment.Owner.CalcHitPosition(this.segment.Index, hitPos);
     divideAction = new CDivideLineAction(Owner, segment.Owner, this.segment.Index, this.hitPos);
 }
Example #2
0
        public void SetPositions(Vector3 localStartPos, Vector3 localEndPos)
        {
            const float width = 0.03f;

            localStartPos = CVShape.CvtAxes(localStartPos);
            localEndPos   = CVShape.CvtAxes(localEndPos);
            Vector3 localDiff = transform.parent.rotation * (localEndPos - localStartPos);

            transform.localPosition = (localStartPos + localEndPos) * 0.5f;
            transform.localScale    = new Vector3(width, localDiff.magnitude * 0.5f, width);
            transform.up            = localDiff.normalized;
            StartCoroutine(CalcSegmentName());
        }
Example #3
0
        public Vector3 CalcHitPosition(int segmentIndex, Vector3 hitPosition)
        {
            Vector3   startPos = points[segmentIndex].Position;
            Vector3   endPos   = points[segmentIndex + 1].Position;
            Transform space    = SegmentAt(segmentIndex).transform.parent;
            Vector3   hitPos   = CVShape.DecvtAxes(space.worldToLocalMatrix * hitPosition);

            Vector3 direction = endPos - startPos;
            Vector3 diffrent  = startPos - hitPos;
            float   t         = -Vector3.Dot(direction, diffrent) / direction.sqrMagnitude;

            return(t * direction + startPos);
        }
Example #4
0
 public CAngleSettingAction(CVShape owner, CVLineSegment segment1, CVLineSegment segment2, int?angle = null) : base(owner)
 {
     this.segment1 = new CVSegmentWrap(Owner, segment1);
     this.segment2 = new CVSegmentWrap(Owner, segment2);
     this.angle    = angle;
 }
Example #5
0
 public CBuildLineAction(CVShape owner, CVPoint point1, CVPoint point2) : base(owner)
 {
     this.point1 = new CVPointWrap(owner, point1);
     this.point2 = new CVPointWrap(owner, point2);
 }
Example #6
0
 public CDivideLineAction(CVShape owner, CVLineSegment segment, Vector3 pointPosition)
     : this(owner, segment.Owner, segment.IndexInLine, pointPosition)
 {
 }
Example #7
0
 public CDivideLineAction(CVShape owner, CVLine line, int segmentIndex, Vector3 pointPosition) : base(owner)
 {
     pointAction = new CCreatePointAction(owner, pointPosition);
     segment     = new CVSegmentWrap(owner, line.Model.Id, segmentIndex);
     ratio       = 0;
 }
Example #8
0
 public CDivideLineAction(CVShape owner, CVLineSegment segment, float ratio)
     : this(owner, segment.Owner, segment.IndexInLine, ratio)
 {
 }
Example #9
0
 public CDivideLineAction(CVShape owner, CVLine line, int segmentIndex, float ratio)
     : this(owner, line, segmentIndex, Vector3.zero)
 {
     this.ratio = ratio;
 }
Example #10
0
 public CCreatePointAction(CVShape owner, Vector3 pointPosition) : base(owner)
 {
     pointPos = pointPosition;
 }
Example #11
0
 public CVSegmentWrap(CVShape owner, CVLineSegment segment)
     : this(owner, segment.Model.Id, segment.IndexInLine)
 {
 }
Example #12
0
 public CVSegmentWrap(CVShape owner) : this(owner, -1, -1)
 {
 }
Example #13
0
 public CVSegmentWrap(CVShape owner, int lineId, int segmentInd)
 {
     this.owner = owner;
     Id         = lineId;
     Index      = segmentInd;
 }
Example #14
0
 public CVPointWrap(CVShape owner, CVPoint point) : this(owner, point.Model.Id)
 {
 }
Example #15
0
 public CVPointWrap(CVShape owner, int pointId = -1)
 {
     this.owner = owner;
     Id         = pointId;
 }
Example #16
0
 public AShapeAction(CVShape owner)
 {
     Owner = owner;
 }