AoMEngineLibrary.AMP.GrnMax.ImportAnimation C# (CSharp) Method

ImportAnimation() private method

private ImportAnimation ( string boneArray ) : void
boneArray string
return void
        private void ImportAnimation(string boneArray)
        {
            Maxscript.Command("frameRate = {0}", 30);
            Maxscript.Interval(0, this.File.Animation.Duration);

            for (int i = 0; i < this.File.Animation.BoneTracks.Count; ++i)
            {
                if (this.File.Bones[i].Name == "__Root")
                {
                    continue;
                }
                GrnBoneTrack bone = this.File.Animation.BoneTracks[i];
                // typically bones and bonetracks match up in a file
                // but won't if an anim file is imported on top of a regular model file
                int boneArrayIndex = this.boneMap[this.File.Bones[i].Name] + 1;

                Vector3D pos = new Vector3D();
                Quaternion rot = new Quaternion();
                Matrix3x3 scale = Matrix3x3.Identity;
                HashSet<float> uKeys = new HashSet<float>();
                uKeys.UnionWith(bone.RotationKeys);
                uKeys.UnionWith(bone.ScaleKeys);
                uKeys.UnionWith(bone.PositionKeys);
                List<float> keys = uKeys.ToList();
                keys.Sort();

                for (int j = 0; j < keys.Count; ++j)
                {
                    int index = bone.PositionKeys.IndexOf(keys[j]);
                    if (index >= 0)
                    {
                        pos = bone.Positions[index];
                    }
                    index = bone.RotationKeys.IndexOf(keys[j]);
                    if (index >= 0)
                    {
                        rot = bone.Rotations[index];
                    }
                    index = bone.ScaleKeys.IndexOf(keys[j]);
                    if (index >= 0)
                    {
                        scale = bone.Scales[index];
                    }

                    Maxscript.AnimateAtTime(keys[j], "{0}[{1}][3].controller.value = {2}",
                        boneArray, boneArrayIndex, this.GetBoneLocalTransform("bAnimMatrix", pos, rot, scale));
                }
            }
        }