/// <summary>
        /// Reads the data-block from a stream.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            // read structure data
            this.VFT          = reader.ReadUInt32();
            this.Unknown_4h   = reader.ReadUInt32();
            this.VertexStride = reader.ReadUInt16();
            this.Unknown_Ah   = reader.ReadUInt16();
            this.Unknown_Ch   = reader.ReadUInt32();
            this.DataPointer1 = reader.ReadUInt64();
            this.VertexCount  = reader.ReadUInt32();
            this.Unknown_1Ch  = reader.ReadUInt32();
            this.DataPointer2 = reader.ReadUInt64();
            this.Unknown_28h  = reader.ReadUInt32();
            this.Unknown_2Ch  = reader.ReadUInt32();
            this.InfoPointer  = reader.ReadUInt64();
            this.Unknown_38h  = reader.ReadUInt32();
            this.Unknown_3Ch  = reader.ReadUInt32();
            this.Unknown_40h  = reader.ReadUInt32();
            this.Unknown_44h  = reader.ReadUInt32();
            this.Unknown_48h  = reader.ReadUInt32();
            this.Unknown_4Ch  = reader.ReadUInt32();
            this.Unknown_50h  = reader.ReadUInt32();
            this.Unknown_54h  = reader.ReadUInt32();
            this.Unknown_58h  = reader.ReadUInt32();
            this.Unknown_5Ch  = reader.ReadUInt32();
            this.Unknown_60h  = reader.ReadUInt32();
            this.Unknown_64h  = reader.ReadUInt32();
            this.Unknown_68h  = reader.ReadUInt32();
            this.Unknown_6Ch  = reader.ReadUInt32();
            this.Unknown_70h  = reader.ReadUInt32();
            this.Unknown_74h  = reader.ReadUInt32();
            this.Unknown_78h  = reader.ReadUInt32();
            this.Unknown_7Ch  = reader.ReadUInt32();

            // read reference data
            this.Info = reader.ReadBlockAt <VertexDeclaration_GTA5_pc>(
                this.InfoPointer // offset
                );
            this.Data1 = reader.ReadBlockAt <VertexData_GTA5_pc>(
                this.DataPointer1, // offset
                this.VertexStride,
                this.VertexCount,
                this.Info
                );
            this.Data2 = reader.ReadBlockAt <VertexData_GTA5_pc>(
                this.DataPointer2, // offset
                this.VertexStride,
                this.VertexCount,
                this.Info
                );
        }
