Inheritance: MiscUtil.IO.EndianBinaryReader
Esempio n. 1
0
        public CAttribute(EndianBinaryReaderEx reader, CPSSGFile file)
        {
            this.file = file;

            id = reader.ReadInt32();
            int size = reader.ReadInt32();

            if (size == 4)
            {
                data = reader.ReadInt32();
                return;
            }
            else if (size > 4)
            {
                int strlen = reader.ReadInt32();
                if (size - 4 == strlen)
                {
                    data = reader.ReadPSSGString(strlen);
                    return;
                }
                else
                {
                    reader.Seek(-4, System.IO.SeekOrigin.Current);
                }
            }
            data = reader.ReadBytes(size);
        }
Esempio n. 2
0
        public CNode(EndianBinaryReaderEx reader, CPSSGFile file)
        {
            this.file = file;

            id = reader.ReadInt32();
            int  size = reader.ReadInt32();
            long end  = reader.BaseStream.Position + size;

            int  attributeSize = reader.ReadInt32();
            long attributeEnd  = reader.BaseStream.Position + attributeSize;

            // Each attr is at least 8 bytes (id + size), so take a conservative guess
            attributes = new Dictionary <string, CAttribute>();
            CAttribute attr;

            while (reader.BaseStream.Position < attributeEnd)
            {
                attr = new CAttribute(reader, file);
                attributes.Add(attr.name, attr);
            }

            switch (name)
            {
            case "BOUNDINGBOX":
            case "DATA":
            case "DATABLOCKDATA":
            case "DATABLOCKBUFFERED":
            case "INDEXSOURCEDATA":
            case "INVERSEBINDMATRIX":
            case "MODIFIERNETWORKINSTANCEUNIQUEMODIFIERINPUT":
            case "NeAnimPacketData_B1":
            case "NeAnimPacketData_B4":
            case "RENDERINTERFACEBOUNDBUFFERED":
            case "SHADERINPUT":
            case "TEXTUREIMAGEBLOCKDATA":
            case "TRANSFORM":
                isDataNode = true;
                break;
            }

            if (isDataNode)
            {
                data = reader.ReadBytes((int)(end - reader.BaseStream.Position));
            }
            else
            {
                // Each node at least 12 bytes (id + size + arg size)
                subNodes = new CNode[(end - reader.BaseStream.Position) / 12];
                int nodeCount = 0;
                while (reader.BaseStream.Position < end)
                {
                    subNodes[nodeCount] = new CNode(reader, file);
                    nodeCount++;
                }
                Array.Resize(ref subNodes, nodeCount);
            }
        }
Esempio n. 3
0
        public CNodeInfo(EndianBinaryReaderEx reader, CPSSGFile file)
        {
            attributeInfo = new Dictionary <int, CAttributeInfo>();

            id   = reader.ReadInt32();
            name = reader.ReadPSSGString();
            int            attributeInfoCount = reader.ReadInt32();
            CAttributeInfo ai;

            for (int i = 0; i < attributeInfoCount; i++)
            {
                ai = new CAttributeInfo(reader);
                attributeInfo.Add(ai.id, ai);

                file.attributeInfo[ai.id - 1] = ai;
            }
        }
Esempio n. 4
0
        public CAttribute(EndianBinaryReaderEx reader, CPSSGFile file)
        {
            this.file = file;

            id = reader.ReadInt32();
            int size = reader.ReadInt32();
            if (size == 4) {
                data = reader.ReadInt32();
                return;
            } else if (size > 4) {
                int strlen = reader.ReadInt32();
                if (size - 4 == strlen) {
                    data = reader.ReadPSSGString(strlen);
                    return;
                } else {
                    reader.Seek(-4, System.IO.SeekOrigin.Current);
                }
            }
            data = reader.ReadBytes(size);
        }
