Exemple #1
0
        public NUD toNUD()
        {
            NUD nud = new NUD();
            int j   = 0;

            foreach (Mesh m in mesh)
            {
                NUD.Mesh n_mesh = new NUD.Mesh();
                nud.Nodes.Add(n_mesh);
                n_mesh.Text = "Mesh_" + j++;
                foreach (List <int> i in m.faces)
                {
                    NUD.Polygon poly = new NUD.Polygon();
                    n_mesh.Nodes.Add(poly);
                    poly.AddDefaultMaterial();

                    List <Vertex> indexSim = new List <Vertex>();

                    foreach (int index in i)
                    {
                        Vertex v = vertices[index];

                        if (!indexSim.Contains(v))
                        {
                            indexSim.Add(v);
                            NUD.Vertex vert = new NUD.Vertex();
                            vert.pos   = v.pos;
                            vert.nrm   = v.nrm;
                            vert.color = v.col;
                            List <Vector2> uvs = new List <Vector2>();
                            uvs.Add(new Vector2(v.tx[0].X, 1 - v.tx[0].Y));
                            vert.uv = uvs;
                            if (vert.boneWeights.Count < 4)
                            {
                                v.weight.Add(0f);
                                v.weight.Add(0f);
                            }
                            vert.boneWeights = v.weight;
                            List <int> nodez = new List <int>();
                            nodez.Add(m.nodeList[0][v.node[0]]);
                            nodez.Add(m.nodeList[0][v.node[1]]);
                            nodez.Add(0);
                            nodez.Add(0);
                            vert.boneIds = nodez;
                            poly.AddVertex(vert);
                        }

                        poly.faces.Add(indexSim.IndexOf(v));
                    }
                }
            }
            return(nud);
        }
Exemple #2
0
        public NUD toNUD()
        {
            NUD nud = new NUD();
            int j   = 0;

            foreach (Mesh m in mesh)
            {
                NUD.Mesh n_mesh = new NUD.Mesh();
                nud.mesh.Add(n_mesh);
                n_mesh.Text = "Mesh_" + j++;
                foreach (List <int> i in m.faces)
                {
                    NUD.Polygon poly = new NUD.Polygon();
                    n_mesh.polygons.Add(poly);
                    poly.setDefaultMaterial();

                    List <Vertex> indexSim = new List <Vertex>();

                    foreach (int index in i)
                    {
                        Vertex v = vertices[index];

                        if (!indexSim.Contains(v))
                        {
                            indexSim.Add(v);
                            NUD.Vertex vert = new NUD.Vertex();
                            vert.pos    = v.pos;
                            vert.nrm    = v.nrm;
                            vert.col    = v.col;
                            vert.tx     = v.tx;
                            vert.weight = v.weight;
                            vert.node   = v.node;
                            poly.AddVertex(vert);
                        }

                        poly.faces.Add(indexSim.IndexOf(v));
                    }
                }
            }
            return(nud);
        }