public static odfTexture FindTextureInfo(string name, odfTextureSection texSection) { for (int i = 0; i < texSection.Count; i++) { if (texSection[i].Name == name) { return(texSection[i]); } } return(null); }
public static odfTexture FindTextureInfo(ObjectID id, odfTextureSection texSection) { for (int i = 0; i < texSection.Count; i++) { if (texSection[i].Id == id) { return(texSection[i]); } } return(null); }
private bool loadTEX(BinaryReader reader, odfFileSection fileSec) { int TEXsize = 64 + 4 + 64; odfTextureSection texSec = new odfTextureSection(fileSec.Size / TEXsize); texSec._FormatType = 10; byte[] buffer = reader.ReadBytes(fileSec.Size); for (int secOffset = 0; secOffset < fileSec.Size; secOffset += TEXsize) { byte[] sub = new byte[64]; Array.Copy(buffer, secOffset, sub, 0, 64); ObjectName name = new ObjectName(sub); sub = new byte[4]; Array.Copy(buffer, secOffset + 64, sub, 0, 4); ObjectID id = new ObjectID(sub); odfTexture tex = new odfTexture(name, id, texSec._FormatType); sub = new byte[64]; Array.Copy(buffer, secOffset + 64 + 4, sub, 0, 64); tex.TextureFile = new ObjectName(sub); if (secOffset == 0 && TEXsize < fileSec.Size) { int notZero = 0; for (int i = 64 + 4 + 64; i < 64 + 4 + 64 + 72; i++) { if (buffer[i] != 0 && ++notZero > 5) { break; } } if (notZero <= 5) { texSec._FormatType = 9; tex.Unknown1 = new byte[72]; TEXsize += 72; } } if (texSec._FormatType < 10) { Array.Copy(buffer, secOffset + 64 + 4 + 64, tex.Unknown1, 0, 72); } texSec.AddChild(tex); } fileSec.Section = texSec; this.TextureSection = texSec; 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); } } }