public void ReadFromFile(BinaryReader reader) { if (reader.ReadInt16() != Magic) { return; } ushort animalInsCount = reader.ReadUInt16(); instances = new AnimalTrafficInstance[animalInsCount]; if (reader.ReadInt32() != Version) { return; } for (int i = 0; i < animalInsCount; i++) { AnimalTrafficInstance instance = new AnimalTrafficInstance(); instance.Name = new HashName(); instance.Name.ReadFromFile(reader); instances[i] = instance; } ushort pathCount = reader.ReadUInt16(); paths = new AnimalTrafficPath[pathCount]; for (int i = 0; i < pathCount; i++) { AnimalTrafficPath path = new AnimalTrafficPath(); byte pathSize = reader.ReadByte(); byte count1 = reader.ReadByte(); byte count2 = reader.ReadByte(); byte count3 = reader.ReadByte(); path.Data0 = reader.ReadBytes(count1); path.Data1 = reader.ReadBytes(count2); path.Data2 = reader.ReadBytes(count3); path.BoundingBox = BoundingBoxExtenders.ReadFromFile(reader); path.Hash = new HashName(); path.Hash.ReadFromFile(reader); //decompiled exe says this is a hash but its always empty path.Unk0 = reader.ReadSingle(); //5 path.Unk1 = reader.ReadSingle(); //15 path.Unk2 = reader.ReadByte(); //1 257 or 513. path.Unk3 = reader.ReadBytes(path.Unk2); path.Vectors = new PathVectors[pathSize]; for (int x = 0; x < pathSize; x++) { PathVectors vector = new PathVectors(); vector.Position = Vector3Extenders.ReadFromFile(reader); //Very large differences between these two vector.Rotation = Vector3Extenders.ReadFromFile(reader); //2nd one could be rotation, in radians. vector.Unk0 = reader.ReadByte(); //7 or 4 path.Vectors[x] = vector; } paths[i] = path; } }
public override void ReadFromFile(MemoryStream stream, bool isBigEndian) { base.ReadFromFile(stream, isBigEndian); NumFrames = stream.ReadInt32(isBigEndian); Frames = new FrameData[NumFrames]; for (int i = 0; i < NumFrames; i++) { FrameData frames = new FrameData(); frames.Unk01 = stream.ReadInt32(isBigEndian); frames.Unk02 = stream.ReadInt32(isBigEndian); frames.Unk03 = stream.ReadByte8(); frames.SoundFile = stream.ReadString16(isBigEndian); frames.Unk04 = stream.ReadByte8(); frames.Unk05 = stream.ReadSingle(isBigEndian); frames.Unk06 = stream.ReadSingle(isBigEndian); frames.Unk07 = stream.ReadSingle(isBigEndian); frames.Unk08 = stream.ReadInt32(isBigEndian); frames.Unk09 = stream.ReadSingle(isBigEndian); frames.Unk10 = stream.ReadInt32(isBigEndian); frames.Unk11 = stream.ReadSingle(isBigEndian); frames.Unk12 = stream.ReadInt32(isBigEndian); frames.Unk13 = stream.ReadSingle(isBigEndian); frames.Unk14 = stream.ReadSingle(isBigEndian); frames.Unk15 = stream.ReadByte8(); frames.Position = Vector3Extenders.ReadFromFile(stream, isBigEndian); frames.Rotation = QuaternionExtensions.ReadFromFile(stream, isBigEndian); frames.Unk16 = stream.ReadByte8(); Frames[i] = frames; } Unk05 = stream.ReadUInt16(isBigEndian); }
public void ReadFromFile(BinaryReader reader) { Position = Vector3Extenders.ReadFromFile(reader); Direction = Vector3Extenders.ReadFromFile(reader); EntityName = XBinCoreUtils.ReadStringPtrWithOffset(reader); LoadFlags = reader.ReadUInt32(); }
public void ReadFromFile(BinaryReader reader) { unk0 = reader.ReadInt16(); position = Vector3Extenders.ReadFromFile(reader); rotation = Vector3Extenders.ReadFromFile(reader); unk1 = Vector3Extenders.ReadFromFile(reader); unk2 = reader.ReadInt32(); }
public void ReadFromFile(BinaryReader reader) { Position = Vector3Extenders.ReadFromFile(reader); Rotation = Vector3Extenders.ReadFromFile(reader); Hash = reader.ReadUInt64(); Unk4 = reader.ReadInt32(); Unk5 = reader.ReadByte(); }
public void ReadFromFile(BinaryReader reader) { unk0 = reader.ReadByte(); unk1 = Vector3Extenders.ReadFromFile(reader); unk2 = Vector3Extenders.ReadFromFile(reader); unk3 = Vector3Extenders.ReadFromFile(reader); unk4 = reader.ReadSingle(); }
public void ReadFromFile(BinaryReader reader) { unk0 = reader.ReadInt32(); fileIDHPD = reader.ReadInt32(); unk3HPD = reader.ReadInt32(); bitFlagsHPD = reader.ReadInt32(); vertSize = reader.ReadInt32(); triSize = reader.ReadInt32(); //writer.WriteLine(string.Format("{0}, ) StreamWriter writer = File.CreateText("NAV_AI_OBJ_DATA_" + fileIDHPD + ".txt"); writer.WriteLine(string.Format("{0} {1} {2} {3}", unk0, fileIDHPD, unk3HPD, bitFlagsHPD)); //List<string> data = new List<string>(); List <Vector3> Points = new List <Vector3>(); vertices = new VertexStruct[vertSize]; for (int i = 0; i < vertSize; i++) { VertexStruct vertex = new VertexStruct(); vertex.Unk7 = reader.ReadUInt32() & 0x7FFFFFFF; vertex.Position = Vector3Extenders.ReadFromFile(reader); Vector3 pos = vertex.Position; float y = pos.Y; pos.Y = -pos.Z; pos.Z = y; vertex.Position = pos; //writer.WriteLine(vertex.Position); vertex.Unk0 = reader.ReadSingle(); vertex.Unk1 = reader.ReadSingle(); vertex.Unk2 = reader.ReadInt32(); vertex.Unk3 = reader.ReadInt16(); vertex.Unk4 = reader.ReadInt16(); vertex.Unk5 = reader.ReadInt32(); vertex.Unk6 = reader.ReadInt32(); vertices[i] = vertex; Points.Add(vertex.Position); } writer.WriteLine(""); connections = new ConnectionStruct[triSize]; for (int i = 0; i < triSize; i++) { ConnectionStruct connection = new ConnectionStruct(); connection.Flags = reader.ReadUInt32() & 0x7FFFFFFF; connection.NodeID = reader.ReadUInt32() & 0x7FFFFFFF; connection.ConnectedNodeID = reader.ReadUInt32() & 0x7FFFFFFF; connections[i] = connection; //writer.WriteLine(string.Format("{0} {1} {2}", connection.Flags, connection.NodeID, connection.ConnectedNodeID)); } //Read KynogonRuntimeMesh runtimeMesh = new KynogonRuntimeMesh(); runtimeMesh.ReadFromFile(reader, writer); }
public override void ReadFromFile(MemoryStream reader, bool isBigEndian) { base.ReadFromFile(reader, isBigEndian); flags = reader.ReadInt32(isBigEndian); for (int i = 0; i < 7; i++) { unkFloat1[i] = reader.ReadSingle(isBigEndian); } unk_int = reader.ReadInt32(isBigEndian); for (int i = 0; i < 5; i++) { unkFloat2[i] = reader.ReadSingle(isBigEndian); } unk_byte1 = reader.ReadByte8(); for (int i = 0; i < 17; i++) { unkFloat3[i] = reader.ReadSingle(isBigEndian); } unk_byte2 = reader.ReadByte8(); for (int i = 0; i < 5; i++) { unkFloat4[i] = reader.ReadSingle(isBigEndian); } nameLight = new HashName(reader, isBigEndian); unk_int2 = reader.ReadInt32(isBigEndian); for (int i = 0; i < 20; i++) { unkFloat5[i] = reader.ReadSingle(isBigEndian); } for (int i = 0; i < 4; i++) { names[i] = new HashName(reader, isBigEndian); } unkVector1 = Vector3Extenders.ReadFromFile(reader, isBigEndian); unkVector2 = Vector3Extenders.ReadFromFile(reader, isBigEndian); unk_byte3 = reader.ReadByte8(); unkVector3 = Vector3Extenders.ReadFromFile(reader, isBigEndian); unkVector4 = Vector3Extenders.ReadFromFile(reader, isBigEndian); unkVector5 = Vector3Extenders.ReadFromFile(reader, isBigEndian); unkVector6 = Vector3Extenders.ReadFromFile(reader, isBigEndian); }
public override void ReadFromFile(MemoryStream stream, bool isBigEndian) { base.ReadFromFile(stream, isBigEndian); NumSounds = stream.ReadInt32(isBigEndian); Sounds = new SoundData_Type19[NumSounds]; for (int i = 0; i < NumSounds; i++) { SoundData_Type19 SoundInfo = new SoundData_Type19(); SoundInfo.Unk01 = stream.ReadInt32(isBigEndian); SoundInfo.Unk02 = stream.ReadInt32(isBigEndian); SoundInfo.Unk03 = stream.ReadByte8(); SoundInfo.SoundFile = stream.ReadString16(isBigEndian); SoundInfo.Unk04 = stream.ReadByte8(); SoundInfo.Unk05 = stream.ReadSingle(isBigEndian); SoundInfo.Unk06 = stream.ReadSingle(isBigEndian); SoundInfo.Unk07 = stream.ReadSingle(isBigEndian); SoundInfo.Unk08 = stream.ReadInt32(isBigEndian); SoundInfo.Unk10 = stream.ReadSingle(isBigEndian); SoundInfo.Unk11 = stream.ReadInt32(isBigEndian); SoundInfo.Unk12 = stream.ReadSingle(isBigEndian); SoundInfo.Unk13 = stream.ReadInt32(isBigEndian); SoundInfo.Unk14 = stream.ReadSingle(isBigEndian); SoundInfo.Unk15 = stream.ReadSingle(isBigEndian); SoundInfo.Unk16 = stream.ReadSingle(isBigEndian); SoundInfo.Unk17 = stream.ReadSingle(isBigEndian); SoundInfo.Unk18 = stream.ReadByte8(); SoundInfo.Position = Vector3Extenders.ReadFromFile(stream, isBigEndian); SoundInfo.Unk19 = stream.ReadSingle(isBigEndian); SoundInfo.Unk20 = stream.ReadSingle(isBigEndian); SoundInfo.Unk21 = stream.ReadSingle(isBigEndian); SoundInfo.Unk22 = stream.ReadSingle(isBigEndian); SoundInfo.IsMeshAvailableFlags = stream.ReadByte8(); if (SoundInfo.IsMeshAvailableFlags == 3) { SoundInfo.FrameName = stream.ReadString16(isBigEndian); SoundInfo.MainJointHash = stream.ReadUInt64(isBigEndian); SoundInfo.FrameHash = stream.ReadUInt64(isBigEndian); } else if (SoundInfo.IsMeshAvailableFlags == 1) { SoundInfo.FrameName = stream.ReadString16(isBigEndian); SoundInfo.MainJointHash = stream.ReadUInt64(isBigEndian); } Sounds[i] = SoundInfo; } Unk05 = stream.ReadUInt16(isBigEndian); }
public void WriteToFile(BinaryWriter writer) { writer.Write(position.Length); for (int i = 0; i < position.Length; i++) { Vector3Extenders.WriteToFile(position[i], writer); } writer.Write(sphere.Length); for (int i = 0; i < sphere.Length; i++) { Vector3Extenders.WriteToFile(sphere[i], writer); } }
public void ReadFromFile(BinaryReader reader) { Vector3 m1 = Vector3Extenders.ReadFromFile(reader); float x = reader.ReadSingle(); Vector3 m2 = Vector3Extenders.ReadFromFile(reader); float y = reader.ReadSingle(); Vector3 m3 = Vector3Extenders.ReadFromFile(reader); float z = reader.ReadSingle(); transformedMatrix = new Matrix33(m1, m2, m3); Decompose(); Position = new Vector3(x, y, z); }
public void ReadFromFile(MemoryStream reader, bool isBigEndian) { Vector3 m1 = Vector3Extenders.ReadFromFile(reader, isBigEndian); float x = reader.ReadSingle(isBigEndian); Vector3 m2 = Vector3Extenders.ReadFromFile(reader, isBigEndian); float y = reader.ReadSingle(isBigEndian); Vector3 m3 = Vector3Extenders.ReadFromFile(reader, isBigEndian); float z = reader.ReadSingle(isBigEndian); transformedMatrix = new Matrix33(m1, m2, m3); Decompose(); Position = new Vector3(x, y, z); }
public bool UpdateInput() { bool bCameraUpdated = false; float Multiplier = ToolkitSettings.CameraSpeed; if (Input.IsKeyDown(Keys.ShiftKey)) { Multiplier *= 2.0f; } float speed = Profile.DeltaTime * Multiplier; if (Input.IsKeyDown(Keys.A)) { Camera.Position -= Vector3Extenders.FromVector4(Vector4.Multiply(Camera.ViewMatrix.Column1, speed)); bCameraUpdated = true; } if (Input.IsKeyDown(Keys.D)) { Camera.Position += Vector3Extenders.FromVector4(Vector4.Multiply(Camera.ViewMatrix.Column1, speed)); bCameraUpdated = true; } if (Input.IsKeyDown(Keys.W)) { Camera.Position -= Vector3Extenders.FromVector4(Vector4.Multiply(Camera.ViewMatrix.Column3, speed)); bCameraUpdated = true; } if (Input.IsKeyDown(Keys.S)) { Camera.Position += Vector3Extenders.FromVector4(Vector4.Multiply(Camera.ViewMatrix.Column3, speed)); bCameraUpdated = true; } if (Input.IsKeyDown(Keys.Q)) { Camera.Position.Z += speed; bCameraUpdated = true; } if (Input.IsKeyDown(Keys.E)) { Camera.Position.Z -= speed; bCameraUpdated = true; } return(bCameraUpdated); }
public void ReadFromFile(BinaryReader reader) { unk0 = reader.ReadInt32(); unk2 = reader.ReadInt32(); unk3 = reader.ReadInt32(); unk4 = reader.ReadInt32(); vertSize = reader.ReadInt32(); triSize = reader.ReadInt32(); vertices = new VertexStruct[vertSize]; for (int i = 0; i < vertSize; i++) { VertexStruct vertex = new VertexStruct(); vertex.unk7 = reader.ReadInt32(); vertex.position = Vector3Extenders.ReadFromFile(reader); float pos = vertex.position.Y; //f**k the third var thing vertex.position.Y = vertex.position.Z; vertex.position.Z = pos; vertex.unk0 = reader.ReadSingle(); vertex.unk1 = reader.ReadSingle(); vertex.unk2 = reader.ReadInt32(); vertex.unk3 = reader.ReadInt16(); vertex.unk4 = reader.ReadInt16(); vertex.unk5 = reader.ReadInt32(); vertex.unk6 = reader.ReadInt32(); vertices[i] = vertex; } //unk6 = reader.ReadInt32(); //unk7 = reader.ReadInt32(); //unk8 = reader.ReadInt16(); //unk9 = reader.ReadInt16(); //int x = 2; //indices = new uint[(triSize - 1) * 3]; //for (int i = 0; i < (triSize - 1) * 3; i++) //{ // if (x == 0) // { // indices[i] = reader.ReadUInt32(); // x = 2; // } // else // { // indices[i] = (uint)reader.ReadInt24(); // reader.ReadByte(); // x--; // } //} //TODO:: }
/// <summary> /// Read data from file. /// </summary> /// <param name="reader">stream</param> public void ReadFromFile(BinaryReader reader) { position = Vector3Extenders.ReadFromFile(reader); rotation = Vector3Extenders.ReadFromFile(reader); Vector3 rot = new Vector3(); rot.X = MathUtil.RadiansToDegrees(rotation.X); rot.Y = MathUtil.RadiansToDegrees(rotation.Y); rot.Z = -MathUtil.RadiansToDegrees(rotation.Z); rotation = rot; hash = reader.ReadUInt64(); unk4 = reader.ReadInt32(); unk5 = reader.ReadByte(); }
public void ReadFromFile(BinaryReader reader) { unk0 = reader.ReadByte(); unk1 = reader.ReadInt32(); unk2 = Vector3Extenders.ReadFromFile(reader); unk3 = reader.ReadSingle(); unk4 = reader.ReadSingle(); short count = reader.ReadInt16(); unk5 = new int[count]; for (int i = 0; i != count; i++) { unk5[i] = reader.ReadInt32(); } }
/// <summary> /// Read data from stream. /// </summary> /// <param name="reader"></param> public void ReadFromFile(MemoryStream reader, bool isBigEndian) { numLods = reader.ReadByte8(); unk01 = reader.ReadInt16(isBigEndian); decompressionOffset = Vector3Extenders.ReadFromFile(reader, isBigEndian); decompressionFactor = reader.ReadSingle(isBigEndian); LOD = new FrameLOD[numLods]; for (int i = 0; i < numLods; i++) { LOD[i] = new FrameLOD(); LOD[i].ReadFromFile(reader, isBigEndian); } }
public override void ReadFromFile(MemoryStream reader, bool isBigEndian) { base.ReadFromFile(reader, isBigEndian); unk_08_int = reader.ReadInt32(isBigEndian); planesSize = reader.ReadInt32(isBigEndian); planes = new Vector4[planesSize]; for (int i = 0; i != planes.Length; i++) { planes[i] = Vector4Extenders.ReadFromFile(reader, isBigEndian); } bounds = BoundingBoxExtenders.ReadFromFile(reader, isBigEndian); unk_13_vector3 = Vector3Extenders.ReadFromFile(reader, isBigEndian); unk_14_vector3 = Vector3Extenders.ReadFromFile(reader, isBigEndian); sectorName = new Hash(reader, isBigEndian); }
public void ReadFromFile(BinaryReader reader) { size = reader.ReadInt32(); actorTypeName = readString(reader); entityType = readString(reader); unkString = readString(reader); unk2String = readString(reader); definitionName = readString(reader); frameName = readString(reader); actortypeID = reader.ReadInt32(); defintionHash = reader.ReadUInt64(); frameNameHash = reader.ReadUInt64(); position = Vector3Extenders.ReadFromFile(reader); quat = Vector4Extenders.ReadFromFile(reader); scale = Vector3Extenders.ReadFromFile(reader); unk3 = reader.ReadUInt16(); dataID = reader.ReadUInt16(); }
public override void ReadFromFile(MemoryStream stream, bool isBigEndian) { base.ReadFromFile(stream, isBigEndian); Debug.Assert(stream.Position != stream.Length, "I've read the parent class data, although i've hit the eof!"); if (stream.Position != stream.Length) { Unk02 = stream.ReadInt32(isBigEndian); Unk03 = Vector3Extenders.ReadFromFile(stream, isBigEndian); Unk04 = stream.ReadSingle(isBigEndian); Unk05 = stream.ReadBytes(24); Unk06 = stream.ReadSingle(isBigEndian); Unk07 = stream.ReadInt32(isBigEndian); Unk08 = stream.ReadByte8(); bDoesHaveExtraData = true; } }
public void WriteToFile() { using (BinaryWriter writer = new BinaryWriter(File.Open(file.FullName + "1", FileMode.Create))) { writer.Write((ushort)21569); //magic writer.Write((ushort)instances.Length); writer.Write(1595612873); for (int i = 0; i < instances.Length; i++) { instances[i].Name.WriteToFile(writer); } writer.Write((ushort)paths.Length); for (int i = 0; i < paths.Length; i++) { AnimalTrafficPath path = paths[i]; writer.Write(path.numPaths); writer.Write((byte)path.unkSet0.Length); writer.Write((byte)path.unkSet1.Length); writer.Write((byte)path.unkSet2.Length); writer.Write(path.unkSet0); writer.Write(path.unkSet1); writer.Write(path.unkSet2); BoundingBoxExtenders.WriteToFile(path.bbox, writer); path.unkHash.WriteToFile(writer); writer.Write(path.Unk0); writer.Write(path.Unk1); writer.Write(path.Unk2); for (int x = 0; x < path.numPaths; x++) { Vector3Extenders.WriteToFile(path.vectors[x].vectors[0], writer); Vector3Extenders.WriteToFile(path.vectors[x].vectors[1], writer); writer.Write(path.vectors[x].unk0); } if (path.Unk2 == 2) { writer.Write(path.unk3); } } } }
public override void ReadFromFile(MemoryStream stream, bool isBigEndian) { base.ReadFromFile(stream, isBigEndian); NumPositions = stream.ReadInt32(isBigEndian); Positions = new PositionData[NumPositions]; for (int i = 0; i < NumPositions; i++) { PositionData position = new PositionData(); position.Unk01 = stream.ReadInt32(isBigEndian); position.Unk02 = stream.ReadInt32(isBigEndian); position.Unk03 = stream.ReadByte8(); position.Position = Vector3Extenders.ReadFromFile(stream, isBigEndian); Positions[i] = position; } Unk05 = stream.ReadUInt16(isBigEndian); }
public void ReadFromFile(BinaryReader reader) { int size = reader.ReadInt32(); position = new Vector3[size]; for (int i = 0; i != size; i++) { position[i] = Vector3Extenders.ReadFromFile(reader); } size = reader.ReadInt32(); sphere = new Vector3[size]; for (int i = 0; i != size; i++) { sphere[i] = Vector3Extenders.ReadFromFile(reader); } }
public void WriteToFile() { using (BinaryWriter writer = new BinaryWriter(File.Open(file.FullName + "1", FileMode.Create))) { writer.Write(Magic); //magic writer.Write((ushort)instances.Length); writer.Write(Version); for (int i = 0; i < instances.Length; i++) { instances[i].Name.WriteToFile(writer); } writer.Write((ushort)paths.Length); for (int i = 0; i < paths.Length; i++) { AnimalTrafficPath path = paths[i]; writer.Write((byte)path.Vectors.Length); writer.Write((byte)path.Data0.Length); writer.Write((byte)path.Data1.Length); writer.Write((byte)path.Data2.Length); writer.Write(path.Data0); writer.Write(path.Data1); writer.Write(path.Data2); BoundingBoxExtenders.WriteToFile(path.BoundingBox, writer); path.Hash.WriteToFile(writer); writer.Write(path.Unk0); writer.Write(path.Unk1); writer.Write(path.Unk2); writer.Write(path.Unk3); for (int x = 0; x < path.Vectors.Length; x++) { Vector3Extenders.WriteToFile(path.Vectors[x].Position, writer); Vector3Extenders.WriteToFile(path.Vectors[x].Rotation, writer); writer.Write(path.Vectors[x].Unk0); } } } }
public void ReadFromFile(BinaryReader reader) { unk0 = reader.ReadByte(); position = Vector3Extenders.ReadFromFile(reader); rotation = Vector3Extenders.ReadFromFile(reader); unk1 = reader.ReadInt32(); unk2 = reader.ReadInt32(); unk3 = reader.ReadInt32(); unk4 = Vector3Extenders.ReadFromFile(reader); unk5 = reader.ReadInt32(); unk6 = reader.ReadByte(); unk7 = reader.ReadByte(); short count = reader.ReadInt16(); unk8 = new int[count]; for (int i = 0; i != count; i++) { unk8[i] = reader.ReadInt32(); } unk9 = reader.ReadInt32(); }
public void WriteToFile(BinaryWriter writer) { writer.Write(unk0); writer.Write(fileIDHPD); writer.Write(unk3HPD); writer.Write(bitFlagsHPD); writer.Write(vertSize); writer.Write(triSize); for (int i = 0; i < vertices.Length; i++) { var vertex = vertices[i]; writer.Write(vertex.Unk7); Vector3 pos = vertex.Position; float z = pos.Z; pos.Z = -pos.Y; pos.Y = z; vertex.Position = pos; Vector3Extenders.WriteToFile(vertex.Position, writer); writer.Write(vertex.Unk0); writer.Write(vertex.Unk1); writer.Write(vertex.Unk2); writer.Write(vertex.Unk3); writer.Write(vertex.Unk4); writer.Write(vertex.Unk5); writer.Write(vertex.Unk6); } for (int i = 0; i < connections.Length; i++) { var connection = connections[i]; writer.Write(connection.Flags); writer.Write(connection.NodeID); writer.Write(connection.ConnectedNodeID); } runtimeMesh.WriteToFile(writer); }
public HPDData(BinaryReader reader) { unk0 = reader.ReadInt32(); unk1 = reader.ReadInt32(); remainingHeader = reader.ReadBytes(132); unkData = new unkStruct[unk1]; for (int i = 0; i != unkData.Length; i++) { unkStruct data = new unkStruct(); data.id = reader.ReadInt32(); data.unk0 = Vector3Extenders.ReadFromFile(reader); data.unk1 = Vector3Extenders.ReadFromFile(reader); data.unkData = reader.ReadBytes(20); unkData[i] = data; } unk2 = StringHelpers.ReadString(reader); unk3 = reader.ReadInt32(); unk4 = reader.ReadInt32(); }
public void WriteRawFormatToFile(BinaryWriter writer, TriangleMesh mesh) { writer.Write(mesh.NumVertices); foreach (var Entry in mesh.Vertices) { Vector3Extenders.WriteToFile(Entry, writer); } writer.Write(mesh.NumTriangles * 3); // Write Number of Indices, not triangles. foreach (var Entry in mesh.Triangles) { writer.Write(Entry.v0); writer.Write(Entry.v1); writer.Write(Entry.v2); } writer.Write(mesh.MaterialIndices.Count); foreach (var Entry in mesh.MaterialIndices) { writer.Write(Entry); } }
public void ReadFromFile(MemoryStream reader, bool isBigEndian) { Vector3 m1 = Vector3Extenders.ReadFromFile(reader, isBigEndian); float x = reader.ReadSingle(isBigEndian); Vector3 m2 = Vector3Extenders.ReadFromFile(reader, isBigEndian); float y = reader.ReadSingle(isBigEndian); Vector3 m3 = Vector3Extenders.ReadFromFile(reader, isBigEndian); float z = reader.ReadSingle(isBigEndian); transformedMatrix = new Matrix33(m1, m2, m3); scale = new Matrix33(new Vector3(m1.Length(), 0.0f, 0.0f), new Vector3(0.0f, m2.Length(), 0.0f), new Vector3(0.0f, 0.0f, m3.Length())); rotation = new Matrix33(); transformedMatrix.M00 = transformedMatrix.M00 / scale.M00; transformedMatrix.M01 = transformedMatrix.M01 / scale.M00; transformedMatrix.M02 = transformedMatrix.M02 / scale.M00; transformedMatrix.M10 = transformedMatrix.M10 / scale.M11; transformedMatrix.M11 = transformedMatrix.M11 / scale.M11; transformedMatrix.M12 = transformedMatrix.M12 / scale.M11; transformedMatrix.M20 = transformedMatrix.M20 / scale.M22; transformedMatrix.M21 = transformedMatrix.M21 / scale.M22; transformedMatrix.M22 = transformedMatrix.M22 / scale.M22; Position = new Vector3(x, y, z); }
public void ReadFromM2T(BinaryReader reader) { if (new string(reader.ReadChars(3)) != fileHeader) { return; } if (reader.ReadByte() != fileVersion) { return; } //mesh name name = reader.ReadString(); //Number of Lods Lods = new Lod[reader.ReadByte()]; for (int i = 0; i != Lods.Length; i++) { Lods[i] = new Lod { VertexDeclaration = 0 }; if (reader.ReadBoolean()) { Lods[i].VertexDeclaration += (int)VertexFlags.Position; } if (reader.ReadBoolean()) { Lods[i].VertexDeclaration += (int)VertexFlags.Normals; } if (reader.ReadBoolean()) { Lods[i].VertexDeclaration += (int)VertexFlags.Tangent; } if (reader.ReadBoolean()) { Lods[i].VertexDeclaration += (int)VertexFlags.Skin; } if (reader.ReadBoolean()) { Lods[i].VertexDeclaration += (int)VertexFlags.Color; } if (reader.ReadBoolean()) { Lods[i].VertexDeclaration += (int)VertexFlags.TexCoords0; } if (reader.ReadBoolean()) { Lods[i].VertexDeclaration += (int)VertexFlags.TexCoords1; } if (reader.ReadBoolean()) { Lods[i].VertexDeclaration += (int)VertexFlags.TexCoords2; } if (reader.ReadBoolean()) { Lods[i].VertexDeclaration += (int)VertexFlags.ShadowTexture; } if (reader.ReadBoolean()) { Lods[i].VertexDeclaration += (int)VertexFlags.Color1; } if (reader.ReadBoolean()) { Lods[i].VertexDeclaration += (int)VertexFlags.BBCoeffs; } if (reader.ReadBoolean()) { Lods[i].VertexDeclaration += (int)VertexFlags.DamageGroup; } //write length and then all vertices. lods[i].Vertices = new Vertex[reader.ReadInt32()]; lods[i].NumUVChannels = 4; for (int x = 0; x != lods[i].Vertices.Length; x++) { Vertex vert = new Vertex(); vert.UVs = new Half2[lods[i].NumUVChannels]; if (Lods[i].VertexDeclaration.HasFlag(VertexFlags.Position)) { vert.Position = Vector3Extenders.ReadFromFile(reader); } if (Lods[i].VertexDeclaration.HasFlag(VertexFlags.Normals)) { vert.Normal = Vector3Extenders.ReadFromFile(reader); } if (Lods[i].VertexDeclaration.HasFlag(VertexFlags.Tangent)) { vert.Tangent = Vector3Extenders.ReadFromFile(reader); } if (Lods[i].VertexDeclaration.HasFlag(VertexFlags.TexCoords0)) { vert.UVs[0] = Half2Extenders.ReadFromFile(reader); } if (Lods[i].VertexDeclaration.HasFlag(VertexFlags.TexCoords1)) { vert.UVs[1] = Half2Extenders.ReadFromFile(reader); } if (Lods[i].VertexDeclaration.HasFlag(VertexFlags.TexCoords2)) { vert.UVs[2] = Half2Extenders.ReadFromFile(reader); } if (Lods[i].VertexDeclaration.HasFlag(VertexFlags.ShadowTexture)) { vert.UVs[3] = Half2Extenders.ReadFromFile(reader); } lods[i].Vertices[x] = vert; } //write mesh count and texture names. Lods[i].Parts = new ModelPart[reader.ReadInt32()]; for (int x = 0; x != Lods[i].Parts.Length; x++) { Lods[i].Parts[x] = new ModelPart(); Lods[i].Parts[x].Material = reader.ReadString(); ulong hash = 0; ulong.TryParse(Lods[i].Parts[x].Material, out hash); Lods[i].Parts[x].Hash = hash; Lods[i].Parts[x].StartIndex = reader.ReadUInt32(); Lods[i].Parts[x].NumFaces = reader.ReadUInt32(); } int numIndices = reader.ReadInt32(); Lods[i].Indices = new ushort[numIndices]; for (int x = 0; x != Lods[i].Indices.Length; x++) { Lods[i].Indices[x] = reader.ReadUInt16(); } Lods[i].CalculatePartBounds(); } }