public void Evaluate(int SpreadMax)
        {
            if (this.FInChannels.IsChanged || this.FInTime.IsChanged)
            {
                this.FOutName.SliceCount     = this.FInChannels.SliceCount;
                this.FOutPos.SliceCount      = this.FInChannels.SliceCount;
                this.FOutRotation.SliceCount = this.FInChannels.SliceCount;
                this.FOutScale.SliceCount    = this.FInChannels.SliceCount;


                for (int i = 0; i < this.FInChannels.SliceCount; i++)
                {
                    AssimpAnimationChannel chan = this.FInChannels[i];
                    this.FOutName[i] = chan.Name;

                    double t        = this.FInTime[i];
                    double duration = this.FInDuration[i];

                    double dt = t * duration;

                    this.FOutPos[i]      = this.InterpolatePosition(dt, chan);
                    this.FOutScale[i]    = this.InterpolateScale(dt, chan);
                    this.FOutRotation[i] = this.InterpolateRotation(dt, chan);
                }
            }
        }
        private Vector3 InterpolatePosition(double dt, AssimpAnimationChannel chan)
        {
            if (chan.PositionKeys.Count == 1)
            {
                return(chan.PositionKeys[0].Value);
            }

            Vector3 pos;
            int     pc = chan.PositionKeys.Count - 1;

            if (dt < chan.PositionKeys[0].Time)
            {
                pos = chan.PositionKeys[0].Value;
            }                                     //Before first element
            else if (dt > chan.PositionKeys[pc].Time)
            {
                pos = chan.PositionKeys[pc].Value;
            }                                      //After last element
            else
            {
                double mindist = double.MaxValue;
                int    idx     = -1;
                for (int j = 0; j < chan.PositionKeys.Count; j++)
                {
                    double dist = Math.Abs(dt - chan.PositionKeys[j].Time);
                    if (dist < mindist)
                    {
                        mindist = dist; idx = j;
                    }
                }

                AnimVectorKey curr = chan.PositionKeys[idx];

                //Interpolate with next or previous
                if (dt > chan.PositionKeys[idx].Time)
                {
                    //Interpolate with next
                    AnimVectorKey next   = chan.PositionKeys[idx + 1];
                    double        amount = (dt - curr.Time) / (next.Time - curr.Time);
                    pos = Vector3.Lerp(curr.Value, next.Value, Convert.ToSingle(amount));
                }
                else
                {
                    if (idx == 0)
                    {
                        pos = chan.PositionKeys[0].Value;
                    }
                    else
                    {
                        //Interpolate with previous
                        AnimVectorKey prev   = chan.PositionKeys[idx - 1];
                        double        amount = (dt - prev.Time) / (curr.Time - prev.Time);
                        pos = Vector3.Lerp(prev.Value, curr.Value, Convert.ToSingle(amount));
                    }
                }
            }
            return(pos);
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInChannels.IsChanged)
            {
                this.FOutName.SliceCount           = this.FInChannels.SliceCount;
                this.FOutPosTime.SliceCount        = this.FInChannels.SliceCount;
                this.FOutPosValues.SliceCount      = this.FInChannels.SliceCount;
                this.FOutScaleTime.SliceCount      = this.FInChannels.SliceCount;
                this.FOutScaleValues.SliceCount    = this.FInChannels.SliceCount;
                this.FOutRotationTime.SliceCount   = this.FInChannels.SliceCount;
                this.FOutRotationValues.SliceCount = this.FInChannels.SliceCount;

                for (int i = 0; i < this.FInChannels.SliceCount; i++)
                {
                    AssimpAnimationChannel chan = this.FInChannels[i];
                    this.FOutName[i] = chan.Name;

                    //Position
                    this.FOutPosTime[i].SliceCount   = chan.PositionKeys.Count;
                    this.FOutPosValues[i].SliceCount = chan.PositionKeys.Count;

                    for (int j = 0; j < chan.PositionKeys.Count; j++)
                    {
                        this.FOutPosTime[i][j]   = chan.PositionKeys[j].Time;
                        this.FOutPosValues[i][j] = chan.PositionKeys[j].Value;
                    }

                    //Scaling
                    this.FOutScaleTime[i].SliceCount   = chan.ScalingKeys.Count;
                    this.FOutScaleValues[i].SliceCount = chan.ScalingKeys.Count;

                    for (int j = 0; j < chan.ScalingKeys.Count; j++)
                    {
                        this.FOutScaleTime[i][j]   = chan.ScalingKeys[j].Time;
                        this.FOutScaleValues[i][j] = chan.ScalingKeys[j].Value;
                    }

                    //Rotation
                    this.FOutRotationTime[i].SliceCount   = chan.RotationKeys.Count;
                    this.FOutRotationValues[i].SliceCount = chan.RotationKeys.Count;

                    for (int j = 0; j < chan.RotationKeys.Count; j++)
                    {
                        this.FOutRotationTime[i][j]   = chan.RotationKeys[j].Time;
                        this.FOutRotationValues[i][j] = chan.RotationKeys[j].Value;
                    }
                }
            }
        }
        private Vector3 InterpolatePosition(double dt, AssimpAnimationChannel chan)
        {
            if (chan.PositionKeys.Count == 1) { return chan.PositionKeys[0].Value; }

            Vector3 pos;
            int pc = chan.PositionKeys.Count - 1;
            if (dt < chan.PositionKeys[0].Time)
            { pos = chan.PositionKeys[0].Value; } //Before first element
            else if (dt > chan.PositionKeys[pc].Time)
            { pos = chan.PositionKeys[pc].Value; } //After last element
            else
            {
                double mindist = double.MaxValue;
                int idx = -1;
                for (int j = 0; j < chan.PositionKeys.Count; j++)
                {
                    double dist = Math.Abs(dt - chan.PositionKeys[j].Time);
                    if (dist < mindist) { mindist = dist; idx = j; }
                }

                AnimVectorKey curr = chan.PositionKeys[idx];

                //Interpolate with next or previous
                if (dt > chan.PositionKeys[idx].Time)
                {
                    //Interpolate with next
                    AnimVectorKey next = chan.PositionKeys[idx + 1];
                    double amount = (dt - curr.Time) / (next.Time - curr.Time);
                    pos = Vector3.Lerp(curr.Value, next.Value, Convert.ToSingle(amount));
                }
                else
                {
                    if (idx == 0)
                    {
                        pos = chan.PositionKeys[0].Value;
                    }
                    else
                    {
                        //Interpolate with previous
                        AnimVectorKey prev = chan.PositionKeys[idx - 1];
                        double amount = (dt - prev.Time) / (curr.Time - prev.Time);
                        pos = Vector3.Lerp(prev.Value, curr.Value, Convert.ToSingle(amount));
                    }
                }
            }
            return pos;
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInChannels.IsChanged || this.FinIgnoreDups.IsChanged)
            {
                this.FOutName.SliceCount   = this.FInChannels.SliceCount;
                this.FOutLength.SliceCount = this.FInChannels.SliceCount;
                this.FOutStart.SliceCount  = this.FInChannels.SliceCount;
                this.FOutEnd.SliceCount    = this.FInChannels.SliceCount;


                for (int i = 0; i < this.FInChannels.SliceCount; i++)
                {
                    double starttime = double.MaxValue;
                    double endtime   = double.MinValue;

                    AssimpAnimationChannel chan = this.FInChannels[i];
                    this.FOutName[i] = chan.Name;

                    for (int j = 0; j < chan.PositionKeys.Count; j++)
                    {
                        if (chan.PositionKeys.Count > 1)
                        {
                            if (this.FinIgnoreDups[0])
                            {
                                if (chan.PositionKeys.Count > 2)
                                {
                                    if (j == 0)
                                    {
                                        if (chan.PositionKeys[j].Value != chan.PositionKeys[j + 1].Value)
                                        {
                                            if (chan.PositionKeys[j].Time > endtime)
                                            {
                                                endtime = chan.PositionKeys[j].Time;
                                            }
                                            if (chan.PositionKeys[j].Time < starttime)
                                            {
                                                starttime = chan.PositionKeys[j].Time;
                                            }
                                        }
                                    }
                                    else if (j == chan.PositionKeys.Count - 1)
                                    {
                                        if (chan.PositionKeys[j].Value != chan.PositionKeys[j - 1].Value)
                                        {
                                            if (chan.PositionKeys[j].Time > endtime)
                                            {
                                                endtime = chan.PositionKeys[j].Time;
                                            }
                                            if (chan.PositionKeys[j].Time < starttime)
                                            {
                                                starttime = chan.PositionKeys[j].Time;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (chan.PositionKeys[j].Time > endtime)
                                        {
                                            endtime = chan.PositionKeys[j].Time;
                                        }
                                        if (chan.PositionKeys[j].Time < starttime)
                                        {
                                            starttime = chan.PositionKeys[j].Time;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (chan.PositionKeys[j].Time > endtime)
                                {
                                    endtime = chan.PositionKeys[j].Time;
                                }
                                if (chan.PositionKeys[j].Time < starttime)
                                {
                                    starttime = chan.PositionKeys[j].Time;
                                }
                            }
                        }
                    }

                    for (int j = 0; j < chan.ScalingKeys.Count; j++)
                    {
                        if (this.FinIgnoreDups[0])
                        {
                            if (chan.ScalingKeys.Count > 2)
                            {
                                if (j == 0)
                                {
                                    if (chan.ScalingKeys[j].Value != chan.ScalingKeys[j + 1].Value)
                                    {
                                        if (chan.ScalingKeys[j].Time > endtime)
                                        {
                                            endtime = chan.ScalingKeys[j].Time;
                                        }
                                        if (chan.ScalingKeys[j].Time < starttime)
                                        {
                                            starttime = chan.ScalingKeys[j].Time;
                                        }
                                    }
                                }
                                else if (j == chan.ScalingKeys.Count - 1)
                                {
                                    if (chan.ScalingKeys[j].Value != chan.ScalingKeys[j - 1].Value)
                                    {
                                        if (chan.ScalingKeys[j].Time > endtime)
                                        {
                                            endtime = chan.ScalingKeys[j].Time;
                                        }
                                        if (chan.ScalingKeys[j].Time < starttime)
                                        {
                                            starttime = chan.ScalingKeys[j].Time;
                                        }
                                    }
                                }
                                else
                                {
                                    if (chan.ScalingKeys.Count > 1)
                                    {
                                        if (chan.ScalingKeys[j].Time > endtime)
                                        {
                                            endtime = chan.ScalingKeys[j].Time;
                                        }
                                        if (chan.ScalingKeys[j].Time < starttime)
                                        {
                                            starttime = chan.ScalingKeys[j].Time;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (chan.ScalingKeys.Count > 1)
                            {
                                if (chan.ScalingKeys[j].Time > endtime)
                                {
                                    endtime = chan.ScalingKeys[j].Time;
                                }
                                if (chan.ScalingKeys[j].Time < starttime)
                                {
                                    starttime = chan.ScalingKeys[j].Time;
                                }
                            }
                        }
                    }

                    for (int j = 0; j < chan.RotationKeys.Count; j++)
                    {
                        if (this.FinIgnoreDups[0])
                        {
                            if (chan.RotationKeys.Count > 2)
                            {
                                if (j == 0)
                                {
                                    if (chan.RotationKeys[j].Value != chan.RotationKeys[j + 1].Value)
                                    {
                                        if (chan.RotationKeys[j].Time > endtime)
                                        {
                                            endtime = chan.RotationKeys[j].Time;
                                        }
                                        if (chan.RotationKeys[j].Time < starttime)
                                        {
                                            starttime = chan.RotationKeys[j].Time;
                                        }
                                    }
                                }
                                else if (j == chan.RotationKeys.Count - 1)
                                {
                                    if (chan.RotationKeys[j].Value != chan.RotationKeys[j - 1].Value)
                                    {
                                        if (chan.RotationKeys[j].Time > endtime)
                                        {
                                            endtime = chan.RotationKeys[j].Time;
                                        }
                                        if (chan.RotationKeys[j].Time < starttime)
                                        {
                                            starttime = chan.RotationKeys[j].Time;
                                        }
                                    }
                                }
                                else
                                {
                                    if (chan.RotationKeys[j].Time > endtime)
                                    {
                                        endtime = chan.RotationKeys[j].Time;
                                    }
                                    if (chan.RotationKeys[j].Time < starttime)
                                    {
                                        starttime = chan.RotationKeys[j].Time;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (chan.RotationKeys.Count > 1)
                            {
                                if (chan.RotationKeys[j].Time > endtime)
                                {
                                    endtime = chan.RotationKeys[j].Time;
                                }
                                if (chan.RotationKeys[j].Time < starttime)
                                {
                                    starttime = chan.RotationKeys[j].Time;
                                }
                            }
                        }
                    }

                    this.FOutStart[i]  = starttime;
                    this.FOutEnd[i]    = endtime;
                    this.FOutLength[i] = endtime - starttime;
                }
            }
        }