Exemplo n.º 1
0
        private void ParseStrips(NiTriStrips strips)
        {
            List <string> export = new List <string>();

            NiTriStripsData geometry = (NiTriStripsData)strips.Data.Object;

            List <Triangle> triangles = new List <Triangle>();

            foreach (ushort[] points in geometry.Points)
            {
                bool t = false;
                int  j = 1;

                ushort p1 = points[0];
                ushort p2 = points[1];

                while (j < points.Length - 1)
                {
                    ushort p3 = points[j + 1];

                    if (p1 != p2 && p1 != p3 && p2 != p3)
                    {
                        if (t)
                        {
                            triangles.Add(new Triangle(p1, p3, p2));
                        }
                        else
                        {
                            triangles.Add(new Triangle(p1, p2, p3));
                        }
                    }

                    j  = j + 1;
                    p1 = p2;
                    p2 = p3;
                    t  = !t;
                }
            }

            // Verticles (v)
            if (geometry.HasVertices && geometry.NumVertices >= 3)
            {
                Matrix transformationMatrix = ComputeWorldMatrix(strips);
                computePolys(triangles.ToArray(), geometry.Vertices, transformationMatrix);
            }
        }
Exemplo n.º 2
0
        private string ParseStrips(NiTriStrips strips)
        {
            if (!strips.Data.IsValid())
            {
                return("");
            }

            NiTriStripsData geometry = (NiTriStripsData)strips.Data.Object;

            Matrix transformationMatrix = ComputeWorldMatrix(strips);

            // The final text
            List <string> export = new List <string>();

            // Set Object name
            export.Add("g Strip " + strips.Name + Environment.NewLine);

            // Verticles (v)
            if (geometry.HasVertices && geometry.NumVertices >= 3)
            {
                export.Add(printVertices(geometry.Vertices, transformationMatrix));
            }

            // Texture coordinates (vt)
            if (geometry.UVSets.Length > 0)
            {
                export.Add(printUvSets(geometry.UVSets));
            }

            // Normals (vn)
            if (geometry.HasNormals)
            {
                export.Add(printNormals(geometry.Normals, transformationMatrix));
            }

            if (geometry.Points.Length > 0)
            {
                List <Triangle> triangles = new List <Triangle>();

                foreach (ushort[] points in geometry.Points)
                {
                    bool t = false;
                    int  j = 1;

                    ushort p1 = points[0];
                    ushort p2 = points[1];

                    while (j < points.Length - 1)
                    {
                        ushort p3 = points[j + 1];

                        if (p1 != p2 && p1 != p3 && p2 != p3)
                        {
                            if (t)
                            {
                                triangles.Add(new Triangle(p1, p3, p2));
                            }
                            else
                            {
                                triangles.Add(new Triangle(p1, p2, p3));
                            }
                        }

                        j  = j + 1;
                        p1 = p2;
                        p2 = p3;
                        t  = !t;
                    }
                }

                export.Add(printTriangles(triangles.ToArray(), (geometry.UVSets.Length > 0)));
            }

            return(string.Join(Environment.NewLine, export));
        }