Ejemplo n.º 1
0
        /// <summary>
        /// Reads tokens.
        /// </summary>
        /// <param name="tokens">The tokens.</param>
        /// <param name="index">The index.</param>
        /// <returns>A quaternion.</returns>
        internal static An8Quaternion ReadTokens(string[] tokens, ref int index)
        {
            var quaternion = new An8Quaternion();

            Tokenizer.ReadOpenData(tokens, ref index);

            quaternion.X = Tokenizer.ReadFloat(tokens, ref index);
            quaternion.Y = Tokenizer.ReadFloat(tokens, ref index);
            quaternion.Z = Tokenizer.ReadFloat(tokens, ref index);
            quaternion.W = Tokenizer.ReadFloat(tokens, ref index);

            Tokenizer.ReadCloseData(tokens, ref index);

            return(quaternion);
        }
        /// <summary>
        /// Parses a pivot chunk.
        /// </summary>
        /// <param name="tokens">The tokens.</param>
        private void ParsePivot(string[] tokens)
        {
            var chunks = Tokenizer.SplitChunks(tokens);

            foreach (var chunk in chunks)
            {
                int index = 0;

                switch (chunk.Ident)
                {
                case "origin":
                    this.PivotOrigin = An8Point.ReadTokens(chunk.Tokens, ref index);
                    break;

                case "orientation":
                    this.PivotOrientation = An8Quaternion.ReadTokens(chunk.Tokens, ref index);
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses the tokens of the chunk.
        /// </summary>
        /// <param name="tokens">The tokens.</param>
        internal override void ParseTokens(string[] tokens)
        {
            var chunks = Tokenizer.SplitChunks(tokens);

            foreach (var chunk in chunks)
            {
                int index = 0;

                switch (chunk.Ident)
                {
                case null:
                    this.Name = Tokenizer.ReadString(chunk.Tokens, ref index);
                    break;

                case "length":
                    this.Length = Tokenizer.ReadFloat(chunk.Tokens, ref index);
                    break;

                case "diameter":
                    this.Diameter = Tokenizer.ReadFloat(chunk.Tokens, ref index);
                    break;

                case "orientation":
                    this.Orientation = An8Quaternion.ReadTokens(chunk.Tokens, ref index);
                    break;

                case "locked":
                    this.IsLocked = true;
                    break;

                case "dof":
                {
                    var dof = new An8DegreeOfFreedom();
                    dof.ParseTokens(chunk.Tokens);
                    this.DegreesOfFreedom.Add(dof);
                    break;
                }

                case "influence":
                {
                    var influence = new An8Influence();
                    influence.ParseTokens(chunk.Tokens);
                    this.Influence = influence;
                    break;
                }

                case "bone":
                {
                    var bone = new An8Bone();
                    bone.ParseTokens(chunk.Tokens);
                    this.Bones.Add(bone);
                    break;
                }
                }
            }

            foreach (var component in An8Component.ParseComponents(tokens))
            {
                this.Components.Add(component);
            }
        }