Esempio n. 1
0
 // Explicit constructor since we need to populate the Range value
 public LineElement(IndexLinePoint start, IndexLinePoint end)
 {
     Start   = start;
     End     = end;
     IsFirst = false;
     IsLast  = false;
     Range   = End.Position - Start.Position;
 }
Esempio n. 2
0
        protected List <AnimationSample> CalculateElements()
        {
            List <AnimationSample> samplePoints = new List <AnimationSample>();
            List <LineElement>     lineElements = new List <LineElement>();

            mGridElements.Clear();
            for (int i = 0; i < mSamples.Count; ++i)
            {
                samplePoints.Add(new AnimationSample(mSamples[i].Animation, mSamples[i].Value));
            }
            if (samplePoints.Count > 1)
            {
                samplePoints.Sort((a, b) =>
                {
                    if (a.Value.X > b.Value.X)
                    {
                        return(1);
                    }
                    if (a.Value.X == b.Value.X)
                    {
                        return(0);
                    }
                    else
                    {
                        return(-1);
                    }
                });

                for (int index = 0; index < samplePoints.Count - 1; ++index)
                {
                    var endIndex   = index + 1;
                    var startPoint = new IndexLinePoint(samplePoints[index].Value.X, index);
                    var endPoint   = new IndexLinePoint(samplePoints[endIndex].Value.X, endIndex);
                    lineElements.Add(new LineElement(startPoint, endPoint));
                }
                lineElements[0].IsFirst = true;
                lineElements[lineElements.Count - 1].IsLast = true;
            }

            var gridRange = mBlendAxises[0].Max - mBlendAxises[0].Min;
            var gridSize  = gridRange / mBlendAxises[0].GridNum;

            for (int i = 0; i < mBlendAxises[0].GridNum + 1; ++i)
            {
                mGridElements.Add(new GridElement(3));
            }

            if (lineElements.Count == 0)
            {
                for (int i = 0; i < mGridElements.Count; ++i)
                {
                    mGridElements[i].Indices[0] = 0;
                    mGridElements[i].Weights[0] = 1.0f;
                }
            }
            else
            {
                for (int elementIndex = 0; elementIndex < mBlendAxises[0].GridNum + 1; ++elementIndex)
                {
                    var element   = mGridElements[elementIndex];
                    var posIngrid = gridSize * elementIndex + mBlendAxises[0].Min;
                    // Try and populate the editor element
                    bool bPopulatedElement = false;
                    for (int i = 0; i < lineElements.Count; ++i)
                    {
                        bPopulatedElement |= lineElements[i].PopulateElement(posIngrid, ref element);
                        if (bPopulatedElement)
                        {
                            break;
                        }
                    }

                    // Ensure that the editor element is populated using the available sample data
                }
            }
            return(samplePoints);
        }