예제 #1
0
        private bool SaveTracks(BaseObject ob, SceneNodeContainer snc, bool slerpRotation)
        {
            var builder = new TrackBuilder();

            builder.LerpType = (slerpRotation) ? LerpType.Slerp : LerpType.Lerp;
            CTrack track = ob.GetFirstCTrack();

            // First occurence of animation tracks?
            if (track == null)
            {
                return(false);
            }

            while (track != null)
            {
                DescID    testID = track.GetDescriptionID();
                DescLevel lv1    = testID.GetAt(0);
                DescLevel lv2    = testID.GetAt(1);

                CCurve curve = track.GetCurve();
                if (curve != null)
                {
                    int keyCount = curve.GetKeyCount();

                    CKey     key = null;
                    BaseTime time;
                    for (int i = 0; i < keyCount; i++)
                    {
                        key  = curve.GetKey(i);
                        time = key.GetTime();

                        switch (lv1.id)
                        {
                        case 903:     // should be replaced with "ID_BASEOBJECT_REL_POSITION"
                            switch (lv2.id)
                            {
                            case 1000: builder.AddTranslationValue("x", (float)time.Get(), key.GetValue()); break;

                            case 1001: builder.AddTranslationValue("y", (float)time.Get(), key.GetValue()); break;

                            case 1002: builder.AddTranslationValue("z", (float)time.Get(), key.GetValue()); break;
                            }
                            break;

                        case 904:     // should be replaced with "ID_BASEOBJECT_REL_ROTATION"
                            switch (lv2.id)
                            {
                            case 1000: builder.AddRotationValue("x", (float)time.Get(), key.GetValue()); break;

                            case 1001: builder.AddRotationValue("y", (float)time.Get(), key.GetValue()); break;

                            case 1002: builder.AddRotationValue("z", (float)time.Get(), key.GetValue()); break;
                            }
                            break;

                        case 905:     // should be replaced with "ID_BASEOBJECT_REL_SCALE"
                            switch (lv2.id)
                            {
                            case 1000: builder.AddScaleValue("x", (float)time.Get(), key.GetValue()); break;

                            case 1001: builder.AddScaleValue("y", (float)time.Get(), key.GetValue()); break;

                            case 1002: builder.AddScaleValue("z", (float)time.Get(), key.GetValue()); break;
                            }
                            break;
                        }
                    }
                }
                track = track.GetNext();
            }

            builder.BuildTracks(snc, _tracks);

            if (_animationsPresent)
            {
                return(false);
            }
            return(true);
        }