/// <summary> /// Calculate position and rotation for the transform and recursively call child transforms. /// </summary> public void Calc() { if (Parent == null) { _storedTotalChange = Change; } else { _storedTotalChange = Parent._storedTotalChange * Change; } if (Parent == null) { Position = SavedPosition; } else { Position = Parent.Position + Parent.Rotation * SavedLocalPosition; } Rotation = _storedTotalChange * SavedRotation; if (Child != null) { Child.Calc(); } }
/// <summary> /// Calculate position and rotation for the transform and recursively call child transforms. /// </summary> public void Calc() { if (Parent == null) { _storedTotalChange = Change; } else { _storedTotalChange = Parent._storedTotalChange * Change; } if (Parent == null) { Position = Link.position; } else { var local = Quaternion.Inverse(Parent.Link.rotation) * (Parent.Link.TransformPoint(Link.localPosition) - Parent.Link.position); Position = Parent.Position + Parent.Rotation * local; } Rotation = _storedTotalChange * Link.rotation; if (Child != null) { Child.Calc(); } }
/// <summary> /// Calculate position and rotation for the transform and recursively call child transforms. /// </summary> public void Calc() { if (Parent == null) { _storedTotalChange = Change; } else { _storedTotalChange = Parent._storedTotalChange * Change; } if (HasOffset) { var offsetOrientation = _storedTotalChange * OffsetOrientation; Rotation = offsetOrientation * SavedRotation; var offset = offsetOrientation * OffsetPosition; if (Parent == null) { Position = SavedPosition + offset; } else { Position = Parent.Position + Parent.Rotation * SavedLocalPosition + offset; } } else { Rotation = _storedTotalChange * SavedRotation; if (Parent == null) { Position = SavedPosition; } else { Position = Parent.Position + Parent.Rotation * SavedLocalPosition; } } if (Child != null) { Child.Calc(); } }