public static odfMaterial FindMaterialInfo(string name, odfMaterialSection matSection) { for (int i = 0; i < matSection.Count; i++) { if (matSection[i].Name == name) { return(matSection[i]); } } return(null); }
public static odfMaterial FindMaterialInfo(ObjectID id, odfMaterialSection matSection) { for (int i = 0; i < matSection.Count; i++) { if (matSection[i].Id == id) { return(matSection[i]); } } return(null); }
private bool loadMAT(BinaryReader reader, odfFileSection fileSec) { int numMats = fileSec.Size / (64 + 4 + 18 * 4); odfMaterialSection matSec = new odfMaterialSection(numMats); if (!loadMaterials(reader, numMats, matSec)) { return(false); } fileSec.Section = matSec; MaterialSection = matSec; return(true); }
private bool loadMaterials(BinaryReader reader, int numMats, odfMaterialSection matSec) { int endOffset = numMats * (64 + 4 + 18 * 4); for (int secOffset = 0; secOffset < endOffset; secOffset += 64 + 4 + 18 * 4) { ObjectName name = new ObjectName(reader.ReadBytes(64)); ObjectID id = new ObjectID(reader.ReadBytes(4)); odfMaterial mat = new odfMaterial(name, id); mat.Diffuse = reader.ReadColor4(); mat.Ambient = reader.ReadColor4(); mat.Specular = reader.ReadColor4(); mat.Emissive = reader.ReadColor4(); mat.SpecularPower = reader.ReadSingle(); mat.Unknown1 = reader.ReadSingle(); matSec.AddChild(mat); } 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); } } }