Exemplo n.º 1
0
 public AnimationCurveTpl(KeyframeTpl <T> keyframe1, KeyframeTpl <T> keyframe2) :
     this(false)
 {
     m_curve    = new KeyframeTpl <T> [2];
     m_curve[0] = keyframe1;
     m_curve[1] = keyframe2;
 }
Exemplo n.º 2
0
 public AnimationCurveTpl(T value1, T inSlope1, T outSlope1, T value2, T inSlope2, T outSlope2, T defaultWeight) :
     this(false)
 {
     m_curve    = new KeyframeTpl <T> [2];
     m_curve[0] = new KeyframeTpl <T>(0.0f, value1, inSlope1, outSlope1, defaultWeight);
     m_curve[1] = new KeyframeTpl <T>(1.0f, value2, inSlope2, outSlope2, defaultWeight);
 }
Exemplo n.º 3
0
 public AnimationCurveTpl(T defaultValue, T defaultWeight) :
     this(false)
 {
     m_curve    = new KeyframeTpl <T> [2];
     m_curve[0] = new KeyframeTpl <T>(0.0f, defaultValue, defaultWeight);
     m_curve[1] = new KeyframeTpl <T>(1.0f, defaultValue, defaultWeight);
 }
Exemplo n.º 4
0
 public AnimationCurveTpl(T value0, T inSlope0, T outSlope0, T value1, T inSlope1, T outSlope1, T defaultWeight) :
     this(true)
 {
     KeyframeTpl <T> firstKey  = new KeyframeTpl <T>(0.0f, value0, inSlope0, outSlope0, defaultWeight);
     KeyframeTpl <T> secondKey = new KeyframeTpl <T>(1.0f, value1, inSlope1, outSlope1, defaultWeight);
     Curve.Add(firstKey);
     Curve.Add(secondKey);
 }
Exemplo n.º 5
0
 public AnimationCurveTpl(T defaultValue, T defaultWeight) :
     this(true)
 {
     KeyframeTpl <T> firstKey  = new KeyframeTpl <T>(0.0f, defaultValue, defaultWeight);
     KeyframeTpl <T> secondKey = new KeyframeTpl <T>(1.0f, defaultValue, defaultWeight);
     Curve.Add(firstKey);
     Curve.Add(secondKey);
 }
Exemplo n.º 6
0
 public AnimationCurveTpl(IReadOnlyList <KeyframeTpl <T> > keyframes) :
     this(false)
 {
     m_curve = new KeyframeTpl <T> [keyframes.Count];
     for (int i = 0; i < keyframes.Count; i++)
     {
         m_curve[i] = keyframes[i];
     }
 }
Exemplo n.º 7
0
 public KeyframeTpl(KeyframeTpl <T> copy)
 {
     Time         = copy.Time;
     Value        = copy.Value;
     InSlope      = copy.InSlope;
     OutSlope     = copy.OutSlope;
     WeightedMode = copy.WeightedMode;
     InWeight     = copy.InWeight;
     OutWeight    = copy.OutWeight;
 }
Exemplo n.º 8
0
        public AnimationCurveTpl(AnimationCurveTpl <T> copy)
        {
            Curve = new List <KeyframeTpl <T> >(copy.Curve.Count);
            foreach (KeyframeTpl <T> keyframe in copy.Curve)
            {
                KeyframeTpl <T> keyframeCopy = new KeyframeTpl <T>(keyframe);
                Curve.Add(keyframeCopy);
            }

            PreInfinity   = copy.PreInfinity;
            PostInfinity  = copy.PostInfinity;
            RotationOrder = copy.RotationOrder;
        }
Exemplo n.º 9
0
 private IReadOnlyList <KeyframeTpl <T> > GetCurves()
 {
     if (Curve.Count == 1)
     {
         KeyframeTpl <T>   firstKey  = Curve[0];
         KeyframeTpl <T>   secondKey = new KeyframeTpl <T>(firstKey.Time + 0.1f, firstKey);
         KeyframeTpl <T>[] curves    = new KeyframeTpl <T> [2];
         curves[0] = firstKey;
         curves[1] = secondKey;
         return(curves);
     }
     else
     {
         return(Curve);
     }
 }
