コード例 #1
0
        public LODModel(FileData f, BaseRenderData.shape baseShape)
        {
            Text = "DetailLevel";
            int subMeshArrayOffset = f.readOffset();

            f.skip(4); // padding
            int unk = f.readOffset();

            f.skip(4); // padding
            int unk2 = f.readOffset();

            f.skip(4);                            // padding
            indexBufferOffset = f.readOffset();
            f.skip(4);                            // padding
            int faceOffset      = f.readOffset(); // is indexes
            int PrimativeFormat = f.readInt();

            faceType = f.readInt();
            fcount   = f.readInt();
            int visgroup     = f.readShort();
            int subMeshCount = f.readShort();

            int temp = f.pos();

            RelocationTable RLT = new RelocationTable(f);

            indexBufferOffset = RLT.DataStart + faceOffset;

            f.seek(indexBufferOffset);
            data   = new ushort[fcount];
            dataui = new uint[fcount];

            for (int i = 0; i < fcount; i++)
            {
                if (faceType == 1)
                {
                    data[i] = (ushort)f.readShort();
                    //  Console.WriteLine(data[i]);

                    //Add to main renderer.
                    ShapeData.Add(new BaseRenderData.shape()
                    {
                        face      = data[i],
                        FmatIndex = baseShape.FmatIndex,
                        name      = baseShape.name,
                        Index     = baseShape.Index,
                        FvtxIndex = baseShape.FvtxIndex,
                    });
                }


                else
                if (faceType == 2)
                {
                    dataui[i] = (uint)f.readInt();
                    type      = DrawElementsType.UnsignedInt;
                }
                else
                {
                    throw new Exception("Unknown face types " + faceType);
                }
            }

            f.seek(temp);
        }
コード例 #2
0
        public FVTX(FileData f)
        {
            Text = "VertexAttributeBuffer";
            if (!f.readString(4).Equals("FVTX"))
            {
                throw new Exception("Error reading Skeleton");
            }
            f.skip(12); //padding
            int vertexAttribArrayOffset = f.readOffset();

            f.skip(4); //padding
            int vertexAttribDictOffset = f.readOffset();

            f.skip(4); //padding
            int unk = f.readOffset();

            f.skip(4); //padding
            int unk2 = f.readOffset();

            f.skip(4); //padding
            int unk3 = f.readOffset();

            f.skip(4); //padding
            int vertexBufferSizeOffset = f.readOffset();

            f.skip(4); //padding
            int vertexStrideSizeOffset = f.readOffset();

            f.skip(4); //padding
            int vertexBufferArrayOffset = f.readOffset();

            f.skip(4); //padding
            int BufferOffset = f.readOffset();
            int attrCount    = f.readByte();
            int bufferCount  = f.readByte();
            int index        = f.readShort();

            vertCount = f.readInt();
            int SkinWeightInfluence = f.readInt();
            int temp = f.pos();



            for (int i = 0; i < attrCount; i++)
            {
                f.seek(vertexAttribArrayOffset + (i * 0x10));
                attributes.Add(new BFRESAttribute(f, buffers));
            }


            //Find buffer size & stride

            RelocationTable RLT = new RelocationTable(f);

            for (int i = 0; i < bufferCount; i++)
            {
                f.seek(vertexBufferSizeOffset + ((i) * 0x10));
                VertexBufferSize = f.readInt();
                f.seek(vertexStrideSizeOffset + ((i) * 0x10));
                vertexStrideSize = f.readInt();

                //So these work by grabbing the RLT offset first and then adding the buffer offset. Then they keep adding each other by their buffer sizes
                if (i == 0)
                {
                    DataOffset = (RLT.DataStart + BufferOffset);
                }
                if (i > 0)
                {
                    DataOffset = BufferOffsets[i - 1].DataOffsetData + BufferOffsets[i - 1].VertexBufferSizeData;
                }
                if (DataOffset % 8 != 0)
                {
                    DataOffset = DataOffset + (8 - (DataOffset % 8));
                }

                BufferOffsets.Add(new BufferData {
                    VertexBufferSizeData = VertexBufferSize, DataOffsetData = DataOffset, VertexStrideSizeData = vertexStrideSize
                });

                dataBuff = f.getSection(BufferOffsets[i].DataOffsetData, BufferOffsets[i].VertexBufferSizeData);
                Console.WriteLine("Data Offset = " + DataOffset + " Vertex Buffer Size =" + BufferOffsets[i].VertexBufferSizeData + " Index = " + i + " vertexStrideSize size =" + vertexStrideSize);


                //WriteByteArray(dataBuff, "dataBuff");

                BuffSizes.Add(new BufferSizes {
                    BuffSizes = dataBuff
                });
            }



            Nodes.AddRange(attributes.ToArray());

            f.seek(BufferOffsets[0].DataOffsetData);
            myRender();

            f.seek(temp);
        }