Ejemplo n.º 1
0
            protected int OnExecute(CommandLineApplication app)
            {
                var doct = new Doct();

                doct.Entry1List.Add(new Doct.Entry1 {
                });
                doct.Entry2List.Add(new Doct.Entry2 {
                });

                File.Create(DoctOut).Using(s => Doct.Write(s, doct));

                return(0);
            }
Ejemplo n.º 2
0
        public void CreateDummyDoctAndReadIt()
        {
            using var stream = new MemoryStream();
            var doct = new Doct();

            doct.Entry1List.Add(new Doct.Entry1 {
            });
            doct.Entry2List.Add(new Doct.Entry2 {
            });

            Doct.Write(stream, doct);

            stream.Position = 0;

            Doct.Read(stream); // confirm that it throws nothing.
        }
Ejemplo n.º 3
0
            protected int OnExecute(CommandLineApplication app)
            {
                MapOut = Path.GetFullPath(MapOut ?? Path.GetFileName(MapIn));

                Console.WriteLine($"Output map file: {MapOut}");

                var entries = File.OpenRead(MapIn).Using(s => Bar.Read(s).ToArray());

                var mapModel = Mdlx.Read(entries.Single(IsMapModel).Stream);

                var numVifPackets = mapModel.MapModel.VifPackets.Count;
                var numAlb2Groups = mapModel.MapModel.vifPacketRenderingGroup.Count;

                Console.WriteLine($"numVifPackets: {numVifPackets:#,##0}");
                Console.WriteLine($"numAlb2Groups: {numAlb2Groups:#,##0}");

                Console.WriteLine($"Note: this tool will build a unoptimized doct that renders all ALB2 {numAlb2Groups:#,##0} groups.");

                var doctStream = new MemoryStream();

                {
                    var doct = new Doct();

                    doct.Entry1List.Add(
                        new Doct.Entry1
                    {
                        Entry2Index     = 0,
                        Entry2LastIndex = Convert.ToUInt16(numAlb2Groups),     // max 65535
                    }
                        );

                    const float WorldBounds = 18000;

                    doct.Entry2List.AddRange(
                        Enumerable.Range(0, numAlb2Groups)
                        .Select(
                            index => new Doct.Entry2
                    {
                        BoundingBox = new BoundingBox(
                            new System.Numerics.Vector3(-WorldBounds),
                            new System.Numerics.Vector3(WorldBounds)
                            )
                    }
                            )
                        );

                    Doct.Write(doctStream, doct);

                    doctStream.Position = 0;
                }

                foreach (var entry in entries.Where(IsDoct))
                {
                    Console.WriteLine("DOCT entry replaced.");
                    entry.Stream = doctStream;
                }

                File.Create(MapOut).Using(s => Bar.Write(s, entries));

                Console.WriteLine("Output map file is written successfully.");
                return(0);
            }