Exemplo n.º 10
0
        private void AddComplexCurve(float time, BindingType bindType, IReadOnlyList <float> curveValues, int offset, string path)
        {
            switch (bindType)
            {
            case BindingType.Translation:
            {
                float x = curveValues[offset + 0];
                float y = curveValues[offset + 1];
                float z = curveValues[offset + 2];

                if (!m_translations.TryGetValue(path, out Vector3Curve transCurve))
                {
                    transCurve = new Vector3Curve(path);
                }

                Vector3f trans     = new Vector3f(x, y, z);
                Vector3f defWeight = new Vector3f(1.0f / 3.0f);
                KeyframeTpl <Vector3f> transKey = new KeyframeTpl <Vector3f>(time, trans, defWeight);
                transCurve.Curve.Curve.Add(transKey);
                m_translations[path] = transCurve;
            }
            break;

            case BindingType.Rotation:
            {
                float x = curveValues[offset + 0];
                float y = curveValues[offset + 1];
                float z = curveValues[offset + 2];
                float w = curveValues[offset + 3];

                if (!m_rotations.TryGetValue(path, out QuaternionCurve rotCurve))
                {
                    rotCurve = new QuaternionCurve(path);
                }

                Quaternionf rot                  = new Quaternionf(x, y, z, w);
                Quaternionf defWeight            = new Quaternionf(1.0f / 3.0f);
                KeyframeTpl <Quaternionf> rotKey = new KeyframeTpl <Quaternionf>(time, rot, defWeight);
                rotCurve.Curve.Curve.Add(rotKey);
                m_rotations[path] = rotCurve;
            }
            break;

            case BindingType.Scaling:
            {
                float x = curveValues[offset + 0];
                float y = curveValues[offset + 1];
                float z = curveValues[offset + 2];

                if (!m_scales.TryGetValue(path, out Vector3Curve scaleCurve))
                {
                    scaleCurve = new Vector3Curve(path);
                }

                Vector3f scale     = new Vector3f(x, y, z);
                Vector3f defWeight = new Vector3f(1.0f / 3.0f);
                KeyframeTpl <Vector3f> scaleKey = new KeyframeTpl <Vector3f>(time, scale, defWeight);
                scaleCurve.Curve.Curve.Add(scaleKey);
                m_scales[path] = scaleCurve;
            }
            break;

            case BindingType.EulerRotation:
            {
                float x = curveValues[offset + 0];
                float y = curveValues[offset + 1];
                float z = curveValues[offset + 2];

                if (!m_eulers.TryGetValue(path, out Vector3Curve eulerCurve))
                {
                    eulerCurve = new Vector3Curve(path);
                }

                Vector3f euler     = new Vector3f(x, y, z);
                Vector3f defWeight = new Vector3f(1.0f / 3.0f);
                KeyframeTpl <Vector3f> eulerKey = new KeyframeTpl <Vector3f>(time, euler, defWeight);
                eulerCurve.Curve.Curve.Add(eulerKey);
                m_eulers[path] = eulerCurve;
            }
            break;

            case BindingType.Floats:
            {
                float value = curveValues[offset];

                if (!m_floats.TryGetValue(path, out FloatCurve floatCurve))
                {
                    floatCurve = new FloatCurve(path);
                }

                Float @float    = new Float(value);
                Float defWeight = new Float(1.0f / 3.0f);
                KeyframeTpl <Float> floatKey = new KeyframeTpl <Float>(time, @float, defWeight);
                floatCurve.Curve.Curve.Add(floatKey);
                m_floats[path] = floatCurve;
            }
            break;

            default:
                throw new NotImplementedException(bindType.ToString());
            }
        }
Exemplo n.º 11
0
 public KeyframeTpl(float time, KeyframeTpl <T> copy) :
     this(copy)
 {
     Time = time;
 }
