Beispiel #1
0
        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);
                    }
                }
            }
        }
Beispiel #2
0
        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++)
                    {
                        Vector3Utils.WriteToFile(path.Vectors[x].Position, writer);
                        Vector3Utils.WriteToFile(path.Vectors[x].Rotation, writer);
                        writer.Write(path.Vectors[x].Unk0);
                    }
                }
            }
        }
Beispiel #3
0
        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);*/
        }
Beispiel #4
0
        private void InternalWriteToFile(BinaryWriter writer)
        {
            writer.Write(version);
            writer.Write(unk1);
            writer.Write(unk2);
            BoundingBoxExtenders.WriteToFile(bounds, writer);
            writer.Write(Grids.Length);

            for (int i = 0; i < Grids.Length; i++)
            {
                Grid grid = Grids[i];
                writer.Write(grid.Key);
                Vector3Extenders.WriteToFile(grid.Origin, writer);
                Vector2Extenders.WriteToFile(grid.CellSize, writer);
                writer.Write(grid.Width);
                writer.Write(grid.Height);

                for (int y = 0; y != grid.Data.Length; y++)
                {
                    writer.Write(grid.Data[y]);
                }
            }

            writer.Write(unk3.Length / 2);
            for (int i = 0; i < unk3.Length; i++)
            {
                writer.Write(unk3[i]);
            }

            writer.Write(ObjectGroups.Length);
            for (int i = 0; i != ObjectGroups.Length; i++)
            {
                ObjectGroup objectGroup = ObjectGroups[i];
                writer.Write(objectGroup.Unk01);
                writer.Write(objectGroup.Objects.Length);

                for (int x = 0; x != objectGroup.NumObjects; x++)
                {
                    Object obj = objectGroup.Objects[x];
                    writer.Write(obj.NumInstance2);
                    writer.Write(obj.Unk02);
                    writer.Write(obj.Name.Hash);
                    StringHelpers.WriteString(writer, obj.Name.String);
                    writer.Write(obj.UnkBytes1);
                    writer.Write(obj.GridMax);
                    writer.Write(obj.GridMin);
                    writer.Write(obj.NumInstances);

                    for (int y = 0; y != obj.NumInstances; y++)
                    {
                        Instance instance = obj.Instances[y];
                        writer.Write(instance.W0);
                        writer.Write(instance.W1);
                        writer.Write(instance.W2);
                        writer.Write(instance.D5);
                        writer.Write(instance.ID);
                        writer.Write(instance.D4);
                    }
                    objectGroup.Objects[x] = obj;
                }
                ObjectGroups[i] = objectGroup;
            }
        }
        public void WriteToFile(BinaryWriter writer)
        {
            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);
            Vector2Extenders.WriteToFile(BoundMin, writer);
            Vector2Extenders.WriteToFile(BoundMax, writer);
            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.Write(Grid[i]);
            }

            for (int i = 0; i < Grid.Length; i++)
            {
                Cell cell = Cells[i];
                writer.Write(cell.Sets.Length);

                if (cell.Sets.Length == 0)
                {
                    continue;
                }

                writer.Write(cell.Offset);

                for (int x = 0; x < cell.Sets.Length; x++)
                {
                    var set = cell.Sets[x];
                    writer.Write(set.X);
                    writer.Write(set.Y);
                    writer.Write(set.Offset);
                }

                for (int x = 0; x < cell.Sets.Length; x++)
                {
                    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.cellUnk10);
                    writer.Write(set.cellUnk11);
                    writer.Write(set.cellUnk12);
                    writer.Write(set.cellUnk13);
                    writer.Write(set.cellUnk14);
                    writer.Write(set.cellUnk15);
                    writer.Write(set.NumEdges);
                    writer.Write(set.cellUnk17);
                    writer.Write(set.cellUnk18);
                    writer.Write(set.cellUnk19);

                    foreach (var dataSet in set.unk10Boxes)
                    {
                        BoundingBoxExtenders.WriteToFile(dataSet.B1, writer);
                        writer.Write(dataSet.UnkOffset);
                        writer.Write(dataSet.Unk20);
                    }

                    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.cellUnk14 > 0)
                    {
                        foreach (var offset in set.unk14Offsets)
                        {
                            writer.Write(offset);
                        }

                        writer.Write(set.unk14End);
                        foreach (var dataSet in set.unk14Boxes)
                        {
                            foreach (var point in dataSet.Points)
                            {
                                Vector3Extenders.WriteToFile(point, writer);
                            }
                        }
                    }

                    foreach (var offset in set.unk16Offsets)
                    {
                        writer.Write(offset);
                    }

                    if (set.NumEdges > 0)
                    {
                        writer.Write(set.EdgesDataEndOffset);

                        foreach (var dataSet in set.EdgeBoxes)
                        {
                            dataSet.WriteToFile(writer);
                        }
                    }

                    if (set.cellUnk18 > 0)
                    {
                        writer.Write(set.unk18End);

                        foreach (var dataSet in set.unk18Set)
                        {
                            writer.Write(dataSet.Unk0);
                            writer.Write(dataSet.Unk1);
                            writer.Write(dataSet.Unk2);
                            writer.Write(dataSet.Offset);
                        }

                        writer.Write(new byte[12]);

                        foreach (var dataSet in set.unk18Set)
                        {
                            foreach (var point in dataSet.Points)
                            {
                                Vector3Extenders.WriteToFile(point, writer);
                            }
                        }
                    }
                }
            }
        }