public void AppendModifier(List <int> vertexIndexes, TRIFile reference, string name) { if (this.header.ModVertexCount <= 0) { this.modVertices = new List <VertexPosition>(); } this.header.ModVertexCount += vertexIndexes.Count; foreach (int vertIndex in vertexIndexes) { this.modVertices.Add(reference.vertices[vertIndex]); } TRIModifierData mod = new TRIModifierData(); mod.NameSize = name.Length; mod.Name = name.Clone() as string; mod.DataSize = vertexIndexes.Count; foreach (int vertIndex in vertexIndexes) { mod.Add(vertIndex); } if (this.header.ModifierCount <= 0) { this.modifiers = new List <TRIModifierData>(); } this.modifiers.Add(mod); this.header.ModifierCount += 1; }
public TRIFile(TRIFile file) { this.header = new TRIHeader(file.header); this.vertices = new List<VertexPosition>(); foreach (VertexPosition data in file.vertices) { this.vertices.Add(data); } if (this.header.ModVertexCount > 0) { this.modVertices = new List<VertexPosition>(); foreach (VertexPosition data in file.modVertices) { this.modVertices.Add(data); } } this.triFaces = new List<TriangleFace>(); foreach (TriangleFace face in file.triFaces) { this.triFaces.Add(face); } this.quadFaces = new List<QuadFace>(); foreach (QuadFace face in file.quadFaces) { this.quadFaces.Add(face); } this.uvVertices = new List<UvVertexPosition>(); foreach (UvVertexPosition vert in file.uvVertices) { this.uvVertices.Add(vert); } this.uvTriFaces = new List<UvTriangleFace>(); foreach (UvTriangleFace uvFace in file.uvTriFaces) { this.uvTriFaces.Add(uvFace); } this.morphs = new List<TRIMorphData>(); foreach (TRIMorphData morph in file.morphs) { this.morphs.Add(new TRIMorphData(morph)); } if (file.header.ModifierCount > 0) { this.modifiers = new List<TRIModifierData>(); foreach (TRIModifierData mod in file.modifiers) { this.modifiers.Add(new TRIModifierData(mod)); } } }
public TRIFile(TRIFile file) { this.header = new TRIHeader(file.header); this.vertices = new List <VertexPosition>(); foreach (VertexPosition data in file.vertices) { this.vertices.Add(data); } if (this.header.ModVertexCount > 0) { this.modVertices = new List <VertexPosition>(); foreach (VertexPosition data in file.modVertices) { this.modVertices.Add(data); } } this.triFaces = new List <TriangleFace>(); foreach (TriangleFace face in file.triFaces) { this.triFaces.Add(face); } this.quadFaces = new List <QuadFace>(); foreach (QuadFace face in file.quadFaces) { this.quadFaces.Add(face); } this.uvVertices = new List <UvVertexPosition>(); foreach (UvVertexPosition vert in file.uvVertices) { this.uvVertices.Add(vert); } this.uvTriFaces = new List <UvTriangleFace>(); foreach (UvTriangleFace uvFace in file.uvTriFaces) { this.uvTriFaces.Add(uvFace); } this.morphs = new List <TRIMorphData>(); foreach (TRIMorphData morph in file.morphs) { this.morphs.Add(new TRIMorphData(morph)); } if (file.header.ModifierCount > 0) { this.modifiers = new List <TRIModifierData>(); foreach (TRIModifierData mod in file.modifiers) { this.modifiers.Add(new TRIModifierData(mod)); } } }
public void Write(BinaryWriter writer) { writer.Write(this.nameSize); writer.Write(TRIFile.StringToBytes(this.name)); writer.Write(this.dataSize); foreach (int nr in this) { writer.Write(nr); } }
public TRIModifierData(BinaryReader reader) : base() { this.nameSize = reader.ReadInt32(); byte[] bytes = reader.ReadBytes(this.nameSize); this.name = TRIFile.BytesToString(bytes); this.dataSize = reader.ReadInt32(); for (int i = 0; i < this.dataSize; i++) { this.Add(reader.ReadInt32()); } }
public void Write(BinaryWriter writer) { writer.Write(this.nameSize); writer.Write(TRIFile.StringToBytes(this.name)); writer.Write(this.scaleMinX); writer.Write(this.scaleMinY); writer.Write(this.scaleMinZ); writer.Write(this.scaleMult); foreach (VertexDisplacement vert in this) { vert.Write(writer); } }
public TRIMorphData(BinaryReader reader, int size) : base() { this.nameSize = reader.ReadInt32(); byte[] bytes = reader.ReadBytes(this.nameSize); this.name = TRIFile.BytesToString(bytes); this.scaleMinX = reader.ReadByte(); this.scaleMinY = reader.ReadByte(); this.scaleMinZ = reader.ReadByte(); this.scaleMult = reader.ReadByte(); for (int i = 0; i < size; i++) { VertexDisplacement vert = new VertexDisplacement(reader); this.Add(vert); } }
public void Write(BinaryWriter writer) { writer.Write(TRIFile.StringToBytes("FR")); writer.Write(TRIFile.StringToBytes("TRI")); writer.Write(TRIFile.StringToBytes(this.version)); writer.Write(this.vertexCount); writer.Write(this.polytriCount); writer.Write(this.polyquadCount); writer.Write(this.unknown2); writer.Write(this.unknown3); writer.Write(this.uvVertexCount); writer.Write(this.flags); writer.Write(this.morphCount); writer.Write(this.modifierCount); writer.Write(this.modVertexCount); writer.Write(this.unknown7); writer.Write(this.unknown8); writer.Write(this.unknown9); writer.Write(this.unknown10); }
public TRIHeader(BinaryReader reader) { reader.ReadBytes(5); byte[] version = reader.ReadBytes(3); this.version = TRIFile.BytesToString(version); this.vertexCount = reader.ReadInt32(); this.polytriCount = reader.ReadInt32(); this.polyquadCount = reader.ReadInt32(); this.unknown2 = reader.ReadInt32(); this.unknown3 = reader.ReadInt32(); this.uvVertexCount = reader.ReadInt32(); this.flags = reader.ReadInt32(); this.morphCount = reader.ReadInt32(); this.modifierCount = reader.ReadInt32(); this.modVertexCount = reader.ReadInt32(); this.unknown7 = reader.ReadInt32(); this.unknown8 = reader.ReadInt32(); this.unknown9 = reader.ReadInt32(); this.unknown10 = reader.ReadInt32(); }
public HeadFile(string fileName) { if (fileName.ToLower().EndsWith("egm")) { FileStream stream = new FileStream(fileName, FileMode.Open); this.egm = new EGMFile(stream); stream.Close(); stream = new FileStream(HeadFile.ReplaceExtention(fileName, "tri"),FileMode.Open); this.tri = new TRIFile(stream); stream.Close(); stream = new FileStream(HeadFile.ReplaceExtention(fileName, "nif"), FileMode.Open); this.nif = new NifFile(stream); stream.Close(); } if (fileName.ToLower().EndsWith("tri")) { FileStream stream = new FileStream(fileName, FileMode.Open); this.tri = new TRIFile(stream); stream.Close(); stream = new FileStream(HeadFile.ReplaceExtention(fileName, "egm"), FileMode.Open); this.egm = new EGMFile(stream); stream.Close(); stream = new FileStream(HeadFile.ReplaceExtention(fileName, "nif"), FileMode.Open); this.nif = new NifFile(stream); stream.Close(); } if (fileName.ToLower().EndsWith("nif")) { FileStream stream = new FileStream(fileName, FileMode.Open); this.nif = new NifFile(stream); stream.Close(); stream = new FileStream(HeadFile.ReplaceExtention(fileName, "egm"), FileMode.Open); this.egm = new EGMFile(stream); stream.Close(); stream = new FileStream(HeadFile.ReplaceExtention(fileName, "tri"), FileMode.Open); this.tri = new TRIFile(stream); stream.Close(); } }
public HeadFile(string fileName) { if (fileName.ToLower().EndsWith("egm")) { FileStream stream = new FileStream(fileName, FileMode.Open); this.egm = new EGMFile(stream); stream.Close(); stream = new FileStream(HeadFile.ReplaceExtention(fileName, "tri"), FileMode.Open); this.tri = new TRIFile(stream); stream.Close(); stream = new FileStream(HeadFile.ReplaceExtention(fileName, "nif"), FileMode.Open); this.nif = new NifFile(stream); stream.Close(); } if (fileName.ToLower().EndsWith("tri")) { FileStream stream = new FileStream(fileName, FileMode.Open); this.tri = new TRIFile(stream); stream.Close(); stream = new FileStream(HeadFile.ReplaceExtention(fileName, "egm"), FileMode.Open); this.egm = new EGMFile(stream); stream.Close(); stream = new FileStream(HeadFile.ReplaceExtention(fileName, "nif"), FileMode.Open); this.nif = new NifFile(stream); stream.Close(); } if (fileName.ToLower().EndsWith("nif")) { FileStream stream = new FileStream(fileName, FileMode.Open); this.nif = new NifFile(stream); stream.Close(); stream = new FileStream(HeadFile.ReplaceExtention(fileName, "egm"), FileMode.Open); this.egm = new EGMFile(stream); stream.Close(); stream = new FileStream(HeadFile.ReplaceExtention(fileName, "tri"), FileMode.Open); this.tri = new TRIFile(stream); stream.Close(); } }
public void AppendModifier(List<int> vertexIndexes, TRIFile reference, string name) { if (this.header.ModVertexCount <= 0) this.modVertices = new List<VertexPosition>(); this.header.ModVertexCount += vertexIndexes.Count; foreach (int vertIndex in vertexIndexes) { this.modVertices.Add(reference.vertices[vertIndex]); } TRIModifierData mod = new TRIModifierData(); mod.NameSize = name.Length; mod.Name = name.Clone() as string; mod.DataSize = vertexIndexes.Count; foreach (int vertIndex in vertexIndexes) { mod.Add(vertIndex); } if (this.header.ModifierCount <= 0) this.modifiers = new List<TRIModifierData>(); this.modifiers.Add(mod); this.header.ModifierCount += 1; }
public HeadFile(HeadFile file) { this.tri = new TRIFile(file.TRI); this.egm = new EGMFile(file.EGM); this.nif = new NifFile(file.Nif); }