Esempio n. 1
0
        public static odfMesh CreateMesh(WorkspaceMesh mesh, int subMeshFormat, out string[] materialNames, out int[] indices, out bool[] worldCoords, out bool[] replaceSubmeshesOption)
        {
            int numUncheckedSubmeshes = 0;
            foreach (ImportedSubmesh submesh in mesh.SubmeshList)
            {
                if (!mesh.isSubmeshEnabled(submesh))
                    numUncheckedSubmeshes++;
            }
            int numSubmeshes = mesh.SubmeshList.Count - numUncheckedSubmeshes;
            materialNames = new string[numSubmeshes];
            indices = new int[numSubmeshes];
            worldCoords = new bool[numSubmeshes];
            replaceSubmeshesOption = new bool[numSubmeshes];

            odfMesh newMesh = new odfMesh(new ObjectName(String.Empty, null), null, numSubmeshes);

            for (int i = 0, submeshIdx = 0; i < numSubmeshes; i++, submeshIdx++)
            {
                while (!mesh.isSubmeshEnabled(mesh.SubmeshList[submeshIdx]))
                    submeshIdx++;

                ImportedSubmesh submesh = mesh.SubmeshList[submeshIdx];

                odfSubmesh newSubmesh = new odfSubmesh(new ObjectName(String.Empty, null), null, subMeshFormat);
                newMesh.AddChild(newSubmesh);

                newSubmesh.MaterialId = ObjectID.INVALID;
                materialNames[i] = submesh.Material;
                indices[i] = submesh.Index;
                worldCoords[i] = submesh.WorldCoords;
                replaceSubmeshesOption[i] = mesh.isSubmeshReplacingOriginal(mesh.SubmeshList[submeshIdx]);

                List<ImportedVertex> vertexList = submesh.VertexList;
                List<odfVertex> newVertexList = new List<odfVertex>(vertexList.Count);
                for (int j = 0; j < vertexList.Count; j++)
                {
                    ImportedVertex vert = vertexList[j];
                    odfVertex newVertex = new odfVertex();

                    newVertex.Normal = vert.Normal;
                    newVertex.UV = new Vector2(vert.UV[0], vert.UV[1]);
                    newVertex.Weights = (float[])vert.Weights.Clone();
                    newVertex.BoneIndices = (byte[])vert.BoneIndices.Clone();
                    newVertex.Position = vert.Position;
                    newVertexList.Add(newVertex);
                }
                newSubmesh.VertexList = newVertexList;

                List<ImportedFace> faceList = submesh.FaceList;
                List<odfFace> newFaceList = new List<odfFace>(faceList.Count);
                for (int j = 0; j < faceList.Count; j++)
                {
                    int[] vertexIndices = faceList[j].VertexIndices;
                    odfFace newFace = new odfFace();
                    newFace.VertexIndices = new ushort[3] { (ushort)vertexIndices[0], (ushort)vertexIndices[1], (ushort)vertexIndices[2] };
                    newFaceList.Add(newFace);
                }
                newSubmesh.FaceList = newFaceList;
            }

            return newMesh;
        }
Esempio n. 2
0
 public static void RemoveMesh(odfParser parser, odfMesh mesh, odfFrame meshFrame, bool deleteMorphs)
 {
     while (mesh.Count > 0)
     {
         odfSubmesh submesh = mesh[0];
         RemoveSubmesh(parser, submesh, deleteMorphs);
     }
     meshFrame.MeshId = ObjectID.INVALID;
     parser.MeshSection.RemoveChild(mesh);
     parser.UsedIDs.Remove((int)mesh.Id);
 }
Esempio n. 3
0
 public static void ExportMorphFbx([DefaultVar]odfParser parser, string path, odfMesh mesh, odfMorphClip morphClip, string exportFormat)
 {
     //			Fbx.Exporter.ExportMorph(path, xxparser, meshFrame, morphClip, xaparser, exportFormat);
 }