Пример #2
0
        /// <summary>
        /// Reads the data-block from a stream.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            // read structure data
            this.VFT = reader.ReadUInt32();
            this.Unknown_4h = reader.ReadUInt32();
            this.VertexStride = reader.ReadUInt16();
            this.Unknown_Ah = reader.ReadUInt16();
            this.Unknown_Ch = reader.ReadUInt32();
            this.DataPointer1 = reader.ReadUInt64();
            this.VertexCount = reader.ReadUInt32();
            this.Unknown_1Ch = reader.ReadUInt32();
            this.DataPointer2 = reader.ReadUInt64();
            this.Unknown_28h = reader.ReadUInt32();
            this.Unknown_2Ch = reader.ReadUInt32();
            this.InfoPointer = reader.ReadUInt64();
            this.Unknown_38h = reader.ReadUInt32();
            this.Unknown_3Ch = reader.ReadUInt32();
            this.Unknown_40h = reader.ReadUInt32();
            this.Unknown_44h = reader.ReadUInt32();
            this.Unknown_48h = reader.ReadUInt32();
            this.Unknown_4Ch = reader.ReadUInt32();
            this.Unknown_50h = reader.ReadUInt32();
            this.Unknown_54h = reader.ReadUInt32();
            this.Unknown_58h = reader.ReadUInt32();
            this.Unknown_5Ch = reader.ReadUInt32();
            this.Unknown_60h = reader.ReadUInt32();
            this.Unknown_64h = reader.ReadUInt32();
            this.Unknown_68h = reader.ReadUInt32();
            this.Unknown_6Ch = reader.ReadUInt32();
            this.Unknown_70h = reader.ReadUInt32();
            this.Unknown_74h = reader.ReadUInt32();
            this.Unknown_78h = reader.ReadUInt32();
            this.Unknown_7Ch = reader.ReadUInt32();

            // read reference data
            this.Info = reader.ReadBlockAt<VertexDeclaration_GTA5_pc>(
                this.InfoPointer // offset
            );
            this.Data1 = reader.ReadBlockAt<VertexData_GTA5_pc>(
                this.DataPointer1, // offset
                this.VertexStride,
                this.VertexCount,
                this.Info
            );
            this.Data2 = reader.ReadBlockAt<VertexData_GTA5_pc>(
                this.DataPointer2, // offset
                this.VertexStride,
                this.VertexCount,
                this.Info
            );
        }
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            int stride = Convert.ToInt32(parameters[0]);
            int count  = Convert.ToInt32(parameters[1]);
            var info   = (VertexDeclaration_GTA5_pc)parameters[2];

            this.cnt  = count;
            this.info = info;



            bool[] IsUsed = new bool[16];
            for (int i = 0; i < 16; i++)
            {
                IsUsed[i] = ((info.Flags >> i) & 0x1) == 1;
            }

            Types = new uint[16];
            for (int i = 0; i < 16; i++)
            {
                Types[i] = (uint)((info.Types >> (int)(4 * i)) & 0xF);
            }



            VertexData = new object[16];
            for (int i = 0; i < 16; i++)
            {
                if (IsUsed[i])
                {
                    switch (Types[i])
                    {
                    case 0: VertexData[i] = new ushort[1 * count]; break;

                    case 1: VertexData[i] = new ushort[2 * count]; break;

                    case 2: VertexData[i] = new ushort[3 * count]; break;

                    case 3: VertexData[i] = new ushort[4 * count]; break;

                    case 4: VertexData[i] = new float[1 * count]; break;

                    case 5: VertexData[i] = new float[2 * count]; break;

                    case 6: VertexData[i] = new float[3 * count]; break;

                    case 7: VertexData[i] = new float[4 * count]; break;

                    case 8: VertexData[i] = new uint[count]; break;

                    case 9: VertexData[i] = new uint[count]; break;

                    case 10: VertexData[i] = new uint[count]; break;

                    default:
                        throw new Exception();
                    }
                }
            }



            long pos = reader.Position;

            // read...
            for (int i = 0; i < count; i++)
            {
                for (int k = 0; k < 16; k++)
                {
                    if (IsUsed[k])
                    {
                        switch (Types[k])
                        {
                        // float16
                        case 0:
                        {
                            var buf = VertexData[k] as ushort[];
                            buf[i * 1 + 0] = reader.ReadUInt16();
                            break;
                        }

                        case 1:
                        {
                            var buf = VertexData[k] as ushort[];
                            buf[i * 2 + 0] = reader.ReadUInt16();
                            buf[i * 2 + 1] = reader.ReadUInt16();
                            break;
                        }

                        case 2:
                        {
                            var buf = VertexData[k] as ushort[];
                            buf[i * 3 + 0] = reader.ReadUInt16();
                            buf[i * 3 + 1] = reader.ReadUInt16();
                            buf[i * 3 + 2] = reader.ReadUInt16();
                            break;
                        }

                        case 3:
                        {
                            var buf = VertexData[k] as ushort[];
                            buf[i * 4 + 0] = reader.ReadUInt16();
                            buf[i * 4 + 1] = reader.ReadUInt16();
                            buf[i * 4 + 2] = reader.ReadUInt16();
                            buf[i * 4 + 3] = reader.ReadUInt16();
                            break;
                        }

                        // float32
                        case 4:
                        {
                            var buf = VertexData[k] as float[];
                            buf[i * 1 + 0] = reader.ReadSingle();
                            break;
                        }

                        case 5:
                        {
                            var buf = VertexData[k] as float[];
                            buf[i * 2 + 0] = reader.ReadSingle();
                            buf[i * 2 + 1] = reader.ReadSingle();
                            break;
                        }

                        case 6:
                        {
                            var buf = VertexData[k] as float[];
                            buf[i * 3 + 0] = reader.ReadSingle();
                            buf[i * 3 + 1] = reader.ReadSingle();
                            buf[i * 3 + 2] = reader.ReadSingle();
                            break;
                        }

                        case 7:
                        {
                            var buf = VertexData[k] as float[];
                            buf[i * 4 + 0] = reader.ReadSingle();
                            buf[i * 4 + 1] = reader.ReadSingle();
                            buf[i * 4 + 2] = reader.ReadSingle();
                            buf[i * 4 + 3] = reader.ReadSingle();
                            break;
                        }

                        case 8:
                        case 9:
                        case 10:
                        {
                            var buf = VertexData[k] as uint[];
                            buf[i * 1 + 0] = reader.ReadUInt32();
                            break;
                        }

                        default:
                            throw new Exception();
                        }
                    }
                }
            }

            this.length = stride * count;
        }
