Beispiel #1
0
        public TerrainModel(FileStream fs, TerrainHead head, byte[] tfragBlock, int num)
        {
            int    offset         = num * 0x30;
            int    texturePointer = ReadInt(tfragBlock, offset + 0x10);
            int    textureCount   = ReadInt(tfragBlock, offset + 0x14);
            ushort vertexIndex    = ReadUshort(tfragBlock, offset + 0x18);
            ushort vertexCount    = ReadUshort(tfragBlock, offset + 0x1A);
            ushort slotNum        = ReadUshort(tfragBlock, offset + 0x22);

            // Oh yes, we are hacking
            int faceStart = ReadInt(ReadBlock(fs, texturePointer + 4, 4), 0);

            textureConfig = GetTextureConfigs(fs, texturePointer, textureCount, 0x10, true);
            faceCount     = GetFaceCount();

            vertexBuffer = GetVertices(fs, head.vertexPointers[slotNum] + vertexIndex * 0x1C, head.UVpointers[slotNum] + vertexIndex * 0x08, vertexCount, 0x1C, 0x08);
            indexBuffer  = GetIndices(fs, head.indexPointers[slotNum] + faceStart * 2, faceCount, vertexIndex);

            rgbas = ReadBlock(fs, head.rgbaPointers[slotNum] + vertexIndex * 4, vertexCount * 4);

            // OOOf hack
            byte[] vertBlock = ReadBlock(fs, head.vertexPointers[slotNum] + vertexIndex * 0x1C, vertexCount * 0x1C);
            for (int i = 0; i < vertBlock.Length / 0x1c; i++)
            {
                off_0C.Add(ReadUint(vertBlock, i * 0x1c + 0x18));
            }
        }
Beispiel #2
0
        }                                   // Always 0


        public TerrainFragment(FileStream fs, TerrainHead head, byte[] tfragBlock, int num)
        {
            int offset = num * 0x30;

            float cullingX = ReadFloat(tfragBlock, offset + 0x00);
            float cullingY = ReadFloat(tfragBlock, offset + 0x04);
            float cullingZ = ReadFloat(tfragBlock, offset + 0x08);

            cullingSize = ReadFloat(tfragBlock, offset + 0x0C);

            off1C = ReadUshort(tfragBlock, offset + 0x1C);
            off1E = ReadUshort(tfragBlock, offset + 0x1E);

            off20 = ReadUshort(tfragBlock, offset + 0x20);
            off24 = ReadUint(tfragBlock, offset + 0x24);
            off28 = ReadUint(tfragBlock, offset + 0x28);
            off2C = ReadUint(tfragBlock, offset + 0x2C);

            model = new TerrainModel(fs, head, tfragBlock, num);

            modelID = model.id;

            modelMatrix = Matrix4.Identity;

            cullingCenter = new Vector3(cullingX, cullingY, cullingZ);
        }
Beispiel #3
0
        protected List <TerrainFragment> GetTerrainModels(int terrainModelPointer)
        {
            List <TerrainFragment> tFrags = new List <TerrainFragment>();

            //Read the whole terrain header
            byte[]      terrainBlock = ReadBlock(fileStream, terrainModelPointer, 0x60);
            TerrainHead head         = new TerrainHead(terrainBlock);

            byte[] tfragBlock = ReadBlock(fileStream, terrainModelPointer + 0x60, head.headCount * 0x30);

            for (int i = 0; i < head.headCount; i++)
            {
                tFrags.Add(new TerrainFragment(fileStream, head, tfragBlock, i));
            }

            return(tFrags);
        }
Beispiel #4
0
        public uint off_2C;     // Always 0


        public TerrainFragment(FileStream fs, TerrainHead head, byte[] tfragBlock, int num)
        {
            int offset = num * 0x30;

            off_00 = ReadFloat(tfragBlock, offset + 0x00);
            off_04 = ReadFloat(tfragBlock, offset + 0x04);
            off_08 = ReadFloat(tfragBlock, offset + 0x08);
            off_0C = ReadFloat(tfragBlock, offset + 0x0C);


            off_1C = ReadUshort(tfragBlock, offset + 0x1C);
            off_1E = ReadUshort(tfragBlock, offset + 0x1E);
            off_20 = ReadUshort(tfragBlock, offset + 0x20);

            off_24 = ReadUint(tfragBlock, offset + 0x24);
            off_28 = ReadUint(tfragBlock, offset + 0x28);
            off_2C = ReadUint(tfragBlock, offset + 0x2C);

            model       = new TerrainModel(fs, head, tfragBlock, num);
            modelMatrix = Matrix4.Identity;
        }
        protected Terrain GetTerrainModels(int terrainModelPointer, GameType game)
        {
            List <TerrainFragment> tFrags = new List <TerrainFragment>();

            //Read the whole terrain header
            int headerSize = (game.num == 4) ? 0x70 : 0x60;

            byte[] terrainBlock = ReadBlock(fileStream, terrainModelPointer, headerSize);

            TerrainHead head = new TerrainHead(terrainBlock, game);

            byte[] tfragBlock = ReadBlock(fileStream, head.headPointer, head.headCount * 0x30);

            for (int i = 0; i < head.headCount; i++)
            {
                tFrags.Add(new TerrainFragment(fileStream, head, tfragBlock, i));
            }

            Terrain terrain = new Terrain(tFrags, head.levelNumber);

            return(terrain);
        }