public void WriteToFile(NavigationWriter writer) { writer.Write(-1); //file size writer.Write(unk01_flags); if (unk01_flags == 3604410608) { writer.Write(fileName.Length); StringHelpers.WriteString(writer, fileName, false); if (data is OBJData) { (data as OBJData).WriteToFile(writer); } else if (data is HPDData) { WriteHPD(writer); // Our HPD file here actually should subtract 12 of the total. writer.BaseStream.Position = 0; writer.Write((uint)(writer.BaseStream.Length - 12)); return; } } else if (unk01_flags == 1005) { (data as AIWorld).WriteToFile(writer); } writer.BaseStream.Position = 0; writer.Write((uint)(writer.BaseStream.Length - 4)); }
public void WriteToFile(NavigationWriter 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); // | 0x80000000 Vector3 pos = vertex.Position; float z = pos.Z; // TODO: Construct KynogonUtils to accomodate this pos.Z = -pos.Y; pos.Y = z; Vector3Utils.WriteToFile(pos, writer); // NB: DO NOT SET vertex.Position as pos!! 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 | 0x80000000); writer.Write(connection.NodeID); writer.Write(connection.ConnectedNodeID); } runtimeMesh.WriteToFile(writer); writer.Write(Footer); // write footer /* if (!runtimeMesh.bDEBUG_HASEXTRADATA) * { * writer.Write(Padding); * StringHelpers.WriteString(writer, Name); * writer.Write(Name.Length + 1); // extra 1 is the padding * writer.Write(303296513); * }*/ }
public void WriteToFile(NavigationWriter writer) { long MESH_START = writer.BaseStream.Position; StringHelpers.WriteString(writer, "KynogonRuntimeMesh", false); writer.Write((ushort)0); //magic is name with two extra 00 writer.Write(2); //version writer.Write(Unk0); writer.Write(Unk1); writer.Write(Unk2); writer.Write(Unk3); writer.Write(BoundMin.X); writer.Write(BoundMax.X); writer.Write(-BoundMax.Y); writer.Write(-BoundMin.Y); writer.Write(CellSizeX); writer.Write(CellSizeY); writer.Write(Radius); writer.Write(Unk4); writer.Write(Height); writer.Write(Offset); for (int i = 0; i < Grid.Length; i++) { writer.PushLooseObjectPtr("GRID_OFFSET_" + i, MESH_START); } writer.PushLooseObjectPtr("GRID_END", MESH_START); for (int i = 0; i < Grid.Length; i++) { writer.SolveLooseObjectPtr("GRID_OFFSET_" + i); Cell cell = Cells[i]; writer.Write(cell.Sets.Length); if (cell.Sets.Length == 0) { continue; } writer.PushLooseObjectPtr("GRID_START_OFFSET", MESH_START); for (int x = 0; x < cell.Sets.Length; x++) { var set = cell.Sets[x]; writer.Write(set.X); writer.Write(set.Y); writer.PushLooseObjectPtr("SET_END_OFFSET_" + x, MESH_START); } writer.SolveLooseObjectPtr("GRID_START_OFFSET"); for (int x = 0; x < cell.Sets.Length; x++) { long SET_START = writer.BaseStream.Position; var set = cell.Sets[x]; writer.Write(set.cellUnk0); writer.Write(set.cellUnk1); writer.Write(set.cellUnk2); writer.Write(set.cellUnk3); writer.Write(set.cellUnk4); writer.Write(set.cellUnk5); writer.Write(set.cellUnk6); writer.Write(set.cellUnk7); writer.Write(set.cellUnk8); writer.Write(set.cellUnk9); writer.Write(set.NumUnk10Boxes); writer.PushLooseObjectPtr("UNK10BOXES_OFFSET", SET_START); writer.Write(set.NumUnk12Boxes); writer.PushLooseObjectPtr("UNK12BOXES_OFFSET", SET_START); writer.Write(set.NumUn14Boxes); writer.PushLooseObjectPtr("UNK14BOXES_OFFSET", SET_START); writer.Write(set.NumEdges); writer.PushLooseObjectPtr("EDGES_OFFSET", SET_START); writer.Write(set.NumUnk18Boxes); writer.PushLooseObjectPtr("UNK18BOXES_OFFSET", SET_START); if (set.NumUnk10Boxes > 0) { writer.SolveLooseObjectPtr("UNK10BOXES_OFFSET"); foreach (var dataSet in set.unk10Boxes) { BoundingBoxExtenders.WriteToFile(dataSet.B1, writer); writer.Write(dataSet.UnkOffset); writer.Write(dataSet.Unk20); } } if (set.NumUnk12Boxes > 0) { writer.SolveLooseObjectPtr("UNK12BOXES_OFFSET"); foreach (var dataSet in set.unk12Boxes) { BoundingBoxExtenders.WriteToFile(dataSet.B1, writer); writer.Write(dataSet.Unk01); writer.Write(dataSet.Unk02); writer.Write(dataSet.Unk03); writer.Write(dataSet.Unk04); writer.Write(dataSet.Unk05); } } if (set.NumUn14Boxes > 0) { // write offset of boxes writer.SolveLooseObjectPtr("UNK14BOXES_OFFSET"); for (int z = 0; z < set.unk14Boxes.Length; z++) { writer.PushLooseObjectPtr("UNK14_BOX_OFFSET_" + z, SET_START); } // write them writer.PushLooseObjectPtr("UNK14_BOX_END", SET_START); for (int z = 0; z < set.unk14Boxes.Length; z++) { writer.SolveLooseObjectPtr("UNK14_BOX_OFFSET_" + z); foreach (var point in set.unk14Boxes[z].Points) { Vector3Utils.WriteToFile(point, writer); } } // end data with ending offset writer.SolveLooseObjectPtr("UNK14_BOX_END"); } if (set.NumEdges > 0) { // write offset of boxes writer.SolveLooseObjectPtr("EDGES_OFFSET"); for (int z = 0; z < set.EdgeBoxes.Length; z++) { writer.PushLooseObjectPtr("EDGE_OFFSET_" + z, SET_START); } // write them writer.PushLooseObjectPtr("EDGE_END", SET_START); for (int z = 0; z < set.EdgeBoxes.Length; z++) { writer.SolveLooseObjectPtr("EDGE_OFFSET_" + z); set.EdgeBoxes[z].WriteToFile(writer); } // end data with ending offset writer.SolveLooseObjectPtr("EDGE_END"); } if (set.NumUnk18Boxes > 0) { // write offset writer.SolveLooseObjectPtr("UNK18BOXES_OFFSET"); writer.PushLooseObjectPtr("UNK18BOXES_END", SET_START); for (int z = 0; z < set.unk18Set.Length; z++) { writer.Write(set.unk18Set[z].Unk0); writer.Write(set.unk18Set[z].Unk1); writer.Write(set.unk18Set[z].Unk2); writer.PushLooseObjectPtr("UNK18_SET_OFFSET_" + z, SET_START); } writer.Write(new byte[12]); writer.SolveLooseObjectPtr("UNK18BOXES_END"); for (int z = 0; z < set.unk18Set.Length; z++) { for (int c = 0; c < set.unk18Set[z].Points.Length; c++) { Vector3Utils.WriteToFile(set.unk18Set[z].Points[c], writer); } writer.SolveLooseObjectPtr("UNK18_SET_OFFSET_" + z); } } // remove any outstanding offsets writer.RemoveLooseObjectPtr("UNK10BOXES_OFFSET"); writer.RemoveLooseObjectPtr("UNK12BOXES_OFFSET"); writer.RemoveLooseObjectPtr("UNK14BOXES_OFFSET"); writer.RemoveLooseObjectPtr("EDGES_OFFSET"); writer.RemoveLooseObjectPtr("UNK18BOXES_OFFSET"); // solve end of set writer.SolveLooseObjectPtr("SET_END_OFFSET_" + x); } } writer.SolveLooseObjectPtr("GRID_END"); /*writer.Write(0); * * // write size of mesh * uint SizeOfMesh = (uint)(writer.BaseStream.Position - MESH_START); * writer.Write(SizeOfMesh);*/ }