public void CreateTable(List <PmxMaterial> ml) { NameToIndex.Clear(); IndexToName.Clear(); int num = 0; for (int i = 0; i < ml.Count; i++) { PmxMaterial pmxMaterial = ml[i]; if (!string.IsNullOrEmpty(pmxMaterial.Tex) && !NameToIndex.ContainsKey(pmxMaterial.Tex)) { NameToIndex.Add(pmxMaterial.Tex, num); IndexToName.Add(num, pmxMaterial.Tex); num++; } if (!string.IsNullOrEmpty(pmxMaterial.Sphere) && !NameToIndex.ContainsKey(pmxMaterial.Sphere)) { NameToIndex.Add(pmxMaterial.Sphere, num); IndexToName.Add(num, pmxMaterial.Sphere); num++; } if (!string.IsNullOrEmpty(pmxMaterial.Toon) && !NameToIndex.ContainsKey(pmxMaterial.Toon) && !SystemToon.IsSystemToon(pmxMaterial.Toon)) { NameToIndex.Add(pmxMaterial.Toon, num); IndexToName.Add(num, pmxMaterial.Toon); num++; } } }
// Token: 0x060001A7 RID: 423 RVA: 0x0000FEE0 File Offset: 0x0000E0E0 public void FromPmxMaterial(PmxMaterial m, bool nonStr) { this.Diffuse = m.Diffuse; this.Specular = m.Specular; this.Power = m.Power; this.Ambient = m.Ambient; this.Flags = m.Flags; this.EdgeColor = m.EdgeColor; this.EdgeSize = m.EdgeSize; this.SphereMode = m.SphereMode; this.FaceCount = m.FaceCount; this.ExDraw = m.ExDraw; bool flag = !nonStr; if (flag) { this.Name = m.Name; this.NameE = m.NameE; this.Tex = m.Tex; this.Sphere = m.Sphere; this.Toon = m.Toon; this.Memo = m.Memo; } this.Attribute = m.Attribute; }
// Token: 0x06000259 RID: 601 RVA: 0x00013014 File Offset: 0x00011214 public void CreateTable(List <PmxMaterial> ml) { this.NameToIndex.Clear(); this.IndexToName.Clear(); int num = 0; for (int i = 0; i < ml.Count; i++) { PmxMaterial pmxMaterial = ml[i]; bool flag = !string.IsNullOrEmpty(pmxMaterial.Tex) && !this.NameToIndex.ContainsKey(pmxMaterial.Tex); if (flag) { this.NameToIndex.Add(pmxMaterial.Tex, num); this.IndexToName.Add(num, pmxMaterial.Tex); num++; } bool flag2 = !string.IsNullOrEmpty(pmxMaterial.Sphere) && !this.NameToIndex.ContainsKey(pmxMaterial.Sphere); if (flag2) { this.NameToIndex.Add(pmxMaterial.Sphere, num); this.IndexToName.Add(num, pmxMaterial.Sphere); num++; } bool flag3 = !string.IsNullOrEmpty(pmxMaterial.Toon) && !this.NameToIndex.ContainsKey(pmxMaterial.Toon) && !SystemToon.IsSystemToon(pmxMaterial.Toon); if (flag3) { this.NameToIndex.Add(pmxMaterial.Toon, num); this.IndexToName.Add(num, pmxMaterial.Toon); num++; } } }
public void FromPmxMaterial(PmxMaterial m, bool nonStr = false) { Diffuse = m.Diffuse; Specular = m.Specular; Power = m.Power; Ambient = m.Ambient; Flags = m.Flags; EdgeColor = m.EdgeColor; EdgeSize = m.EdgeSize; SphereMode = m.SphereMode; FaceCount = m.FaceCount; ExDraw = m.ExDraw; if (!nonStr) { Name = m.Name; NameE = m.NameE; Tex = m.Tex; Sphere = m.Sphere; Toon = m.Toon; Memo = m.Memo; } Attribute = m.Attribute; FromID(m); }
public virtual void FromStream(Stream s, bool id) { Action <Action> action = delegate(Action a) { try { a(); } catch (Exception) { LoadErrCount++; } }; PmxHeader head = new PmxHeader(); head.FromStreamEx(s); Header.FromHeader(head); head.ElementFormat.WithID = id; action(delegate { ModelInfo.FromStreamEx(s, head.ElementFormat); }); int count = 0; action(delegate { count = PmxStreamHelper.ReadElement_Int32(s); }); VertexList.Clear(); VertexList.Capacity = count; for (int k = 0; k < count; k++) { PmxVertex v = new PmxVertex(); action(delegate { v.FromStreamEx(s, head.ElementFormat); }); VertexList.Add(v); } action(delegate { count = PmxStreamHelper.ReadElement_Int32(s); }); FaceList.Clear(); FaceList.Capacity = count; for (int l = 0; l < count; l++) { int ix = 0; action(delegate { ix = PmxStreamHelper.ReadElement_Int32(s, head.ElementFormat.VertexSize, signed: false); }); FaceList.Add(ix); } PmxTextureTable tx = new PmxTextureTable(); action(delegate { tx.FromStreamEx(s, head.ElementFormat); }); action(delegate { count = PmxStreamHelper.ReadElement_Int32(s); }); MaterialList.Clear(); MaterialList.Capacity = count; for (int m = 0; m < count; m++) { PmxMaterial j = new PmxMaterial(); action(delegate { j.FromStreamEx_TexTable(s, tx, head.ElementFormat); }); MaterialList.Add(j); } action(delegate { count = PmxStreamHelper.ReadElement_Int32(s); }); BoneList.Clear(); BoneList.Capacity = count; for (int n = 0; n < count; n++) { PmxBone b = new PmxBone(); action(delegate { b.FromStreamEx(s, head.ElementFormat); }); BoneList.Add(b); } action(delegate { count = PmxStreamHelper.ReadElement_Int32(s); }); MorphList.Clear(); MorphList.Capacity = count; for (int num = 0; num < count; num++) { PmxMorph morph = new PmxMorph(); action(delegate { morph.FromStreamEx(s, head.ElementFormat); }); MorphList.Add(morph); } action(delegate { count = PmxStreamHelper.ReadElement_Int32(s); }); NodeList.Clear(); NodeList.Capacity = count; for (int num2 = 0; num2 < count; num2++) { PmxNode node = new PmxNode(); action(delegate { node.FromStreamEx(s, head.ElementFormat); }); NodeList.Add(node); if (NodeList[num2].SystemNode) { if (NodeList[num2].Name == "Root") { RootNode = NodeList[num2]; } else if (NodeList[num2].Name == "表情") { ExpNode = NodeList[num2]; } } } action(delegate { count = PmxStreamHelper.ReadElement_Int32(s); }); BodyList.Clear(); BodyList.Capacity = count; for (int num3 = 0; num3 < count; num3++) { PmxBody b2 = new PmxBody(); action(delegate { b2.FromStreamEx(s, head.ElementFormat); }); BodyList.Add(b2); } action(delegate { count = PmxStreamHelper.ReadElement_Int32(s); }); JointList.Clear(); JointList.Capacity = count; for (int num4 = 0; num4 < count; num4++) { PmxJoint i = new PmxJoint(); action(delegate { i.FromStreamEx(s, head.ElementFormat); }); JointList.Add(i); } if (head.Ver >= 2.1f) { action(delegate { count = PmxStreamHelper.ReadElement_Int32(s); }); SoftBodyList.Clear(); SoftBodyList.Capacity = count; for (int num5 = 0; num5 < count; num5++) { PmxSoftBody b3 = new PmxSoftBody(); action(delegate { b3.FromStreamEx(s, head.ElementFormat); }); SoftBodyList.Add(b3); } } if (id) { action(delegate { FilePath = PmxStreamHelper.ReadString(s, head.ElementFormat); }); } head.ElementFormat.WithID = false; }
// Token: 0x060001A6 RID: 422 RVA: 0x0000FECB File Offset: 0x0000E0CB public PmxMaterial(PmxMaterial m, bool nonStr) : this() { this.FromPmxMaterial(m, nonStr); }
public PmxMaterial(PmxMaterial m, bool nonStr = false) : this() { FromPmxMaterial(m, nonStr); }
// Token: 0x060002B3 RID: 691 RVA: 0x00014E10 File Offset: 0x00013010 public SystemToon.ToonInfo GetToonInfo(List <PmxMaterial> list) { int count = list.Count; bool flag = count < 0; SystemToon.ToonInfo result; if (flag) { result = null; } else { SystemToon.ToonInfo toonInfo = new SystemToon.ToonInfo(count); bool[] array = new bool[10]; List <string> list2 = new List <string>(count); Dictionary <string, int> dictionary = new Dictionary <string, int>(count); for (int i = 0; i < count; i++) { PmxMaterial pmxMaterial = list[i]; bool flag2 = string.IsNullOrEmpty(pmxMaterial.Toon); if (flag2) { toonInfo.MaterialToon[i] = -1; } else { int toonIndex = SystemToon.GetToonIndex(pmxMaterial.Toon); toonInfo.MaterialToon[i] = toonIndex; bool flag3 = -1 <= toonIndex && toonIndex < 10; if (flag3) { bool flag4 = toonIndex >= 0; if (flag4) { array[toonIndex] = true; } } else { bool flag5 = !dictionary.ContainsKey(pmxMaterial.Toon); if (flag5) { list2.Add(pmxMaterial.Toon); dictionary.Add(pmxMaterial.Toon, 0); } } } } bool flag6 = list2.Count > 0; if (flag6) { Dictionary <string, int> dictionary2 = new Dictionary <string, int>(list2.Count); int num = 0; for (int j = 0; j < list2.Count; j++) { for (int k = num; k < array.Length; k++) { bool flag7 = !array[k]; if (flag7) { toonInfo.ToonNames[k] = list2[j]; dictionary2.Add(list2[j], k); array[k] = true; num = k + 1; break; } } } for (int l = 0; l < count; l++) { bool flag8 = toonInfo.MaterialToon[l] < -1; if (flag8) { PmxMaterial pmxMaterial2 = list[l]; bool flag9 = dictionary2.ContainsKey(pmxMaterial2.Toon); if (flag9) { toonInfo.MaterialToon[l] = dictionary2[pmxMaterial2.Toon]; } else { toonInfo.MaterialToon[l] = -1; toonInfo.IsRejection = true; } } } } result = toonInfo; } return(result); }
// Token: 0x060000B2 RID: 178 RVA: 0x0000CC80 File Offset: 0x0000AE80 public virtual void FromStreamEx(Stream s, PmxElementFormat f) { PmxHeader pmxHeader = new PmxHeader(2.1f); pmxHeader.FromStreamEx(s, null); this.Header.FromHeader(pmxHeader); this.ModelInfo.FromStreamEx(s, pmxHeader.ElementFormat); int num = PmxStreamHelper.ReadElement_Int32(s, 4, true); this.VertexList.Clear(); this.VertexList.Capacity = num; for (int i = 0; i < num; i++) { PmxVertex pmxVertex = new PmxVertex(); pmxVertex.FromStreamEx(s, pmxHeader.ElementFormat); this.VertexList.Add(pmxVertex); } num = PmxStreamHelper.ReadElement_Int32(s, 4, true); this.FaceList.Clear(); this.FaceList.Capacity = num; for (int j = 0; j < num; j++) { int item = PmxStreamHelper.ReadElement_Int32(s, pmxHeader.ElementFormat.VertexSize, false); this.FaceList.Add(item); } PmxTextureTable pmxTextureTable = new PmxTextureTable(); pmxTextureTable.FromStreamEx(s, pmxHeader.ElementFormat); num = PmxStreamHelper.ReadElement_Int32(s, 4, true); this.MaterialList.Clear(); this.MaterialList.Capacity = num; for (int k = 0; k < num; k++) { PmxMaterial pmxMaterial = new PmxMaterial(); pmxMaterial.FromStreamEx_TexTable(s, pmxTextureTable, pmxHeader.ElementFormat); this.MaterialList.Add(pmxMaterial); } num = PmxStreamHelper.ReadElement_Int32(s, 4, true); this.BoneList.Clear(); this.BoneList.Capacity = num; for (int l = 0; l < num; l++) { PmxBone pmxBone = new PmxBone(); pmxBone.FromStreamEx(s, pmxHeader.ElementFormat); this.BoneList.Add(pmxBone); } num = PmxStreamHelper.ReadElement_Int32(s, 4, true); this.MorphList.Clear(); this.MorphList.Capacity = num; for (int m = 0; m < num; m++) { PmxMorph pmxMorph = new PmxMorph(); pmxMorph.FromStreamEx(s, pmxHeader.ElementFormat); this.MorphList.Add(pmxMorph); } num = PmxStreamHelper.ReadElement_Int32(s, 4, true); this.NodeList.Clear(); this.NodeList.Capacity = num; for (int n = 0; n < num; n++) { PmxNode pmxNode = new PmxNode(); pmxNode.FromStreamEx(s, pmxHeader.ElementFormat); this.NodeList.Add(pmxNode); bool systemNode = this.NodeList[n].SystemNode; if (systemNode) { bool flag = this.NodeList[n].Name == "Root"; if (flag) { this.RootNode = this.NodeList[n]; } else { bool flag2 = this.NodeList[n].Name == "表情"; if (flag2) { this.ExpNode = this.NodeList[n]; } } } } num = PmxStreamHelper.ReadElement_Int32(s, 4, true); this.BodyList.Clear(); this.BodyList.Capacity = num; for (int num2 = 0; num2 < num; num2++) { PmxBody pmxBody = new PmxBody(); pmxBody.FromStreamEx(s, pmxHeader.ElementFormat); this.BodyList.Add(pmxBody); } num = PmxStreamHelper.ReadElement_Int32(s, 4, true); this.JointList.Clear(); this.JointList.Capacity = num; for (int num3 = 0; num3 < num; num3++) { PmxJoint pmxJoint = new PmxJoint(); pmxJoint.FromStreamEx(s, pmxHeader.ElementFormat); this.JointList.Add(pmxJoint); } bool flag3 = pmxHeader.Ver >= 2.1f; if (flag3) { num = PmxStreamHelper.ReadElement_Int32(s, 4, true); this.SoftBodyList.Clear(); this.SoftBodyList.Capacity = num; for (int num4 = 0; num4 < num; num4++) { PmxSoftBody pmxSoftBody = new PmxSoftBody(); pmxSoftBody.FromStreamEx(s, pmxHeader.ElementFormat); this.SoftBodyList.Add(pmxSoftBody); } } }
public ToonInfo GetToonInfo(List <PmxMaterial> list) { int count = list.Count; if (count < 0) { return(null); } ToonInfo toonInfo = new ToonInfo(count); bool[] array = new bool[10]; List <string> list2 = new List <string>(count); Dictionary <string, int> dictionary = new Dictionary <string, int>(count); for (int i = 0; i < count; i++) { PmxMaterial pmxMaterial = list[i]; if (string.IsNullOrEmpty(pmxMaterial.Toon)) { toonInfo.MaterialToon[i] = -1; continue; } int toonIndex = GetToonIndex(pmxMaterial.Toon); toonInfo.MaterialToon[i] = toonIndex; if (-1 <= toonIndex && toonIndex < 10) { if (toonIndex >= 0) { array[toonIndex] = true; } } else if (!dictionary.ContainsKey(pmxMaterial.Toon)) { list2.Add(pmxMaterial.Toon); dictionary.Add(pmxMaterial.Toon, 0); } } if (list2.Count > 0) { Dictionary <string, int> dictionary2 = new Dictionary <string, int>(list2.Count); int num = 0; for (int j = 0; j < list2.Count; j++) { for (int k = num; k < array.Length; k++) { if (!array[k]) { toonInfo.ToonNames[k] = list2[j]; dictionary2.Add(list2[j], k); array[k] = true; num = k + 1; break; } } } for (int l = 0; l < count; l++) { if (toonInfo.MaterialToon[l] < -1) { PmxMaterial pmxMaterial2 = list[l]; if (dictionary2.ContainsKey(pmxMaterial2.Toon)) { toonInfo.MaterialToon[l] = dictionary2[pmxMaterial2.Toon]; continue; } toonInfo.MaterialToon[l] = -1; toonInfo.IsRejection = true; } } } return(toonInfo); }