Ejemplo n.º 1
0
        public FSHP(FileData f)
        {
            ImageKey         = "polygon";
            SelectedImageKey = "polygon";

            if (!f.readString(4).Equals("FSHP"))
            {
                throw new Exception("Error reading Mesh Shape");
            }
            f.skip(12); // padding
            Text = f.readString(f.readOffset() + 2, -1);
            f.skip(4);  // padding
            fvtxOffset = f.readOffset();
            f.skip(4);  // padding
            int lodOffset = f.readOffset();

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

            f.skip(20); // padding
            int boundingBoxOffset = f.readOffset();

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

            f.skip(12); // padding
            int flags = f.readInt();
            int index = f.readShort();

            fmatIndex  = f.readShort();
            singleBind = (short)f.readShort();
            fvtxindex  = f.readShort();
            int SkinBoneIndexCount = f.readShort();
            int VertexSkinCount    = f.readByte();
            int lodCount           = f.readByte();
            int visGroupCount      = f.readInt();
            int fsklarraycount     = f.readShort();



            // level of detail models
            //IndexGroup fmdlGroup = new IndexGroup(f);
            for (int i = 0; i < lodCount; i++)
            {
                f.seek(lodOffset + (i * 56));
                var baseShape = new BaseRenderData.shape()
                {
                    name      = Text,
                    Index     = index,
                    FvtxIndex = fvtxindex,
                    FmatIndex = fmatIndex,
                };

                lodModels.Add(new LODModel(f, baseShape));
            }
            Nodes.AddRange(lodModels.ToArray());

            // visibility group
        }
Ejemplo n.º 2
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);
        }