Пример #4
0
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            int stride = Convert.ToInt32(parameters[0]);
            int count = Convert.ToInt32(parameters[1]);
            var info = (VertexDeclaration_GTA5_pc)parameters[2];
            this.cnt = count;
            this.info = info;



            bool[] IsUsed = new bool[16];
            for (int i = 0; i < 16; i++)
                IsUsed[i] = ((info.Flags >> i) & 0x1) == 1;

            Types = new uint[16];
            for (int i = 0; i < 16; i++)
                Types[i] = (uint)((info.Types >> (int)(4 * i)) & 0xF);



            VertexData = new object[16];
            for (int i = 0; i < 16; i++)
            {
                if (IsUsed[i])
                {
                    switch (Types[i])
                    {
                        case 0: VertexData[i] = new ushort[1 * count]; break;
                        case 1: VertexData[i] = new ushort[2 * count]; break;
                        case 2: VertexData[i] = new ushort[3 * count]; break;
                        case 3: VertexData[i] = new ushort[4 * count]; break;
                        case 4: VertexData[i] = new float[1 * count]; break;
                        case 5: VertexData[i] = new float[2 * count]; break;
                        case 6: VertexData[i] = new float[3 * count]; break;
                        case 7: VertexData[i] = new float[4 * count]; break;
                        case 8: VertexData[i] = new uint[count]; break;
                        case 9: VertexData[i] = new uint[count]; break;
                        case 10: VertexData[i] = new uint[count]; break;
                        default:
                            throw new Exception();
                    }
                }
            }



            long pos = reader.Position;

            // read...
            for (int i = 0; i < count; i++)
            {

                for (int k = 0; k < 16; k++)
                {
                    if (IsUsed[k])
                    {
                        switch (Types[k])
                        {
                            // float16
                            case 0:
                                {
                                    var buf = VertexData[k] as ushort[];
                                    buf[i * 1 + 0] = reader.ReadUInt16();
                                    break;
                                }
                            case 1:
                                {
                                    var buf = VertexData[k] as ushort[];
                                    buf[i * 2 + 0] = reader.ReadUInt16();
                                    buf[i * 2 + 1] = reader.ReadUInt16();
                                    break;
                                }
                            case 2:
                                {
                                    var buf = VertexData[k] as ushort[];
                                    buf[i * 3 + 0] = reader.ReadUInt16();
                                    buf[i * 3 + 1] = reader.ReadUInt16();
                                    buf[i * 3 + 2] = reader.ReadUInt16();
                                    break;
                                }
                            case 3:
                                {
                                    var buf = VertexData[k] as ushort[];
                                    buf[i * 4 + 0] = reader.ReadUInt16();
                                    buf[i * 4 + 1] = reader.ReadUInt16();
                                    buf[i * 4 + 2] = reader.ReadUInt16();
                                    buf[i * 4 + 3] = reader.ReadUInt16();
                                    break;
                                }

                            // float32
                            case 4:
                                {
                                    var buf = VertexData[k] as float[];
                                    buf[i * 1 + 0] = reader.ReadSingle();
                                    break;
                                }
                            case 5:
                                {
                                    var buf = VertexData[k] as float[];
                                    buf[i * 2 + 0] = reader.ReadSingle();
                                    buf[i * 2 + 1] = reader.ReadSingle();
                                    break;
                                }
                            case 6:
                                {
                                    var buf = VertexData[k] as float[];
                                    buf[i * 3 + 0] = reader.ReadSingle();
                                    buf[i * 3 + 1] = reader.ReadSingle();
                                    buf[i * 3 + 2] = reader.ReadSingle();
                                    break;
                                }
                            case 7:
                                {
                                    var buf = VertexData[k] as float[];
                                    buf[i * 4 + 0] = reader.ReadSingle();
                                    buf[i * 4 + 1] = reader.ReadSingle();
                                    buf[i * 4 + 2] = reader.ReadSingle();
                                    buf[i * 4 + 3] = reader.ReadSingle();
                                    break;
                                }

                            case 8:
                            case 9:
                            case 10:
                                {
                                    var buf = VertexData[k] as uint[];
                                    buf[i * 1 + 0] = reader.ReadUInt32();
                                    break;
                                }

                            default:
                                throw new Exception();
                        }
                    }
                }

            }

            this.length = stride * count;
        }