Ejemplo n.º 1
0
        public static void RemoveSubmesh(odfParser parser, odfSubmesh submesh, bool deleteMorphs)
        {
            odfBoneList boneList = odf.FindBoneList(submesh.Id, parser.EnvelopeSection);

            if (boneList != null)
            {
                parser.EnvelopeSection.RemoveChild(boneList);
                parser.UsedIDs.Remove((int)boneList.Id);
            }

            if (parser.MorphSection != null && deleteMorphs)
            {
                for (int i = 0; i < parser.MorphSection.Count; i++)
                {
                    odfMorphObject morphObj = parser.MorphSection[i];
                    if (morphObj.SubmeshId == submesh.Id)
                    {
                        parser.MorphSection.RemoveChild(i);
                        --i;
                    }
                }
            }

            ((odfMesh)submesh.Parent).RemoveChild(submesh);
        }
Ejemplo n.º 2
0
Archivo: Mqo.cs Proyecto: kkdevs/sb3u
            public static void Export(string dirPath, odfParser parser, odfMorphObject morphObj, bool skipUnusedProfiles)
            {
                DirectoryInfo dir      = new DirectoryInfo(dirPath);
                ExporterMorph exporter = new ExporterMorph(dir, parser, morphObj, skipUnusedProfiles);

                exporter.Export(dir);
            }
Ejemplo n.º 3
0
Archivo: Mqo.cs Proyecto: kkdevs/sb3u
        public static void ExportMorphMqo([DefaultVar] string dirPath, odfParser odfParser, string morphObjName, bool skipUnusedProfiles)
        {
            if (dirPath == null)
            {
                dirPath = Path.GetDirectoryName(odfParser.ODFPath) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(odfParser.ODFPath);
            }
            odfMorphObject morphObj = odf.FindMorphObject(morphObjName, odfParser.MorphSection);

            Mqo.ExporterMorph.Export(dirPath, odfParser, morphObj, skipUnusedProfiles);
        }
Ejemplo n.º 4
0
        public static odfMorphProfile FindMorphProfile(String name, odfMorphObject morphObj)
        {
            for (int profileIdx = 0; profileIdx < morphObj.Count; profileIdx++)
            {
                odfMorphProfile profile = morphObj[profileIdx];
                if (profile.Name == name)
                {
                    return(profile);
                }
            }

            return(null);
        }
Ejemplo n.º 5
0
        public static odfMorphObject FindMorphObject(String name, odfMorphSection morphSection)
        {
            for (int morphObjIdx = 0; morphObjIdx < morphSection.Count; morphObjIdx++)
            {
                odfMorphObject morphObj = morphSection[morphObjIdx];
                if (morphObj.Name == name)
                {
                    return(morphObj);
                }
            }

            return(null);
        }
Ejemplo n.º 6
0
        private bool loadMORP(BinaryReader reader, odfFileSection fileSec)
        {
            ObjectName      name            = new ObjectName(reader.ReadBytes(64));
            ObjectID        id              = new ObjectID(reader.ReadBytes(4));
            int             numMorphObjects = reader.ReadInt32();
            odfMorphSection morpSection     = new odfMorphSection(id, numMorphObjects);

            morpSection.Name = name;
            for (int morphObjIdx = 0; morphObjIdx < numMorphObjects; morphObjIdx++)
            {
                id = new ObjectID(reader.ReadBytes(4));
                byte[]         alwaysZero       = reader.ReadBytes(16);
                int            numSelectorInfos = reader.ReadInt32();
                int            numProfiles      = reader.ReadInt32();
                odfMorphObject morphObj         = new odfMorphObject(id, numSelectorInfos, numProfiles);
                morphObj.AlwaysZero16 = alwaysZero;
                morphObj.Name         = new ObjectName(reader.ReadBytes(64));

                morphObj.NumIndices     = reader.ReadInt32();
                morphObj.MeshIndices    = reader.ReadUInt16Array(morphObj.NumIndices);
                morphObj.UnknownIndices = reader.ReadInt32Array(morphObj.NumIndices);

                for (int idx = 0; idx < numProfiles; idx++)
                {
                    odfMorphProfile profile = new odfMorphProfile();
                    profile.VertexList = ParseVertexList(reader, morphObj.NumIndices);
                    profile.Name       = new ObjectName(reader.ReadBytes(64));

                    morphObj.AddChild(profile);
                }

                List <odfMorphSelector> selectorList = new List <odfMorphSelector>(numSelectorInfos);
                for (int idx = 0; idx < numSelectorInfos; idx++)
                {
                    odfMorphSelector selectorInfo = new odfMorphSelector();
                    selectorInfo.Threshold    = reader.ReadInt32();
                    selectorInfo.ProfileIndex = reader.ReadInt32();

                    selectorList.Add(selectorInfo);
                }
                morphObj.SelectorList = selectorList;

                morphObj.ClipType = reader.ReadInt32();
                if (morphObj.ClipType > 0)
                {
                    int numClipInfos             = reader.ReadInt32();
                    List <odfMorphClip> clipList = new List <odfMorphClip>(numClipInfos);
                    for (int idx = 0; idx < numClipInfos; idx++)
                    {
                        odfMorphClip clipInfo = new odfMorphClip();
                        clipInfo.StartIndex = reader.ReadInt32();
                        clipInfo.EndIndex   = reader.ReadInt32();
                        clipInfo.Unknown    = reader.ReadInt32();

                        clipList.Add(clipInfo);
                    }
                    morphObj.MorphClipList = clipList;
                }

                morphObj.MinusOne = reader.ReadInt32();
                morphObj.FrameId  = new ObjectID(reader.ReadBytes(4));

                morpSection.AddChild(morphObj);
            }

            fileSec.Section = morpSection;
            MorphSection    = morpSection;
            return(true);
        }
