示例#1
0
        /// <summary>
        /// Pares a Face Line
        /// </summary>
        /// <param name="content"></param>
        void ProcessFaceList(string content)
        {
            string[] tokens = content.Split(" ".ToCharArray());
            if (tokens.Length == 4)           //process a Quad (only convex quads are supported)
            {
                string s = tokens[0] + " " + tokens[1] + " " + tokens[2];
                ProcessFaceList(s);

                s = tokens[2] + " " + tokens[3] + " " + tokens[0];
                ProcessFaceList(s);
            }
            else if (tokens.Length == 3)           //process triangle
            {
                try
                {
                    for (int i = 0; i < 3; i++)
                    {
                        float[] data = new float[3];
                        data[0] = 0; data[1] = 0; data[2] = 0;

                        string[] items = tokens[i].Split("/".ToCharArray());
                        for (int j = 0; j < Math.Min(items.Length, 3); j++)
                        {
                            if (items[j].Trim() == "")
                            {
                                items[j] = "0";
                            }
                            data[j] = Convert.ToInt32(items[j]);
                        }
                        SimPe.Plugin.Gmdc.GmdcElementValueThreeFloat v = new GmdcElementValueThreeFloat(data[0], data[1], data[2]);
                        faces.Add(v);
                    }
                }
                catch
                {
                    lineerror = "Unable to pares index Value.";
                    return;
                }
            }
            else
            {
                lineerror = "No valid Face List.";
            }
        }
示例#2
0
        /// <summary>
        /// Pares a Line containing three Float Values and add them to the given List
        /// </summary>
        /// <param name="list"></param>
        /// <param name="line"></param>
        /// <param name="normal">true, if the triplet represents a Normal Vector</param>
        void ParseTriplets(ArrayList list, string line, bool normal)
        {
            string[] tokens = line.Split(" ".ToCharArray());
            if (tokens.Length >= 3)
            {
                float[] data = new float[3];
                try
                {
                    for (int i = 0; i < 3; i++)
                    {
                        data[i] = Convert.ToSingle(tokens[i], AbstractGmdcImporter.DefaultCulture);
                    }

                    Vector3f vec = new Vector3f(data[0], data[1], data[2]);
                    if (!normal)
                    {
                        vec = Component.InverseTransformScaled(vec);
                    }
                    else
                    {
                        vec = Component.InverseTransformNormal(vec);
                    }
                    SimPe.Plugin.Gmdc.GmdcElementValueThreeFloat v = new GmdcElementValueThreeFloat((float)vec.X, (float)vec.Y, (float)vec.Z);
                    list.Add(v);
                }
                catch
                {
                    lineerror = "Unable to pares float Value.";
                    return;
                }
            }

            if (tokens.Length < 3 || (tokens.Length != 3 && Helper.WindowsRegistry.HiddenMode))
            {
                lineerror = "No FloatTriplet line";
            }
        }