Exemplo n.º 1
0
        public void RemoveMesh(int idx, bool deleteMorphs)
        {
            odfMesh  mesh      = Parser.MeshSection[idx];
            odfFrame meshFrame = odf.FindMeshFrame(mesh.Id, Parser.FrameSection.RootFrame);

            odf.RemoveMesh(Parser, mesh, meshFrame, deleteMorphs);
        }
Exemplo n.º 2
0
        public static void CalculateNormals(odfMesh mesh, float threshold)
        {
            var pairList = new List <Tuple <List <odfFace>, List <odfVertex> > >(mesh.Count);

            for (int i = 0; i < mesh.Count; i++)
            {
                pairList.Add(new Tuple <List <odfFace>, List <odfVertex> >(mesh[i].FaceList, mesh[i].VertexList));
            }
            CalculateNormals(pairList, threshold);
        }
Exemplo n.º 3
0
        public odfMesh Clone()
        {
            odfMesh mesh = new odfMesh(Name, Id, Count);

            foreach (odfSubmesh submesh in this)
            {
                odfSubmesh newSubmesh = submesh.Clone();
                mesh.AddChild(newSubmesh);
            }
            return(mesh);
        }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
        public void MergeFrame(odfFrame srcFrame, odfParser srcParser, int destParentIdx)
        {
            List <ObjectID>    newMeshIDs   = new List <ObjectID>();
            odfFrame           newFrame     = srcFrame.Clone(true, newMeshIDs, true);
            List <odfMesh>     newMeshes    = new List <odfMesh>(newMeshIDs.Count);
            List <odfBoneList> newBoneLists = new List <odfBoneList>(srcParser.EnvelopeSection != null ? srcParser.EnvelopeSection.Count : 0);
            string             boneWarning  = String.Empty;

            foreach (ObjectID meshID in newMeshIDs)
            {
                odfMesh srcMesh = odf.FindMeshListSome(meshID, srcParser.MeshSection);
                odfMesh mesh    = srcMesh.Clone();
                newMeshes.Add(mesh);
                if (srcParser.EnvelopeSection != null)
                {
                    foreach (odfSubmesh submesh in mesh)
                    {
                        odfBoneList boneList = odf.FindBoneList(submesh.Id, srcParser.EnvelopeSection);
                        if (boneList != null)
                        {
                            if (Parser.EnvelopeSection != null)
                            {
                                odfBoneList copy = boneList.Clone();
                                newBoneLists.Add(copy);
                            }
                            else
                            {
                                boneWarning += (boneWarning != String.Empty ? ", " : "") + mesh.ToString();
                                break;
                            }
                        }
                    }
                }
            }
            MergeFrame(newFrame, destParentIdx);
            foreach (odfMesh mesh in newMeshes)
            {
                Parser.MeshSection.AddChild(mesh);
            }
            if (Parser.EnvelopeSection != null)
            {
                foreach (odfBoneList boneList in newBoneLists)
                {
                    Parser.EnvelopeSection.AddChild(boneList);
                }
            }
            Parser.CollectObjectIDs();
            if (boneWarning != String.Empty)
            {
                Report.ReportLog("Warning! Bones of " + boneWarning + " dropped because the destination had no Envelope section.");
            }
        }
Exemplo n.º 6
0
        public void RemoveSubmesh(int meshIdx, int submeshIdx, bool deleteMorphs)
        {
            odfMesh mesh = Parser.MeshSection[meshIdx];

            if (mesh.Count == 1)
            {
                RemoveMesh(meshIdx, deleteMorphs);
            }
            else
            {
                odf.RemoveSubmesh(Parser, mesh[submeshIdx], deleteMorphs);
            }
        }
Exemplo n.º 7
0
        void DeleteMeshesInSubframes(odfFrame frame, bool deleteMorphs)
        {
            if ((int)frame.MeshId != 0)
            {
                odfMesh mesh = odf.FindMeshListSome(frame.MeshId, Parser.MeshSection);
                odf.RemoveMesh(Parser, mesh, frame, deleteMorphs);
            }

            for (int i = 0; i < frame.Count; i++)
            {
                odfFrame subframe = frame[i];
                DeleteMeshesInSubframes(subframe, deleteMorphs);
            }
        }
Exemplo n.º 8
0
        private void numericMeshId_ValueChanged(object sender, EventArgs e)
        {
            textBoxMeshFrameName.Text = (numericMeshId.Value < 0) ? String.Empty : editor.Frames[Decimal.ToInt32(numericMeshId.Value)].Name;
            odfFrame frame = odf.FindFrame(textBoxMeshFrameName.Text, editor.Parser.FrameSection.RootFrame);

            textBoxMeshName.Text = String.Empty;
            if ((int)frame.MeshId != 0)
            {
                odfMesh mesh = odf.FindMeshListSome(frame.MeshId, editor.Parser.MeshSection);
                if (mesh != null)
                {
                    textBoxMeshName.Text = mesh.Name;
                }
            }
        }
Exemplo n.º 9
0
 public static void MergeBoneLists(odfMesh mesh, Dictionary <ObjectID, ObjectID> submeshIDtrans, odfParser parser)
 {
     foreach (odfSubmesh submesh in mesh)
     {
         ObjectID baseSubmeshId = submeshIDtrans[submesh.Id];
         for (int i = 0; i < parser.EnvelopeSection.Count; i++)
         {
             odfBoneList boneList = parser.EnvelopeSection[i];
             if (boneList.SubmeshId == baseSubmeshId)
             {
                 Dictionary <int, int> boneDic = new Dictionary <int, int>(boneList.Count);
                 for (int j = 0; j < boneList.Count; j++)
                 {
                     odfBone bone = boneList[j];
                     boneDic.Add((int)bone.FrameId, j);
                 }
                 for (int j = i + 1; j < parser.EnvelopeSection.Count; j++)
                 {
                     odfBoneList boneList2 = parser.EnvelopeSection[j];
                     if (boneList2.SubmeshId == submesh.Id)
                     {
                         foreach (odfBone bone in boneList2)
                         {
                             int boneIdx;
                             if (boneDic.TryGetValue((int)bone.FrameId, out boneIdx))
                             {
                                 boneList.RemoveChild(boneIdx);
                                 boneList.InsertChild(boneIdx, bone);
                             }
                             else
                             {
                                 boneList.AddChild(bone);
                                 boneDic.Add((int)bone.FrameId, boneDic.Count);
                             }
                         }
                         parser.EnvelopeSection.RemoveChild(boneList2);
                     }
                 }
                 break;
             }
             else
             {
                 Report.ReportLog("wrong");
             }
         }
     }
 }