Ejemplo n.º 7
0
        public static void ReplaceMorph(string destMorphName, odfParser parser, WorkspaceMorph wsMorphList, string newMorphName, bool replaceNormals, float minSquaredDistance)
        {
            odfMorphSection morphSection = parser.MorphSection;

            if (morphSection == null)
            {
                Report.ReportLog("The .odf file doesn't have a morph section. Skipping these morphs");
                return;
            }

            odfMorphObject morphObj = odf.FindMorphObject(destMorphName, morphSection);

            if (morphObj == null)
            {
                Report.ReportLog("Couldn't find morph object " + destMorphName + ". Skipping these morphs");
                return;
            }

            Report.ReportLog("Replacing morphs ...");
            try
            {
                ushort[] meshIndices = morphObj.MeshIndices;
                foreach (ImportedMorphKeyframe wsMorph in wsMorphList.KeyframeList)
                {
                    if (!wsMorphList.isMorphKeyframeEnabled(wsMorph))
                    {
                        continue;
                    }
                    odfMorphProfile profile = odf.FindMorphProfile(wsMorph.Name, morphObj);
                    if (profile == null)
                    {
                        Report.ReportLog("Warning: Couldn't find morph profile " + wsMorph.Name + ". Skipping this morph");
                        continue;
                    }

                    List <ImportedVertex> vertList = wsMorph.VertexList;
                    for (int i = 0; i < meshIndices.Length; i++)
                    {
                        Vector3 orgPos = new Vector3(profile.VertexList[i].Position.X, profile.VertexList[i].Position.Y, profile.VertexList[i].Position.Z),
                                newPos = new Vector3(vertList[meshIndices[i]].Position.X, vertList[meshIndices[i]].Position.Y, vertList[meshIndices[i]].Position.Z);
                        if ((orgPos - newPos).LengthSquared() >= minSquaredDistance)
                        {
                            profile.VertexList[i].Position = vertList[meshIndices[i]].Position;
                        }
                        if (replaceNormals)
                        {
                            profile.VertexList[i].Normal = vertList[meshIndices[i]].Normal;
                        }
                    }

                    string morphNewName = wsMorphList.getMorphKeyframeNewName(wsMorph);
                    if (morphNewName != String.Empty)
                    {
                        profile.Name = new ObjectName(morphNewName, null);
                    }
                }
                if (newMorphName != String.Empty)
                {
                    morphObj.Name = new ObjectName(newMorphName, null);
                }
            }
            catch (Exception ex)
            {
                Utility.ReportException(ex);
            }
        }
Ejemplo n.º 8
0
Archivo: Mqo.cs Proyecto: kkdevs/sb3u
 private ExporterMorph(DirectoryInfo dir, odfParser parser, odfMorphObject morphObj, bool skipUnusedProfiles)
 {
     this.parser             = parser;
     this.morphObj           = morphObj;
     this.skipUnusedProfiles = skipUnusedProfiles;
 }