private void AddTransformCurve(float time, TransformType transType, IReadOnlyList <float> curveValues,
                                       IReadOnlyList <float> inSlopeValues, IReadOnlyList <float> outSlopeValues, int offset, string path)
        {
            switch (transType)
            {
            case TransformType.Translation:
            {
                Vector3Curve curve = new Vector3Curve(path);
                if (!m_translations.TryGetValue(curve, out List <KeyframeTpl <Vector3f> > transCurve))
                {
                    transCurve = new List <KeyframeTpl <Vector3f> >();
                    m_translations.Add(curve, 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);
                KeyframeTpl <Vector3f> transKey = new KeyframeTpl <Vector3f>(time, value, inSlope, outSlope, Vector3f.DefaultWeight);
                transCurve.Add(transKey);
            }
            break;

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

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

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

                float outX = outSlopeValues[0];
                float outY = outSlopeValues[1];
                float outZ = outSlopeValues[2];
                float outW = 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);
                KeyframeTpl <Quaternionf> rotKey = new KeyframeTpl <Quaternionf>(time, value, inSlope, outSlope, Quaternionf.DefaultWeight);
                rotCurve.Add(rotKey);
            }
            break;

            case TransformType.Scaling:
            {
                Vector3Curve curve = new Vector3Curve(path);
                if (!m_scales.TryGetValue(curve, out List <KeyframeTpl <Vector3f> > scaleCurve))
                {
                    scaleCurve = new List <KeyframeTpl <Vector3f> >();
                    m_scales.Add(curve, 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);
                KeyframeTpl <Vector3f> scaleKey = new KeyframeTpl <Vector3f>(time, value, inSlope, outSlope, Vector3f.DefaultWeight);
                scaleCurve.Add(scaleKey);
            }
            break;

            case TransformType.EulerRotation:
            {
                Vector3Curve curve = new Vector3Curve(path);
                if (!m_eulers.TryGetValue(curve, out List <KeyframeTpl <Vector3f> > eulerCurve))
                {
                    eulerCurve = new List <KeyframeTpl <Vector3f> >();
                    m_eulers.Add(curve, 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);
                KeyframeTpl <Vector3f> eulerKey = new KeyframeTpl <Vector3f>(time, value, inSlope, outSlope, Vector3f.DefaultWeight);
                eulerCurve.Add(eulerKey);
            }
            break;

            default:
                throw new NotImplementedException(transType.ToString());
            }
        }
Exemple #2
0
 public Vector3Curve(Vector3Curve copy, IReadOnlyList <KeyframeTpl <Vector3f> > keyframes) :
     this(copy.Path, keyframes)
 {
 }