/// <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.Location         = An8Point.ReadTokens(chunk.Tokens, ref index);
                    this.ForwardDirection = An8Point.ReadTokens(chunk.Tokens, ref index);
                    this.ReverseDirection = An8Point.ReadTokens(chunk.Tokens, ref index);

                    if (index < chunk.Tokens.Length)
                    {
                        this.SegmentsCount = Tokenizer.ReadInt(chunk.Tokens, ref index);
                    }

                    break;

                case "corner":
                    this.IsCorner = true;
                    break;
                }
            }
        }
        /// <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;
                }
            }
        }
Exemple #3
0
        internal override void ParseTokens(string[] tokens)
        {
            base.ParseTokens(tokens);

            var chunks = Tokenizer.SplitChunks(tokens);

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

                switch (chunk.Ident)
                {
                case "material":
                {
                    var material = new An8Material();
                    material.ParseTokens(chunk.Tokens);
                    this.Material = material;
                    break;
                }

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

                case "working":
                    this.Divisions = Tokenizer.ReadInt(chunk.Tokens, ref index);
                    break;

                case "divisions":
                    this.RenderDivisions = Tokenizer.ReadInt(chunk.Tokens, ref index);
                    break;

                case "materiallist":
                    this.MaterialList.Clear();
                    foreach (var material in Tokenizer.SplitChunks(chunk.Tokens)
                             .Where(t => string.Equals(t.Ident, "materialname", StringComparison.Ordinal))
                             .Select(t =>
                    {
                        int i = 0;
                        return(Tokenizer.ReadString(t.Tokens, ref i));
                    }))
                    {
                        this.MaterialList.Add(material);
                    }

                    break;

                case "points":
                    this.Points.Clear();
                    while (index < chunk.Tokens.Length)
                    {
                        this.Points.Add(An8Point.ReadTokens(chunk.Tokens, ref index));
                    }

                    break;

                case "normals":
                    this.Normals.Clear();
                    while (index < chunk.Tokens.Length)
                    {
                        this.Normals.Add(An8Point.ReadTokens(chunk.Tokens, ref index));
                    }

                    break;

                case "edges":
                    this.Edges.Clear();
                    while (index < chunk.Tokens.Length)
                    {
                        this.Edges.Add(An8Edge.ReadTokens(chunk.Tokens, ref index));
                    }

                    break;

                case "texcoords":
                    this.TexCoords.Clear();
                    while (index < chunk.Tokens.Length)
                    {
                        this.TexCoords.Add(An8TexCoord.ReadTokens(chunk.Tokens, ref index));
                    }

                    break;

                case "faces":
                    this.Faces.Clear();
                    while (index < chunk.Tokens.Length)
                    {
                        this.Faces.Add(An8Face.ReadTokens(chunk.Tokens, ref index));
                    }

                    break;
                }
            }
        }