Beispiel #1
0
        public static odfBoneList FindBoneList(ObjectID submeshID, odfEnvelopeSection envSection)
        {
            if (envSection == null)
            {
                return(null);
            }

            for (int envIdx = 0; envIdx < envSection.Count; envIdx++)
            {
                if (envSection[envIdx].SubmeshId == submeshID)
                {
                    return(envSection[envIdx]);
                }
            }

            return(null);
        }
Beispiel #2
0
        private bool loadENVL(BinaryReader reader, odfFileSection fileSec)
        {
            ObjectID id = new ObjectID(reader.ReadBytes(4));

            byte[]             alwaysZero   = reader.ReadBytes(64);
            int                numEnvelopes = reader.ReadInt32();
            odfEnvelopeSection envSection   = new odfEnvelopeSection(numEnvelopes);

            envSection.Id           = id;
            envSection.AlwaysZero64 = alwaysZero;
            envSection._FormatType  = MeshSection != null ? MeshSection._FormatType : -1;
            for (int envIdx = 0; envIdx < numEnvelopes; envIdx++)
            {
                odfBoneList boneList = ParseBoneList(reader, envSection._FormatType);
                envSection.AddChild(boneList);
            }

            fileSec.Section = envSection;
            EnvelopeSection = envSection;
            return(true);
        }
Beispiel #3
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);
                }
            }
        }