Exemplo n.º 1
0
        public void createFromPathWithOffset(String filename, long offset, int length)
        {
            path = filename;
            //Save the filename for opening later
            beginningOffset = offset;

            BinaryReader file = openReader();
            //Get the header of the gff
            header = new GFFHeader(file);
            dataOffset = header.dataOffset + beginningOffset;

            //Get the struct definitions
            structs = new BiowareStruct[header.structCount];

            for (int i = 0; i < header.structCount; i++)
            {
                structs[i] = new BiowareStruct(this, new GFFStructDefinition(file, beginningOffset));
            }
            file.Close();
        }
 public TerrainMeshVertex(BiowareStruct definition, BinaryReader file)
 {
     _definition = definition;
     readData(file);
 }
 public TerrainMapEdge(BiowareStruct definition, BinaryReader file)
 {
     _definition = definition;
     readData(file);
 }
Exemplo n.º 4
0
 public TerrainMapEdge(BiowareStruct definition, BinaryReader file)
 {
     _definition = definition;
     readData(file);
 }
        //Reading from a file constructor (normal meshes)
        public MeshChunk(BinaryReader file, long dataOffset, BiowareStruct chunkDef, BiowareStruct vertStruct)
        {
            uint listLength;
            long reference;
            long position = file.BaseStream.Position;
            materialObjectName = "";

            //Read the name
            file.BaseStream.Seek(chunkDef.fields[0].index + position, SeekOrigin.Begin);
            name = IOUtilities.readECString(file, dataOffset + file.ReadInt32());


            //Seek to vertex size offset and read it
            file.BaseStream.Seek(chunkDef.fields[1].index + position, SeekOrigin.Begin);
            vertexSize = (int)file.ReadUInt32();

            //Seek to vertex count offset and read it
            file.BaseStream.Seek(chunkDef.fields[2].index + position, SeekOrigin.Begin);
            vertexCount = file.ReadUInt32();

            verts = new float[vertexCount * vertexElementCount];

            //Seek to vertex offset offset and read it
            file.BaseStream.Seek(chunkDef.fields[7].index + position, SeekOrigin.Begin);
            vertexOffset = file.ReadUInt32();

            //Seek to index count offset and read it
            file.BaseStream.Seek(chunkDef.fields[3].index + position, SeekOrigin.Begin);
            indexCount = file.ReadUInt32();
            indices = new uint[indexCount];

            //Seek to index offset offset and read it
            file.BaseStream.Seek(chunkDef.fields[10].index + position, SeekOrigin.Begin);
            startIndex = file.ReadUInt32();

            //Seek to vertex declarator offset and read in the list reference
            file.BaseStream.Seek(chunkDef.fields[13].index + position, SeekOrigin.Begin);
            reference = file.ReadUInt32();

            //Make the triangle array to be filled later
            tris = new Triangle[indexCount / 3];

            //Seek to the list
            file.BaseStream.Seek(reference + dataOffset, SeekOrigin.Begin);
            listLength = file.ReadUInt32();
            reference = file.BaseStream.Position;
            usesTwoTexCoords = false;
            Usage type;

            //Get the offsets
            for (int i = 0; i < listLength; i++)
            {
                file.BaseStream.Seek(reference + (vertStruct.structSize * i) + vertStruct.fields[3].index, SeekOrigin.Begin);
                type = (Usage)file.ReadUInt32();
                file.BaseStream.Seek(reference + (vertStruct.structSize * i) + vertStruct.fields[1].index, SeekOrigin.Begin);
                switch (type)
                {
                    case Usage.POSITION:
                        positionOffset = file.ReadInt32();
                        break;

                    case Usage.TEXCOORD:
                        int offset = file.ReadInt32();
                        file.BaseStream.Seek(reference + (vertStruct.structSize * i) + vertStruct.fields[4].index, SeekOrigin.Begin);
                        uint index = file.ReadUInt32();
                        if (index == 0)
                        {
                            textureOffset = offset;
                            texture2Offset = offset;
                        }
                        else if (index == 1)
                        {
                            texture2Offset = offset;
                            usesTwoTexCoords = true;
                        }
                        break;

                    case Usage.NORMAL:
                        normalOffset = file.ReadInt32();
                        break;

                }
            }
        }
 public TerrainMeshVertex(BiowareStruct definition, BinaryReader file)
 {
     _definition = definition;
     readData(file);
 }
 private void setStructDefinitions()
 {
     for (int i = 0; i < binaryFile.structs.Length; i++)
     {
         switch (binaryFile.structs[i].type)
         {
             case GFFSTRUCTTYPE.MMH_MSH_STRUCT:
                 meshChunkInfoIndex = i;
                 meshChunkInfoStruct = binaryFile.structs[i]; break;
             case GFFSTRUCTTYPE.MMH_NODE_STRUCT:
                 nodeStructIndex = i;
                 nodeStruct = binaryFile.structs[i]; break;
             case GFFSTRUCTTYPE.MMH_ORIENTATION:
                 rotationStructIndex = i; break;
             case GFFSTRUCTTYPE.MMH_OFFSET:
                 translationStructIndex = i; break;
         }
     }
 }
 private void setStructDefinitions()
 {
     for (int i = 0; i < binaryFile.structs.Length; i++)
     {
         switch (binaryFile.structs[i].type)
         {
             case GFFSTRUCTTYPE.TRN_MAP_EDGE:
                 mapEdgeStruct = binaryFile.structs[i]; break;
             case GFFSTRUCTTYPE.TRN_MAP_FACE:
                 mapFaceStruct = binaryFile.structs[i]; break;
             case GFFSTRUCTTYPE.TRN_MAP_VERT:
                 mapVertexStruct = binaryFile.structs[i]; break;
             case GFFSTRUCTTYPE.TRN_MESH_EDGE:
                 meshEdgeStruct = binaryFile.structs[i]; break;
             case GFFSTRUCTTYPE.TRN_MESH_FACE:
                 meshFaceStruct = binaryFile.structs[i]; break;
             case GFFSTRUCTTYPE.TRN_MESH_VERT:
                 meshVertexStruct = binaryFile.structs[i]; break;
             case GFFSTRUCTTYPE.TRN_AREA_INFO:
                 infoStruct = binaryFile.structs[i]; break;
         }
     }
 }