Esempio n. 5
0
        public CPSSGFile(System.IO.Stream fileStream)
        {
            EndianBinaryReaderEx reader = new EndianBinaryReaderEx(new BigEndianBitConverter(), fileStream);

            magic = reader.ReadPSSGString(4);
            // TODO: Check magic
            int size = reader.ReadInt32();
            int attributeInfoCount = reader.ReadInt32();
            int nodeInfoCount      = reader.ReadInt32();

            attributeInfo = new CAttributeInfo[attributeInfoCount];
            nodeInfo      = new CNodeInfo[nodeInfoCount];

            for (int i = 0; i < nodeInfoCount; i++)
            {
                nodeInfo[i] = new CNodeInfo(reader, this);
            }

            rootNode = new CNode(reader, this);
        }
Esempio n. 6
0
 public CAttributeInfo(EndianBinaryReaderEx reader)
 {
     id = reader.ReadInt32();
     name = reader.ReadPSSGString();
 }
Esempio n. 7
0
        public CPSSGFile(System.IO.Stream fileStream)
        {
            EndianBinaryReaderEx reader = new EndianBinaryReaderEx(new BigEndianBitConverter(), fileStream);

            magic = reader.ReadPSSGString(4);
            // TODO: Check magic
            int size = reader.ReadInt32();
            int attributeInfoCount = reader.ReadInt32();
            int nodeInfoCount = reader.ReadInt32();

            attributeInfo = new CAttributeInfo[attributeInfoCount];
            nodeInfo = new CNodeInfo[nodeInfoCount];

            for (int i = 0; i < nodeInfoCount; i++) {
                nodeInfo[i] = new CNodeInfo(reader, this);
            }

            rootNode = new CNode(reader, this);
        }
Esempio n. 8
0
        public CNodeInfo(EndianBinaryReaderEx reader, CPSSGFile file)
        {
            attributeInfo = new Dictionary<int, CAttributeInfo>();

            id = reader.ReadInt32();
            name = reader.ReadPSSGString();
            int attributeInfoCount = reader.ReadInt32();
            CAttributeInfo ai;
            for (int i = 0; i < attributeInfoCount; i++) {
                ai = new CAttributeInfo(reader);
                attributeInfo.Add(ai.id, ai);

                file.attributeInfo[ai.id - 1] = ai;
            }
        }
Esempio n. 9
0
        public CNode(EndianBinaryReaderEx reader, CPSSGFile file)
        {
            this.file = file;

            id = reader.ReadInt32();
            int size = reader.ReadInt32();
            long end = reader.BaseStream.Position + size;

            int attributeSize = reader.ReadInt32();
            long attributeEnd = reader.BaseStream.Position + attributeSize;
            // Each attr is at least 8 bytes (id + size), so take a conservative guess
            attributes = new Dictionary<string, CAttribute>();
            CAttribute attr;
            while (reader.BaseStream.Position < attributeEnd) {
                attr = new CAttribute(reader, file);
                attributes.Add(attr.name, attr);
            }

            switch (name) {
                case "BOUNDINGBOX":
                case "DATABLOCKDATA":
                case "DATABLOCKBUFFERED":
                case "INDEXSOURCEDATA":
                case "INVERSEBINDMATRIX":
                case "MODIFIERNETWORKINSTANCEUNIQUEMODIFIERINPUT":
                case "RENDERINTERFACEBOUNDBUFFERED":
                case "SHADERINPUT":
                case "TEXTUREIMAGEBLOCKDATA":
                case "TRANSFORM":
                    isDataNode = true;
                    break;
            }

            if (isDataNode) {
                data = reader.ReadBytes((int)(end - reader.BaseStream.Position));
            } else {
                // Each node at least 12 bytes (id + size + arg size)
                subNodes = new CNode[(end - reader.BaseStream.Position) / 12];
                int nodeCount = 0;
                while (reader.BaseStream.Position < end) {
                    subNodes[nodeCount] = new CNode(reader, file);
                    nodeCount++;
                }
                Array.Resize(ref subNodes, nodeCount);
            }
        }
Esempio n. 10
0
 public CAttributeInfo(EndianBinaryReaderEx reader)
 {
     id   = reader.ReadInt32();
     name = reader.ReadPSSGString();
 }