// //ORIGINAL LINE: Track convertToTrack(Track::AddressingMode addressingMode =Track::AM_RELATIVE_LINEIC) const // public Track convertToTrack(Track.AddressingMode addressingMode) { Track t = new Track(addressingMode); //for (List<Vector2>.Enumerator it = mPoints.GetEnumerator(); it.MoveNext(); ++it) foreach (var it in mPoints) { t.addKeyFrame(it.x, it.y); } return t; }
/// Creates a shape with the keys of this shape and extra keys coming from a track /// @param track the track to merge keys with /// @return a new Shape coming from the merge between original shape and the track //----------------------------------------------------------------------- // //ORIGINAL LINE: Shape mergeKeysWithTrack(const Track& track) const public Shape mergeKeysWithTrack(Track track) { if (!track.isInsertPoint() || track.getAddressingMode() == Track.AddressingMode.AM_POINT) return this; float totalLength = getTotalLength(); float lineicPos = 0; float shapeLineicPos = 0; Shape outputShape = new Shape(); if (mClosed) outputShape.close(); outputShape.addPoint(getPoint(0)); for (int i = 1; i < mPoints.Count; ) { float nextLineicPos = shapeLineicPos + (mPoints[i] - mPoints[i - 1]).Length; //std.map<Real,Real>.Enumerator it = track._getKeyValueAfter(lineicPos, lineicPos/totalLength, i-1); std_pair<float, float> it = track._getKeyValueAfter(lineicPos, lineicPos / totalLength, ((uint)i - 1)); float nextTrackPos = it.first; if (track.getAddressingMode() == Track.AddressingMode.AM_RELATIVE_LINEIC) nextTrackPos *= totalLength; // Adds the closest point to the curve, being either from the shape or the track if (nextLineicPos <= nextTrackPos || lineicPos >= nextTrackPos) { outputShape.addPoint(mPoints[i]); i++; lineicPos = nextLineicPos; shapeLineicPos = nextLineicPos; } else { outputShape.addPoint(getPosition((uint)i - 1, (nextTrackPos - shapeLineicPos) / (nextLineicPos - shapeLineicPos))); lineicPos = nextTrackPos; } } return outputShape; }
/// Creates a path with the keys of this path and extra keys coming from a track // //ORIGINAL LINE: Path mergeKeysWithTrack(const Track& track) const public Path mergeKeysWithTrack(Track track) { if (!track.isInsertPoint() || track.getAddressingMode() == Track.AddressingMode.AM_POINT) return this; float totalLength = getTotalLength(); float lineicPos = 0; float pathLineicPos = 0; Path outputPath = new Path(); outputPath.addPoint(getPoint(0)); for (int i = 1; i < mPoints.size(); ) { float nextLineicPos = pathLineicPos + (mPoints[i] - mPoints[i - 1]).Length; std_pair<float, float> it = track._getKeyValueAfter(lineicPos, lineicPos / totalLength, (uint)(i - 1)); float nextTrackPos = it.first; if (track.getAddressingMode() == Track.AddressingMode.AM_RELATIVE_LINEIC) nextTrackPos *= totalLength; // Adds the closest point to the curve, being either from the path or the track if (nextLineicPos <= nextTrackPos || lineicPos >= nextTrackPos) { outputPath.addPoint(mPoints[i]); i++; lineicPos = nextLineicPos; pathLineicPos = nextLineicPos; } else { outputPath.addPoint(getPosition(i - 1, (nextTrackPos - pathLineicPos) / (nextLineicPos - pathLineicPos))); lineicPos = nextTrackPos; } } return outputPath; }