Beispiel #1
0
        public override string ToString()
        {
            string value = "";

            bool external = Entry == null;

            string extra = "";

            if (Entry == null)
            {
                string file = BundleCache.GetFileByEntryID(EntryID);
                if (!string.IsNullOrEmpty(file))
                {
                    extra = ", Path: " + BundleCache.GetRelativePath(file);
                    BundleArchive archive = BundleArchive.Read(file);
                    Entry = archive.GetEntryByID(EntryID);
                }
            }

            if (Entry != null && Entry.Type == EntryType.VertexDescriptor)
            {
                VertexDesc desc = VertexDesc.Read(Entry);
                value = ", Attribute Count: " + desc.AttributeCount.ToString("D2");
            }

            string location = external ? "External" : "Internal";

            string info = "(External)";

            if (Entry != null)
            {
                info = "(" + location + ": " + EntryIndex.ToString("D3") + ", " + Entry.Type + value + extra + ")";
            }
            return("ID: 0x" + EntryID.ToString("X8") + ", PtrOffset: 0x" + EntryPointerOffset.ToString("X8") + " " + info);
        }
Beispiel #2
0
        public static VertexDesc Read(BundleEntry entry)
        {
            VertexDesc result = new VertexDesc();

            MemoryStream  ms = entry.MakeStream();
            BinaryReader2 br = new BinaryReader2(ms);

            br.BigEndian = entry.Console;

            result.Unknown1       = br.ReadInt32();
            result.Unknown2       = br.ReadInt32();
            result.Unknown3       = br.ReadInt32();
            result.AttributeCount = br.ReadInt32();

            for (int i = 0; i < result.AttributeCount; i++)
            {
                VertexAttribute attribute = new VertexAttribute();

                if (result.Unknown2 != 0) // BPR
                {
                    attribute.Type = (VertexAttributeType)br.ReadInt32();
                    if (!Enum.IsDefined(typeof(VertexAttributeType), attribute.Type))
                    {
                        MessageBox.Show("Unknown vertex attribute type: " + attribute.Type);
                    }
                    attribute.Unknown1 = br.ReadUInt32();
                    attribute.Offset   = br.ReadUInt32();
                    attribute.Unknown2 = br.ReadUInt32();
                    attribute.Size     = br.ReadUInt32();
                }
                else
                {
                    br.BaseStream.Position += 1;
                    attribute.Size          = br.ReadByte();
                    attribute.Offset        = br.ReadByte();

                    // These are probably in the following bytes but I'll need to check where.
                    attribute.Unknown1 = 0;
                    attribute.Unknown2 = 0;

                    br.BaseStream.Position += 8;

                    byte type = br.ReadByte();
                    switch (type)
                    {
                    case 1:
                        attribute.Type = VertexAttributeType.Positions;
                        break;

                    case 3:
                        attribute.Type = VertexAttributeType.Normals;
                        break;

                    case 6:
                        attribute.Type = VertexAttributeType.UV1;
                        break;

                    case 7:
                        attribute.Type = VertexAttributeType.UV2;
                        break;

                    case 14:
                        attribute.Type = VertexAttributeType.BoneIndexes;
                        break;

                    case 15:
                        attribute.Type = VertexAttributeType.BoneWeights;
                        break;

                    case 21:
                        attribute.Type = VertexAttributeType.Tangents;
                        break;

                    default:
                        attribute.Type = VertexAttributeType.Invalid;
                        MessageBox.Show("Unknown vertex attribute type: " + type);
                        break;
                    }

                    br.BaseStream.Position += 4;
                }

                result.Attributes.Add(attribute);
            }

            br.Close();
            ms.Close();

            return(result);
        }