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); }
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); } } }
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); }
public odfBoneList(ObjectName name, ObjectID id, int childCapacity) { Name = name; Id = id; InitChildren(childCapacity); }
public odfBone(ObjectID frameId) { FrameId = frameId; }
public odfMaterial(ObjectName name, ObjectID id) { Name = new ObjectName(name.Name, name.Info); Id = id; }
public odfMesh(ObjectName name, ObjectID id, int numMeshObjects) { Name = name; Id = id; InitChildren(numMeshObjects); }
public override bool Equals(object obj) { ObjectID id = obj as ObjectID; return(id != null && id[0] == this[0] && id[1] == this[1] && id[2] == this[2] && id[3] == this[3]); }
public ObjectID(ObjectID id) : this(id.Id) { }
public odfBANMSection(ObjectID id, int childCapacity) : base(id, childCapacity) { Range = new odfUncountedBlock(); }
public odfANIMSection(ObjectID id, int childCapacity) : base(childCapacity) { Id = id; }
public odfMorphObject(ObjectID submeshId, int numSelectors, int numProfiles) { SubmeshId = submeshId; InitChildren(numProfiles); SelectorList = new List <odfMorphSelector>(numSelectors); }