Exemplo n.º 9
0
        //Reading from a file constructor (normal meshes)
        public MeshChunk(BinaryReader file, long dataOffset, BiowareStruct chunkDef, BiowareStruct vertStruct)
        {
            uint listLength;
            long reference;
            long position = file.BaseStream.Position;

            materialObjectName = "";

            //Read the name
            file.BaseStream.Seek(chunkDef.fields[0].index + position, SeekOrigin.Begin);
            name = IOUtilities.readECString(file, dataOffset + file.ReadInt32());


            //Seek to vertex size offset and read it
            file.BaseStream.Seek(chunkDef.fields[1].index + position, SeekOrigin.Begin);
            vertexSize = (int)file.ReadUInt32();

            //Seek to vertex count offset and read it
            file.BaseStream.Seek(chunkDef.fields[2].index + position, SeekOrigin.Begin);
            vertexCount = file.ReadUInt32();

            verts = new float[vertexCount * vertexElementCount];

            //Seek to vertex offset offset and read it
            file.BaseStream.Seek(chunkDef.fields[7].index + position, SeekOrigin.Begin);
            vertexOffset = file.ReadUInt32();

            //Seek to index count offset and read it
            file.BaseStream.Seek(chunkDef.fields[3].index + position, SeekOrigin.Begin);
            indexCount = file.ReadUInt32();
            indices    = new uint[indexCount];

            //Seek to index offset offset and read it
            file.BaseStream.Seek(chunkDef.fields[10].index + position, SeekOrigin.Begin);
            startIndex = file.ReadUInt32();

            //Seek to vertex declarator offset and read in the list reference
            file.BaseStream.Seek(chunkDef.fields[13].index + position, SeekOrigin.Begin);
            reference = file.ReadUInt32();

            //Make the triangle array to be filled later
            tris = new Triangle[indexCount / 3];

            //Seek to the list
            file.BaseStream.Seek(reference + dataOffset, SeekOrigin.Begin);
            listLength       = file.ReadUInt32();
            reference        = file.BaseStream.Position;
            usesTwoTexCoords = false;
            Usage type;

            //Get the offsets
            for (int i = 0; i < listLength; i++)
            {
                file.BaseStream.Seek(reference + (vertStruct.structSize * i) + vertStruct.fields[3].index, SeekOrigin.Begin);
                type = (Usage)file.ReadUInt32();
                file.BaseStream.Seek(reference + (vertStruct.structSize * i) + vertStruct.fields[1].index, SeekOrigin.Begin);
                switch (type)
                {
                case Usage.POSITION:
                    positionOffset = file.ReadInt32();
                    break;

                case Usage.TEXCOORD:
                    int offset = file.ReadInt32();
                    file.BaseStream.Seek(reference + (vertStruct.structSize * i) + vertStruct.fields[4].index, SeekOrigin.Begin);
                    uint index = file.ReadUInt32();
                    if (index == 0)
                    {
                        textureOffset  = offset;
                        texture2Offset = offset;
                    }
                    else if (index == 1)
                    {
                        texture2Offset   = offset;
                        usesTwoTexCoords = true;
                    }
                    break;

                case Usage.NORMAL:
                    normalOffset = file.ReadInt32();
                    break;
                }
            }
        }
Exemplo n.º 10
0
 private void setStructDefinitions()
 {
     for (int i = 0; i < headerFile.structs.Length; i++)
     {
         switch (headerFile.structs[i].type)
         {
             case GFFSTRUCTTYPE.EVN_ROOM:
                 roomStruct = headerFile.structs[i]; break;
             case GFFSTRUCTTYPE.ENV_WORLD_ROOM:
                 environmentStruct = headerFile.structs[i]; break;
             case GFFSTRUCTTYPE.ENV_WORLD_TERRAIN:
                 environmentStruct = headerFile.structs[i]; break;
             case GFFSTRUCTTYPE.ENV_AREA:
                 areaStruct = headerFile.structs[i]; break;
             case GFFSTRUCTTYPE.LIGHT:
                 lightStruct = headerFile.structs[i]; break;
             case GFFSTRUCTTYPE.MODEL:
                 modelStruct = headerFile.structs[i]; break;
             case GFFSTRUCTTYPE.TERRAIN_CHUNK:
                 terrainChunkStruct = headerFile.structs[i]; break;
             case GFFSTRUCTTYPE.TS_PROPERTY:
                 propertyStruct = headerFile.structs[i]; break;
             case GFFSTRUCTTYPE.LVL_GROUP:
                 levelGroupStruct = headerFile.structs[i]; break;
         }
     }
 }