Esempio n. 1
0
        /// Loads the animation file and populates the Dialogue class, YOffset and ScaleFactor
        private void LoadConfigFile(string filename)
        {
            // Make sure the file exists
            System.IO.FileInfo fInfo = new System.IO.FileInfo(filename);
            if (!fInfo.Exists)
            {
                return;
            }

            fInfo = null;

            // Open the config file
            System.IO.StreamReader pobjReader = new System.IO.StreamReader(filename, System.Text.Encoding.ASCII);

            // Now read the complete contents.
            string contents = pobjReader.ReadToEnd();

            pobjReader.Close();
            pobjReader = null;

            // Split it up into lines and load the animation settings.
            string[] lines = contents.Split('\n');

            animations = new AnimationCollection();

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].StartsWith("#"))
                {
                    continue;
                }

                Match m = Regex.Match(lines[i], @"^(?<name>\w+)\s+(?<start>\d+)\s+(?<end>\d+)\s+(?<delay>\d+)");
                if (m.Success)
                {
                    Milkshape.Animation anim = new Milkshape.Animation();
                    anim.Name          = m.Groups["name"].Value;
                    anim.StartKeyframe = int.Parse(m.Groups["start"].Value);
                    anim.EndKeyFrame   = int.Parse(m.Groups["end"].Value);
                    anim.Delay         = int.Parse(m.Groups["delay"].Value);
                    anim.StartTime     = anim.StartKeyframe * 41;
                    anim.EndTime       = anim.EndKeyFrame * 41;
                    animations.Add(anim);
                }
            }

            // Set animations for the model
            base.model_data.Animations = (Milkshape.Animation[])animations.ToArray();
        }
Esempio n. 2
0
        /// Loads the animation file and populates the Dialogue class, YOffset and ScaleFactor
        private void LoadConfigFile(string filename)
        {
            // Make sure the file exists
            System.IO.FileInfo fInfo = new System.IO.FileInfo(filename);
            if (!fInfo.Exists)
                return;

            fInfo = null;

            // Open the config file
            System.IO.StreamReader pobjReader = new System.IO.StreamReader(filename, System.Text.Encoding.ASCII);

            // Now read the complete contents.
            string contents = pobjReader.ReadToEnd();
            pobjReader.Close();
            pobjReader = null;

            // Split it up into lines and load the animation settings.
            string[] lines = contents.Split('\n');

            animations = new AnimationCollection();

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].StartsWith("#"))
                    continue;

                Match m = Regex.Match(lines[i], @"^(?<name>\w+)\s+(?<start>\d+)\s+(?<end>\d+)\s+(?<delay>\d+)");
                if (m.Success)
                {
                    Milkshape.Animation anim = new Milkshape.Animation();
                    anim.Name = m.Groups["name"].Value;
                    anim.StartKeyframe = int.Parse(m.Groups["start"].Value);
                    anim.EndKeyFrame = int.Parse(m.Groups["end"].Value);
                    anim.Delay = int.Parse(m.Groups["delay"].Value);
                    anim.StartTime = anim.StartKeyframe * 41;
                    anim.EndTime = anim.EndKeyFrame * 41;
                    animations.Add(anim);
                }
            }

            // Set animations for the model
            base.model_data.Animations = (Milkshape.Animation[])animations.ToArray();
        }