Exemplo n.º 1
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());
            }
        }
        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 Vector3Curve transCurve))
                {
                    transCurve = new Vector3Curve(path);
                }

                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.Curve.Curve.Add(transKey);
                m_translations[path] = transCurve;
            }
            break;

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

                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.Curve.Curve.Add(rotKey);
                m_rotations[path] = rotCurve;
            }
            break;

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

                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.Curve.Curve.Add(scaleKey);
                m_scales[path] = scaleCurve;
            }
            break;

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

                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.Curve.Curve.Add(eulerKey);
                m_eulers[path] = eulerCurve;
            }
            break;

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

                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.Curve.Curve.Add(floatKey);
                m_floats[path] = floatCurve;
            }
            break;

            default:
                throw new NotImplementedException(bindType.ToString());
            }
        }