public Matrix44 CalcPointTransform(float amount) { var length = 0f; var segmentCount = GetSegmentCount(); var scale = GlobalTransform.GetScale(false); for (int i = 0; i < segmentCount; i++) { var point1 = GetPoint(i); var point2 = GetPoint(i + 1); var segmentLength = ((point2.Position - point1.Position) * scale).Length; if (length <= amount && amount < length + segmentLength) { return(Interpolate((amount - length) / segmentLength, point1, point2)); } length += segmentLength; } if (Nodes.Count > 1) { return(Interpolate(1.0f, GetPoint(segmentCount - 1), GetPoint(segmentCount))); } if (Nodes.Count == 1) { return(Matrix44.CreateTranslation(((SplinePoint3D)Nodes[0]).Position)); } return(Matrix44.Identity); }
public float CalcLengthRough() { var length = 0f; var segmentCount = GetSegmentCount(); var scale = GlobalTransform.GetScale(false); for (int i = 0; i < segmentCount; i++) { length += ((GetPoint(i + 1).Position - GetPoint(i).Position) * scale).Length; } return(length); }