Exemplo n.º 10
0
        public void SetMeshId(int idx, string id)
        {
            ObjectID newMeshID = new ObjectID(id);

            if (Parser.IsUsedID(newMeshID))
            {
                throw new FormatException("ID is already in use");
            }

            odfMesh  mesh      = Parser.MeshSection[idx];
            ObjectID oldMeshId = mesh.Id;
            odfFrame meshFrame = odf.FindMeshFrame(mesh.Id, Parser.FrameSection.RootFrame);

            meshFrame.MeshId = mesh.Id = newMeshID;
            Parser.UsedIDs.Add((int)newMeshID, typeof(odfMesh));
            Parser.UsedIDs.Remove((int)oldMeshId);
        }
Exemplo n.º 11
0
        public static odfSubmesh FindMeshObject(ObjectID id, odfMeshSection meshSection)
        {
            for (int meshIdx = 0; meshIdx < meshSection.Count; meshIdx++)
            {
                odfMesh mesh = meshSection[meshIdx];
                for (int submeshIdx = 0; submeshIdx < mesh.Count; submeshIdx++)
                {
                    odfSubmesh meshObj = mesh[submeshIdx];
                    if (meshObj.Id == id)
                    {
                        return(meshObj);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 12
0
Arquivo: Mqo.cs Projeto: kkdevs/sb3u
        public static void ExportMqo([DefaultVar] odfParser parser, object[] meshNames, string dirPath, bool singleMqo, bool worldCoords)
        {
            List <odfMesh> meshes = new List <odfMesh>(meshNames.Length);

            foreach (string meshName in Utility.Convert <string>(meshNames))
            {
                odfMesh mesh = odf.FindMeshListSome(meshName, parser.MeshSection);
                if (mesh != null || (mesh = odf.FindMeshListSome(new ObjectID(meshName), parser.MeshSection)) != null)
                {
                    meshes.Add(mesh);
                }
                else
                {
                    Report.ReportLog("Mesh " + meshName + " not found");
                }
            }
            Mqo.Exporter.Export(dirPath, parser, meshes, singleMqo, worldCoords);
        }
Exemplo n.º 13
0
        private new void listViewAnimationTrack_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            List <DockContent> formODFList;

            if (!Gui.Docking.DockContents.TryGetValue(typeof(FormMeshView), out formODFList))
            {
                return;
            }

            foreach (FormMeshView formMesh in formODFList)
            {
                odfFrame boneFrame = odf.FindFrame(e.Item.Text, formMesh.Editor.Parser.FrameSection.RootFrame);
                if (boneFrame == null)
                {
                    continue;
                }
                for (int i = 0; i < formMesh.renderObjectMeshes.Count; i++)
                {
                    RenderObjectODF mesh = formMesh.renderObjectMeshes[i];
                    if (mesh != null && formMesh.renderObjectIds[i] > -1)
                    {
                        odfMesh odfMesh = formMesh.Editor.Parser.MeshSection[i];
                        for (int j = 0; j < odfMesh.Count; j++)
                        {
                            odfSubmesh  submesh = odfMesh[j];
                            odfBoneList bones   = odf.FindBoneList(submesh.Id, formMesh.Editor.Parser.EnvelopeSection);
                            if (bones == null)
                            {
                                continue;
                            }
                            for (int k = 0; k < bones.Count; k++)
                            {
                                if (bones[k].FrameId == boneFrame.Id)
                                {
                                    mesh.HighlightBone(formMesh.Editor.Parser, i, j, e.IsSelected ? k : -1);
                                    Gui.Renderer.Render();
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        void MergeFrame(odfFrame srcParent, odfFrame destParent)
        {
            for (int i = 0; i < destParent.Count; i++)
            {
                var dest = destParent[i];
                for (int j = 0; j < srcParent.Count; j++)
                {
                    var src = srcParent[j];
                    if (src.Name.ToString() == dest.Name.ToString())
                    {
                        MergeFrame(src, dest);

                        srcParent.RemoveChild(j);
                        if (dest.MeshId != null && (int)dest.MeshId != 0)
                        {
                            odfMesh mesh = odf.FindMeshListSome(dest.MeshId, Parser.MeshSection);
                            odf.RemoveMesh(Parser, mesh, dest, false);
                        }
                        destParent.RemoveChild(i);
                        destParent.InsertChild(i, src);
                        break;
                    }
                }
            }

            if (srcParent.Name.ToString() == destParent.Name.ToString())
            {
                while (destParent.Count > 0)
                {
                    var dest = destParent[0];
                    destParent.RemoveChild(0);
                    srcParent.AddChild(dest);
                }
            }
            else
            {
                while (srcParent.Count > 0)
                {
                    var src = srcParent[0];
                    srcParent.RemoveChild(0);
                    destParent.AddChild(src);
                }
            }
        }
Exemplo n.º 15
0
        public static HashSet <int> SearchHierarchy(odfParser parser, HashSet <int> meshIDs)
        {
            HashSet <int> exportFrames = new HashSet <int>();

            SearchHierarchy(parser.FrameSection.RootFrame, parser.FrameSection.RootFrame, meshIDs, exportFrames);
            if (parser.EnvelopeSection != null)
            {
                for (int meshIdx = 0; meshIdx < parser.MeshSection.Count; meshIdx++)
                {
                    odfMesh mesh = parser.MeshSection[meshIdx];
                    if (!meshIDs.Contains((int)mesh.Id))
                    {
                        continue;
                    }
                    for (int meshObjIdx = 0; meshObjIdx < mesh.Count; meshObjIdx++)
                    {
                        odfSubmesh meshObj = mesh[meshObjIdx];
                        for (int envIdx = 0; envIdx < parser.EnvelopeSection.Count; envIdx++)
                        {
                            odfBoneList boneList = parser.EnvelopeSection[envIdx];
                            if (meshObj.Id != boneList.SubmeshId)
                            {
                                continue;
                            }
                            for (int i = 0; i < boneList.Count; i++)
                            {
                                ObjectID boneID = boneList[i].FrameId;
                                if (!exportFrames.Contains((int)boneID))
                                {
                                    odfFrame boneParent = FindFrame(boneID, parser.FrameSection.RootFrame);
                                    while (boneParent != null && exportFrames.Add((int)boneParent.Id))
                                    {
                                        boneParent = boneParent.Parent as odfFrame;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(exportFrames);
        }
Exemplo n.º 16
0
        public void ReplaceFrame(odfFrame srcFrame, odfParser srcParser, int destParentIdx, bool deleteMorphs)
        {
            List <ObjectID> meshIDs  = new List <ObjectID>();
            odfFrame        newFrame = srcFrame.Clone(true, meshIDs, true);

            ReplaceFrame(newFrame, destParentIdx, deleteMorphs);
            string boneWarning = String.Empty;

            foreach (ObjectID meshID in meshIDs)
            {
                odfMesh srcMesh = odf.FindMeshListSome(meshID, srcParser.MeshSection);
                odfMesh mesh    = srcMesh.Clone();
                Parser.MeshSection.AddChild(mesh);
                if (srcParser.EnvelopeSection != null)
                {
                    foreach (odfSubmesh submesh in mesh)
                    {
                        odfBoneList boneList = odf.FindBoneList(submesh.Id, srcParser.EnvelopeSection);
                        if (boneList != null)
                        {
                            if (Parser.EnvelopeSection != null)
                            {
                                odfBoneList copy = boneList.Clone();
                                Parser.EnvelopeSection.AddChild(copy);
                            }
                            else
                            {
                                boneWarning += (boneWarning != String.Empty ? ", " : "") + mesh.ToString();
                                break;
                            }
                        }
                    }
                }
            }
            Parser.CollectObjectIDs();
            if (boneWarning != String.Empty)
            {
                Report.ReportLog("Warning! Bones of " + boneWarning + " dropped because the destination had no Envelope section.");
            }
        }
Exemplo n.º 17
0
Arquivo: Mqo.cs Projeto: kkdevs/sb3u
            private static List <odfTexture> Export(string dest, odfParser parser, List <odfMesh> meshes, bool worldCoords)
            {
                List <odfTexture> usedTextures = new List <odfTexture>(parser.TextureSection.Count);
                DirectoryInfo     dir          = new DirectoryInfo(Path.GetDirectoryName(dest));

                if (!dir.Exists)
                {
                    dir.Create();
                }

                List <odfMaterial> materialList = new List <odfMaterial>(parser.MaterialSection.Count);
                Dictionary <ObjectName, ObjectName> matTexDic = new Dictionary <ObjectName, ObjectName>();

                using (StreamWriter writer = new StreamWriter(dest, false))
                {
                    for (int i = 0; i < meshes.Count; i++)
                    {
                        odfMesh meshListSome = meshes[i];
                        for (int j = 0; j < meshListSome.Count; j++)
                        {
                            odfSubmesh  meshObj = meshListSome[j];
                            odfMaterial mat     = odf.FindMaterialInfo(meshObj.MaterialId, parser.MaterialSection);
                            if (mat != null)
                            {
                                if (!materialList.Contains(mat))
                                {
                                    materialList.Add(mat);
                                }
                                odfTexture tex = odf.FindTextureInfo(meshObj.TextureIds[0], parser.TextureSection);
                                if (tex != null && !usedTextures.Contains(tex))
                                {
                                    usedTextures.Add(tex);
                                }
                                if (tex != null && !matTexDic.ContainsKey(mat.Name))
                                {
                                    matTexDic.Add(mat.Name, tex.Name);
                                }
                            }
                            else
                            {
                                Report.ReportLog("Warning: Mesh " + meshes[i].Name + " Object " + meshObj.Name + " has an invalid material");
                            }
                        }
                    }

                    writer.WriteLine("Metasequoia Document");
                    writer.WriteLine("Format Text Ver 1.0");
                    writer.WriteLine();
                    writer.WriteLine("Material " + materialList.Count + " {");
                    foreach (odfMaterial mat in materialList)
                    {
                        string     s = "\t\"" + mat.Name + "\" col(0.800 0.800 0.800 1.000) dif(0.500) amb(0.100) emi(0.500) spc(0.100) power(30.00)";
                        ObjectName matTexName;
                        if (matTexDic.TryGetValue(mat.Name, out matTexName))
                        {
                            s += " tex(\"" + matTexName + "\")";
                        }
                        writer.WriteLine(s);
                    }
                    writer.WriteLine("}");

                    Random rand = new Random();
                    for (int i = 0; i < meshes.Count; i++)
                    {
                        Matrix transform = Matrix.Identity;
                        if (worldCoords)
                        {
                            odfFrame parent = odf.FindMeshFrame(meshes[i].Id, parser.FrameSection.RootFrame);
                            while (parent != null)
                            {
                                transform = parent.Matrix * transform;
                                parent    = parent.Parent as odfFrame;
                            }
                        }

                        odfMesh meshListSome = meshes[i];
                        string  meshName     = meshes[i].Name;
                        if (meshName == String.Empty)
                        {
                            meshName = meshes[i].Id.ToString();
                        }
                        for (int j = 0; j < meshListSome.Count; j++)
                        {
                            odfSubmesh  meshObj   = meshListSome[j];
                            odfMaterial mat       = odf.FindMaterialInfo(meshObj.MaterialId, parser.MaterialSection);
                            int         mqoMatIdx = -1;
                            if (mat != null)
                            {
                                mqoMatIdx = materialList.IndexOf(mat);
                            }
                            float[] color = new float[3];
                            for (int k = 0; k < color.Length; k++)
                            {
                                color[k] = (float)((rand.NextDouble() / 2) + 0.5);
                            }

                            string mqoName = meshName + "[" + j + "]";
                            if (worldCoords)
                            {
                                mqoName += "[W]";
                            }
                            string meshObjName = meshObj.Name;
                            if (meshObjName != String.Empty)
                            {
                                mqoName += meshObjName;
                            }
                            writer.WriteLine("Object \"" + mqoName + "\" {");
                            writer.WriteLine("\tshading 1");
                            writer.WriteLine("\tcolor " + color[0].ToFloatString() + " " + color[1].ToFloatString() + " " + color[2].ToFloatString());
                            writer.WriteLine("\tcolor_type 1");

                            List <ImportedVertex> vertList = odf.ImportedVertexListUnskinned(meshObj.VertexList);
                            List <ImportedFace>   faceList = odf.ImportedFaceList(meshObj.FaceList);
                            if (worldCoords)
                            {
                                for (int k = 0; k < vertList.Count; k++)
                                {
                                    Vector4 v4 = Vector3.Transform(vertList[k].Position, transform);
                                    vertList[k].Position = new Vector3(v4.X, v4.Y, v4.Z);
                                }
                            }

                            SB3Utility.Mqo.ExporterCommon.WriteMeshObject(writer, vertList, faceList, mqoMatIdx, null);
                            writer.WriteLine("}");
                        }
                    }
                    writer.WriteLine("Eof");
                }

                return(usedTextures);
            }
Exemplo n.º 18
0
Arquivo: Fbx.cs Projeto: kkdevs/sb3u
        public static void ExportFbx([DefaultVar] odfParser parser, object[] meshNames, object[] animations, int startKeyframe, int endKeyframe, bool linear, bool EulerFilter, double filterPrecision, string path, string exportFormat, bool allFrames, bool skins, bool odaSkeleton, bool compatibility)
        {
            List <string>  meshStrList = new List <string>(Utility.Convert <string>(meshNames));
            List <odfMesh> meshes      = new List <odfMesh>(meshStrList.Count);

            foreach (string meshName in meshStrList)
            {
                odfMesh mesh = odf.FindMeshListSome(meshName, parser.MeshSection);
                if (mesh != null || (mesh = odf.FindMeshListSome(new ObjectID(meshName), parser.MeshSection)) != null)
                {
                    meshes.Add(mesh);
                }
                else
                {
                    Report.ReportLog("Mesh " + meshName + " not found.");
                }
            }

            ODFConverter imp = new ODFConverter(parser, meshes);

            if (animations != null)
            {
                for (int i = 0; i < animations.Length; i++)
                {
                    odfParser odaParser = animations[i] as odfParser;
                    if (odaParser != null)
                    {
                        string animName = animations[++i] as string;
                        if (animName == null)
                        {
                            imp.ConvertAnimations((odfParser)odaParser, odaSkeleton);
                        }
                        else
                        {
                            if (animName == "ANIM")
                            {
                                imp.ConvertAnimation(odaParser.AnimSection, odaParser, odaSkeleton);
                            }
                            else
                            {
                                bool found = false;
                                if (odaParser.BANMList != null)
                                {
                                    foreach (odfANIMSection anim in odaParser.BANMList)
                                    {
                                        if (anim.Name == animName)
                                        {
                                            imp.ConvertAnimation(anim, odaParser, odaSkeleton);
                                            found = true;
                                            break;
                                        }
                                    }
                                }
                                if (!found)
                                {
                                    Report.ReportLog("animation \"" + animName + "\" not found");
                                }
                            }
                        }
                    }
                    else
                    {
                        Report.ReportLog("bad argument type for parameter 'animations' " + odaParser.GetType().ToString());
                    }
                }
            }

            FbxUtility.Export(path, imp, startKeyframe, endKeyframe, linear, EulerFilter, (float)filterPrecision, exportFormat, allFrames, false, skins, compatibility);
        }
Exemplo n.º 19
0
Arquivo: Fbx.cs Projeto: kkdevs/sb3u
        public static void ExportMorphFbx([DefaultVar] odfParser parser, string path, odfMesh mesh, odfMorphClip morphClip, string exportFormat)
        {
//			Fbx.Exporter.ExportMorph(path, xxparser, meshFrame, morphClip, xaparser, exportFormat);
        }
Exemplo n.º 20
0
        public static void ReplaceMesh(odfFrame frame, odfParser parser, WorkspaceMesh mesh, List <ImportedMaterial> materials, List <ImportedTexture> textures, bool merge, CopyMeshMethod normalsMethod, CopyMeshMethod bonesMethod)
        {
            Matrix   transform      = Matrix.Identity;
            odfFrame transformFrame = frame;

            while (transformFrame != null)
            {
                transform     *= transformFrame.Matrix;
                transformFrame = transformFrame.Parent as odfFrame;
            }
            transform.Invert();

            string[] materialNames;
            int[]    indices;
            bool[]   worldCoords;
            bool[]   replaceSubmeshesOption;
            odfMesh  newMesh = CreateMesh(mesh, parser.MeshSection._FormatType, out materialNames, out indices, out worldCoords, out replaceSubmeshesOption);

            odfMesh frameMesh = odf.FindMeshListSome(frame.MeshId, parser.MeshSection);

            if (frameMesh != null)
            {
                if (parser.UsedIDs == null)                 // prevent misleading error message
                {
                    parser.CollectObjectIDs();
                }
                newMesh.Id   = frameMesh.Id;
                newMesh.Name = frameMesh.Name;
                parser.MeshSection.InsertChild(parser.MeshSection.IndexOf(frameMesh), newMesh);
            }
            else
            {
                newMesh.Id   = parser.GetNewID(typeof(odfMesh));
                frame.MeshId = newMesh.Id;
                parser.MeshSection.AddChild(newMesh);
            }

            Dictionary <ObjectID, ObjectID> submeshIDtranslation = new Dictionary <ObjectID, ObjectID>(newMesh.Count);

            odfSubmesh[]      replaceSubmeshes = frameMesh != null ? new odfSubmesh[frameMesh.Count] : null;
            List <odfSubmesh> addSubmeshes     = new List <odfSubmesh>(newMesh.Count);

            for (int i = 0; i < newMesh.Count; i++)
            {
                ObjectID[] texIDs = new ObjectID[4] {
                    ObjectID.INVALID, ObjectID.INVALID, ObjectID.INVALID, ObjectID.INVALID
                };
                odfMaterial mat = odf.FindMaterialInfo(materialNames[i], parser.MaterialSection);
                if (materials != null && mat == null)
                {
                    ImportedMaterial impMat = ImportedHelpers.FindMaterial(materialNames[i], materials);
                    if (impMat != null)
                    {
                        mat = CreateMaterial(impMat, parser.GetNewID(typeof(odfMaterial)));
                        parser.MaterialSection.AddChild(mat);
                        for (int j = 0; j < impMat.Textures.Length; j++)
                        {
                            string     texName = impMat.Textures[j];
                            odfTexture tex     = odf.FindTextureInfo(texName, parser.TextureSection);
                            if (tex == null)
                            {
                                ImportedTexture impTex = ImportedHelpers.FindTexture(texName, textures);
                                if (impTex != null)
                                {
                                    tex = CreateTexture(impTex, parser.GetNewID(typeof(odfTexture)), parser.TextureSection._FormatType, Path.GetDirectoryName(parser.ODFPath));
                                    parser.TextureSection.AddChild(tex);
                                    texIDs[j] = tex.Id;
                                }
                            }
                            else
                            {
                                texIDs[j] = tex.Id;
                            }
                        }
                    }
                }

                odfSubmesh newSubmesh = newMesh[i];
                newSubmesh.Id         = parser.GetNewID(typeof(odfSubmesh));
                newSubmesh.MaterialId = mat != null ? mat.Id : ObjectID.INVALID;
                newSubmesh.TextureIds = texIDs;

                List <odfVertex> newVertexList = newSubmesh.VertexList;
                if (worldCoords[i])
                {
                    for (int j = 0; j < newVertexList.Count; j++)
                    {
                        newVertexList[j].Position = Vector3.TransformCoordinate(newVertexList[j].Position, transform);
                    }
                }

                odfSubmesh  baseSubmesh = null;
                odfBoneList newBones    = null;
                int         newBonesIdx = -1;
                int         idx         = indices[i];
                if ((frameMesh != null) && (idx >= 0) && (idx < frameMesh.Count))
                {
                    baseSubmesh = frameMesh[idx];
                    submeshIDtranslation.Add(newSubmesh.Id, baseSubmesh.Id);
                    for (int j = 0; j < baseSubmesh.TextureIds.Length; j++)
                    {
                        ObjectID texID = baseSubmesh.TextureIds[j];
                        newSubmesh.TextureIds[j] = texID;
                    }
                    newSubmesh.Name = new ObjectName(baseSubmesh.Name.Name, baseSubmesh.Name.Info);
                    CopyUnknowns(baseSubmesh, newSubmesh, parser.MeshSection._FormatType);

                    if ((bonesMethod == CopyMeshMethod.CopyOrder) || (bonesMethod == CopyMeshMethod.CopyNear))
                    {
                        odfBoneList baseBones = odf.FindBoneList(baseSubmesh.Id, parser.EnvelopeSection);
                        if (baseBones != null)
                        {
                            newBones           = baseBones.Clone();
                            newBones.Id        = ObjectID.INVALID;                     // parser.GetNewID(typeof(odfBoneList));
                            newBones.SubmeshId = newSubmesh.Id;
                            newBonesIdx        = parser.EnvelopeSection.IndexOf(baseBones);
                        }
                    }
                    else if (bonesMethod == CopyMeshMethod.Replace)
                    {
                        newBones    = CreateBoneList(ObjectID.INVALID /*parser.GetNewID(typeof(odfBoneList))*/, frame.Id, newSubmesh, mesh.BoneList, transform, parser.FrameSection.RootFrame);
                        newBonesIdx = parser.EnvelopeSection.Count;
                    }
                }
                else
                {
                    CreateUnknowns(newSubmesh, parser.MeshSection._FormatType);

                    newBones    = CreateBoneList(ObjectID.INVALID /*parser.GetNewID(typeof(odfBoneList))*/, frame.Id, newSubmesh, mesh.BoneList, transform, parser.FrameSection.RootFrame);
                    newBonesIdx = parser.EnvelopeSection.Count;
                }
                if (newBones != null)
                {
                    parser.EnvelopeSection.InsertChild(newBonesIdx, newBones);
                }

                if (baseSubmesh != null)
                {
                    if (normalsMethod == CopyMeshMethod.CopyOrder)
                    {
                        odf.CopyNormalsOrder(baseSubmesh.VertexList, newSubmesh.VertexList);
                    }
                    else if (normalsMethod == CopyMeshMethod.CopyNear)
                    {
                        odf.CopyNormalsNear(baseSubmesh.VertexList, newSubmesh.VertexList);
                    }

                    if (bonesMethod == CopyMeshMethod.CopyOrder)
                    {
                        odf.CopyBonesOrder(baseSubmesh.VertexList, newSubmesh.VertexList, newBones);
                    }
                    else if (bonesMethod == CopyMeshMethod.CopyNear)
                    {
                        odf.CopyBonesNear(baseSubmesh.VertexList, newSubmesh.VertexList, newBones);
                    }
                }

                if ((baseSubmesh != null) && merge && replaceSubmeshesOption[i])
                {
                    replaceSubmeshes[idx] = newSubmesh;
                }
                else
                {
                    addSubmeshes.Add(newSubmesh);
                }
            }

            if ((frameMesh != null) && merge)
            {
                newMesh.Clear();
                newMesh.Capacity = replaceSubmeshes.Length + addSubmeshes.Count;
                for (int i = 0, submeshesRemoved = 0; i < replaceSubmeshes.Length; i++)
                {
                    if (replaceSubmeshes[i] == null)
                    {
                        odfSubmesh newSubmesh = frameMesh[i - submeshesRemoved++];
                        frameMesh.RemoveChild(newSubmesh);                         // save the bone list from being deleted in RemoveMesh
                        newMesh.AddChild(newSubmesh);
                    }
                    else
                    {
                        newMesh.AddChild(replaceSubmeshes[i]);
                    }
                }
                newMesh.AddRange(addSubmeshes);
            }

            if (frameMesh != null)
            {
                RemoveMesh(parser, frameMesh, frame, false);
                parser.UsedIDs.Add((int)newMesh.Id, typeof(odfMesh));
                frame.MeshId = newMesh.Id;
                List <ObjectID> removeKeyList = new List <ObjectID>();
                foreach (odfSubmesh submesh in newMesh)
                {
                    ObjectID newSubmeshID = submesh.Id;
                    ObjectID baseSubmeshID;
                    if (submeshIDtranslation.TryGetValue(newSubmeshID, out baseSubmeshID))
                    {
                        if (odf.FindBoneList(baseSubmeshID, parser.EnvelopeSection) == null)
                        {
                            odfBoneList boneList = odf.FindBoneList(newSubmeshID, parser.EnvelopeSection);
                            if (boneList != null)
                            {
                                boneList.SubmeshId = baseSubmeshID;
                            }
                            submesh.Id = baseSubmeshID;
                            parser.UsedIDs.Remove((int)newSubmeshID);
                        }

                        foreach (KeyValuePair <ObjectID, ObjectID> pair in submeshIDtranslation)
                        {
                            if (pair.Value == baseSubmeshID)
                            {
                                removeKeyList.Add(pair.Key);
                            }
                        }
                        foreach (ObjectID removeId in removeKeyList)
                        {
                            submeshIDtranslation.Remove(removeId);
                        }
                        removeKeyList.Clear();
                    }
                }
            }
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
0
        private AnimationFrame CreateFrame(odfFrame frame, odfParser parser, HashSet <int> extractFrames, HashSet <int> meshIDs, Device device, Matrix combinedParent, List <AnimationFrame> meshFrames)
        {
            AnimationFrame animationFrame = new AnimationFrame();

            animationFrame.Name = frame.Name;
            animationFrame.TransformationMatrix = frame.Matrix;
            animationFrame.OriginalTransform    = animationFrame.TransformationMatrix;
            animationFrame.CombinedTransform    = combinedParent * animationFrame.TransformationMatrix;

            if ((int)frame.MeshId != 0 && meshIDs.Contains((int)frame.MeshId))
            {
                odfMesh            mesh      = odf.FindMeshListSome(frame.MeshId, parser.MeshSection);
                ExtendedMaterial[] materials = new ExtendedMaterial[mesh.Count];

                AnimationMeshContainer[] meshContainers = new AnimationMeshContainer[mesh.Count];
                Vector3 min = new Vector3(Single.MaxValue);
                Vector3 max = new Vector3(Single.MinValue);
                for (int i = 0; i < mesh.Count; i++)
                {
                    odfSubmesh       submesh    = mesh[i];
                    List <odfFace>   faceList   = submesh.FaceList;
                    List <odfVertex> vertexList = submesh.VertexList;

                    odfBoneList boneList    = odf.FindBoneList(submesh.Id, parser.EnvelopeSection);
                    bool        skinned     = boneList != null;
                    int         numBones    = skinned ? boneList.Count : 0;
                    string[]    boneNames   = new string[numBones];
                    Matrix[]    boneOffsets = new Matrix[numBones];
                    for (int boneIdx = 0; boneIdx < numBones; boneIdx++)
                    {
                        odfBone bone = boneList[boneIdx];
                        boneNames[boneIdx] = odf.FindFrame(bone.FrameId, parser.FrameSection.RootFrame).Name;
                        Matrix mirrored;
                        if (!BoneMatrixDic.TryGetValue(boneNames[boneIdx], out mirrored))
                        {
#if !DONT_MIRROR
                            Vector3    translate, scale;
                            Quaternion rotate;
                            bone.Matrix.Decompose(out scale, out rotate, out translate);
                            mirrored = Matrix.Scaling(scale.X, scale.Y, -scale.Z) * Matrix.RotationQuaternion(rotate) * Matrix.Translation(translate);
#else
                            mirrored = bone.Matrix;
#endif
                            BoneMatrixDic.Add(boneNames[boneIdx], mirrored);
                        }
                        boneOffsets[boneIdx] = mirrored;
                    }

                    Mesh animationMesh = new Mesh(device, faceList.Count, vertexList.Count, MeshFlags.Managed, PositionBlendWeightsIndexedNormalTexturedColoured.Format);

                    using (DataStream indexStream = animationMesh.LockIndexBuffer(LockFlags.None))
                    {
                        for (int j = 0; j < faceList.Count; j++)
                        {
                            ushort[] indices = faceList[j].VertexIndices;
                            indexStream.Write(indices[0]);
                            indexStream.Write(indices[1]);
                            indexStream.Write(indices[2]);
                        }
                        animationMesh.UnlockIndexBuffer();
                    }

                    float[][] vertexWeights = ConvertVertexWeights(vertexList, boneList);
                    FillVertexBuffer(animationMesh, vertexList, vertexWeights, -1);

                    var normalLines = new PositionBlendWeightsIndexedColored[vertexList.Count * 2];
                    for (int j = 0; j < vertexList.Count; j++)
                    {
                        odfVertex vertex = vertexList[j];
#if !DONT_MIRROR
                        Vector3 position = new Vector3(vertex.Position.X, vertex.Position.Y, -vertex.Position.Z);
                        Vector3 normal   = new Vector3(vertex.Normal.X, vertex.Normal.Y, -vertex.Normal.Z);
#else
                        Vector3 position = vertex.Position;
                        Vector3 normal   = vertex.Normal;
#endif
                        float[] boneWeights = vertexWeights[j];

                        normalLines[j * 2]       = new PositionBlendWeightsIndexedColored(position, boneWeights, vertex.BoneIndices, Color.Yellow.ToArgb());
                        normalLines[(j * 2) + 1] = new PositionBlendWeightsIndexedColored(position + (normal / 11), boneWeights, vertex.BoneIndices, Color.Blue.ToArgb());

                        min = Vector3.Minimize(min, position);
                        max = Vector3.Maximize(max, position);
                    }

                    AnimationMeshContainer meshContainer = new AnimationMeshContainer();
                    meshContainer.Name        = animationFrame.Name;
                    meshContainer.MeshData    = new MeshData(animationMesh);
                    meshContainer.NormalLines = normalLines;
                    meshContainer.BoneNames   = boneNames;
                    meshContainer.BoneOffsets = boneOffsets;
                    meshContainers[i]         = meshContainer;

                    odfMaterial mat = odf.FindMaterialInfo(submesh.MaterialId, parser.MaterialSection);
                    if (mat != null)
                    {
                        Material material3D = new Material();
                        material3D.Ambient  = mat.Ambient;
                        material3D.Diffuse  = mat.Diffuse;
                        material3D.Emissive = mat.Emissive;
                        material3D.Specular = mat.Specular;
                        material3D.Power    = mat.SpecularPower;
                        int matIdx = parser.MaterialSection.IndexOf(mat);
                        Materials[matIdx]           = material3D;
                        meshContainer.MaterialIndex = matIdx;

                        int texIdx = -1;
                        if ((int)submesh.TextureIds[0] != 0 && !TextureDic.TryGetValue((int)submesh.TextureIds[0], out texIdx))
                        {
                            odfTexture tex = odf.FindTextureInfo(submesh.TextureIds[0], parser.TextureSection);
                            if (tex != null)
                            {
                                try
                                {
                                    odfTextureFile  texFile  = new odfTextureFile(null, Path.GetDirectoryName(parser.ODFPath) + Path.DirectorySeparatorChar + tex.TextureFile);
                                    int             fileSize = 0;
                                    ImportedTexture impTex   = new ImportedTexture(texFile.DecryptFile(ref fileSize).BaseStream, tex.TextureFile);
                                    Texture         memTex   = impTex.ToTexture(device);
                                    texIdx = TextureDic.Count;
                                    TextureDic.Add((int)submesh.TextureIds[0], texIdx);
                                    Textures[texIdx] = memTex;
                                }
                                catch (SlimDXException ex)
                                {
                                    Utility.ReportException(ex);
                                    Report.ReportLog("Please check " + tex.TextureFile + ". It may have an unsupported format.");
                                }
                                catch (Exception ex)
                                {
                                    Utility.ReportException(ex);
                                }
                            }
                        }
                        meshContainer.TextureIndex = texIdx;
                    }
                }

                for (int i = 0; i < (meshContainers.Length - 1); i++)
                {
                    meshContainers[i].NextMeshContainer = meshContainers[i + 1];
                }

                animationFrame.Bounds        = new BoundingBox(min, max);
                animationFrame.MeshContainer = meshContainers[0];
                meshFrames.Add(animationFrame);
            }

            for (int i = 0; i < frame.Count; i++)
            {
                odfFrame child = frame[i];
                if (extractFrames.Contains((int)child.Id))
                {
                    AnimationFrame childAnimationFrame = CreateFrame(child, parser, extractFrames, meshIDs, device, animationFrame.CombinedTransform, meshFrames);
                    childAnimationFrame.Parent = animationFrame;
                    animationFrame.AppendChild(childAnimationFrame);
                }
            }

            numFrames++;
            return(animationFrame);
        }
Exemplo n.º 23
0
        private void CollectObjectIDs(IObjInfo obj)
        {
            ObjectID id = null;

            if (obj is odfMaterial)
            {
                id = ((odfMaterial)obj).Id;
            }
            else if (obj is odfTexture)
            {
                id = ((odfTexture)obj).Id;
            }
            else if (obj is odfMesh)
            {
                odfMesh mesh = (odfMesh)obj;
                for (int i = 0; i < mesh.Count; i++)
                {
                    odfSubmesh submesh = mesh[i];
                    CollectObjectIDs(submesh);
                }
                id = ((odfMesh)obj).Id;
            }
            else if (obj is odfSubmesh)
            {
                id = ((odfSubmesh)obj).Id;
            }
            else if (obj is odfFrame)
            {
                odfFrame frame = (odfFrame)obj;
                for (int i = 0; i < frame.Count; i++)
                {
                    odfFrame childFrame = frame[i];
                    CollectObjectIDs(childFrame);
                }
                id = frame.Id;
            }
            else if (obj is odfMaterialSection)
            {
                odfMaterialSection matSec = (odfMaterialSection)obj;
                foreach (odfMaterial mat in matSec)
                {
                    CollectObjectIDs(mat);
                }
            }
            else if (obj is odfTextureSection)
            {
                odfTextureSection texSec = (odfTextureSection)obj;
                foreach (odfTexture tex in texSec)
                {
                    CollectObjectIDs(tex);
                }
            }
            else if (obj is odfMeshSection)
            {
                odfMeshSection meshSec = (odfMeshSection)obj;
                foreach (odfMesh mesh in meshSec)
                {
                    CollectObjectIDs(mesh);
                }
            }
            else if (obj is odfFrameSection)
            {
                odfFrameSection frameSec = (odfFrameSection)obj;
                foreach (odfFrame frame in frameSec)
                {
                    CollectObjectIDs(frame);
                }
            }
            else if (obj is odfEnvelopeSection)
            {
                odfEnvelopeSection envSec = (odfEnvelopeSection)obj;
                foreach (odfBoneList boneList in envSec.ChildList)
                {
                    CollectObjectIDs(boneList);
                }
                id = envSec.Id;
            }
            else if (obj is odfBoneList)
            {
                odfBoneList boneList = (odfBoneList)obj;
                foreach (odfBone bone in boneList)
                {
                    CollectObjectIDs(bone);
                }
                id = boneList.Id;
            }
            else if (obj is odfMorphSection)
            {
                id = ((odfMorphSection)obj).Id;
            }
            else if (obj is odfTXPTSection)
            {
                id = ((odfTXPTSection)obj).Id;
            }
            else if (obj is odfMATASection)
            {
                id = ((odfMATASection)obj).Id;
            }
            else if (obj is odfANIMSection)
            {
                id = ((odfANIMSection)obj).Id;
            }
            else if (obj is odfBANMSection)
            {
                id = ((odfBANMSection)obj).Id;
            }

            if (id != null)
            {
                int idVal = (int)id;
                if (idVal != 0)
                {
                    try
                    {
                        this.UsedIDs.Add(idVal, obj.GetType());
                    }
                    catch (ArgumentException argEx)
                    {
                        Type typeInDic;
                        this.UsedIDs.TryGetValue(idVal, out typeInDic);
                        Report.ReportLog(obj.GetType() + " ID: " + id + " - " + argEx.Message + " - " + typeInDic);
                    }
                    catch (Exception ex)
                    {
                        Report.ReportLog(obj.GetType() + " ID: " + id + " - " + ex.Message);
                    }
                }
                else if (!(obj is odfBoneList))
                {
                    Report.ReportLog("Invalid ID used by " + obj.GetType().Name);
                }
            }
        }
Exemplo n.º 24
0
        private bool loadMESH(BinaryReader reader, odfFileSection fileSec)
        {
            odfMeshSection meshSection = new odfMeshSection(0);

            meshSection._FormatType = 10;
            if (!reader.BaseStream.CanSeek)
            {
                byte[] buffer = reader.ReadBytes(fileSec.Size);
                reader = new BinaryReader(new MemoryStream(buffer));
            }
            for (int endPosition = (int)reader.BaseStream.Position + fileSec.Size; reader.BaseStream.Position < endPosition;)
            {
                ObjectName name         = new ObjectName(reader.ReadBytes(64));
                ObjectID   id           = new ObjectID(reader.ReadBytes(4));
                int        numSubmeshes = reader.ReadInt32();
                odfMesh    mesh         = new odfMesh(name, id, numSubmeshes);

                for (int submeshIdx = 0; submeshIdx < numSubmeshes; submeshIdx++)
                {
                    name = new ObjectName(reader.ReadBytes(64));
                    id   = new ObjectID(reader.ReadBytes(4));

                    int    unknown1    = reader.ReadInt32();
                    byte[] alwaysZero1 = reader.ReadBytes(4);

                    ObjectID   materialId = new ObjectID(reader.ReadBytes(4));
                    ObjectID[] texID      = new ObjectID[4];
                    for (int texIdx = 0; texIdx < 4; texIdx++)
                    {
                        texID[texIdx] = new ObjectID(reader.ReadBytes(4));
                    }

                    UInt32 unknown31 = reader.ReadUInt32();

                    byte[] alwaysZero2 = reader.ReadBytes(16);

                    int unknown3 = reader.ReadInt32();

                    byte[] numVertsOrUnknown       = reader.ReadBytes(4);
                    byte[] numVertIndicesOrUnknown = reader.ReadBytes(4);
                    int    unknown4                = reader.ReadInt32();
                    int    unknown5                = reader.ReadInt32();
                    byte[] unknownOrNumVerts       = reader.ReadBytes(4);
                    byte[] unknownOrNumVertIndices = reader.ReadBytes(4);

                    if (meshSection.Count == 0)
                    {
                        int numVerts      = BitConverter.ToInt32(numVertsOrUnknown, 0);
                        int numVertexIdxs = BitConverter.ToInt32(numVertIndicesOrUnknown, 0);
                        if (numVerts * numVertexIdxs == 0)
                        {
                            meshSection._FormatType = 9;
                        }
                    }
                    odfSubmesh submesh = new odfSubmesh(name, id, meshSection._FormatType);
                    submesh.Unknown1    = unknown1;
                    submesh.AlwaysZero1 = alwaysZero1;
                    submesh.MaterialId  = materialId;
                    submesh.TextureIds  = texID;
                    submesh.Unknown31   = unknown31;
                    submesh.AlwaysZero2 = alwaysZero2;
                    submesh.Unknown4    = unknown3;
                    submesh.Unknown5    = unknown4;
                    submesh.Unknown6    = unknown5;
                    int numVertices, numVertexIndices;
                    if (meshSection._FormatType < 10)
                    {
                        submesh.Unknown7    = BitConverter.ToInt32(numVertsOrUnknown, 0);
                        submesh.Unknown8    = numVertIndicesOrUnknown;
                        numVertices         = BitConverter.ToInt32(unknownOrNumVerts, 0);
                        numVertexIndices    = BitConverter.ToInt32(unknownOrNumVertIndices, 0);
                        submesh.AlwaysZero3 = reader.ReadBytes(448);
                    }
                    else
                    {
                        numVertices      = BitConverter.ToInt32(numVertsOrUnknown, 0);
                        numVertexIndices = BitConverter.ToInt32(numVertIndicesOrUnknown, 0);
                        submesh.Unknown7 = BitConverter.ToInt32(unknownOrNumVerts, 0);
                        submesh.Unknown8 = unknownOrNumVertIndices;
                    }

                    submesh.VertexList = ParseVertexList(reader, numVertices);
                    submesh.FaceList   = ParseFaceList(reader, numVertexIndices / 3);

                    submesh.AlwaysZero4 = reader.ReadBytes(24);

                    mesh.AddChild(submesh);
                }
                meshSection.AddChild(mesh);
            }

            fileSec.Section = meshSection;
            MeshSection     = meshSection;
            return(true);
        }