Beispiel #1
0
        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);
        }
Beispiel #2
0
        public void ReadFromFile(BinaryReader reader)
        {
            unk0        = reader.ReadInt32();
            fileIDHPD   = reader.ReadInt32();
            unk3HPD     = reader.ReadInt32();
            bitFlagsHPD = reader.ReadInt32();

            vertSize = reader.ReadInt32();
            triSize  = reader.ReadInt32();

            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();               // ^ 0x80000000
                vertex.Position = Vector3Utils.ReadFromFile(reader); // TODO: Construct KynogonUtils to accomodate this
                Vector3 pos = vertex.Position;
                float   y   = pos.Y;
                pos.Y           = -pos.Z;
                pos.Z           = y;
                vertex.Position = 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;

                Points.Add(vertex.Position);
            }

            connections = new ConnectionStruct[triSize];
            for (int i = 0; i < triSize; i++)
            {
                ConnectionStruct connection = new ConnectionStruct();
                connection.Flags           = reader.ReadUInt32() ^ 0x80000000;
                connection.NodeID          = reader.ReadUInt32();
                connection.ConnectedNodeID = reader.ReadUInt32();
                connections[i]             = connection;
            }

            //Read KynogonRuntimeMesh
            runtimeMesh = new KynogonRuntimeMesh();
            runtimeMesh.ReadFromFile(reader);

            // read footer

            /*if (!runtimeMesh.bDEBUG_HASEXTRADATA)
             * {
             *  Name = StringHelpers.ReadString(reader);
             *  uint SizeofName = reader.ReadUInt32();
             *  uint Header = reader.ReadUInt32();
             * }*/

            Footer = reader.ReadBytes((int)(reader.BaseStream.Length - reader.BaseStream.Position));

            GenerateConnections();
            DumpToASCII("NAV_OBJ_DATA_" + fileIDHPD + ".txt");
        }