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); }
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()); }
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); }
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; }
public CBuildLineAction(CVShape owner, CVPoint point1, CVPoint point2) : base(owner) { this.point1 = new CVPointWrap(owner, point1); this.point2 = new CVPointWrap(owner, point2); }
public CDivideLineAction(CVShape owner, CVLineSegment segment, Vector3 pointPosition) : this(owner, segment.Owner, segment.IndexInLine, pointPosition) { }
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; }
public CDivideLineAction(CVShape owner, CVLineSegment segment, float ratio) : this(owner, segment.Owner, segment.IndexInLine, ratio) { }
public CDivideLineAction(CVShape owner, CVLine line, int segmentIndex, float ratio) : this(owner, line, segmentIndex, Vector3.zero) { this.ratio = ratio; }
public CCreatePointAction(CVShape owner, Vector3 pointPosition) : base(owner) { pointPos = pointPosition; }
public CVSegmentWrap(CVShape owner, CVLineSegment segment) : this(owner, segment.Model.Id, segment.IndexInLine) { }
public CVSegmentWrap(CVShape owner) : this(owner, -1, -1) { }
public CVSegmentWrap(CVShape owner, int lineId, int segmentInd) { this.owner = owner; Id = lineId; Index = segmentInd; }
public CVPointWrap(CVShape owner, CVPoint point) : this(owner, point.Model.Id) { }
public CVPointWrap(CVShape owner, int pointId = -1) { this.owner = owner; Id = pointId; }
public AShapeAction(CVShape owner) { Owner = owner; }