コード例 #1
0
        /// <summary>
        /// Averages the intersection point at the start of this chunk with the intersection point at the end of the previous chunk, weighted equally.
        /// </summary>
        /// <param name="currentChunkToAdd">The current chunk of points under consideration</param>
        /// <param name="intersectionPointAtStart">The intersection point at the start of the current chunk</param>
        /// <param name="previousChunk">The previous chunk of points</param>
        private static Vector2WithUV AverageIntersectionPointsEqually(ChunkBetweenIntersections currentChunkToAdd, Vector2WithUV intersectionPointAtStart, ChunkBetweenIntersections previousChunk)
        {
            var intersectionPointAtPreviousEnd   = new Vector2WithUV(previousChunk.EndIntersection);
            var averagedIntersectionPointAtStart = intersectionPointAtStart.AverageWith(intersectionPointAtPreviousEnd, 0.5f);

            return(averagedIntersectionPointAtStart);
        }
コード例 #2
0
        /// <summary>
        /// Convert a list of <see cref="ChunkBetweenIntersectionsCollection"/> into a list of <see cref="Vector2WithUV[]"/>.
        /// </summary>
        /// <param name="chunkCollectionList">A list of <see cref="ChunkBetweenIntersectionsCollection"/>.</param>
        /// <param name="intersectionUVCalculation">Method for calculating UV of intersection points</param>
        public List <Vector2WithUV[]> ConnnectChunksBetweenIntersectionsIntoPointsLists(List <ChunkBetweenIntersectionsCollection> chunkCollectionList)
        {
            List <Vector2WithUV[]> ret = new List <Vector2WithUV[]>();

            for (int i = 0; i < chunkCollectionList.Count; i++)
            {
                var             currentChunkCollection          = chunkCollectionList[i];
                var             currentChunkCollectionNumPoints = currentChunkCollection.TotalNumberOfPoints;
                Vector2WithUV[] currentChunkArray = new Vector2WithUV[currentChunkCollectionNumPoints];
                int             index             = 0;
                for (int chunkIndex = 0; chunkIndex < currentChunkCollection.Chunks.Count; chunkIndex++)
                {
                    var currentChunkToAdd = currentChunkCollection.Chunks[chunkIndex];

                    //Add start intersection
                    var intersectionPointAtStart = new Vector2WithUV(currentChunkToAdd.StartIntersection);
                    if (chunkIndex > 0)
                    {
                        ChunkBetweenIntersections previousChunk = currentChunkCollection.Chunks[chunkIndex - 1];
                        intersectionPointAtStart = DetermineChunkStartIntersectionPointWithRecalculatedUVs(currentChunkToAdd, intersectionPointAtStart, previousChunk);
                    }

                    currentChunkArray[index++] = intersectionPointAtStart;

                    //Add middle points
                    for (int k = 0; k < currentChunkToAdd.ExtrudedPoints.Count; k++)
                    {
                        currentChunkArray[index++] = new Vector2WithUV(currentChunkToAdd.ExtrudedPoints[k]);
                    }

                    //If at the very end, add final point
                    if (chunkIndex == currentChunkCollection.Chunks.Count - 1)
                    {
                        currentChunkArray[index++] = new Vector2WithUV(currentChunkToAdd.EndIntersection);
                    }
                }
                ret.Add(currentChunkArray);
            }

            return(ret);
        }
コード例 #3
0
 /// <summary>
 /// Determines the intersection point calculated from the one at the start of a given chunk with the intersection point at the end of the previous chunk.
 /// </summary>
 /// <param name="currentChunkToAdd">The current chunk of points under consideration</param>
 /// <param name="intersectionPointAtStart">The intersection point at the start of the current chunk</param>
 /// <param name="previousChunk">The previous chunk of points</param>
 protected abstract Vector2WithUV DetermineChunkStartIntersectionPointWithRecalculatedUVs(ChunkBetweenIntersections currentChunkToAdd, Vector2WithUV intersectionPointAtStart, ChunkBetweenIntersections previousChunk);
コード例 #4
0
 /// <summary>
 /// Determines the intersection point calculated from the one at the start of a given chunk with the intersection point at the end of the previous chunk.
 /// </summary>
 /// <param name="currentChunkToAdd">The current chunk of points under consideration</param>
 /// <param name="intersectionPointAtStart">The intersection point at the start of the current chunk</param>
 /// <param name="previousChunk">The previous chunk of points</param>
 protected override Vector2WithUV DetermineChunkStartIntersectionPointWithRecalculatedUVs(ChunkBetweenIntersections currentChunkToAdd, Vector2WithUV intersectionPointAtStart, ChunkBetweenIntersections previousChunk)
 {
     return(AverageIntersectionPointsEqually(currentChunkToAdd, intersectionPointAtStart, previousChunk));
 }
コード例 #5
0
        /// <summary>
        /// Determine if a chunk of extruded points is too close to a line of points, determined by comparing the extruded point whose parameter is furthest from any intersection points.
        /// </summary>
        /// <param name="extrudedContinuousChunk">Chunk of extruded points between two intersection endpoints.</param>
        /// <param name="linePoints">Points on the line from which to determine distance.</param>
        /// <param name="intersectionPoints">All intersection points between extruded segments.</param>
        /// <param name="extrusionAmount">The extrusion amount.</param>
        private static bool IsExtractedContinuousChunkooClose_DeterminedFromFurthestParameter(ChunkBetweenIntersections extrudedContinuousChunk, SegmentwiseLinePointListUV linePoints, IList <IntersectionPoint> intersectionPoints, float extrusionAmount)
        {
            bool tooClose;

            if (extrudedContinuousChunk.ExtrudedPoints.Count > 0)
            {
                var pointToCheck = PointOfLargestParameterDifference(extrudedContinuousChunk.ExtrudedPoints, intersectionPoints);
                tooClose = SegmentedLineUtil.IsCloserThanExtrusionDistance_Segmentwise(pointToCheck, linePoints, extrusionAmount);
            }
            else
            {
                tooClose = IsIntersectionPointChunkSegmentCloserThanExtrusionDistance(extrudedContinuousChunk.StartIntersection, extrudedContinuousChunk.EndIntersection, linePoints, extrusionAmount);
            }
            return(tooClose);
        }