Exemplo n.º 12
0
        private void AddComplexCurve(float time, BindingType bindType, IReadOnlyList <float> curveValues,
                                     IReadOnlyList <float> inSlopeValues, IReadOnlyList <float> outSlopeValues, int offset, string path)
        {
            switch (bindType)
            {
            case BindingType.Translation:
            {
                if (!m_translations.TryGetValue(path, out List <KeyframeTpl <Vector3f> > transCurve))
                {
                    transCurve = new List <KeyframeTpl <Vector3f> >();
                    m_translations.Add(path, transCurve);
                }

                float x = curveValues[offset + 0];
                float y = curveValues[offset + 1];
                float z = curveValues[offset + 2];

                float inX = inSlopeValues[0];
                float inY = inSlopeValues[1];
                float inZ = inSlopeValues[2];

                float outX = outSlopeValues[0];
                float outY = outSlopeValues[1];
                float outZ = outSlopeValues[2];

                Vector3f value     = new Vector3f(x, y, z);
                Vector3f inSlope   = new Vector3f(inX, inY, inZ);
                Vector3f outSlope  = new Vector3f(outX, outY, outZ);
                Vector3f defWeight = new Vector3f(1.0f / 3.0f);
                KeyframeTpl <Vector3f> transKey = new KeyframeTpl <Vector3f>(time, value, inSlope, outSlope, defWeight);
                transCurve.Add(transKey);
                m_translations[path] = transCurve;
            }
            break;

            case BindingType.Rotation:
            {
                if (!m_rotations.TryGetValue(path, out List <KeyframeTpl <Quaternionf> > rotCurve))
                {
                    rotCurve = new List <KeyframeTpl <Quaternionf> >();
                    m_rotations.Add(path, rotCurve);
                }

                float x = curveValues[offset + 0];
                float y = curveValues[offset + 1];
                float z = curveValues[offset + 2];
                float w = curveValues[offset + 3];

                float inX = 0;                                //inSlopeValues[0];
                float inY = 0;                                //inSlopeValues[1];
                float inZ = 0;                                //inSlopeValues[2];
                float inW = 0;                                //inSlopeValues[3];

                float outX = 0;                               //outSlopeValues[0];
                float outY = 0;                               //outSlopeValues[1];
                float outZ = 0;                               //outSlopeValues[2];
                float outW = 0;                               //outSlopeValues[3];

                Quaternionf value                = new Quaternionf(x, y, z, w);
                Quaternionf inSlope              = new Quaternionf(inX, inY, inZ, inW);
                Quaternionf outSlope             = new Quaternionf(outX, outY, outZ, outW);
                Quaternionf defWeight            = new Quaternionf(1.0f / 3.0f);
                KeyframeTpl <Quaternionf> rotKey = new KeyframeTpl <Quaternionf>(time, value, inSlope, outSlope, defWeight);
                rotCurve.Add(rotKey);
                m_rotations[path] = rotCurve;
            }
            break;

            case BindingType.Scaling:
            {
                if (!m_scales.TryGetValue(path, out List <KeyframeTpl <Vector3f> > scaleCurve))
                {
                    scaleCurve = new List <KeyframeTpl <Vector3f> >();
                    m_scales.Add(path, scaleCurve);
                }

                float x = curveValues[offset + 0];
                float y = curveValues[offset + 1];
                float z = curveValues[offset + 2];

                float inX = inSlopeValues[0];
                float inY = inSlopeValues[1];
                float inZ = inSlopeValues[2];

                float outX = outSlopeValues[0];
                float outY = outSlopeValues[1];
                float outZ = outSlopeValues[2];

                Vector3f value     = new Vector3f(x, y, z);
                Vector3f inSlope   = new Vector3f(inX, inY, inZ);
                Vector3f outSlope  = new Vector3f(outX, outY, outZ);
                Vector3f defWeight = new Vector3f(1.0f / 3.0f);
                KeyframeTpl <Vector3f> scaleKey = new KeyframeTpl <Vector3f>(time, value, inSlope, outSlope, defWeight);
                scaleCurve.Add(scaleKey);
                m_scales[path] = scaleCurve;
            }
            break;

            case BindingType.EulerRotation:
            {
                if (!m_eulers.TryGetValue(path, out List <KeyframeTpl <Vector3f> > eulerCurve))
                {
                    eulerCurve = new List <KeyframeTpl <Vector3f> >();
                    m_eulers.Add(path, eulerCurve);
                }

                float x = curveValues[offset + 0];
                float y = curveValues[offset + 1];
                float z = curveValues[offset + 2];

                float inX = inSlopeValues[0];
                float inY = inSlopeValues[1];
                float inZ = inSlopeValues[2];

                float outX = outSlopeValues[0];
                float outY = outSlopeValues[1];
                float outZ = outSlopeValues[2];

                Vector3f value     = new Vector3f(x, y, z);
                Vector3f inSlope   = new Vector3f(inX, inY, inZ);
                Vector3f outSlope  = new Vector3f(outX, outY, outZ);
                Vector3f defWeight = new Vector3f(1.0f / 3.0f);
                KeyframeTpl <Vector3f> eulerKey = new KeyframeTpl <Vector3f>(time, value, inSlope, outSlope, defWeight);
                eulerCurve.Add(eulerKey);
                m_eulers[path] = eulerCurve;
            }
            break;

            case BindingType.Floats:
            {
                if (!m_floats.TryGetValue(path, out List <KeyframeTpl <Float> > floatCurve))
                {
                    floatCurve = new List <KeyframeTpl <Float> >();
                    m_floats.Add(path, floatCurve);
                }

                float x    = curveValues[offset];
                float inX  = inSlopeValues[0];
                float outX = outSlopeValues[0];

                Float value     = new Float(x);
                Float inSlope   = new Float(inX);
                Float outSlope  = new Float(outX);
                Float defWeight = new Float(1.0f / 3.0f);
                KeyframeTpl <Float> floatKey = new KeyframeTpl <Float>(time, value, inSlope, outSlope, defWeight);
                floatCurve.Add(floatKey);
                m_floats[path] = floatCurve;
            }
            break;

            default:
                throw new NotImplementedException(bindType.ToString());
            }
        }
Exemplo n.º 13
0
 public AnimationCurveTpl(KeyframeTpl <T> keyframe) :
     this(false)
 {
     m_curve    = new KeyframeTpl <T> [1];
     m_curve[0] = keyframe;
 }